]> OCCT Git - occt.git/commitdiff
0033410: Data Exchange, Step Import - TRIANGULATED_FACE from STEP where there are...
authorichesnok <ichesnok@opencascade.com>
Tue, 12 Mar 2024 18:01:09 +0000 (18:01 +0000)
committerdpasukhi <dpasukhi@opencascade.com>
Sun, 31 Mar 2024 21:42:35 +0000 (22:42 +0100)
Problem fixed by using array of nodes in case when aPnindices is empty.

src/StepToTopoDS/StepToTopoDS_TranslateFace.cxx
tests/bugs/step/bug33410 [new file with mode: 0644]

index 93539a1aef71069e54f4b8427907f9fc0bfaf8e2..c33ac4a3bd9b53543bb59042cac296b03e7d1e7f 100644 (file)
@@ -105,12 +105,13 @@ namespace {
   // ============================================================================
   static void SetNodes(const Handle(Poly_Triangulation)& theMesh,
                        Handle(TColgp_HArray1OfXYZ)& theNodes,
+                       const Standard_Integer theNumPnindex,
                        Handle(TColStd_HArray1OfInteger)& thePnindices,
                        const Standard_Real theLengthFactor)
   {
     for (Standard_Integer aPnIndex = 1; aPnIndex <= theMesh->NbNodes(); ++aPnIndex)
     {
-      const gp_XYZ& aPoint = theNodes->Value(thePnindices->Value(aPnIndex));
+      const gp_XYZ& aPoint = theNodes->Value((theNumPnindex > 0) ? thePnindices->Value(aPnIndex) : aPnIndex);
       theMesh->SetNode(aPnIndex, theLengthFactor * aPoint);
     }
   }
@@ -326,10 +327,11 @@ namespace {
 
     const Standard_Boolean aHasUVNodes = Standard_False;
     const Standard_Boolean aHasNormals = (aNormNum > 0);
+    const Standard_Integer aNbNodes = (aNumPnindex > 0) ? aNumPnindex : aNodes->Length();
 
     if (aTrianStripsNum == 0 && aTrianFansNum == 0)
     {
-      aMesh = new Poly_Triangulation(aNumPnindex, aTrianNum, aHasUVNodes, aHasNormals);
+      aMesh = new Poly_Triangulation(aNbNodes, aTrianNum, aHasUVNodes, aHasNormals);
     }
     else
     {
@@ -359,14 +361,14 @@ namespace {
         aNbTriaFans += aTriangleFan->Length() - 2;
       }
 
-      aMesh = new Poly_Triangulation(aNumPnindex, aNbTriaStrips + aNbTriaFans, aHasUVNodes, aHasNormals);
+      aMesh = new Poly_Triangulation(aNbNodes, aNbTriaStrips + aNbTriaFans, aHasUVNodes, aHasNormals);
     }
 
-    SetNodes(aMesh, aNodes, aPnindices, theLocalFactors.LengthFactor());
+    SetNodes(aMesh, aNodes, aNumPnindex, aPnindices, theLocalFactors.LengthFactor());
 
     if (aHasNormals)
     {
-      SetNormals(aMesh, aNormals, aNormNum, aNumPnindex);
+      SetNormals(aMesh, aNormals, aNormNum, aNbNodes);
     }
 
     SetTriangles(aMesh, aTriangles, aTrianStripsNum, aTriaStrips, aTrianFansNum, aTriaFans);
diff --git a/tests/bugs/step/bug33410 b/tests/bugs/step/bug33410
new file mode 100644 (file)
index 0000000..441b389
--- /dev/null
@@ -0,0 +1,12 @@
+puts "========================"
+puts "0033410: Data Exchange, Step Import - TRIANGULATED_FACE from STEP where there are no pnval entries"
+puts "========================"
+
+pload OCAF
+
+# Read file
+ReadStep D [locate_data_file bug33410.step]
+XGetOneShape sh D
+checktrinfo sh -face 1 -nod 81 -tri 128
+
+Close D