From 059c9fb7d5b7d544f1a2db4e5e8e0820e3ca3d2f Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 5 Dec 2023 21:13:43 +0100 Subject: [PATCH] remove_degenerate_faces() in order to prevent division by zero --- src/ifcgeom/kernels/cgal/CgalConversionResult.cpp | 6 ++++++ src/ifcgeom/kernels/cgal/CgalConversionResult.h | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp b/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp index f29b935501..207a55e186 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp +++ b/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp @@ -18,6 +18,12 @@ using ifcopenshell::geometry::NumberEpeck; #define NumberType NumberEpeck #endif +ifcopenshell::geometry::CgalShape::CgalShape(const cgal_shape_t & shape) { + shape_ = shape; + CGAL::Polygon_mesh_processing::triangulate_faces(*shape_); + CGAL::Polygon_mesh_processing::remove_degenerate_faces(*shape_); +} + #ifndef IFOPSH_SIMPLE_KERNEL void ifcopenshell::geometry::CgalShape::to_poly() const { if (!shape_) { diff --git a/src/ifcgeom/kernels/cgal/CgalConversionResult.h b/src/ifcgeom/kernels/cgal/CgalConversionResult.h index b0e3da28c0..0811b1968d 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionResult.h +++ b/src/ifcgeom/kernels/cgal/CgalConversionResult.h @@ -171,9 +171,7 @@ namespace ifcopenshell { namespace geometry { mutable boost::optional> nef_; #endif public: - CgalShape(const cgal_shape_t& shape) { - shape_ = shape; - } + CgalShape(const cgal_shape_t& shape); #ifndef IFOPSH_SIMPLE_KERNEL CgalShape(const CGAL::Nef_polyhedron_3& shape) {