star-cad

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

commit aa56ff24cf73d0af653b4a72bc050a5706b81540
parent ff863c4029a9dc0b90e2af6de6826a5da29b0866
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Thu, 12 Dec 2024 09:48:02 +0100

Add geometries visibility management

Geometries can be made visible/Hidden and meshing can be restricted to
visible geometries using the MeshOnlyVisible dedicated option.

Diffstat:
Msrc/scad.h | 20+++++++++++++++-----
Msrc/scad_geometry.c | 32++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/src/scad.h b/src/scad.h @@ -88,14 +88,15 @@ enum scad_log_refcounting { /* A type to specify options for the gmsh library */ struct scad_options { struct { - enum scad_mesh_algorithm Algorithm; - enum scad_sizes_extend_from_boundary MeshSizeExtendFromBoundary; double MeshSizeFactor; double MeshSizeFromCurvature; - int MeshSizeFromPoints; double MeshSizeMax; double MeshSizeMin; double Smoothing; + int MeshSizeFromPoints; + int MeshOnlyVisible; + enum scad_mesh_algorithm Algorithm; + enum scad_sizes_extend_from_boundary MeshSizeExtendFromBoundary; enum scad_stl_solids StlOneSolidPerSurface; } Mesh; struct { @@ -114,8 +115,10 @@ struct scad_options { }; #define SCAD_DEFAULT_OPTIONS__ \ - { { Scad_frontal_Delaunay, Scad_surfaces_and_volumes, 1, 36, 1, 1e+22, 1e-6, \ - 1, Scad_one_solid_per_physical_surface }, \ + { { 1, 36, 1e+22, 1e-6, 1, 1, 1, \ + Scad_frontal_Delaunay, \ + Scad_surfaces_and_volumes, \ + Scad_one_solid_per_physical_surface }, \ { Scad_verbosity_errors, 1 }, \ { 1 }, \ { 0, 0, Scad_log_none, 0 } \ @@ -398,6 +401,13 @@ scad_geometry_copy const char* name, /* Can be NULL */ struct scad_geometry** out_copy); +/* copy the geometry `geom'. */ +SCAD_API res_T +scad_geometry_set_visibility + (const struct scad_geometry* geom, + int visible, + int recursive); + /* Change the name of geometry `geom'. */ SCAD_API res_T scad_geometry_rename diff --git a/src/scad_geometry.c b/src/scad_geometry.c @@ -490,6 +490,38 @@ error: } res_T +scad_geometry_set_visibility + (const struct scad_geometry* geom, + int visible, + int recursive) +{ + res_T res = RES_OK; + int ierr; + int* data = NULL; + size_t sz; + + if(!geom) { + res = RES_BAD_ARG; + goto error; + } + + ERR(check_device(FUNC_NAME)); + + data = geom->gmsh_dimTags; + sz = geom->gmsh_dimTags_n; + + gmshModelSetVisibility(data, sz, visible, recursive, &ierr); + ERR(gmsh_err_to_res_T(ierr)); + + get_device()->need_synchro = 1; + +exit: + return res; +error: + goto exit; +} + +res_T scad_geometry_get_name (const struct scad_geometry* geom, const char** name)