sphin_geometry.h (3524B)
1 /* Copyright (C) 2024-2026 Centre National de la Recherche Scientifique 2 * Copyright (C) 2024-2026 Clermont Auvergne INP 3 * Copyright (C) 2024-2026 INSA Lyon 4 * Copyright (C) 2024-2026 Institut Mines Télécom Albi-Carmaux 5 * Copyright (C) 2024-2026 Institut National Polytechnique de Toulouse 6 * Copyright (C) 2024-2026 |Méso|Star> (contact@meso-star.com) 7 * Copyright (C) 2024-2026 PhotonLyX (info@photonlyx.com) 8 * Copyright (C) 2024-2026 Université de Lorraine 9 * Copyright (C) 2024-2026 Université Paul Sabatier 10 * Copyright (C) 2024-2026 Université Toulouse - Jean Jaurès 11 * 12 * This program is free software: you can redistribute it and/or modify 13 * it under the terms of the GNU General Public License as published by 14 * the Free Software Foundation, either version 3 of the License, or 15 * (at your option) any later version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * You should have received a copy of the GNU General Public License 23 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 24 25 #ifndef SPHIN_GEOMETRY_H 26 #define SPHIN_GEOMETRY_H 27 28 #include "sphin.h" 29 30 #include <rsys/dynamic_array_double.h> 31 #include <rsys/dynamic_array_size_t.h> 32 #include <rsys/ref_count.h> 33 #include <rsys/rsys.h> 34 #include <rsys/str.h> 35 36 struct mem_allocator; 37 38 struct sphin_geometry { 39 struct str stl_filename; 40 enum sphin_side side; 41 42 /* Mesh data */ 43 struct darray_double coords; 44 struct darray_size_t indices; 45 46 struct sphin* sphin; 47 ref_T ref; 48 }; 49 50 extern LOCAL_SYM res_T 51 geometry_parse 52 (struct sphin* sphin, 53 char* value, 54 struct sphin_geometry** out_geom); 55 56 extern LOCAL_SYM double 57 geometry_compute_area 58 (const struct sphin_geometry* geom); 59 60 extern LOCAL_SYM double 61 geometry_compute_volume 62 (const struct sphin_geometry* geom, 63 const enum sphin_side side); 64 65 /* Generate a dynamic array for storing sphin_geometry* elements and its API 66 * using the API provided by rsys/dynamic_array.h 67 * 68 * Define the prefix used for API functions and structures related to this 69 * dynamic array. This prefix will be used to generate function and type names, 70 * such as: 71 * - darray_sphin_surface_ptr_release 72 * - darray_sphin_surface_ptr_init 73 * - darray_sphin_surface_ptr_push_back => append element to the end of the 74 * dynamic array 75 * - darray_sphin_surface_ptr_size_get => returns the number of elements 76 * (size_t) of the dynamic array 77 * - darray_sphin_surface_ptr_data_get => returns the array itself 78 * - darray_sphin_surface_ptr_resize 79 * Among other functions 80 */ 81 #define DARRAY_NAME sphin_geometry_ptr 82 83 /* Define the data type stored in the dynamic array: ptrs to sphin_geometry */ 84 #define DARRAY_DATA struct sphin_geometry* 85 86 /* 87 * Include the dynamic array implementation from rsys/dynamic_array.h. 88 * 89 * Note that this header is included twice in the source code: 90 * 1. At the beginning of the file (with other #include statements): 91 * - This ensures access to general definitions, utility functions, or 92 * declarations needed throughout the codebase. 93 * 94 * 2. Here, after defining DARRAY_NAME and DARRAY_DATA: 95 * - This triggers the preprocessor to generate a type-specific 96 * implementation of the dynamic array for 'struct sphin_geometry*' based 97 * on the provided macros. 98 */ 99 #include <rsys/dynamic_array.h> 100 101 #endif /* SPHIN_GEOMETRY_H */