sgs_geometry_c.h (2746B)
1 /* Copyright (C) 2021-2023 Centre National de la Recherche Scientifique 2 * Copyright (C) 2021-2023 INSA Lyon 3 * Copyright (C) 2021-2023 Institut Mines Télécom Albi-Carmaux 4 * Copyright (C) 2021-2023 |Méso|Star> (contact@meso-star.com) 5 * Copyright (C) 2021-2023 Institut Pascal 6 * Copyright (C) 2021-2023 PhotonLyX (info@photonlyx.com) 7 * Copyright (C) 2021-2023 Université de Lorraine 8 * Copyright (C) 2021-2023 Université Paul Sabatier 9 * Copyright (C) 2021-2023 Université Toulouse - Jean Jaurès 10 * 11 * This program is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation, either version 3 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 23 24 #ifndef SGS_GEOMETRY_C_H 25 #define SGS_GEOMETRY_C_H 26 27 #include <rsys/dynamic_array_double.h> 28 #include <rsys/dynamic_array_int.h> 29 #include <rsys/dynamic_array_size_t.h> 30 #include <rsys/ref_count.h> 31 32 /* Forwar declarations */ 33 struct sgs; 34 struct s3d_scene_view; 35 36 struct sgs_geometry { 37 struct darray_double verts; 38 struct darray_size_t tris; 39 struct darray_int tris_rt_type; /* List of enum sgs_surface_type */ 40 struct darray_int tris_sp_type; /* List of enum sgs_surface_type */ 41 42 struct s3d_scene_view* view_rt; 43 struct s3d_scene_view* view_sp; 44 45 double low[3], upp[3]; /* Axis aligned bounding box */ 46 47 int sampling_mask; /* Combination of enum sgs_surface_type */ 48 49 struct sgs* sgs; 50 ref_T ref; 51 }; 52 53 extern LOCAL_SYM res_T 54 geometry_create 55 (struct sgs* sgs, 56 const int sampling_mask, 57 struct sgs_geometry** out_geom); 58 59 extern LOCAL_SYM void 60 geometry_compute_aabb 61 (struct sgs_geometry* geom); 62 63 extern LOCAL_SYM res_T 64 geometry_setup_view_rt 65 (struct sgs_geometry* geom); 66 67 extern LOCAL_SYM res_T 68 geometry_setup_view_sp 69 (struct sgs_geometry* geom, 70 const int sampling_mask); /* Combination of enum sgs_surface_type */ 71 72 /* Return the number of vertices */ 73 static FINLINE size_t 74 geometry_get_nvertices(const struct sgs_geometry* geom) 75 { 76 ASSERT(geom); 77 return darray_double_size_get(&geom->verts) / 3/*#coords per vertex*/; 78 } 79 80 /* Return the overall number of triangles */ 81 static FINLINE size_t 82 geometry_get_ntriangles(const struct sgs_geometry* geom) 83 { 84 ASSERT(geom); 85 return darray_size_t_size_get(&geom->tris) / 3/*#ids per triangles*/; 86 } 87 88 #endif /* SGS_GEOMETRY_C_H */ 89