commit 919a80d3f0c0e7f93762093cd802b19cc52d495c
parent f5db3052bf75463e410aa4c24fb87f6da14a79c1
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Tue, 9 Sep 2025 10:49:29 +0200
Change APIs that create geometries and set their names
These calls now create unnamed geometries that can be collectively named
using the new scad_geometries_set_name API call.
Diffstat:
6 files changed, 170 insertions(+), 138 deletions(-)
diff --git a/src/scad.c b/src/scad.c
@@ -906,9 +906,10 @@ scad_stl_export_split
size_t i;
struct scad_geometry** parts = NULL;
struct scad_device* dev = get_device();
- size_t count;
+ size_t cpt = 0, count;
+ struct str name;
+ int init = 0;
res_T res = RES_OK;
- (void)binary;
if(!geometry || (!file_name && str_is_empty(&geometry->name))) {
res = RES_BAD_ARG;
@@ -917,10 +918,13 @@ scad_stl_export_split
ERR(check_device(FUNC_NAME));
- ERR(scad_geometry_explode(file_name, geometry, &parts, &count));
+ ERR(scad_geometry_explode(geometry, &parts, &count));
ASSERT(count*2 == geometry->gmsh_dimTags_n);
+ str_init(dev->allocator, &name);
+ init = 1;
for(i = 0; i < count; i++) {
- ERR(scad_stl_export(parts[i], NULL, orientation, binary));
+ ERR(str_printf(&name, "%s_%ld", file_name, cpt++));
+ ERR(scad_stl_export(parts[i], str_cget(&name), orientation, binary));
}
exit:
@@ -928,6 +932,7 @@ exit:
for(i = 0; i < count; i++) SCAD(geometry_ref_put(parts[i]));
MEM_RM(dev->allocator, parts);
}
+ if(init) str_release(&name);
return res;
error:
goto exit;
diff --git a/src/scad.h b/src/scad.h
@@ -347,16 +347,13 @@ scad_geometry_extrude
struct scad_geometry** out_geometry);
/* Return a list of geometries which form the geometry `geometry'.
- * The output geometries are named <base>_<rank>, where <base> is either
- * prefix_name (first choice) or geom's name, <rank> counting from 0. Otherwise
- * they remain unnamed.
+ * The output geometries are created unnamed.
* Whatever the names, if defined they must be unique.
* The result `out_geometries' being allocated using the allocator provided when
* initializing star-cad, it should be freed accordingly. */
SCAD_API res_T
scad_geometry_explode
- (const char* prefix_name, /* Can be NULL */
- const struct scad_geometry* geometry,
+ (const struct scad_geometry* geometry,
struct scad_geometry*** out_geometries,
size_t* out_count);
@@ -405,6 +402,17 @@ scad_geometry_set_name
(struct scad_geometry* geometry,
const char* name); /* Can be NULL */
+/* Set the name of geometries in `geometries'.
+ * If `prefix_name' is not NULL, the geometries are named <prefix_name>_<rank>,
+ * <rank> counting from `from_rank'. Otherwise their names are set to NULL.
+ * If not NULL, names must be unique. */
+SCAD_API res_T
+scad_geometries_set_name
+ (struct scad_geometry** geometries,
+ const size_t geometries_count,
+ const char* prefix_name, /* Can be NULL */
+ const size_t from_rank);
+
/* Get a pointer to `geometry's name, NULL if unnamed.
* Note that this reference is only valid during the lifetime of `geometry'
* (don't use name after deleting `geometry'). */
@@ -557,9 +565,7 @@ scad_geometries_partition
/* compute boundary intersection (the common part) of the geometries in
* `geometries' and `tools'.
- * If `prefix_name' is not NULL, the output geometries are named
- * <prefix_name>_<rank>, <rank> counting from 0. Otherwise they remain unnamed.
- * If `prefix_name' is provided, the resulting names must be unique.
+ * The output geometries are created unnamed.
* The result `out_boundaries' being allocated using the allocator provided when
* initializing star-cad, it should be freed accordingly.
* If there is no common boundary, `out_boundaries' is set to NULL and
@@ -568,8 +574,7 @@ scad_geometries_partition
* they have been partitioned. */
SCAD_API res_T
scad_geometries_common_boundaries
- (const char* prefix_name, /* Can be NULL */
- struct scad_geometry** geometries,
+ (struct scad_geometry** geometries,
const size_t geometries_count,
struct scad_geometry** tools,
const size_t tools_count,
@@ -577,15 +582,12 @@ scad_geometries_common_boundaries
size_t *out_count);
/* Get the boundary of the geometries in `geometries', considered as a whole.
- * If `prefix_name' is not NULL, the output geometries are named
- * <prefix_name>_<rank>, <rank> counting from 0. Otherwise they remain unnamed.
- * If `prefix_name' is provided, the resulting names must be unique.
+ * The output geometries are created unnamed.
* The result `out_boundaries' being allocated using the allocator provided when
* initializing star-cad, it should be freed accordingly. */
SCAD_API res_T
scad_geometries_boundary
- (const char* prefix_name, /* Can be NULL */
- struct scad_geometry** geometries,
+ (struct scad_geometry** geometries,
const size_t geometries_count,
struct scad_geometry*** out_boundaries,
size_t *out_count);
@@ -661,15 +663,12 @@ scad_geometries_clear_mesh
/* Import a step model from file `filename'.
* The imported geometries are recorded in `out_geometries'.
+ * The output geometries are created unnamed.
* Note that `out_geometries' is allocated using the allocator provided when
- * initializing star-cad and should be freed accordingly.
- * If `prefix_name' is not NULL, the output geometries are named
- * <prefix_name>_<rank>, <rank> counting from 0. Otherwise they remain unnamed.
- * If `prefix_name' is provided, the resulting names must be unique. */
+ * initializing star-cad and should be freed accordingly. */
SCAD_API res_T
scad_step_import
- (const char* prefix_name, /* Can be NULL */
- const char* filename, /* name of step file */
+ (const char* filename, /* name of step file */
struct scad_geometry*** out_geometries,
size_t* out_count);
diff --git a/src/scad_geometry.c b/src/scad_geometry.c
@@ -1958,8 +1958,7 @@ error:
res_T
scad_geometries_common_boundaries
- (const char* prefix_name, /* Can be NULL */
- struct scad_geometry** geometries,
+ (struct scad_geometry** geometries,
const size_t geometries_count,
struct scad_geometry** tools,
const size_t tools_count,
@@ -1982,8 +1981,8 @@ scad_geometries_common_boundaries
int log;
enum log_type log_type;
size_t i, c = 0, n;
- struct str msg, name;
- int msg_initialized = 0, name_initialized = 0;
+ struct str msg;
+ int msg_initialized = 0;
if(!geometries || !geometries_count || !tools || !tools_count
|| !out_boundaries || !out_count)
@@ -2013,19 +2012,10 @@ scad_geometries_common_boundaries
c = tagoutn / 2;
if(tagoutn == 0) {
- if(prefix_name) {
- log_message(dev, "Common boundary list '%s' is empty.\n", prefix_name);
- } else {
- log_message(dev, "Unnamed common boundary list is empty.\n");
- }
+ log_message(dev, "Common boundary list is empty.\n");
goto exit;
}
- if(prefix_name) {
- str_init(allocator, &name);
- name_initialized = 1;
- }
-
log = (dev->options.Misc.LogRefCounting & SCAD_LOG_DIMTAGS_ALL);
log_type = dev->log_type;
if(log) {
@@ -2060,11 +2050,6 @@ scad_geometries_common_boundaries
struct tag_desc* desc;
ASSERT(dim == 2);
ERR(geometry_create(out_geom+n));
- if(prefix_name) {
- ERR(str_set(&name, prefix_name));
- ERR(str_append_printf(&name,"_%lu", (unsigned long)i));
- ERR(geom_set_name(out_geom[n], &name));
- }
out_geom[n]->gmsh_dimTags_n = 2;
out_geom[n]->gmsh_dimTags = MEM_ALLOC(allocator,
2 * sizeof(*out_geom[n]->gmsh_dimTags));
@@ -2088,7 +2073,6 @@ scad_geometries_common_boundaries
exit:
if(msg_initialized) str_release(&msg);
- if(name_initialized) str_release(&name);
if(out_boundaries) *out_boundaries = out_geom;
if(out_count) *out_count = c;
if(allocator) {
@@ -2281,8 +2265,7 @@ error:
res_T
scad_geometry_explode
- (const char* prefix_name, /* Can be NULL */
- const struct scad_geometry* geom,
+ (const struct scad_geometry* geom,
struct scad_geometry*** out_geometry,
size_t* out_n)
{
@@ -2294,7 +2277,6 @@ scad_geometry_explode
int name_initialized = 0;
struct scad_device* dev = get_device();
struct mem_allocator* allocator = NULL;
- const char* base_name = NULL;
if(!geom || !out_geometry || !out_n) {
res = RES_BAD_ARG;
@@ -2314,21 +2296,10 @@ scad_geometry_explode
goto error;
}
- if(prefix_name || !str_is_empty(&geom->name)) {
- base_name = prefix_name ? prefix_name : str_cget(&geom->name);
- str_init(allocator, &name);
- name_initialized = 1;
- }
-
for(i = 0, n = 0; i < sz; i += 2, n++) {
const int dim = data[i];
const int tag = data[i+1];
ERR(geometry_create(geom_array+n));
- if(base_name) {
- ERR(str_set(&name, base_name));
- ERR(str_append_printf(&name,"_%lu", (unsigned long)n));
- ERR(geom_set_name(geom_array[n], &name));
- }
geom_array[n]->gmsh_dimTags_n = 2;
geom_array[n]->gmsh_dimTags
= MEM_ALLOC(allocator, 2 * sizeof(*geom_array[0]->gmsh_dimTags));
@@ -2413,6 +2384,52 @@ error:
}
res_T
+scad_geometries_set_name
+ (struct scad_geometry** geometries,
+ const size_t geometries_count,
+ const char* prefix_name, /* Can be NULL */
+ const size_t from_rank) /* Can be NULL */
+{
+ res_T res = RES_OK;
+ struct str tmp;
+ int initialized = 0;
+ struct mem_allocator* allocator = NULL;
+ size_t i, cpt;
+
+ if(!geometries || geometries_count == 0) {
+ res = RES_BAD_ARG;
+ goto error;
+ }
+
+ ERR(check_device(FUNC_NAME));
+
+ if(!prefix_name) {
+ for(i = 0; i < geometries_count; i++) {
+ ERR(geom_set_name(geometries[i], NULL));
+ }
+ }
+ else if(strlen(prefix_name) == 0) {
+ log_error(get_device(), "Geometry name \"\" is invalid.\n");
+ res = RES_BAD_ARG;
+ goto error;
+ } else {
+ str_init(allocator, &tmp);
+ initialized = 1;
+ cpt = from_rank;
+ for(i = 0; i < geometries_count; i++) {
+ ERR(str_printf(&tmp, "%s_%ld", prefix_name, cpt++));
+ ERR(geom_set_name(geometries[i], &tmp));
+ }
+ }
+
+exit:
+ if(initialized) str_release(&tmp);
+ return res;
+error:
+ goto exit;
+}
+
+res_T
scad_geometry_set_name
(struct scad_geometry* geom,
const char* name) /* Can be NULL */
@@ -2896,8 +2913,7 @@ error:
res_T
scad_geometries_boundary
- (const char* prefix_name,
- struct scad_geometry** geometries,
+ (struct scad_geometry** geometries,
const size_t geometries_count,
struct scad_geometry*** out_boundaries,
size_t *out_count)
@@ -2913,8 +2929,8 @@ scad_geometries_boundary
int log;
enum log_type log_type;
size_t i, c = 0, n;
- struct str msg, name;
- int msg_initialized = 0, name_initialized = 0;
+ struct str msg;
+ int msg_initialized = 0;
if(!geometries || geometries_count == 0 || !out_boundaries || !out_count) {
res = RES_BAD_ARG;
@@ -2937,11 +2953,6 @@ scad_geometries_boundary
goto error;
}
- if(prefix_name) {
- str_init(allocator, &name);
- name_initialized = 1;
- }
-
log = (dev->options.Misc.LogRefCounting & SCAD_LOG_DIMTAGS_ALL);
log_type = dev->log_type;
if(log) {
@@ -2969,11 +2980,6 @@ scad_geometries_boundary
struct tag_desc* desc = NULL;
ASSERT(dim == 2);
ERR(geometry_create(out_geom+n));
- if(prefix_name) {
- ERR(str_set(&name, prefix_name));
- ERR(str_append_printf(&name,"_%lu", (unsigned long)i));
- ERR(geom_set_name(out_geom[n], &name));
- }
out_geom[n]->gmsh_dimTags_n = 2;
out_geom[n]->gmsh_dimTags = MEM_ALLOC(allocator, 2 * sizeof(*tagout));
if(!out_geom[n]->gmsh_dimTags) {
@@ -2998,7 +3004,6 @@ scad_geometries_boundary
exit:
if(msg_initialized) str_release(&msg);
- if(name_initialized) str_release(&name);
if(allocator) MEM_RM(allocator, data);
if(out_boundaries) *out_boundaries = out_geom;
if(out_count) *out_count = c;
@@ -3019,8 +3024,7 @@ error:
res_T
scad_step_import
- (const char* prefix_name,
- const char* filename,
+ (const char* filename,
struct scad_geometry*** out_geometry,
size_t* out_n)
{
@@ -3058,12 +3062,6 @@ scad_step_import
name_initialized = 1;
for(i=0; i<ga_sz; ++i) {
ERR(geometry_create(geom_array+i));
- if (prefix_name) {
- ERR(str_set(&strname, prefix_name));
- ERR(str_append_printf(&strname,"_%lu", (unsigned long)i));
- ERR(geom_set_name(geom_array[i], &strname));
- }
-
geom_array[i]->gmsh_dimTags_n = 2;
geom_array[i]->gmsh_dimTags
= MEM_ALLOC(allocator, 2 * sizeof(*geom_array[i]->gmsh_dimTags));
diff --git a/src/test_api.c b/src/test_api.c
@@ -110,7 +110,7 @@ main(int argc, char* argv[])
BAD(scad_geometry_translate(geom1, p1, &geom));
BAD(scad_geometry_rotate(geom1, p1, p1, 2, &geom));
BAD(scad_geometry_extrude(geom1, p1, &geom));
- BAD(scad_geometry_explode(NULL, geom1, &geom_array, &c));
+ BAD(scad_geometry_explode(geom1, &geom_array, &c));
BAD(scad_geometry_ref_get(geom1));
BAD(scad_geometry_ref_put(geom1));
BAD(scad_geometry_get_count(geom1, NULL));
@@ -118,6 +118,7 @@ main(int argc, char* argv[])
BAD(scad_geometry_set_custom_data(geom1, NULL, NULL));
BAD(scad_geometry_get_custom_data(geom1, (void*)&trg));
BAD(scad_geometry_set_name(geom1, name));
+ BAD(scad_geometries_set_name(&geom1, 1, name, 0));
BAD(scad_geometry_get_name(geom1, &name));
BAD(scad_geometries_swap(&geom1, &geom2, 1, 0));
BAD(scad_geometry_get_mass(geom1, &m));
@@ -132,15 +133,15 @@ main(int argc, char* argv[])
BAD(scad_geometries_cut(&geom1, 1, &geom2, 1, &geom));
BAD(scad_geometries_intersect(&geom1, 1, &geom2, 1, &geom));
BAD(scad_geometries_partition(&geom1, 1, 0, &geom));
- BAD(scad_geometries_common_boundaries(NULL, &geom1, 1, &geom2, 1, &geom_array, &c));
- BAD(scad_geometries_boundary(NULL, &geom1, 1, &geom_array, &c));
+ BAD(scad_geometries_common_boundaries(&geom1, 1, &geom2, 1, &geom_array, &c));
+ BAD(scad_geometries_boundary(&geom1, 1, &geom_array, &c));
BAD(scad_geometry_copy(geom1, &geom2));
BAD(scad_geometry_set_visibility(geom1, 0, 0));
BAD(scad_geometries_set_periodic(&geom1, 1, &geom2, 1, affine));
BAD(scad_geometries_set_mesh_size_modifier(&geom1, 1, SCAD_ABSOLUTE_SIZE, 1));
BAD(scad_geometries_set_mesh_algorithm(&geom1, 1, SCAD_QUASI_STRUCTURED));
BAD(scad_geometries_clear_mesh(&geom1, 1));
- BAD(scad_step_import("prefix", "test.step", &geom_array, &c));
+ BAD(scad_step_import("test.step", &geom_array, &c));
BAD(scad_stl_export(geom1, "test.stl", SCAD_KEEP_NORMALS_UNCHANGED, 0));
BAD(scad_stl_export_partial(geom1, &geom1, 1, "test.stl",
SCAD_KEEP_NORMALS_UNCHANGED, 0));
@@ -177,7 +178,7 @@ main(int argc, char* argv[])
BAD(scad_geometry_translate(geom1, p1, &geom));
BAD(scad_geometry_rotate(geom1, p1, p1, 2, &geom));
BAD(scad_geometry_extrude(geom1, p1, &geom));
- BAD(scad_geometry_explode(NULL, geom1, &geom_array, &c));
+ BAD(scad_geometry_explode(geom1, &geom_array, &c));
BAD(scad_geometry_ref_get(geom1));
BAD(scad_geometry_ref_put(geom1));
BAD(scad_geometry_get_count(geom1, NULL));
@@ -185,6 +186,7 @@ main(int argc, char* argv[])
BAD(scad_geometry_set_custom_data(geom1, NULL, NULL));
BAD(scad_geometry_get_custom_data(geom1, (void*)&trg));
BAD(scad_geometry_set_name(geom1, name));
+ BAD(scad_geometries_set_name(&geom1, 1, name, 0));
BAD(scad_geometry_get_name(geom1, &name));
BAD(scad_geometries_swap(&geom1, &geom2, 1, 0));
BAD(scad_geometry_get_mass(geom1, &m));
@@ -199,15 +201,15 @@ main(int argc, char* argv[])
BAD(scad_geometries_cut(&geom1, 1, &geom2, 1, &geom));
BAD(scad_geometries_intersect(&geom1, 1, &geom2, 1, &geom));
BAD(scad_geometries_partition(&geom1, 1, 0, &geom));
- BAD(scad_geometries_common_boundaries(NULL, &geom1, 1, &geom2, 1, &geom_array, &c));
- BAD(scad_geometries_boundary(NULL, &geom1, 1, &geom_array, &c));
+ BAD(scad_geometries_common_boundaries(&geom1, 1, &geom2, 1, &geom_array, &c));
+ BAD(scad_geometries_boundary(&geom1, 1, &geom_array, &c));
BAD(scad_geometry_copy(geom1, &geom2));
BAD(scad_geometry_set_visibility(geom1, 0, 0));
BAD(scad_geometries_set_periodic(&geom1, 1, &geom2, 1, affine));
BAD(scad_geometries_set_mesh_size_modifier(&geom1, 1, SCAD_ABSOLUTE_SIZE, 1));
BAD(scad_geometries_set_mesh_algorithm(&geom1, 1, SCAD_QUASI_STRUCTURED));
BAD(scad_geometries_clear_mesh(&geom1, 1));
- BAD(scad_step_import("prefix", "test.step", &geom_array, &c));
+ BAD(scad_step_import("test.step", &geom_array, &c));
BAD(scad_stl_export(geom1, "test.stl", SCAD_KEEP_NORMALS_UNCHANGED, 0));
BAD(scad_stl_export_partial(geom1, &geom1, 1, "test.stl",
SCAD_KEEP_NORMALS_UNCHANGED, 0));
@@ -616,14 +618,14 @@ main(int argc, char* argv[])
OK(scad_geometries_collect(geoms, 2, &geom));
OK(scad_geometry_ref_put(geoms[0]));
OK(scad_geometry_ref_put(geoms[1]));
- BAD(scad_geometry_explode(NULL, NULL, NULL, NULL));
- BAD(scad_geometry_explode(NULL, NULL, NULL, &c));
- BAD(scad_geometry_explode(NULL, NULL, &geom_array, NULL));
- BAD(scad_geometry_explode(NULL, geom, NULL, NULL));
- BAD(scad_geometry_explode(NULL, NULL, &geom_array, &c));
- BAD(scad_geometry_explode(NULL, geom, NULL, &c));
- BAD(scad_geometry_explode(NULL, geom, &geom_array, NULL));
- OK(scad_geometry_explode(NULL, geom, &geom_array, &c));
+ BAD(scad_geometry_explode(NULL, NULL, NULL));
+ BAD(scad_geometry_explode(NULL, NULL, &c));
+ BAD(scad_geometry_explode(NULL, &geom_array, NULL));
+ BAD(scad_geometry_explode(geom, NULL, NULL));
+ BAD(scad_geometry_explode(NULL, &geom_array, &c));
+ BAD(scad_geometry_explode(geom, NULL, &c));
+ BAD(scad_geometry_explode(geom, &geom_array, NULL));
+ OK(scad_geometry_explode(geom, &geom_array, &c));
OK(scad_geometry_ref_put(geom));
CHK(c == 2);
OK(scad_geometry_ref_put(geom_array[0]));
@@ -714,6 +716,30 @@ main(int argc, char* argv[])
OK(scad_scene_count(&c));
CHK(c == 0);
+
+ OK(scad_add_sphere(p1, 1, &geoms[0]));
+ OK(scad_add_sphere(p2, 2, &geoms[1]));
+ BAD(scad_geometries_set_name(NULL, 0, NULL, 0));
+ BAD(scad_geometries_set_name(NULL, 2, NULL, 0));
+ BAD(scad_geometries_set_name(geoms, 0, NULL, 0));
+ OK(scad_geometries_set_name(geoms, 2, NULL, 0));
+ BAD(scad_geometries_set_name(NULL, 0, "name", 0));
+ BAD(scad_geometries_set_name(NULL, 2, "name", 0));
+ BAD(scad_geometries_set_name(geoms, 0, "name", 0));
+ OK(scad_geometries_set_name(geoms, 2, "name", 0));
+ OK(scad_geometries_set_name(geoms, 2, "name", 0)); /* Same geometries: OK */
+ OK(scad_geometry_get_name(geoms[1], &name));
+ BAD(scad_geometries_set_name(geoms+1, 1, "name", 0)); /* Name already in use */
+ OK(scad_geometry_get_name(geoms[1], &name2));
+ CHK(0 == strcmp(name, name2)); /* Name was left unchanged */
+ OK(scad_geometry_ref_put(geoms[0]));
+ OK(scad_geometry_ref_put(geoms[1]));
+
+ OK(scad_scene_count(&c));
+ CHK(c == 0);
+
+ OK(scad_scene_count(&c));
+ CHK(c == 0);
OK(scad_add_sphere(p1, 1, &geom));
BAD(scad_geometry_get_name(NULL, &name));
BAD(scad_geometry_get_name(geom, NULL));
@@ -1239,12 +1265,12 @@ main(int argc, char* argv[])
OK(scad_geometries_swap(geoms, out_geoms, 2, SCAD_SWAP_GEOMETRY));
OK(scad_geometry_ref_put(out_geoms[0]));
OK(scad_geometry_ref_put(out_geoms[1]));
- BAD(scad_geometries_common_boundaries(NULL, geoms+0, 2, NULL, 0, &geom_array, &c));
- BAD(scad_geometries_common_boundaries(NULL, NULL, 1, geoms+1, 1, &geom_array, &c));
- BAD(scad_geometries_common_boundaries(NULL, geoms+0, 1, NULL, 1, &geom_array, &c));
- BAD(scad_geometries_common_boundaries(NULL, geoms+0, 1, geoms+1, 1, &geom_array, NULL));
- BAD(scad_geometries_common_boundaries(NULL, geoms+0, 1, geoms+1, 1, NULL, &c));
- OK(scad_geometries_common_boundaries(NULL, geoms+0, 1, geoms+1, 1, &geom_array, &c));
+ BAD(scad_geometries_common_boundaries(geoms, 2, NULL, 0, &geom_array, &c));
+ BAD(scad_geometries_common_boundaries(NULL, 1, geoms+1, 1, &geom_array, &c));
+ BAD(scad_geometries_common_boundaries(geoms, 1, NULL, 1, &geom_array, &c));
+ BAD(scad_geometries_common_boundaries(geoms, 1, geoms+1, 1, &geom_array, NULL));
+ BAD(scad_geometries_common_boundaries(geoms, 1, geoms+1, 1, NULL, &c));
+ OK(scad_geometries_common_boundaries(geoms, 1, geoms+1, 1, &geom_array, &c));
CHK(c == 0);
MEM_RM(&allocator, geom_array);
OK(scad_geometry_ref_put(geoms[0]));
@@ -1259,7 +1285,7 @@ main(int argc, char* argv[])
OK(scad_geometries_swap(geoms, out_geoms, 2, SCAD_SWAP_GEOMETRY));
OK(scad_geometry_ref_put(out_geoms[0]));
OK(scad_geometry_ref_put(out_geoms[1]));
- OK(scad_geometries_common_boundaries(NULL, geoms+0, 1, geoms+1, 1, &geom_array, &c));
+ OK(scad_geometries_common_boundaries(geoms+0, 1, geoms+1, 1, &geom_array, &c));
CHK(c == 4);
for(i = 0; i < c; i++) {
OK(scad_geometry_ref_put(geom_array[i]));
@@ -1277,7 +1303,7 @@ main(int argc, char* argv[])
OK(scad_geometries_swap(geoms, out_geoms, 2, SCAD_SWAP_GEOMETRY));
OK(scad_geometry_ref_put(out_geoms[0]));
OK(scad_geometry_ref_put(out_geoms[1]));
- OK(scad_geometries_common_boundaries(NULL, geoms+0, 1, geoms+1, 1, &geom_array, &c));
+ OK(scad_geometries_common_boundaries(geoms+0, 1, geoms+1, 1, &geom_array, &c));
CHK(c == 1);
for(i = 0; i < c; i++) {
OK(scad_geometry_ref_put(geom_array[i]));
@@ -1290,22 +1316,22 @@ main(int argc, char* argv[])
CHK(c == 0);
OK(scad_add_sphere(p1, 0.1, &geom1));
- BAD(scad_geometries_boundary(NULL, NULL, 0, NULL, NULL));
- BAD(scad_geometries_boundary(NULL, NULL, 0, NULL, &c));
- BAD(scad_geometries_boundary(NULL, NULL, 0, &geom_array, NULL));
- BAD(scad_geometries_boundary(NULL, NULL, 1, NULL, NULL));
- BAD(scad_geometries_boundary(NULL, &geom1, 0, NULL, NULL));
- BAD(scad_geometries_boundary(NULL, NULL, 0, &geom_array, &c));
- BAD(scad_geometries_boundary(NULL, NULL, 1, NULL, &c));
- BAD(scad_geometries_boundary(NULL, &geom1, 0, NULL, &c));
- BAD(scad_geometries_boundary(NULL, NULL, 1, &geom_array, NULL));
- BAD(scad_geometries_boundary(NULL, &geom1, 0, &geom_array, NULL));
- BAD(scad_geometries_boundary(NULL, &geom1, 1, NULL, NULL));
- BAD(scad_geometries_boundary(NULL, &geom1, 1, &geom_array, NULL));
- BAD(scad_geometries_boundary(NULL, &geom1, 1, NULL, &c));
- BAD(scad_geometries_boundary(NULL, &geom1, 0, &geom_array, &c));
- BAD(scad_geometries_boundary(NULL, NULL, 1, &geom_array, &c));
- OK(scad_geometries_boundary(NULL, &geom1, 1, &geom_array, &c));
+ BAD(scad_geometries_boundary(NULL, 0, NULL, NULL));
+ BAD(scad_geometries_boundary(NULL, 0, NULL, &c));
+ BAD(scad_geometries_boundary(NULL, 0, &geom_array, NULL));
+ BAD(scad_geometries_boundary(NULL, 1, NULL, NULL));
+ BAD(scad_geometries_boundary(&geom1, 0, NULL, NULL));
+ BAD(scad_geometries_boundary(NULL, 0, &geom_array, &c));
+ BAD(scad_geometries_boundary(NULL, 1, NULL, &c));
+ BAD(scad_geometries_boundary(&geom1, 0, NULL, &c));
+ BAD(scad_geometries_boundary(NULL, 1, &geom_array, NULL));
+ BAD(scad_geometries_boundary(&geom1, 0, &geom_array, NULL));
+ BAD(scad_geometries_boundary(&geom1, 1, NULL, NULL));
+ BAD(scad_geometries_boundary(&geom1, 1, &geom_array, NULL));
+ BAD(scad_geometries_boundary(&geom1, 1, NULL, &c));
+ BAD(scad_geometries_boundary(&geom1, 0, &geom_array, &c));
+ BAD(scad_geometries_boundary(NULL, 1, &geom_array, &c));
+ OK(scad_geometries_boundary(&geom1, 1, &geom_array, &c));
for(i = 0; i < c; i++) {
OK(scad_geometry_ref_put(geom_array[i]));
}
@@ -1446,15 +1472,15 @@ main(int argc, char* argv[])
OK(scad_add_box(p4, d1, &geoms[1]));
name = "/tmp/test"LINE_STRING".step";
OK(scad_scene_write(name));
- BAD(scad_step_import(NULL, NULL, NULL, NULL));
- BAD(scad_step_import(NULL, NULL, NULL, &c));
- BAD(scad_step_import(NULL, NULL, &geom_array, NULL));
- BAD(scad_step_import(NULL, "/tmp/test.step", NULL, NULL));
- BAD(scad_step_import(NULL, NULL, &geom_array, &c));
- BAD(scad_step_import(NULL, "/tmp/test.step", NULL, &c));
- BAD(scad_step_import(NULL, "/tmp/test.step", &geom_array, NULL));
- ERR(scad_step_import(NULL, "dont_exist.step", &geom_array, &c));
- OK(scad_step_import(NULL, name, &geom_array, &c));
+ BAD(scad_step_import(NULL, NULL, NULL));
+ BAD(scad_step_import(NULL, NULL, &c));
+ BAD(scad_step_import(NULL, &geom_array, NULL));
+ BAD(scad_step_import("/tmp/test.step", NULL, NULL));
+ BAD(scad_step_import(NULL, &geom_array, &c));
+ BAD(scad_step_import("/tmp/test.step", NULL, &c));
+ BAD(scad_step_import("/tmp/test.step", &geom_array, NULL));
+ ERR(scad_step_import("dont_exist.step", &geom_array, &c));
+ OK(scad_step_import(name, &geom_array, &c));
CHK(c == 2);
for(i = 0; i < 2; i++) {
OK(scad_geometries_cut(geoms+i, 1, geom_array+i, 1, &geom));
diff --git a/src/test_lifetime.c b/src/test_lifetime.c
@@ -36,7 +36,8 @@ alive_and_well
ASSERT(g && allocator);
- OK(scad_geometry_explode("alive_and_well", g, &geom_array, &c));
+ OK(scad_geometry_explode(g, &geom_array, &c));
+ OK(scad_geometries_set_name(geom_array, c, "alive_and_well", 0));
OK(scad_geometry_ref_put(g));
OK(scad_synchronize());
for(i = 0; i < c; i++) {
@@ -77,7 +78,8 @@ main(int argc, char* argv[])
/* Check that 2D constituants of a deleted 3D object are alive and well */
OK(scad_add_box(p1, diago, &geom));
- OK(scad_geometries_boundary("boundary", &geom, 1, &list, &list_n));
+ OK(scad_geometries_boundary(&geom, 1, &list, &list_n));
+ OK(scad_geometries_set_name(list, list_n, "boundary", 0));
OK(scad_geometry_ref_put(geom));
for(i = 0; i < list_n; i++) {
alive_and_well(list[i], &allocator);
@@ -88,7 +90,8 @@ main(int argc, char* argv[])
OK(scad_add_rectangle(p1, base, &geom));
OK(scad_geometry_extrude(geom, dir1, &geom1));
OK(scad_geometry_ref_put(geom));
- OK(scad_geometries_boundary("boundary", &geom1, 1, &list, &list_n));
+ OK(scad_geometries_boundary(&geom1, 1, &list, &list_n));
+ OK(scad_geometries_set_name(list, list_n, "boundary", 0));
OK(scad_geometry_ref_put(geom1));
for(i = 0; i < list_n; i++) {
alive_and_well(list[i], &allocator);
@@ -102,7 +105,8 @@ main(int argc, char* argv[])
alive_and_well(geom, &allocator);
OK(scad_add_box(p1, diago, &geom1));
- OK(scad_geometries_boundary("bcavity", &geom1, 1, &list, &list_n));
+ OK(scad_geometries_boundary(&geom1, 1, &list, &list_n));
+ OK(scad_geometries_set_name(list, list_n, "bcavity", 0));
for(i = 0; i < list_n; i++) {
OK(scad_geometry_get_count(list[i], ¢er_n));
ASSERT(center_n == 1);
@@ -120,8 +124,8 @@ main(int argc, char* argv[])
* a partition */
OK(scad_add_box(p1, diago, geoms+0));
OK(scad_add_box(p1, diago_, geoms+1));
- OK(scad_geometries_boundary(NULL, geoms+0, 1, &list, &list_n));
- OK(scad_geometries_boundary(NULL, geoms+1, 1, &list2, &list_n2));
+ OK(scad_geometries_boundary(geoms+0, 1, &list, &list_n));
+ OK(scad_geometries_boundary(geoms+1, 1, &list2, &list_n2));
OK(scad_geometries_partition(geoms, 2, 0, out_geoms));
OK(scad_geometry_ref_put(geoms[0]));
OK(scad_geometry_ref_put(geoms[1]));
diff --git a/src/test_periodic.c b/src/test_periodic.c
@@ -52,7 +52,7 @@ main(int argc, char* argv[])
OK(scad_geometries_cut(&cyl2, 1, &cyl1, 1, &cyl));
OK(scad_geometry_ref_put(cyl1));
OK(scad_geometry_ref_put(cyl2));
- OK(scad_geometries_boundary(NULL, &cyl, 1, &faces, &facesn));
+ OK(scad_geometries_boundary(&cyl, 1, &faces, &facesn));
ASSERT(facesn == 4);
d3_add(p2, p1, d2);
len = d3_len(d2);