diff --git a/src/ifcgeom/kernels/cgal/CgalIfcGeomShapes.cpp b/src/ifcgeom/kernels/cgal/CgalIfcGeomShapes.cpp index e3264e78ec..7b64a21321 100644 --- a/src/ifcgeom/kernels/cgal/CgalIfcGeomShapes.cpp +++ b/src/ifcgeom/kernels/cgal/CgalIfcGeomShapes.cpp @@ -100,8 +100,14 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcExtrudedAreaSolid *l, cgal nef_shape.transform(trsf); } - nef_shape.convert_to_polyhedron(shape); - return true; + try { + nef_shape.convert_to_polyhedron(shape); + return true; + } catch (...) { + std::cout << "IfcExtrudedAreaSolid: cannot convert Nef to polyhedron!" << std::endl; + return false; + } + } #ifdef USE_IFC4 @@ -244,8 +250,13 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcExtrudedAreaSolidTapered* nef_shape.transform(trsf); } - nef_shape.convert_to_polyhedron(shape); - return true; + try { + nef_shape.convert_to_polyhedron(shape); + return true; + } catch (...) { + std::cout << "IfcExtrudedAreaSolidTapered: cannot convert Nef to polyhedron!" << std::endl; + return false; + } } #endif @@ -458,8 +469,13 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcBooleanResult* l, cgal_sha // fresult.open("/Users/ken/Desktop/result.off"); // fresult << result << std::endl; // fresult.close(); - } nef_result.convert_to_polyhedron(shape); - return true; + } try { + nef_result.convert_to_polyhedron(shape); + return true; + } catch (...) { + std::cout << "IfcBooleanResult: cannot convert Nef to polyhedron!" << std::endl; + return false; + } } else if (op == IfcSchema::IfcBooleanOperator::IfcBooleanOperator_UNION) { @@ -475,8 +491,13 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcBooleanResult* l, cgal_sha // fresult.open("/Users/ken/Desktop/result.off"); // fresult << result << std::endl; // fresult.close(); - } nef_result.convert_to_polyhedron(shape); - return true; + } try { + nef_result.convert_to_polyhedron(shape); + return true; + } catch (...) { + std::cout << "IfcBooleanResult: cannot convert Nef to polyhedron!" << std::endl; + return false; + } } else if (op == IfcSchema::IfcBooleanOperator::IfcBooleanOperator_INTERSECTION) { @@ -492,8 +513,13 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcBooleanResult* l, cgal_sha // fresult.open("/Users/ken/Desktop/result.off"); // fresult << result << std::endl; // fresult.close(); - } nef_result.convert_to_polyhedron(shape); - return true; + } try { + nef_result.convert_to_polyhedron(shape); + return true; + } catch (...) { + std::cout << "IfcBooleanResult: cannot convert Nef to polyhedron!" << std::endl; + return false; + } } return false; } diff --git a/src/ifcgeom/kernels/cgal/CgalKernel.cpp b/src/ifcgeom/kernels/cgal/CgalKernel.cpp index 9c9512ceac..d13dab80ec 100644 --- a/src/ifcgeom/kernels/cgal/CgalKernel.cpp +++ b/src/ifcgeom/kernels/cgal/CgalKernel.cpp @@ -300,8 +300,16 @@ bool IfcGeom::CgalKernel::convert_openings(const IfcSchema::IfcProduct* entity, } if (brep_cut_result.is_valid()) { - nef_brep_cut_result.convert_to_Polyhedron(brep_cut_result); - cut_shapes.push_back(IfcGeom::ConversionResult(new CgalShape(brep_cut_result), &it3->Style())); + try { + nef_brep_cut_result.convert_to_polyhedron(brep_cut_result); + cut_shapes.push_back(IfcGeom::ConversionResult(new CgalShape(brep_cut_result), &it3->Style())); + } catch (...) { + // Apparently processing the boolean operation failed or resulted in an invalid result + // in which case the original shape without the subtractions is returned instead + // we try convert the openings in the original way, one by one. + Logger::Message(Logger::LOG_WARNING, "Subtracting combined openings compound failed:", entity->entity); + return false; + } } else { // Apparently processing the boolean operation failed or resulted in an invalid result // in which case the original shape without the subtractions is returned instead