star-cad

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

commit 6119461920bf964bb00e14017df95fc23fac7a58
parent e705d1ccfcced084d1bf31e70bc0c47f5eb316e7
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Fri, 15 Sep 2023 17:32:09 +0200

Fix a crash with triangle sets including overlapping triangles

Diffstat:
Msrc/scad.c | 12+++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/scad.c b/src/scad.c @@ -468,7 +468,7 @@ scad_stl_sort_orientation struct sg3d_geometry_add_callbacks callbacks = SG3D_ADD_CALLBACKS_NULL__; struct darray_double new_triangles; char *process = NULL, *contact_0 = NULL; - unsigned process_count = 0; + unsigned ocount = 0, process_count = 0; if(!triangles || !set_name) { res = RES_BAD_ARG; @@ -517,6 +517,16 @@ scad_stl_sort_orientation tcount, sg3d_sencXd_geometry_get_indices, NULL, vcount, sg3d_sencXd_geometry_get_position, geom, &senc3d_scn)); + ERR(senc3d_scene_get_overlapping_triangles_count(senc3d_scn, &ocount)); + if(ocount) { + logger_print(logger, LOG_ERROR, + "Overlapping triangles where found when sorting out normals (%u / %u) " + "in set '%s'.\n", + tcount_in - ocount, tcount_in, set_name); + res = RES_BAD_ARG; + goto error; + } + ERR(senc3d_scene_get_enclosure_count(senc3d_scn, &ecount)); if(ecount < 2) { /* Must define a closed volume */