diff --git a/src/cgalutils-tess.cc b/src/cgalutils-tess.cc index e230e9db..7a8b80f0 100644 --- a/src/cgalutils-tess.cc +++ b/src/cgalutils-tess.cc @@ -107,6 +107,8 @@ namespace CGALUtils { else { // Calculate best guess at face normal using Newell's method CGAL::normal_vector_newell_3(polygons.front().begin(), polygons.front().end(), normalvec); + double sqrl = normalvec.squared_length(); + if (sqrl > 0.0) normalvec = normalvec / sqrt(sqrl); } // Pass the normal vector to the (undocumented) diff --git a/src/cgalutils.cc b/src/cgalutils.cc index 5d951936..7003eb3e 100644 --- a/src/cgalutils.cc +++ b/src/cgalutils.cc @@ -917,10 +917,13 @@ namespace CGALUtils { and let the tessellater deal with the holes, and then just output the resulting 3d triangles*/ - CGAL::Vector_3 nvec = plane.orthogonal_vector(); - K::Vector_3 normal(CGAL::to_double(nvec.x()), CGAL::to_double(nvec.y()), CGAL::to_double(nvec.z())); + // We cannot trust the plane from Nef polyhedron to be correct. + // Passing an incorrect normal vector can cause a crash in the constrained delaunay triangulator + // See http://cgal-discuss.949826.n4.nabble.com/Nef3-Wrong-normal-vector-reported-causes-triangulator-crash-tt4660282.html + // CGAL::Vector_3 nvec = plane.orthogonal_vector(); + // K::Vector_3 normal(CGAL::to_double(nvec.x()), CGAL::to_double(nvec.y()), CGAL::to_double(nvec.z())); std::vector triangles; - bool err = CGALUtils::tessellatePolygonWithHoles(polyholes, triangles, &normal); + bool err = CGALUtils::tessellatePolygonWithHoles(polyholes, triangles, NULL); if (!err) { BOOST_FOREACH(const Polygon &p, triangles) { if (p.size() != 3) {