commit 23215e478b68d5d892c601469daad82069fa5a41
parent 282c2ab70a54fa16ef600a81f6fda39c74772a72
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Fri, 12 Jul 2024 10:11:56 +0200
Fix a test
The partition test should not have passed, as some geometries were
output to STL with forced normals and these geometries did not comply
with the afferent constraints.
Diffstat:
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/src/test_partition.c b/src/test_partition.c
@@ -41,9 +41,8 @@ two_geoms
double d1[3] = {1, 1, 1};
double p2[3];
double d2[3] = {0.5, 0.5, 0.5};
- struct scad_geometry* geoms[2];
- struct scad_geometry* tmp[2];
- struct scad_geometry* out_geoms[2];
+ struct scad_geometry* geoms[3];
+ struct scad_geometry* out_geoms[3];
char name[64];
res_T res;
@@ -52,13 +51,11 @@ two_geoms
/* set position for cube #2 */
d3(p2, x, 0.25, 0.25);
- OK(scad_add_box("cube0", p0, d0, tmp));
- OK(scad_add_box("cube1", p1, d1, tmp+1));
+ OK(scad_add_box("cube0", p0, d0, geoms));
+ OK(scad_add_box("cube1", p1, d1, geoms+1));
+ OK(scad_add_box("cube2", p2, d2, geoms+2));
- OK(scad_fuse_geometries("cubes", tmp, 1, tmp+1, 1, geoms));
- OK(scad_add_box("cube2", p2, d2, geoms+1));
-
- res = scad_geometries_partition(geoms, 2, allow_overlapping, out_geoms);
+ res = scad_geometries_partition(geoms, 3, allow_overlapping, out_geoms);
if(res != RES_OK) goto end;
OK(scad_scene_mesh());
@@ -67,12 +64,26 @@ two_geoms
snprintf(name, sizeof(name), "part_%g_1o", x);
OK(scad_stl_export(out_geoms[0], name, Scad_force_normals_outward, 0));
snprintf(name, sizeof(name), "part_%g_2o", x);
- OK(scad_stl_export(out_geoms[1], name, Scad_force_normals_outward, 1));
+ /* If 0.9, cubes 1 & 2 intersect and the partitioned geometry cannot have
+ * its normals forced */
+ if(x == 0.9) {
+ BAD(scad_stl_export(out_geoms[1], name, Scad_force_normals_outward, 1));
+ OK(scad_stl_export(out_geoms[1], name, Scad_keep_normals_unchanged, 1));
+ snprintf(name, sizeof(name), "part_%g_3o", x);
+ BAD(scad_stl_export(out_geoms[2], name, Scad_force_normals_outward, 1));
+ OK(scad_stl_export(out_geoms[2], name, Scad_keep_normals_unchanged, 1));
+ } else {
+ OK(scad_stl_export(out_geoms[1], name, Scad_force_normals_outward, 1));
+ snprintf(name, sizeof(name), "part_%g_3o", x);
+ OK(scad_stl_export(out_geoms[2], name, Scad_force_normals_outward, 1));
+ }
} else {
snprintf(name, sizeof(name), "part_%g_1", x);
OK(scad_stl_export(geoms[0], name, Scad_force_normals_outward, 0));
snprintf(name, sizeof(name), "part_%g_2", x);
OK(scad_stl_export(geoms[1], name, Scad_force_normals_outward, 1));
+ snprintf(name, sizeof(name), "part_%g_3", x);
+ OK(scad_stl_export(out_geoms[2], name, Scad_force_normals_outward, 1));
}
end: