]> SALOME platform Git repositories - tools/sat_salome.git/commitdiff
Salome HOME
updated patch for almost planar faces not being created in IfcOpenShell
authormbs <martin.bernhard@opencascade.com>
Tue, 27 Jun 2023 15:35:45 +0000 (16:35 +0100)
committermbs <martin.bernhard@opencascade.com>
Tue, 27 Jun 2023 15:35:45 +0000 (16:35 +0100)
products/patches/IfcOpenShell_OCC.patch

index 610dbaa205c1ec9a4511ff80ff6d7a964c3d3984..a779dcb111b0a9c8c3f349952cba21568079ed48 100755 (executable)
@@ -1,3 +1,66 @@
+diff --git a/src/ifcgeom/IfcGeomFaces.cpp b/src/ifcgeom/IfcGeomFaces.cpp
+index 5626864..ba86e07 100644
+--- a/src/ifcgeom/IfcGeomFaces.cpp
++++ b/src/ifcgeom/IfcGeomFaces.cpp
+@@ -53,12 +53,15 @@
+ #include <Geom_TrimmedCurve.hxx>
+ #include <Geom_OffsetCurve.hxx>
++#include <BRepLib_FindSurface.hxx>
++
+ #include <BRepPrimAPI_MakePrism.hxx>
+ #include <BRepPrimAPI_MakeHalfSpace.hxx>
+ #include <BRepOffsetAPI_Sewing.hxx>
+ #include <BRepOffsetAPI_MakeOffset.hxx>
++#include <BRepBuilderAPI_Copy.hxx>
+ #include <BRepBuilderAPI_MakeFace.hxx>
+ #include <BRepBuilderAPI_MakeEdge.hxx>
+ #include <BRepBuilderAPI_MakeWire.hxx>
+@@ -221,6 +224,42 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) {
+                                               mf = new BRepBuilderAPI_MakeFace(pln, wire, true);
+                                       } else {
+                                               mf = new BRepBuilderAPI_MakeFace(wire);
++            if (!mf->IsDone()) {
++              Standard_Boolean isPlanarWanted = Standard_True;
++              // Find a deviation
++              Standard_Real aToleranceReached, aTol;
++              BRepLib_FindSurface aFS;
++              aFS.Init(wire, -1., isPlanarWanted);
++              aToleranceReached = aFS.ToleranceReached();
++              aTol = aFS.Tolerance();
++              if (!aFS.Found()) {
++                aFS.Init(wire, aToleranceReached, isPlanarWanted);
++                if (aFS.Found()) {
++                  aToleranceReached = aFS.ToleranceReached();
++                  aTol = aFS.Tolerance();
++                }
++              }
++              aTol = Max(1.2 * aToleranceReached, aTol);
++
++              // Copy the wire, because it can be updated with very-very big tolerance here
++              BRepBuilderAPI_Copy aMC (wire);
++              if (aMC.IsDone()) {
++                TopoDS_Wire aWire = TopoDS::Wire(aMC.Shape());
++                // Update tolerances to <aTol>
++                BRep_Builder B;
++                for (TopExp_Explorer expE (aWire, TopAbs_EDGE); expE.More(); expE.Next()) {
++                  TopoDS_Edge anE = TopoDS::Edge(expE.Current());
++                  B.UpdateEdge(anE, aTol);
++                }
++                for (TopExp_Explorer expV (aWire, TopAbs_VERTEX); expV.More(); expV.Next()) {
++                  TopoDS_Vertex aV = TopoDS::Vertex(expV.Current());
++                  B.UpdateVertex(aV, aTol);
++                }
++                // Build face
++                delete mf;
++                mf = new BRepBuilderAPI_MakeFace(aWire, isPlanarWanted);
++              }
++            }
+                                       }
+                               } else {
+                                       /// @todo check necessity of false here
 diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp
 index a3ac68c..fc988bd 100644
 --- a/src/ifcgeom/IfcGeomFunctions.cpp