commit 1151ed7ba9e3030d89f4dd7361e9b5f03c59da3e
parent e28310d88d073315b3a6352c7c31c1df4c05e110
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Fri, 25 Nov 2022 16:53:45 +0100
Fix tests compilation
Diffstat:
3 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/src/test1.c b/src/test1.c
@@ -35,11 +35,11 @@ main(int argc, char* argv[])
struct scad_geometry* geom2 = NULL;
struct scad_geometry* cyl = NULL;
struct scad_geometry* tmp1 = NULL;
- struct scad_geometry* tmp3 = NULL;
struct scad_geometry* f1 = NULL;
struct scad_geometry* f2 = NULL;
struct scad_geometry* sphere = NULL;
struct scad_geometry* geoms[2];
+ struct scad_geometry* out_geoms[2];
struct scad_geometry* tools[5];
struct mem_allocator allocator;
@@ -53,9 +53,11 @@ main(int argc, char* argv[])
OK(scad_add_box("b1", p2, d2, &geom2));
geoms[0] = geom1;
geoms[1] = geom2;
- BAD(scad_geometries_partition(NULL, NULL, 0, 0, &tmp1));
- OK(scad_geometries_partition(NULL, geoms, 2, 1, &tmp1));
- OK(scad_geometry_delete(tmp1));
+ BAD(scad_geometries_partition(NULL, 0, 0, NULL));
+ BAD(scad_geometries_partition(geoms, 2, 1, NULL));
+ OK(scad_geometries_partition(geoms, 2, 1, out_geoms));
+ OK(scad_geometry_delete(out_geoms[0]));
+ OK(scad_geometry_delete(out_geoms[1]));
OK(scad_cut_geometries("cut_c1", &geom1, 1, & geom2, 1, &tmp1));
@@ -70,7 +72,7 @@ main(int argc, char* argv[])
tools[1] = tmp1;
tools[2] = geom1;
tools[3] = f1;
- BAD(scad_geometries_partition(NULL, tools, 4, 0, &tmp3));
+ BAD(scad_geometries_partition(tools, 4, 0, NULL));
/* OK(scad_scene_mesh()); */
OK(scad_stl_export(geom1, NULL, 1));
diff --git a/src/test_api.c b/src/test_api.c
@@ -49,6 +49,7 @@ main(int argc, char* argv[])
struct scad_geometry* geom = NULL;
struct scad_geometry** geom_array = NULL;
struct scad_geometry* geoms[2];
+ struct scad_geometry* out_geoms[2];
struct mem_allocator allocator;
struct logger logger;
size_t c;
@@ -181,10 +182,10 @@ main(int argc, char* argv[])
OK(scad_geometries_common_boundaries(NULL, &geom1, 1, &geom2, 1, &geom));
OK(scad_geometry_delete(geom));
- BAD(scad_geometries_partition(NULL, NULL, 2, 1, geoms));
- BAD(scad_geometries_partition(NULL, geoms, 0, 1, geoms));
- BAD(scad_geometries_partition(NULL, geoms, 2, 1, NULL));
- OK(scad_geometries_partition(NULL, geoms, 2, 1, geoms));
+ BAD(scad_geometries_partition(NULL, 2, 1, out_geoms));
+ BAD(scad_geometries_partition(geoms, 0, 1, out_geoms));
+ BAD(scad_geometries_partition(geoms, 2, 1, NULL));
+ OK(scad_geometries_partition(geoms, 2, 1, out_geoms));
OK(scad_geometry_delete(geom));
BAD(scad_geometry_boundary(NULL, NULL, 0, &geom));
diff --git a/src/test_partition.c b/src/test_partition.c
@@ -43,7 +43,7 @@ two_geoms
double d2[3] = {0.5, 0.5, 0.5};
struct scad_geometry* geoms[2];
struct scad_geometry* tmp[2];
- struct scad_geometry* pgeoms[2];
+ struct scad_geometry* out_geoms[2];
char name[64];
res_T res;
@@ -58,15 +58,22 @@ two_geoms
OK(scad_fuse_geometries("cubes", tmp, 1, tmp+1, 1, geoms));
OK(scad_add_box("cube2", p2, d2, geoms+1));
- res = scad_geometries_partition(NULL, geoms, 2, allow_overlapping, pgeoms);
+ res = scad_geometries_partition(geoms, 2, allow_overlapping, out_geoms);
if(res != RES_OK) goto end;
OK(scad_scene_mesh());
- snprintf(name, sizeof(name), "part_%g_1", x);
- OK(scad_stl_export(pgeoms[0], name, 0));
- snprintf(name, sizeof(name), "part_%g_2", x);
- OK(scad_stl_export(pgeoms[1], name, 1));
+ if(allow_overlapping) {
+ snprintf(name, sizeof(name), "part_%g_1o", x);
+ OK(scad_stl_export(out_geoms[0], name, 0));
+ snprintf(name, sizeof(name), "part_%g_2o", x);
+ OK(scad_stl_export(out_geoms[1], name, 1));
+ } else {
+ snprintf(name, sizeof(name), "part_%g_1", x);
+ OK(scad_stl_export(geoms[0], name, 0));
+ snprintf(name, sizeof(name), "part_%g_2", x);
+ OK(scad_stl_export(geoms[1], name, 1));
+ }
end:
OK(scad_finalize());