star-cad

Geometric operators for computer-aided design
git clone git://git.meso-star.fr/star-cad.git
Log | Files | Refs | README | LICENSE

commit 824ff8bfea364942354cbac1a4c71d96fc60136a
parent 632e64b00f456d80a36c384f6334d6a49d5be1a4
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Tue, 29 Jul 2025 13:52:18 +0200

Add scene_get_count and geometry_is_empty API calls.

Diffstat:
Msrc/scad.h | 11+++++++++++
Msrc/scad_geometry.c | 44++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/src/scad.h b/src/scad.h @@ -195,6 +195,11 @@ scad_get_options * All these calls process the scene (i.e. all the existing geomeries) at once. ******************************************************************************/ +/* Get the number of geometries in the scene */ +SCAD_API res_T +scad_scene_count + (size_t* count); + /* Clear the scene from all its geometries */ SCAD_API res_T scad_scene_clear @@ -337,6 +342,12 @@ scad_geometry_get_count (const struct scad_geometry* geometry, size_t* count); +/* Check if the geometry `geometry' is empty (has count 0). */ +SCAD_API res_T +scad_geometry_is_empty + (const struct scad_geometry* geometry, + int* empty); + /* Attach some custom data `data' to geometry `geometry'. * If provided, release() is called when `geometry' is released or if * set_custom_data is called again. */ diff --git a/src/scad_geometry.c b/src/scad_geometry.c @@ -471,6 +471,28 @@ error: } res_T +scad_scene_count + (size_t* count) +{ + res_T res = RES_OK; + struct scad_device* dev = get_device(); + + if(!count) { + res =RES_BAD_ARG; + goto error; + } + + ERR(check_device(FUNC_NAME)); + + *count = htable_geometries_size_get(&dev->allgeom); + +end: + return res; +error: + goto end; +} + +res_T scad_scene_clear (void) { @@ -550,6 +572,28 @@ error: } res_T +scad_geometry_is_empty + (const struct scad_geometry* geom, + int* empty) +{ + res_T res = RES_OK; + + if(!geom || !empty) { + res = RES_BAD_ARG; + goto error; + } + + ERR(check_device(FUNC_NAME)); + + *empty = (geom->gmsh_dimTags_n == 0); + +exit: + return res; +error: + goto exit; +} + +res_T scad_geometry_set_custom_data (struct scad_geometry* geom, void (*release) (void* data),