star-cad

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

commit 51237ee237a6011d814e67578e61db2269a51da6
parent 02f86514d122c90858dcbd578dab74872612bb15
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Thu, 12 Jan 2023 15:32:00 +0100

Allow fine grained control on refcounting logs

Diffstat:
Msrc/scad.h | 10++++++++--
Msrc/scad_device.c | 52++++++++++++++++++++++++++++++++--------------------
Msrc/scad_device.h | 4+++-
Msrc/scad_geometry.c | 159++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
Msrc/scad_geometry.h | 5++++-
5 files changed, 164 insertions(+), 66 deletions(-)

diff --git a/src/scad.h b/src/scad.h @@ -76,6 +76,12 @@ enum scad_stl_solids { Scad_one_solid_per_physical_surface = 2 }; +enum scad_log_refcounting { + Scad_log_none, + Scad_log_only_undeleted, + Scad_log_all +}; + /* A type to specify options for the gmsh library */ struct scad_options { struct { @@ -99,7 +105,7 @@ struct scad_options { struct { int Step; /* Run UI when entering any scad API function; requires a FLTK-enabled gmsh build */ int SynchronizeOnRunUI; - int LogOpenCascadeTagsRefCounting; + enum scad_log_refcounting LogOpenCascadeTagsRefCounting; int DebugOpenCascadeSync; /* Systematic call to synchronize; if results change there is a sync bug in star-cad! */ } Misc; }; @@ -109,7 +115,7 @@ struct scad_options { 1, Scad_one_solid_per_physical_surface }, \ { Scad_verbosity_errors, 1 }, \ { 1 }, \ - { 0, 0, 0, 0 } \ + { 0, Scad_log_none, 0, 0 } \ } static const struct scad_options SCAD_DEFAULT_OPTIONS = SCAD_DEFAULT_OPTIONS__; diff --git a/src/scad_device.c b/src/scad_device.c @@ -35,10 +35,16 @@ device_release(struct scad_device* dev) { struct htable_geometries tmp; struct htable_geometries_iterator it, end; - int log; + int log, empty; + enum scad_log_refcounting option; + enum log_type log_type; ASSERT(dev); - log = dev->options.Misc.LogOpenCascadeTagsRefCounting; + + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + empty = htable_geometries_is_empty(&dev->allgeom); + log_type = empty ? LOG_OUTPUT : LOG_WARNING; + log = (option == Scad_log_all) || (!empty && option == Scad_log_only_undeleted); /* Duplicate the htable we iterate on as dev->allgeom will be altered during * the process (through calls to geometry_release) */ @@ -46,12 +52,12 @@ device_release(struct scad_device* dev) CHK(RES_OK == htable_geometries_copy(&tmp, &dev->allgeom)); htable_geometries_begin(&tmp, &it); htable_geometries_end(&tmp, &end); - if(log && htable_geometries_iterator_eq(&it, &end)) { - log_message(dev, "No scad geometry.\n"); + if(log && empty) { + logger_print(dev->logger, log_type, "No scad geometry.\n"); } while(!htable_geometries_iterator_eq(&it, &end)) { struct scad_geometry* geom = *htable_geometries_iterator_key_get(&it); - CHK(RES_OK == geometry_release(geom)); + CHK(RES_OK == geometry_release(log, log_type, geom)); htable_geometries_iterator_next(&it); } htable_names_release(&dev->geometry_names); @@ -59,7 +65,7 @@ device_release(struct scad_device* dev) htable_tags2geom_release(&dev->tags2geom[1]); htable_geometries_release(&dev->allgeom); if(log) { - log_message(dev, "End finalizing scad.\n"); + logger_print(dev->logger, log_type, "End finalizing scad.\n"); } MEM_RM(dev->allocator, dev); htable_geometries_release(&tmp); @@ -152,7 +158,7 @@ device_register_tags int* dimTags; size_t count, i; struct scad_device* dev = get_device(); - int log = dev->options.Misc.LogOpenCascadeTagsRefCounting; + int log = (dev->options.Misc.LogOpenCascadeTagsRefCounting == Scad_log_all); ASSERT(geom); @@ -212,13 +218,14 @@ error: res_T device_unregister_tags - (struct scad_geometry* geom) + (const int log, + const enum log_type log_type, + struct scad_geometry* geom) { res_T res = RES_OK; int* dimTags; size_t count, i; struct scad_device* dev = get_device(); - int log = dev->options.Misc.LogOpenCascadeTagsRefCounting; ASSERT(geom); @@ -227,11 +234,11 @@ device_unregister_tags if(log) { if(str_is_empty(&geom->name)) { - log_message(dev, "Unregistering tags for unnamed geometry %p.\n", - (void*)geom); + logger_print(dev->logger, log_type, + "Unregistering tags for unnamed geometry %p.\n", (void*)geom); } else { - log_message(dev, "Unregistering tags for geometry '%s'.\n", - str_cget(&geom->name)); + logger_print(dev->logger, log_type, + "Unregistering tags for geometry '%s'.\n", str_cget(&geom->name)); } } @@ -250,14 +257,14 @@ device_unregister_tags n = htable_geometries_size_get(geoms); if(n > 0) { if(log) { - log_message(dev, "Dim %d tag %d (count decreased to %lu).\n", - dim, tag, (unsigned long)n); + logger_print(dev->logger, log_type, + "Dim %d tag %d (count decreased to %lu).\n", dim, tag, (unsigned long)n); } continue; } /* The gmsh geometry with tag 'tag' is not in use anymore: release it */ if(log) { - log_message(dev, "Dim %d tag %d removed.\n", dim, tag); + logger_print(dev->logger, log_type, "Dim %d tag %d removed.\n", dim, tag); } gmshModelOccRemove(dimTags+i, 2, 1, &ierr); @@ -330,15 +337,20 @@ scad_finalize (void) { res_T res = RES_OK; - struct scad_device* dev = get_device(); - int log; int ierr; + struct scad_device* dev = get_device(); + int log, empty; + enum scad_log_refcounting option; + enum log_type log_type; ERR(check_device(FUNC_NAME)); + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; - log = dev->options.Misc.LogOpenCascadeTagsRefCounting; + empty = htable_geometries_is_empty(&dev->allgeom); + log_type = empty ? LOG_OUTPUT : LOG_WARNING; + log = (option == Scad_log_all) || (!empty && option == Scad_log_only_undeleted); if(log) { - log_message(dev, + logger_print(dev->logger, log_type, "Finalizing scad; undeleted tags will be automatically unregistered.\n"); } diff --git a/src/scad_device.h b/src/scad_device.h @@ -144,7 +144,9 @@ device_register_tags LOCAL_SYM res_T device_unregister_tags - (struct scad_geometry* geom); + (const int log, + const enum log_type log_type, + struct scad_geometry* geom); LOCAL_SYM res_T device_apply_mappings diff --git a/src/scad_geometry.c b/src/scad_geometry.c @@ -13,6 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "rsys/logger.h" #include "scad.h" #include "scad_c.h" #include "scad_device.h" @@ -114,8 +115,12 @@ scad_geometry_create struct scad_device* dev = get_device(); struct mem_allocator* allocator = dev->allocator; char one = 1; + int log; + enum scad_log_refcounting option; ASSERT(out_geometry); + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; geom = (struct scad_geometry*)MEM_CALLOC(allocator, 1, sizeof(*geom)); if(!geom) { @@ -133,7 +138,7 @@ end: return res; error: if(geom) { - CHK(RES_OK == geometry_release(geom)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, geom)); geom = NULL; } goto end; @@ -233,7 +238,9 @@ free_gmsh_map ******************************************************************************/ res_T geometry_release - (struct scad_geometry* geom) + (const int log, + const enum log_type log_type, + struct scad_geometry* geom) { struct scad_device* dev = get_device(); struct mem_allocator* allocator = dev->allocator; @@ -244,7 +251,7 @@ geometry_release dev->need_synchro = 1; - ERR(device_unregister_tags(geom)); + ERR(device_unregister_tags(log, log_type, geom)); MEM_RM(allocator, geom->gmsh_dimTags); if(str_len(&geom->name) != 0) { n = htable_names_erase(&dev->geometry_names, &geom->name); @@ -269,6 +276,9 @@ scad_geometry_delete (struct scad_geometry* geom) { res_T res = RES_OK; + struct scad_device* dev = get_device(); + int log; + enum scad_log_refcounting option; if(!geom) { res = RES_BAD_ARG; @@ -276,8 +286,10 @@ scad_geometry_delete } ERR(check_device(FUNC_NAME)); + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; - ERR(geometry_release(geom)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, geom)); end: return res; @@ -295,29 +307,34 @@ scad_scene_clear struct htable_geometries_iterator it, end; struct scad_device* dev = get_device(); struct mem_allocator* allocator = NULL; - int log; + int log, empty; + enum scad_log_refcounting option; + enum log_type log_type; ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; - log = dev->options.Misc.LogOpenCascadeTagsRefCounting; htable_geometries_init(allocator, &tmp); ERR(htable_geometries_copy(&tmp, &dev->allgeom)); htable_geometries_begin(&tmp, &it); htable_geometries_end(&tmp, &end); + empty = htable_geometries_is_empty(&dev->allgeom); + log_type = empty ? LOG_OUTPUT : LOG_WARNING; + log = (option == Scad_log_all) || (!empty && option == Scad_log_only_undeleted); if(log) { - log_message(dev, "Clearing scene.\n"); - if(htable_geometries_iterator_eq(&it, &end)) { - log_message(dev, "scene is empty.\n"); + logger_print(dev->logger, log_type, "Clearing scene.\n"); + if(empty) { + logger_print(dev->logger, log_type, "scene is empty.\n"); } } while(!htable_geometries_iterator_eq(&it, &end)) { struct scad_geometry* geom = *htable_geometries_iterator_key_get(&it); - CHK(RES_OK == geometry_release(geom)); + CHK(RES_OK == geometry_release(log, log_type, geom)); htable_geometries_iterator_next(&it); } if(log) { - log_message(dev, "End clearing scene.\n"); + logger_print(dev->logger, log_type, "End clearing scene.\n"); } /* Ensure clear is complete (not scad-registered tags) */ @@ -453,7 +470,6 @@ exit: if(allocator) MEM_RM(allocator, data); return res; error: - res = RES_BAD_ARG; goto exit; } @@ -487,7 +503,6 @@ scad_geometry_get_centerofmass exit: return res; error: - res = RES_BAD_ARG; goto exit; } @@ -498,11 +513,13 @@ scad_add_rectangle const double dxdy[2], struct scad_geometry** out_geometry) { + res_T res = RES_OK; int ierr, gmsh_ID; struct scad_geometry* geom = NULL; struct scad_device* dev = get_device(); struct mem_allocator* allocator = NULL; - res_T res = RES_OK; + int log; + enum scad_log_refcounting option; if(!xyz || !dxdy || !out_geometry) { res = RES_BAD_ARG; @@ -511,6 +528,8 @@ scad_add_rectangle ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; gmsh_ID = gmshModelOccAddRectangle(SPLIT3(xyz), SPLIT2(dxdy), -1, 0, &ierr); ERR(gmsh_err_to_res_T(ierr)); @@ -533,7 +552,7 @@ exit: return res; error: if(geom) { - CHK(RES_OK == geometry_release(geom)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, geom)); geom = NULL; } goto exit; @@ -546,11 +565,13 @@ scad_add_disk const double radius, struct scad_geometry** out_geometry) { + res_T res = RES_OK; int ierr, gmsh_ID; struct scad_geometry* geom = NULL; struct scad_device* dev = get_device(); struct mem_allocator* allocator = NULL; - res_T res = RES_OK; + int log; + enum scad_log_refcounting option; if(!xyz || radius <= 0 || !out_geometry) { res = RES_BAD_ARG; @@ -559,6 +580,8 @@ scad_add_disk ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; gmsh_ID = gmshModelOccAddDisk(SPLIT3(xyz), radius, radius, -1, &ierr); ERR(gmsh_err_to_res_T(ierr)); @@ -581,7 +604,7 @@ exit: return res; error: if(geom) { - CHK(RES_OK == geometry_release(geom)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, geom)); geom = NULL; } goto exit; @@ -596,6 +619,7 @@ scad_add_polygon const size_t count, struct scad_geometry** out_geometry) { + res_T res = RES_OK; int ierr, gmsh_ID; struct scad_geometry* geom = NULL; size_t i; @@ -604,7 +628,8 @@ scad_add_polygon int loop; struct scad_device* dev = get_device(); struct mem_allocator* allocator = NULL; - res_T res = RES_OK; + int log; + enum scad_log_refcounting option; if(!get_position || count < 3 || !out_geometry) { res = RES_BAD_ARG; @@ -613,6 +638,8 @@ scad_add_polygon ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; points = MEM_ALLOC(allocator, count * sizeof(*points)); lines = MEM_ALLOC(allocator, count * sizeof(*lines)); @@ -661,7 +688,7 @@ exit: return res; error: if(geom) { - CHK(RES_OK == geometry_release(geom)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, geom)); geom = NULL; } goto exit; @@ -674,11 +701,13 @@ scad_add_box const double dxdydz[3], struct scad_geometry** out_geometry) { + res_T res = RES_OK; int ierr, gmsh_ID; struct scad_geometry* geom = NULL; struct scad_device* dev = get_device(); struct mem_allocator* allocator = NULL; - res_T res = RES_OK; + int log; + enum scad_log_refcounting option; if(!xyz || !dxdydz || !out_geometry) { res = RES_BAD_ARG; @@ -687,6 +716,8 @@ scad_add_box ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; gmsh_ID = gmshModelOccAddBox(SPLIT3(xyz), SPLIT3(dxdydz), -1, &ierr); ERR(gmsh_err_to_res_T(ierr)); @@ -708,7 +739,7 @@ exit: return res; error: if(geom) { - CHK(RES_OK == geometry_release(geom)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, geom)); geom = NULL; } goto exit; @@ -723,11 +754,13 @@ scad_add_cylinder const double angle, struct scad_geometry** out_geometry) { + res_T res = RES_OK; int ierr, gmsh_ID; struct scad_geometry* geom = NULL; struct scad_device* dev = get_device(); struct mem_allocator* allocator = NULL; - res_T res = RES_OK; + int log; + enum scad_log_refcounting option; if(!xyz || !axis || radius <= 0 || angle < 0 || angle > 2*PI || !out_geometry) { res = RES_BAD_ARG; @@ -736,6 +769,8 @@ scad_add_cylinder ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; gmsh_ID = gmshModelOccAddCylinder(SPLIT3(xyz), SPLIT3(axis), radius, -1, angle, &ierr); @@ -758,7 +793,7 @@ exit: return res; error: if(geom) { - CHK(RES_OK == geometry_release(geom)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, geom)); geom = NULL; } goto exit; @@ -771,11 +806,13 @@ scad_add_sphere const double radius, struct scad_geometry** out_geometry) { + res_T res = RES_OK; int ierr, gmsh_ID; struct scad_geometry* geom = NULL; struct scad_device* dev = get_device(); struct mem_allocator* allocator = NULL; - res_T res = RES_OK; + int log; + enum scad_log_refcounting option; if(!xyz || radius <= 0 || !out_geometry) { res = RES_BAD_ARG; @@ -784,6 +821,8 @@ scad_add_sphere ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; gmsh_ID = gmshModelOccAddSphere(SPLIT3(xyz), radius, -1, -PI/2, PI/2, 2*PI, &ierr); @@ -806,7 +845,7 @@ exit: return res; error: if(geom) { - CHK(RES_OK == geometry_release(geom)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, geom)); geom = NULL; } goto exit; @@ -821,6 +860,7 @@ scad_fuse_geometries const size_t tools_count, struct scad_geometry** out_geometry) { + res_T res = RES_OK; int* tagout = NULL; int** map = NULL; size_t* mapn = NULL; @@ -831,7 +871,8 @@ scad_fuse_geometries struct scad_geometry* geom = NULL; struct scad_device* dev = get_device(); struct mem_allocator* allocator = NULL; - res_T res = RES_OK; + int log; + enum scad_log_refcounting option; if(!geometries || !geometries_count || !tools || !tools_count || !out_geometry) { res = RES_BAD_ARG; @@ -840,6 +881,8 @@ scad_fuse_geometries ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; ERR(gather_tags(geometries, geometries_count, &data1, &sz1)); ERR(gather_tags(tools, tools_count, &data2, &sz2)); @@ -873,7 +916,7 @@ exit: return res; error: if(geom) { - CHK(RES_OK == geometry_release(geom)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, geom)); geom = NULL; } if(tagout) gmshModelOccRemove(tagout, tagoutn, 1, &ierr); @@ -889,6 +932,7 @@ scad_cut_geometries const size_t tools_count, struct scad_geometry** out_geometry) { + res_T res = RES_OK; int* tagout = NULL; int** map = NULL; size_t* mapn = NULL; @@ -899,7 +943,8 @@ scad_cut_geometries struct scad_geometry* geom = NULL; struct scad_device* dev = get_device(); struct mem_allocator* allocator = NULL; - res_T res = RES_OK; + int log; + enum scad_log_refcounting option; if(!geometries || !geometries_count || !tools || !tools_count || !out_geometry) { res = RES_BAD_ARG; @@ -908,6 +953,8 @@ scad_cut_geometries ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; ERR(gather_tags(geometries, geometries_count, &data1, &sz1)); ERR(gather_tags(tools, tools_count, &data2, &sz2)); @@ -941,7 +988,7 @@ exit: return res; error: if(geom) { - CHK(RES_OK == geometry_release(geom)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, geom)); geom = NULL; } if(tagout) gmshModelOccRemove(tagout, tagoutn, 1, &ierr); @@ -957,6 +1004,7 @@ scad_intersect_geometries const size_t tools_count, struct scad_geometry** out_geometry) { + res_T res = RES_OK; int* tagout = NULL; int** map = NULL; size_t* mapn = NULL; @@ -967,7 +1015,8 @@ scad_intersect_geometries struct scad_geometry* geom = NULL; struct scad_device* dev = get_device(); struct mem_allocator* allocator = NULL; - res_T res = RES_OK; + int log; + enum scad_log_refcounting option; if(!geometries || !geometries_count || !tools || !tools_count || !out_geometry) { res = RES_BAD_ARG; @@ -976,6 +1025,8 @@ scad_intersect_geometries ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; ERR(gather_tags(geometries, geometries_count, &data1, &sz1)); ERR(gather_tags(tools, tools_count, &data2, &sz2)); @@ -1009,7 +1060,7 @@ exit: return res; error: if(geom) { - CHK(RES_OK == geometry_release(geom)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, geom)); geom = NULL; } if(tagout) gmshModelOccRemove(tagout, tagoutn, 1, &ierr); @@ -1025,6 +1076,7 @@ scad_geometries_common_boundaries const size_t tools_count, struct scad_geometry** out_geometry) { + res_T res = RES_OK; int* tagout = NULL; int** map = NULL; size_t* mapn = NULL; @@ -1038,7 +1090,8 @@ scad_geometries_common_boundaries struct scad_geometry* geom = NULL; struct mem_allocator* allocator = NULL; struct scad_device* dev = get_device(); - res_T res = RES_OK; + int log; + enum scad_log_refcounting option; if(!geometries || !geometries_count || !tools || !tools_count || !out_geometry) { res = RES_BAD_ARG; @@ -1047,6 +1100,8 @@ scad_geometries_common_boundaries ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; ERR(gather_tags(geometries, geometries_count, &data1, &sz1)); ERR(gather_tags(tools, tools_count, &data2, &sz2)); @@ -1086,7 +1141,7 @@ exit: return res; error: if(geom) { - CHK(RES_OK == geometry_release(geom)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, geom)); geom = NULL; } if(tagout) gmshModelOccRemove(tagout, tagoutn, 1, &ierr); @@ -1131,6 +1186,7 @@ scad_geometry_extrude const double dxdydz[3], struct scad_geometry** out_geometry) { + res_T res = RES_OK; int* tagout = NULL; size_t tagoutn; size_t i, j; @@ -1140,7 +1196,8 @@ scad_geometry_extrude struct scad_geometry* extrude_geom = NULL; struct scad_device* dev = get_device(); struct mem_allocator* allocator = NULL; - res_T res = RES_OK; + int log; + enum scad_log_refcounting option; if(!geom || !dxdydz || !out_geometry) { res = RES_BAD_ARG; @@ -1149,6 +1206,8 @@ scad_geometry_extrude ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; gmshModelOccExtrude(geom->gmsh_dimTags, geom->gmsh_dimTags_n, SPLIT3(dxdydz), &tagout, &tagoutn, NULL, 0, NULL, 0, 0, &ierr); @@ -1188,7 +1247,7 @@ exit: return res; error: if(extrude_geom) { - CHK(RES_OK == geometry_release(extrude_geom)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, extrude_geom)); extrude_geom = NULL; } goto exit; @@ -1276,6 +1335,7 @@ scad_geometry_copy const char* name, /* Can be NULL */ struct scad_geometry** out_geometry) { + res_T res = RES_OK; int* data1; int* tagout = NULL; size_t sz1, tagoutn; @@ -1283,7 +1343,8 @@ scad_geometry_copy struct scad_geometry* copy = NULL; struct scad_device* dev = get_device(); struct mem_allocator* allocator = NULL; - res_T res = RES_OK; + int log; + enum scad_log_refcounting option; if(!geom || !out_geometry) { res = RES_BAD_ARG; @@ -1292,6 +1353,8 @@ scad_geometry_copy ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; sz1 = geom->gmsh_dimTags_n; data1 = geom->gmsh_dimTags; @@ -1316,7 +1379,7 @@ exit: return res; error: if(copy) { - CHK(RES_OK == geometry_release(copy)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, copy)); copy = NULL; } if(tagout) gmshModelOccRemove(tagout, tagoutn, 1, &ierr); @@ -1397,6 +1460,8 @@ scad_geometries_partition struct htable_tags_iterator it, end; int ht_initialized = 0; struct mem_allocator* allocator = NULL; + int log; + enum scad_log_refcounting option; if(!geometries || !geometries_count || (allow_overlapping && !out_geometries)) { res = RES_BAD_ARG; @@ -1405,6 +1470,8 @@ scad_geometries_partition ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; ERR(gather_tags(geometries, geometries_count, &data, &sz)); @@ -1544,7 +1611,7 @@ exit: error: if(geoms) { for(i = 0; i < geometries_count; i++) { - if(geoms[i]) CHK(RES_OK == geometry_release(geoms[i])); + if(geoms[i]) CHK(RES_OK == geometry_release(log, LOG_OUTPUT, geoms[i])); } } if(tagout) { @@ -1562,6 +1629,7 @@ scad_fragment_geometries const size_t tools_count, struct scad_geometry** out_geometry) { + res_T res = RES_OK; int* tagout = NULL; int** map = NULL; size_t* mapn = NULL; @@ -1572,7 +1640,8 @@ scad_fragment_geometries struct scad_geometry* geom = NULL; struct scad_device* dev = get_device(); struct mem_allocator* allocator = NULL; - res_T res = RES_OK; + int log; + enum scad_log_refcounting option; if(!geometries || !geometries_count || !tools || !tools_count || !out_geometry) { res = RES_BAD_ARG; @@ -1581,6 +1650,8 @@ scad_fragment_geometries ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; ERR(gather_tags(geometries, geometries_count, &data1, &sz1)); ERR(gather_tags(tools, tools_count, &data2, &sz2)); @@ -1614,7 +1685,7 @@ exit: return res; error: if(geom) { - CHK(RES_OK == geometry_release(geom)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, geom)); geom = NULL; } if(tagout) gmshModelOccRemove(tagout, tagoutn, 1, &ierr); @@ -1630,6 +1701,7 @@ scad_geometry_boundary const size_t geometries_count, struct scad_geometry** out_geometry) { + res_T res = RES_OK; int* tagout = NULL; size_t tagoutn, sz; int* data = NULL; @@ -1637,7 +1709,8 @@ scad_geometry_boundary struct scad_geometry* geom = NULL; struct scad_device* dev = get_device(); struct mem_allocator* allocator = NULL; - res_T res = RES_OK; + int log; + enum scad_log_refcounting option; if(!geometries || !out_geometry) { res = RES_BAD_ARG; @@ -1646,6 +1719,8 @@ scad_geometry_boundary ERR(check_device(FUNC_NAME)); allocator = dev->allocator; + option = dev->options.Misc.LogOpenCascadeTagsRefCounting; + log = option == Scad_log_all; ERR(gather_tags(geometries, geometries_count, &data, &sz)); gmshModelGetBoundary(data, sz, &tagout, &tagoutn, 1, 0, 0, &ierr); @@ -1669,7 +1744,7 @@ exit: return res; error: if(geom) { - CHK(RES_OK == geometry_release(geom)); + CHK(RES_OK == geometry_release(log, LOG_OUTPUT, geom)); geom = NULL; } if(tagout) gmshModelOccRemove(tagout, tagoutn, 1, &ierr); diff --git a/src/scad_geometry.h b/src/scad_geometry.h @@ -20,6 +20,7 @@ #include <rsys/rsys.h> #include <rsys/str.h> +#include <rsys/logger.h> struct scad_geometry { int* gmsh_dimTags; @@ -29,6 +30,8 @@ struct scad_geometry { LOCAL_SYM res_T geometry_release - (struct scad_geometry* geom); + (const int log, + const enum log_type log_type, + struct scad_geometry* geom); #endif