Salome HOME
PR: debug SMDS memimp
[modules/smesh.git] / src / SMDS / SMDS_MeshNode.cxx
index f7fe97cd30fac4eff867abca12fdcf97c5ddfa3b..1752046b0bf49607c5c9d52cf6d553bd2ac0ccc2 100644 (file)
@@ -36,6 +36,8 @@
 #define protected protected
 
 #include "utilities.h"
+#include "Utils_SALOME_Exception.hxx"
+#include <cassert>
 
 using namespace std;
 
@@ -49,18 +51,19 @@ SMDS_MeshNode::SMDS_MeshNode() :
   SMDS_MeshElement(-1, -1, -1),
   myPosition(SMDS_SpacePosition::originSpacePosition())
 {
+  nbNodes++;
 }
 
 SMDS_MeshNode::SMDS_MeshNode(int id, int meshId, int shapeId, double x, double y, double z):
   SMDS_MeshElement(id, meshId, shapeId),
   myPosition(SMDS_SpacePosition::originSpacePosition())
 {
+  nbNodes++;
   init(id, meshId, shapeId, x, y ,z);
 }
 
 void SMDS_MeshNode::init(int id, int meshId, int shapeId, double x, double y, double z)
 {
-  nbNodes++;
   myID = id;
   myMeshId = meshId;
   myShapeId = shapeId;
@@ -69,42 +72,10 @@ void SMDS_MeshNode::init(int id, int meshId, int shapeId, double x, double y, do
   SMDS_Mesh* mesh = SMDS_Mesh::_meshList[myMeshId];
   vtkUnstructuredGrid * grid = mesh->getGrid();
   vtkPoints *points = grid->GetPoints();
-  //int nbp = points->GetNumberOfPoints();
   points->InsertPoint(myID, x, y, z);
-  if (myID >= mesh->myCellLinksSize)
-  {
-      //points->SetNumberOfPoints(myID+SMDS_Mesh::chunkSize);
-      vtkCellLinks *cellLinks = grid->GetCellLinks();
-
-//      int imax = cellLinks->Size;
-//      for (int i =0; i<imax; i++)
-//      {
-//        vtkCellLinks::Link &ilink = cellLinks->GetLink(i);
-//        int ncells = ilink.ncells;
-//        int *cells = ilink.cells;
-//        MESSAGE("NODE " << i << " " << cellLinks << " " << cells << " " << ncells);
-//        for (int j=0; j< ncells; j++)
-//          MESSAGE("             " << j << " " << cells[j]);
-//      }
-
-      cellLinks->Resize(myID+SMDS_Mesh::chunkSize);
-
-//      cellLinks = grid->GetCellLinks();
-//      imax = cellLinks->Size;
-//      for (int i =0; i<imax; i++)
-//      {
-//        vtkCellLinks::Link &ilink = cellLinks->GetLink(i);
-//        int ncells = ilink.ncells;
-//        int *cells = ilink.cells;
-//        MESSAGE("NODE " << i << " " << cellLinks << " " << cells << " " << ncells);
-//        for (int j=0; j< ncells; j++)
-//          MESSAGE("             " << j << " " << cells[j]);
-//      }
-
-      mesh->myCellLinksSize = cellLinks->Size;
-      //MESSAGE(" -------------------------------------- resize CellLinks " << myID << " --> " << mesh->myCellLinksSize);
-  }
-  //setXYZ(x, y, z);
+  vtkCellLinks *cellLinks = grid->GetCellLinks();
+  if (myID >=cellLinks->Size)
+         cellLinks->Resize(myID+SMDS_Mesh::chunkSize);
 }
 
 SMDS_MeshNode::~SMDS_MeshNode()
@@ -191,6 +162,12 @@ private:
       int vtkId = myCells[iter];
       int smdsId = myMesh->fromVtkToSmds(vtkId);
       const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
+      if (!elem)
+      {
+         assert(0);
+         throw SALOME_Exception("SMDS_MeshNode_MyInvIterator problem Null element");
+      }
+      //MESSAGE("vtkId " << vtkId << " smdsId " << smdsId << " " << (elem!=0));
       iter++;
       return elem;
   }    
@@ -200,7 +177,7 @@ SMDS_ElemIteratorPtr SMDS_MeshNode::
        GetInverseElementIterator(SMDSAbs_ElementType type) const
 {
     vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myID);
-    //MESSAGE("ncells " << l.ncells);
+    //MESSAGE("myID " << myID << " ncells " << l.ncells);
     return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type));
 }
 
@@ -223,16 +200,19 @@ private:
                            SMDSAbs_ElementType type):
     myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0)
   {
-        for (; iter<ncells; iter++)
+       //MESSAGE("myNcells " << myNcells);
+       for (; iter<ncells; iter++)
         {
            int vtkId = myCells[iter];
            int smdsId = myMesh->fromVtkToSmds(vtkId);
+           //MESSAGE("vtkId " << vtkId << " smdsId " << smdsId);
            const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
            if (elem->GetType() == type)
                myFiltCells.push_back((SMDS_MeshElement*)elem);
         }
         myNcells = myFiltCells.size();
-        iter = 0;
+               //MESSAGE("myNcells " << myNcells);
+       iter = 0;
         //MESSAGE("SMDS_MeshNode_MyIterator (filter) " << ncells << " " << myNcells);
   }