commit 1e85435e83dee649f120b865b4f43d4c66c8cab4
parent 508b076e2b1147f348d23a1271be0f02c02616cf
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Wed, 3 Sep 2025 11:34:45 +0200
Improve naming and comments for Misc star-cad options
Also add a new debug option.
Diffstat:
3 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/src/scad.c b/src/scad.c
@@ -265,7 +265,7 @@ scad_synchronize
}
gmshModelOccSynchronize(&ierr);
- get_device()->need_synchro = dev->options.Misc.DebugOpenCascadeSync;
+ get_device()->need_synchro = dev->options.Misc.DebugAutoSync;
ERR(gmsh_err_to_res_T(ierr));
exit:
@@ -296,6 +296,9 @@ scad_run_ui(void)
}
gmshFltkRun(&ierr);
+ if(ierr) {
+ log_error(dev, "Cannot call FLTK: you probably need to build gmsh locally.\n");
+ }
ERR(gmsh_err_to_res_T(ierr));
exit:
diff --git a/src/scad.h b/src/scad.h
@@ -87,13 +87,6 @@ enum scad_log_refcounting {
SCAD_LOG_GEOMETRY = BIT(2)
};
-/* A type to specify the kind of mesh size specification set by a call to the
- * scad_geometries_set_mesh_size_modifier API call */
-enum scad_size_modifier_type {
- SCAD_ABSOLUTE_SIZE,
- SCAD_SIZE_FACTOR
-};
-
/* A type to specify options for the gmsh library */
struct scad_options {
struct {
@@ -116,14 +109,20 @@ struct scad_options {
int OCCParallel;
} Geometry;
struct {
- /* Run UI when entering any scad API function; requires a FLTK-enabled gmsh build */
- int Step;
- /* Call synchronize first when runui is called */
+ /* Run UI when entering any star-cad API call; requires a FLTK-enabled gmsh
+ * build, possibly a local build of gmsh and OCC */
+ int RunUIAtEachStep;
+ /* Call synchronize first when run_ui is called */
int SynchronizeOnRunUI;
/* Log ref counting operations on geometries (lot of logs expected) */
enum scad_log_refcounting LogRefCounting;
- /* Systematic call to synchronize; if results change there is a sync bug in star-cad! */
- int DebugOpenCascadeSync;
+ /* Triggers a synchronize operation before any star-cad API call. If results
+ * change, there is a bug in star-cad auto-synchronize mechanism.
+ * This slows down star-cad a lot! */
+ int DebugAutoSync;
+ /* Check gmsh and OCC contexts are empty everytime star-cad context is
+ * empty. As a side effect, triggers a synchronize operation. */
+ int DebugEmptyContext;
} Misc;
};
@@ -134,11 +133,18 @@ struct scad_options {
SCAD_ONE_SOLID_PER_PHYSICAL_SURFACE }, \
{ SCAD_VERBOSITY_ERRORS, 1 }, \
{ 1 }, \
- { 0, 0, SCAD_LOG_NONE, 0 } \
+ { 0, 0, SCAD_LOG_NONE, 0, 0 } \
}
static const struct scad_options SCAD_DEFAULT_OPTIONS = SCAD_DEFAULT_OPTIONS__;
+/* A type to specify the kind of mesh size specification set by a call to the
+ * scad_geometries_set_mesh_size_modifier API call */
+enum scad_size_modifier_type {
+ SCAD_ABSOLUTE_SIZE,
+ SCAD_SIZE_FACTOR
+};
+
/* A type to specify what to swap in geometries_swap calls */
enum scad_swap_elements {
SCAD_SWAP_NAME = BIT(0),
diff --git a/src/scad_device.c b/src/scad_device.c
@@ -153,15 +153,15 @@ check_device
ERR(scad_synchronize());
}
- if(g_device->options.Misc.Step) {
+ if(g_device->options.Misc.RunUIAtEachStep) {
ERR(scad_run_ui());
}
-#ifndef NDEBUG
- if(htable_geometries_size_get(&g_device->allgeom) == 0) {
+ if(g_device->options.Misc.DebugEmptyContext
+ && htable_geometries_size_get(&g_device->allgeom) == 0)
+ {
ERR(check_empty_gmsh_occ(g_device));
}
-#endif
exit:
return res;
@@ -629,7 +629,7 @@ scad_initialize
}
g_device->logger = logger ? logger : LOGGER_DEFAULT;
g_device->allocator = allocator;
- g_device->need_synchro = g_device->options.Misc.DebugOpenCascadeSync;
+ g_device->need_synchro = g_device->options.Misc.DebugAutoSync;
g_device->verbose = verbose;
g_device->log_type = LOG_OUTPUT;
g_device->log = (g_device->options.Misc.LogRefCounting != SCAD_LOG_NONE);
@@ -741,10 +741,11 @@ scad_set_options
if(options) {
/* Check non-gmsh option validity if user-provided */
- (void)actual_options->Misc.Step; /* int boolean: always OK */
+ (void)actual_options->Misc.RunUIAtEachStep; /* int boolean: always OK */
(void)actual_options->Misc.SynchronizeOnRunUI; /* int boolean: always OK */
(void)actual_options->Misc.LogRefCounting; /* int boolean: always OK */
- (void)actual_options->Misc.DebugOpenCascadeSync; /* int boolean: always OK */
+ (void)actual_options->Misc.DebugAutoSync; /* int boolean: always OK */
+ (void)actual_options->Misc.DebugEmptyContext; /* int boolean: always OK */
}
dev->options = *actual_options;