Salome HOME
Regression of smesh/mesh_Projection_2D_01/B7
[modules/smesh.git] / src / SMDS / SMDS_MeshNode.cxx
index 309be4ceba8472d4ab288ed53b6acfd60bd67b57..3bd528bb766e2a5087596d7a1a5808e8605da430 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -71,8 +71,7 @@ void SMDS_MeshNode::init(int id, int meshId, int shapeId, double x, double y, do
   points->InsertPoint(myVtkID, x, y, z);
   SMDS_CellLinks *cellLinks = dynamic_cast<SMDS_CellLinks*>(grid->GetCellLinks());
   assert(cellLinks);
-  if (myVtkID >= cellLinks->GetLinksSize())
-          cellLinks->ResizeL(myVtkID+SMDS_Mesh::chunkSize);
+  cellLinks->ResizeForPoint( myVtkID );
 }
 
 SMDS_MeshNode::~SMDS_MeshNode()
@@ -127,7 +126,7 @@ void SMDS_MeshNode::SetPosition(const SMDS_PositionPtr& aPos)
 
 const SMDS_PositionPtr& SMDS_MeshNode::GetPosition() const
 {
-        return myPosition;
+  return myPosition;
 }
 
 //=======================================================================
@@ -150,30 +149,26 @@ public:
   SMDS_MeshNode_MyInvIterator(SMDS_Mesh *mesh, vtkIdType* cells, int ncells, SMDSAbs_ElementType type) :
     myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0)
   {
-    //MESSAGE("SMDS_MeshNode_MyInvIterator : ncells " << myNcells);
-    cellList.clear();
+    cellList.reserve( ncells );
     if (type == SMDSAbs_All)
+      cellList.assign( cells, cells + ncells );
+    else
       for (int i = 0; i < ncells; i++)
-        cellList.push_back(cells[i]);
-    else for (int i = 0; i < ncells; i++)
       {
         int vtkId = cells[i];
         int smdsId = myMesh->fromVtkToSmds(vtkId);
         const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
         if (elem->GetType() == type)
-          {
-            //MESSAGE("Add element vtkId " << vtkId << " " << elem->GetType())
-            cellList.push_back(vtkId);
-          }
+        {
+          cellList.push_back(vtkId);
+        }
       }
-    myCells = &cellList[0];
+    myCells = cellList.empty() ? 0 : &cellList[0];
     myNcells = cellList.size();
-    //MESSAGE("myNcells="<<myNcells);
   }
 
   bool more()
   {
-    //MESSAGE("iter " << iter << " ncells " << myNcells);
     return (iter < myNcells);
   }