star-cad

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

commit 455ce14a7685428dbc584f567c22407bc33272c4
parent 60ab2efa18c8c1e4674a7e8a05868c79bf284283
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Wed, 17 Aug 2022 09:26:15 +0200

Fix a warning

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

diff --git a/src/scad.c b/src/scad.c @@ -59,7 +59,7 @@ write_ascii_stl size_t j; for(j = 0; j < coord_n[i]; j += 9) { int k; - float n[3]; + float n[3] = { 0,0,0 }, zero[3] = { 0,0,0 }; float vtx[3][3]; float tmp[3], edge1[3], edge2[3];; f3_set_d3(vtx[0], coord[i]+j+0); @@ -68,6 +68,11 @@ write_ascii_stl f3_sub(edge1, vtx[1], vtx[0]); f3_sub(edge2, vtx[2], vtx[0]); f3_cross(tmp, edge1, edge2); + if(f3_eq(tmp, zero)) { + fprintf(stderr, "Error: nul triangle in exported geometry.\n"); + res = RES_BAD_ARG; + goto error; + } f3_normalize(n, tmp); OKP(fprintf(stl_file, " facet normal %g %g %g\n", SPLIT3(n)));