From 142b15e3322a366818166832573636a486f4d120 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 28 Dec 2023 19:08:08 +0000 Subject: [PATCH] CgalShape: Triangulate before calculating area/volume --- src/ifcgeom/kernels/cgal/CgalConversionResult.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp b/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp index bcb4eac0ff..fb26abeed4 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp +++ b/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp @@ -36,7 +36,7 @@ void ifcopenshell::geometry::CgalShape::to_poly() const { convert_to_polyhedron(*nef_, *shape_); // @todo why is this necessary? we have the mark of the volumes? - CGAL::Polygon_mesh_processing::orient(*shape_); + CGAL::Polygon_mesh_processing::orient_to_bound_a_volume(*shape_); // nef_->convert_to_polyhedron(*shape_); } @@ -275,13 +275,17 @@ OpaqueNumber* ifcopenshell::geometry::CgalShape::CgalShape::length() OpaqueNumber* ifcopenshell::geometry::CgalShape::area() { to_poly(); - return new NumberType(CGAL::Polygon_mesh_processing::area(*shape_)); + auto s = *shape_; + CGAL::Polygon_mesh_processing::triangulate_faces(s); + return new NumberType(CGAL::Polygon_mesh_processing::area(s)); } OpaqueNumber* ifcopenshell::geometry::CgalShape::volume() { to_poly(); - return new NumberType(CGAL::Polygon_mesh_processing::volume(*shape_)); + auto s = *shape_; + CGAL::Polygon_mesh_processing::triangulate_faces(s); + return new NumberType(CGAL::Polygon_mesh_processing::volume(s)); } OpaqueCoordinate<3> ifcopenshell::geometry::CgalShape::position()