diff --git a/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp b/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp index 5dfcf9ebfb..94913a9e0b 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp +++ b/src/ifcgeom/kernels/cgal/CgalConversionResult.cpp @@ -337,7 +337,7 @@ const cgal_shape_t& ifcopenshell::geometry::CgalShape::poly() const { void ifcopenshell::geometry::CgalShape::to_poly() const { if (!shape_) { cgal_shape_t poly; - convert_to_polyhedron(*nef_, poly); + convert_to_polyhedron(*nef_, poly, std::numeric_limits::max()); if (poly.size_of_vertices() > 0) { // @todo why is this necessary? we have the mark of the volumes? CGAL::Polygon_mesh_processing::orient_to_bound_a_volume(poly); diff --git a/src/ifcgeom/kernels/cgal/nef_to_halfspace_tree.h b/src/ifcgeom/kernels/cgal/nef_to_halfspace_tree.h index df90aa2b47..d07c6959f7 100644 --- a/src/ifcgeom/kernels/cgal/nef_to_halfspace_tree.h +++ b/src/ifcgeom/kernels/cgal/nef_to_halfspace_tree.h @@ -1332,20 +1332,27 @@ size_t edge_contract(Graph& G) { // For some reason gives better results then Nef_polyhedron_3.convert_to_polyhedron() in some cases template bool convert_to_polyhedron(const CGAL::Nef_polyhedron_3& a, CGAL::Polyhedron_3& b, size_t volume_index=0) { + const bool all_volumes = volume_index == std::numeric_limits::max(); size_t v = 0; + Polysoup_builder vis; for (auto it = a.volumes_begin(); it != a.volumes_end(); ++it) { if (!it->mark()) { continue; } for (auto jt = it->shells_begin(); jt != it->shells_end(); ++jt) { - if (v++ == volume_index) { - Polysoup_builder vis; + if (v++ == volume_index || all_volumes) { a.visit_shell_objects(typename CGAL::Nef_polyhedron_3::SFace_const_handle(jt), vis); - vis.build(b); - return true; + if (!all_volumes) { + vis.build(b); + return true; + } } } } + if (all_volumes && v > 0) { + vis.build(b); + return true; + } return false; }