From 5b066c9f9523389628c65fb2afb54de749b7e2ab Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 25 Jan 2019 15:19:52 +0100 Subject: [PATCH] Don't convert to Nef if there are no voids --- .../cgal/CgalIfcGeomShapesWithStyles.cpp | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/ifcgeom/kernels/cgal/CgalIfcGeomShapesWithStyles.cpp b/src/ifcgeom/kernels/cgal/CgalIfcGeomShapesWithStyles.cpp index ef3adc858f..b1c2110955 100644 --- a/src/ifcgeom/kernels/cgal/CgalIfcGeomShapesWithStyles.cpp +++ b/src/ifcgeom/kernels/cgal/CgalIfcGeomShapesWithStyles.cpp @@ -66,10 +66,9 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcShellBasedSurfaceModel* l, bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcManifoldSolidBrep* l, ConversionResults& shape) { cgal_shape_t s; const SurfaceStyle* collective_style = get_style(l); + const SurfaceStyle* indiv_style = get_style(l->Outer()); + if (convert_shape(l->Outer(),s) ) { - CGAL::Nef_polyhedron_3 nef_s = create_nef_polyhedron(s); - const SurfaceStyle* indiv_style = get_style(l->Outer()); - IfcSchema::IfcClosedShell::list::ptr voids(new IfcSchema::IfcClosedShell::list); if (l->as()) { voids = l->as()->Voids(); @@ -79,15 +78,20 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcManifoldSolidBrep* l, Conv voids = l->as()->Voids(); } #endif - - for (IfcSchema::IfcClosedShell::list::it it = voids->begin(); it != voids->end(); ++it) { - cgal_shape_t s2; - if (convert_shape(*it, s2)) { - nef_s -= CGAL::Nef_polyhedron_3(s2); + + if (voids->size()) { + CGAL::Nef_polyhedron_3 nef_s = create_nef_polyhedron(s); + + for (IfcSchema::IfcClosedShell::list::it it = voids->begin(); it != voids->end(); ++it) { + cgal_shape_t s2; + if (convert_shape(*it, s2)) { + nef_s -= CGAL::Nef_polyhedron_3(s2); + } } + + s = create_polyhedron(nef_s); } - s = create_polyhedron(nef_s); shape.push_back(ConversionResult(l->data().id(), new CgalShape(s), indiv_style ? indiv_style : collective_style)); return true; }