]> OCCT Git - occt-copy.git/commitdiff
0032491: Application Framework - BinTools_ShapeWriter attempts to get normals from... CR32491
authormsv <msv@opencascade.com>
Fri, 23 Jul 2021 18:18:22 +0000 (21:18 +0300)
committermsv <msv@opencascade.com>
Fri, 23 Jul 2021 19:14:51 +0000 (22:14 +0300)
Check if triangulation has normals before requesting them.

src/BinTools/BinTools_ShapeWriter.cxx

index ac604c7bd4813a1f5b2d686c842311b49768747d..a6c1a972040ee4c132db2ef7e0dd0e367a9dddc9 100644 (file)
@@ -470,7 +470,8 @@ void BinTools_ShapeWriter::WriteTriangulation (BinTools_OStream& theStream,
   const Standard_Integer aNbNodes = theTriangulation->NbNodes();
   const Standard_Integer aNbTriangles = theTriangulation->NbTriangles();
   theStream << aNbNodes << aNbTriangles << theTriangulation->HasUVNodes();
-  theStream << theNeedToWriteNormals << theTriangulation->Deflection();
+  theStream << (theTriangulation->HasNormals() && theNeedToWriteNormals);
+  theStream << theTriangulation->Deflection();
   // write the 3d nodes
   for (Standard_Integer aNodeIter = 1; aNodeIter <= aNbNodes; ++aNodeIter)
     theStream << theTriangulation->Node (aNodeIter);
@@ -484,7 +485,7 @@ void BinTools_ShapeWriter::WriteTriangulation (BinTools_OStream& theStream,
   for (Standard_Integer aTriIter = 1; aTriIter <= aNbTriangles; ++aTriIter)
     theStream << theTriangulation->Triangle (aTriIter);
 
-  if (theNeedToWriteNormals)
+  if (theTriangulation->HasNormals() && theNeedToWriteNormals)
   {
     gp_Vec3f aNormal;
     for (Standard_Integer aNormalIter = 1; aNormalIter <= aNbNodes; ++aNormalIter)