commit e20b5a9eb73c33969250f8d53d2de38907727a08
parent 7a9bc8e8f712df1e7c92ec7e2f02be5f278a8d68
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Wed, 23 Nov 2022 14:46:12 +0100
Remove obsolete code; rename geometry partition API call
Diffstat:
3 files changed, 6 insertions(+), 135 deletions(-)
diff --git a/src/scad.h b/src/scad.h
@@ -246,21 +246,6 @@ scad_geometries_common_boundaries
struct scad_geometry** out_geometry);
/* Compute the boolean fragments (general fuse) resulting from the
- * intersection of the geometries in `geometries' and `tools', making all
- * interfaces conformal. When applied to geometries of different dimensions, the
- * lower dimensional geometries will be automatically embedded in the higher
- * dimensional geometries if they are not on their boundary. */
-SCAD_API res_T
-scad_geometries_partition
- (const char* name, /* Can be NULL */
- struct scad_geometry** geometries,
- const size_t geometries_count,
- struct scad_geometry** tools,
- const size_t tools_count,
- const int allow_overlapping,
- struct scad_geometry** out_geometry);
-
-/* Compute the boolean fragments (general fuse) resulting from the
* intersection of every single geometry in `geometries' and the
* other geometries in `geometries' used as tools, making all interfaces
* conformal.
@@ -270,7 +255,7 @@ scad_geometries_partition
* geometries will be automatically embedded in the higher dimensional
* geometries if they are not on their boundary. */
SCAD_API res_T
-scad_geometries_partition_one
+scad_geometries_partition
(char** names, /* Can be NULL */
struct scad_geometry** geometries,
const size_t geometries_count,
diff --git a/src/scad_geometry.c b/src/scad_geometry.c
@@ -180,92 +180,6 @@ error:
goto exit;
}
-static res_T
-scad_geometries_partition_core
- (const char* name,
- struct scad_geometry** geometries,
- const size_t geometries_count,
- const size_t except,
- struct scad_geometry** tools,
- const size_t tools_count,
- const int allow_overlapping,
- struct scad_geometry** out_geom)
-{
- int* tagout = NULL;
- int** map = NULL;
- size_t* mapn = NULL;
- size_t tagoutn = 0, mapnn, sz1, sz2 = 0;
- int* data1 = NULL;
- int* data2 = NULL;
- int ierr = 0;
- struct scad_geometry* geom = NULL;
- res_T res = RES_OK;
-
- if(!geometries || !geometries_count || !tools || !tools_count || !out_geom) {
- res = RES_BAD_ARG;
- goto error;
- }
-
- ERR(check_device(FUNC_NAME));
- if(get_device()->need_synchro) {
- ERR(scad_synchronize());
- }
-
- ERR(gather_tags(geometries, geometries_count, except, &data1, &sz1));
- ERR(gather_tags(tools, tools_count, SIZE_MAX, &data2, &sz2));
-
- /* We don't remove gmsh objects here; they are only removed when their tags
- * are no longuer used by any star-cad geometry */
- gmshModelOccFragment(data1, sz1, data2, sz2, &tagout, &tagoutn, &map, &mapn,
- &mapnn, -1, 0, 0, &ierr);
- ERR(gmsh_err_to_res_T(ierr));
- if(!allow_overlapping) {
- /* Each tag in geometries must have been translated to a single tag in map */
- size_t i, err;
- for(i = 0, err = SIZE_MAX; i < mapnn; i++) {
- if(mapn[i] != 2) {
- err = i;
- break;
- }
- }
- if(err != SIZE_MAX) {
- struct scad_geometry* problem = geometries[err];
- res = RES_BAD_ARG;
- if(str_is_empty(&problem->name)) {
- log_error(get_device(), "Unnamed geometry overlapping tools.\n");
- } else {
- log_error(get_device(), "Geometry '%s' overlapping tools.\n",
- str_cget(&problem->name));
- }
- goto error;
- }
- }
-
- ERR(scad_geometry_create(name, &geom));
- geom->gmsh_dimTags_n = tagoutn;
- geom->gmsh_dimTags = tagout;
- tagout = NULL; /* Prevent possible double free */
-
- ERR(device_register_tags(geom));
-
-exit:
- if(out_geom) *out_geom = geom;
- free(data1);
- free(data2);
- free(mapn);
- free(map);
- return res;
-error:
- if(geom) {
- CHK(RES_OK == geometry_release(geom));
- geom = NULL;
- }
- if(tagout) {
- gmshModelOccRemove(tagout, tagoutn, 1, &ierr);
- free(tagout);
- }
- goto exit;
-}
/*******************************************************************************
* Local functions
******************************************************************************/
@@ -1286,7 +1200,7 @@ error:
}
res_T
-scad_geometries_partition_one
+scad_geometries_partition
(char** names, /* Can be NULL */
struct scad_geometry** geometries,
const size_t geometries_count,
@@ -1460,20 +1374,6 @@ error:
}
res_T
-scad_geometries_partition
- (const char* name,
- struct scad_geometry** geometries,
- const size_t geometries_count,
- struct scad_geometry** tools,
- const size_t tools_count,
- const int allow_overlapping,
- struct scad_geometry** out_geometry)
-{
- return scad_geometries_partition_core(name, geometries, geometries_count,
- SIZE_MAX, tools, tools_count, allow_overlapping, out_geometry);
-}
-
-res_T
scad_fragment_geometries
(const char* name,
struct scad_geometry** geometries,
diff --git a/src/test1.c b/src/test1.c
@@ -35,7 +35,6 @@ main(int argc, char* argv[])
struct scad_geometry* geom2 = NULL;
struct scad_geometry* cyl = NULL;
struct scad_geometry* tmp1 = NULL;
- struct scad_geometry* tmp2 = NULL;
struct scad_geometry* tmp3 = NULL;
struct scad_geometry* f1 = NULL;
struct scad_geometry* f2 = NULL;
@@ -43,7 +42,6 @@ main(int argc, char* argv[])
struct scad_geometry* geoms[2];
struct scad_geometry* tools[5];
struct mem_allocator allocator;
- struct scad_options options = SCAD_DEFAULT_OPTIONS__;
(void)argc; (void)argv;
@@ -51,23 +49,15 @@ main(int argc, char* argv[])
OK(scad_initialize(NULL, &allocator, 1));
- options.Misc.Step = 1;
- options.Misc.SynchronizeOnRunUI = 1;
- OK(scad_set_options(&options));
-
OK(scad_add_cylinder("c1", p1, d1, 2, PI, &geom1));
OK(scad_add_box("b1", p2, d2, &geom2));
geoms[0] = geom1;
geoms[1] = geom2;
- BAD(scad_geometries_partition(NULL, geoms, 2, NULL, 0, 0, &tmp1));
- OK(scad_geometries_partition(NULL, geoms, 2, NULL, 0, 1, &tmp1));
+ BAD(scad_geometries_partition(NULL, NULL, 0, 0, &tmp1));
+ OK(scad_geometries_partition(NULL, geoms, 2, 1, &tmp1));
OK(scad_geometry_delete(tmp1));
OK(scad_cut_geometries("cut_c1", &geom1, 1, & geom2, 1, &tmp1));
- OK(scad_geometries_partition("tmp2", &tmp1, 1, &geom2, 1, 1, &tmp2));
- OK(scad_geometry_delete(tmp2));
-
- OK(scad_geometries_partition("tmp2", &tmp1, 1, &geom2, 1, 0, &tmp2));
OK(scad_add_cylinder("cyl", p1, d1, 1, 2*PI, &cyl));
@@ -78,9 +68,9 @@ main(int argc, char* argv[])
tools[0] = geom2;
tools[1] = tmp1;
- tools[2] = tmp2;
+ tools[2] = geom1;
tools[3] = f1;
- BAD(scad_geometries_partition(NULL, &geom1, 1, tools, 4, 0, &tmp3));
+ BAD(scad_geometries_partition(NULL, tools, 4, 0, &tmp3));
/* OK(scad_scene_mesh()); */
OK(scad_stl_export(geom1, NULL, 1));
@@ -90,7 +80,6 @@ main(int argc, char* argv[])
/* OK(scad_stl_export(f1, NULL, 1)); */
/* OK(scad_stl_export(f2, NULL, 0)); */
-exit:
OK(scad_finalize());
check_memory_allocator(&allocator);
@@ -98,7 +87,4 @@ exit:
CHK(mem_allocated_size() == 0);
return (res == RES_OK) ? EXIT_SUCCESS : EXIT_FAILURE;
-error:
- fprintf(stderr, "Something failed.\n");
- goto exit;
}