From 637d3e2eb63fd2f34e148cd88215eeefaa68ff22 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Mon, 14 May 2018 11:06:07 +0200 Subject: [PATCH] Optimize generation of faces with large (n > 128) number of edges. --- src/ifcgeom/IfcGeomFaces.cpp | 10 +++++++++- src/ifcgeom/IfcGeomFunctions.cpp | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ifcgeom/IfcGeomFaces.cpp b/src/ifcgeom/IfcGeomFaces.cpp index 0b5b2e3b8c..b0ea4dd278 100644 --- a/src/ifcgeom/IfcGeomFaces.cpp +++ b/src/ifcgeom/IfcGeomFaces.cpp @@ -213,7 +213,15 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) { process_wire: if (face_surface.IsNull()) { - mf = new BRepBuilderAPI_MakeFace(wire); + if (count(wire, TopAbs_EDGE) > 128) { + // tfk: optimization find the underlying surface ourselves since it's going + // to be planar in IFC if no explicit surface is given. Should we always do this? + gp_Pln pln; + approximate_plane_through_wire(wire, pln); + mf = new BRepBuilderAPI_MakeFace(pln, wire, true); + } else { + mf = new BRepBuilderAPI_MakeFace(wire); + } } else { /// @todo check necessity of false here mf = new BRepBuilderAPI_MakeFace(face_surface, wire, false); diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index c9dcc1577e..ffe67d8959 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -2838,7 +2838,10 @@ bool IfcGeom::Kernel::wire_intersections(const TopoDS_Wire& wire, TopTools_ListO } int n = count(wire, TopAbs_EDGE); - if (n < 3) { + if (n < 3 || n > 128) { + if (n > 128) { + Logger::Notice("Too many segments for detection of self-intersections"); + } wires.Append(wire); return false; }