]> OCCT Git - occt.git/commitdiff
Werth 606: Import of STEP file crashes at the very end when visualizing the boundary...
authormzernova <mzernova@opencascade.com>
Wed, 18 Jan 2023 09:55:16 +0000 (09:55 +0000)
committermzernova <mzernova@opencascade.com>
Wed, 18 Jan 2023 09:55:16 +0000 (09:55 +0000)
When an edge (BRepMeshData_Edge) has multiple PCurve curves (IMeshData_PCurve) with different orientations, the index array is filled for only one PCurve curve.
This would cause problems later, so a fix was made to fill index arrays for curves with another orientation.

src/BRepMesh/BRepMesh_BaseMeshAlgo.cxx
src/BRepMeshData/BRepMeshData_Edge.cxx
src/BRepMeshData/BRepMeshData_Edge.hxx
src/IMeshData/IMeshData_Edge.hxx

index e914fb284cad0ae502a12183a70803d5a69e9946..df87c02cf458e0d9ff4081e44b4a26195b4f2150 100644 (file)
@@ -101,38 +101,44 @@ Standard_Boolean BRepMesh_BaseMeshAlgo::initDataStructure()
 
     for (Standard_Integer aEdgeIt = 0; aEdgeIt < aDWire->EdgesNb(); ++aEdgeIt)
     {
-      const IMeshData::IEdgeHandle    aDEdge = aDWire->GetEdge(aEdgeIt);
+      const IMeshData::IEdgeHandle    aDEdge = aDWire->GetEdge (aEdgeIt);
       const IMeshData::ICurveHandle&  aCurve = aDEdge->GetCurve();
-      const IMeshData::IPCurveHandle& aPCurve = aDEdge->GetPCurve(
-        myDFace.get(), aDWire->GetEdgeOrientation(aEdgeIt));
+      const IMeshData::ListOfInteger& aListOfPCurves = aDEdge->GetPCurves (myDFace.get());
 
-      const TopAbs_Orientation aOri = fixSeamEdgeOrientation(aDEdge, aPCurve);
-
-      Standard_Integer aPrevNodeIndex = -1;
-      const Standard_Integer aLastPoint = aPCurve->ParametersNb() - 1;
-      for (Standard_Integer aPointIt = 0; aPointIt <= aLastPoint; ++aPointIt)
+      for (IMeshData::ListOfInteger::Iterator aPCurveIt(aListOfPCurves); aPCurveIt.More(); aPCurveIt.Next())
       {
-        const Standard_Integer aNodeIndex = registerNode(
-          aCurve ->GetPoint(aPointIt),
-          aPCurve->GetPoint(aPointIt),
-          BRepMesh_Frontier, Standard_False/*aPointIt > 0 && aPointIt < aLastPoint*/);
+        const IMeshData::IPCurveHandle& aPCurve = aDEdge->GetPCurve (aPCurveIt.Value());
+
+        const TopAbs_Orientation aOri = fixSeamEdgeOrientation(aDEdge, aPCurve);
 
-        aPCurve->GetIndex(aPointIt) = aNodeIndex;
-        myUsedNodes->Bind(aNodeIndex, aNodeIndex);
+        Standard_Integer aPrevNodeIndex = -1;
+        const Standard_Integer aLastPoint = aPCurve->ParametersNb() - 1;
 
-        if (aPrevNodeIndex != -1 && aPrevNodeIndex != aNodeIndex)
+        Standard_Integer aPointIt = 0;
+        for (; aPointIt <= aLastPoint; ++aPointIt)
         {
-          const Standard_Integer aLinksNb   = myStructure->NbLinks();
-          const Standard_Integer aLinkIndex = addLinkToMesh(aPrevNodeIndex, aNodeIndex, aOri);
-          if (aWireIt != 0 && aLinkIndex <= aLinksNb)
+          const Standard_Integer aNodeIndex = registerNode(
+            aCurve->GetPoint(aPointIt),
+            aPCurve->GetPoint(aPointIt),
+            BRepMesh_Frontier, Standard_False/*aPointIt > 0 && aPointIt < aLastPoint*/);
+
+          aPCurve->GetIndex (aPointIt) = aNodeIndex;
+          myUsedNodes->Bind (aNodeIndex, aNodeIndex);
+
+          if (aPrevNodeIndex != -1 && aPrevNodeIndex != aNodeIndex)
           {
-            // Prevent holes around wire of zero area.
-            BRepMesh_Edge& aLink = const_cast<BRepMesh_Edge&>(myStructure->GetLink(aLinkIndex));
-            aLink.SetMovability(BRepMesh_Fixed);
+            const Standard_Integer aLinksNb = myStructure->NbLinks();
+            const Standard_Integer aLinkIndex = addLinkToMesh(aPrevNodeIndex, aNodeIndex, aOri);
+            if (aWireIt != 0 && aLinkIndex <= aLinksNb)
+            {
+              // Prevent holes around wire of zero area.
+              BRepMesh_Edge& aLink = const_cast<BRepMesh_Edge&>(myStructure->GetLink(aLinkIndex));
+              aLink.SetMovability(BRepMesh_Fixed);
+            }
           }
-        }
 
-        aPrevNodeIndex = aNodeIndex;
+          aPrevNodeIndex = aNodeIndex;
+        }
       }
     }
   }
index 1af0dc15c0a1e05fb37f3c9b0f82bff205cd7f9b..012d2fc5d1134c29904c0bb48c293489370a9fdf 100644 (file)
@@ -93,6 +93,15 @@ const IMeshData::IPCurveHandle& BRepMeshData_Edge::GetPCurve (
     myPCurves (aListOfPCurves.Last ());
 }
 
+//=======================================================================
+// Function: GetPCurves
+// Purpose : 
+//=======================================================================
+const IMeshData::ListOfInteger& BRepMeshData_Edge::GetPCurves (const IMeshData::IFacePtr& theDFace) const
+{
+  return myPCurvesMap.Find (theDFace);
+}
+
 //=======================================================================
 // Function: GetPCurve
 // Purpose : 
index 74a5a57f1995622a6e381fde2640ac20d4fdc7b5..cbfd35d3f2dd6746dc78d1fd9fc1af30aae58f42 100644 (file)
@@ -49,6 +49,10 @@ public:
     const IMeshData::IFacePtr& theDFace,
     const TopAbs_Orientation   theOrientation) const Standard_OVERRIDE;
 
+  //! Returns an array of pcurves indices for the specified discrete face.
+  Standard_EXPORT virtual const IMeshData::ListOfInteger& GetPCurves(
+    const IMeshData::IFacePtr& theDFace) const Standard_OVERRIDE;
+
   //! Returns pcurve with the given index.
   Standard_EXPORT virtual const IMeshData::IPCurveHandle& GetPCurve (
     const Standard_Integer theIndex) const Standard_OVERRIDE;
index 5a83d344125d3ef015069ebf15d8b63bc27e2e57..7679b5bd70b7d1383720512e97b6dff65876e50b 100644 (file)
@@ -57,6 +57,10 @@ public:
     const IMeshData::IFacePtr& theDFace,
     const TopAbs_Orientation   theOrientation) const = 0;
 
+  //! Returns an array of pcurves indices for the specified discrete face.
+  Standard_EXPORT virtual const IMeshData::ListOfInteger& GetPCurves (
+    const IMeshData::IFacePtr& theDFace) const = 0;
+
   //! Returns pcurve with the given index.
   Standard_EXPORT virtual const IMeshData::IPCurveHandle& GetPCurve (
     const Standard_Integer theIndex) const = 0;