commit 198cbf15723531c46eceb81e8b66a4e913cb12b7
parent 2580f7a37551a32d2de624b989b01c55c5b28782
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Fri, 20 Dec 2024 11:22:47 +0100
Add an API call to select a specific mesh algorithm for some geometries
Diffstat:
2 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/src/scad.h b/src/scad.h
@@ -593,6 +593,15 @@ scad_geometries_set_mesh_size_modifier
enum scad_size_modifier_type type,
double modifier);
+/* Set a specific mesh algorithm for geometries in `geometries'.
+ * Only apply to surfaces (dimension 2). If called on a volume, it applies to
+ * its 2D constituents. */
+SCAD_API res_T
+scad_geometries_set_mesh_algorithm
+ (struct scad_geometry** geometries,
+ const size_t geometries_count,
+ enum scad_mesh_algorithm algorithm);
+
/* 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. */
diff --git a/src/scad_geometry.c b/src/scad_geometry.c
@@ -2809,6 +2809,42 @@ error:
}
res_T
+scad_geometries_set_mesh_algorithm
+(struct scad_geometry** geometries,
+ const size_t geometries_count,
+ enum scad_mesh_algorithm algorithm)
+{
+ res_T res = RES_OK;
+ struct scad_device* dev = get_device();
+ int ierr;
+ int* tagout[4] = { NULL, NULL, NULL, NULL };
+ size_t tagoutn[4], i;
+
+ if(!geometries || geometries_count == 0) {
+ res = RES_BAD_ARG;
+ goto error;
+ }
+
+ ERR(check_device(FUNC_NAME));
+
+ ERR(gather_tags_recursive(geometries, geometries_count, 2, tagout, tagoutn));
+ for(i = 0; i < tagoutn[2]; i += 2) {
+ int dim = tagout[2][i];
+ int tag = tagout[2][i+1];
+ gmshModelMeshSetAlgorithm(dim, tag, (int)algorithm, &ierr);
+ ERR(gmsh_err_to_res_T(ierr));
+ }
+
+exit:
+ for(i = 2; i < 4; i++) {
+ MEM_RM(dev->allocator, tagout[i]);
+ }
+ return res;
+error:
+ goto exit;
+}
+
+res_T
scad_geometries_set_periodic
(struct scad_geometry** source,
const size_t source_count,