]> OCCT Git - occt.git/commitdiff
0033631: Data Exchange, Step import - Crash by reading STEP file
authorichesnok <ichesnok@opencascade.com>
Fri, 8 Mar 2024 13:38:18 +0000 (13:38 +0000)
committervglukhik <vglukhik@opencascade.com>
Sat, 16 Mar 2024 19:36:18 +0000 (19:36 +0000)
Creating Poly_Triangulation from ComplexTriangulatedSurfaceSet was fixed.

src/STEPCAFControl/STEPCAFControl_Reader.cxx

index 9c61aa1f85d3e4d8cedd5d5ee314e10ba7ce9e74..0dd16f6189ac18adb964fc1b72be5d3caeb5dbf9 100644 (file)
@@ -2018,7 +2018,7 @@ Handle(Poly_Triangulation) createMesh(const Handle(StepVisual_ComplexTriangulate
   const Standard_Integer aNbNormals = theTriangulatedSufaceSet->NbNormals();
   // Number of pairs (Point, Normal). It is possible for one point to have multiple normals. This is
   // useful when the underlying surface is not C1 continuous.
-  const Standard_Integer aNbPairs = aNbNormals > 1 ? theTriangulatedSufaceSet->NbPnindex() : aNodes->Length();
+  const Standard_Integer aNbPairs = aNbNormals > 1 ? theTriangulatedSufaceSet->Pnmax() : aNodes->Length();
   const Standard_Boolean aHasNormals = aNbNormals > 0;
 
   // Counting number of triangles in the triangle strips list.
@@ -2043,7 +2043,7 @@ Handle(Poly_Triangulation) createMesh(const Handle(StepVisual_ComplexTriangulate
 
   for (Standard_Integer j = 1; j <= aNbPairs; ++j)
   {
-    const gp_XYZ& aPoint = aNodes->Value(aNbNormals > 1 ? theTriangulatedSufaceSet->PnindexValue(j) : j);
+    const gp_XYZ& aPoint = aNodes->Value((aNbNormals > 1 && theTriangulatedSufaceSet->NbPnindex() > 0) ? theTriangulatedSufaceSet->PnindexValue(j) : j);
     aMesh->SetNode(j, theFact * aPoint);
   }