]> OCCT Git - occt-copy.git/commitdiff
Fixed incorrect range in initialization of a collection of elements CR25936
authorssv <ssv@opencascade.com>
Tue, 25 Aug 2015 08:14:55 +0000 (11:14 +0300)
committerssv <ssv@opencascade.com>
Tue, 25 Aug 2015 08:14:55 +0000 (11:14 +0300)
src/Poly/Poly_Mesh.cxx

index 7aace317d8d39db9477c5dc11075194f9a77f4f9..dabb3a83ad1aa0b59e8dc651e4ba7e55a7bcb603 100644 (file)
@@ -37,11 +37,14 @@ Poly_Mesh::Poly_Mesh (const Handle(Poly_Triangulation)& theTriangulation)
 : Poly_Triangulation ( theTriangulation ),
   myNbQuads (0)
 {
+  const Standard_Integer aNbTris = theTriangulation->NbTriangles();
+  
   // Fill collection of elements
-  myElements.SetValue( theTriangulation->NbTriangles(), Poly_Element() );
+  if ( aNbTris )
+    myElements.SetValue( aNbTris - 1, Poly_Element() );
 
   // Populate elements with triangles
-  for ( Standard_Integer i = 1; i <= theTriangulation->NbTriangles(); ++i )
+  for ( Standard_Integer i = 1; i <= aNbTris; ++i )
   {
     myElements(i - 1).Set(i, 0);
   }