commit 1e871accee115e344204bd5da66dfcc8e2ab5114
parent b3e3af653cdbdcd3b2c0cb44ec11d1bb5c951c3c
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Thu, 12 Dec 2024 09:57:42 +0100
Add an API call to clear the mesh for some geometries
Diffstat:
2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/src/scad.h b/src/scad.h
@@ -548,6 +548,14 @@ SCAD_API res_T
scad_scene_mesh
(void);
+/* Clear the mesh of the geometries in `geometries'.
+ * Note that the mesh of a geometry can only be cleared if it is not on the
+ * boundary of another geometry with a non-empty mesh. */
+SCAD_API res_T
+scad_geometries_clear_mesh
+ (struct scad_geometry** geometries,
+ const size_t geometries_count);
+
/* Get the normal of the geometry `geom' at position `p'.
* The normal is set in `N' and the underlying 2D entity to which `p' belongs is
* returned as a new geometry in `out_geometry'. */
diff --git a/src/scad_geometry.c b/src/scad_geometry.c
@@ -522,6 +522,39 @@ error:
}
res_T
+scad_geometries_clear_mesh
+ (struct scad_geometry** geometries,
+ const size_t geometries_count)
+{
+ res_T res = RES_OK;
+ int ierr;
+ size_t sz;
+ int* data = NULL;
+ struct scad_device* dev = get_device();
+ struct mem_allocator* allocator = NULL;
+
+ if(!geometries) {
+ res = RES_BAD_ARG;
+ goto error;
+ }
+
+ ERR(check_device(FUNC_NAME));
+
+ allocator = dev->allocator;
+ ERR(gather_tags(geometries, geometries_count, &data, &sz));
+ gmshModelMeshClear(data, sz, &ierr);
+ ERR(gmsh_err_to_res_T(ierr));
+
+ dev->need_synchro = 1;
+
+exit:
+ if(allocator) MEM_RM(allocator, data);
+ return res;
+error:
+ goto exit;
+}
+
+res_T
scad_geometry_get_name
(const struct scad_geometry* geom,
const char** name)