Salome HOME
ObjectPool and SMDS_Position
authorprascle <prascle>
Tue, 5 Jan 2010 19:11:30 +0000 (19:11 +0000)
committerprascle <prascle>
Tue, 5 Jan 2010 19:11:30 +0000 (19:11 +0000)
30 files changed:
src/SMDS/Notes
src/SMDS/ObjectPool.hxx [new file with mode: 0644]
src/SMDS/SMDS_Mesh.cxx
src/SMDS/SMDS_Mesh.hxx
src/SMDS/SMDS_MeshElement.cxx
src/SMDS/SMDS_MeshElement.hxx
src/SMDS/SMDS_MeshElementIDFactory.cxx
src/SMDS/SMDS_MeshElementIDFactory.hxx
src/SMDS/SMDS_MeshNode.cxx
src/SMDS/SMDS_MeshNode.hxx
src/SMDS/SMDS_Position.hxx
src/SMDS/SMDS_SpacePosition.cxx
src/SMDS/SMDS_SpacePosition.hxx
src/SMDS/SMDS_VolumeOfNodes.cxx
src/SMDS/SMDS_VolumeOfNodes.hxx
src/SMESH/SMESH_Algo.cxx
src/SMESH/SMESH_Gen.cxx
src/SMESH/SMESH_MeshEditor.cxx
src/SMESH/SMESH_MesherHelper.cxx
src/SMESH/SMESH_Pattern.cxx
src/SMESHDS/SMESHDS_SubMesh.cxx
src/SMESH_I/Makefile.am
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/StdMeshers/StdMeshers_FaceSide.cxx
src/StdMeshers/StdMeshers_Hexa_3D.cxx
src/StdMeshers/StdMeshers_MEFISTO_2D.cxx
src/StdMeshers/StdMeshers_Penta_3D.cxx
src/StdMeshers/StdMeshers_ProjectionUtils.cxx
src/StdMeshers/StdMeshers_Projection_2D.cxx

index 3107b51f3ba1341ff5cb3d7c1b5eb3b0d3bbdfc8..a0e3eef8c4ac24f46e652f92212b2d3f979db3d1 100644 (file)
@@ -58,17 +58,92 @@ enlever vtkId de SMDS_MeshCell, utiliser SMDS_MeshElementIDFactory.
 ajouter ID dans SMDS_Mesh::createTriangle 
 verifier ID dans SMDS_Mesh::Find*OrCreate
 
-========================
+===================================================
 occupation memoire cube 100*100*100 sans affichage
 
-Ubuntu 9.10 64 bits 15/12/2009
-/home/prascle/projets/SALOME/SMESH/BR_SMDS_MEMIMP/SMESH_SRC/src/SMESH/SMESH_Gen.cxx:143
-in use bytes     =   32843200 
-/home/prascle/projets/SALOME/SMESH/BR_SMDS_MEMIMP/SMESH_SRC/src/SMESH/SMESH_Gen.cxx [294] : VSR - SMESH_Gen::Compute() finished, OK = 1
-in use bytes     =  498773760
-delta = 460 Mo (45 Mo de plus que sur Sarge 64 bits ?)
-
-Debian Sarge 64 bits
-in use bytes     =   17076352
-in use bytes     =  431600032
-delta = 415 Mo
+Reference : V513 Debian Sarge 64 bits: --> 463 - 33 = 430 Mo
+-------------------------------------
+Total (incl. mmap):
+system bytes     =   43757568
+in use bytes     =   32909584 = 33M
+max mmap regions =         41
+max mmap bytes   =   16371712
+----
+Total (incl. mmap):
+system bytes     =  464670720
+in use bytes     =  463105120 = 463M
+max mmap regions =         47
+max mmap bytes   =   28188672
+
+Debian Sarge 64 bits, vtkUnstructuredGrid nodes et hexa, 4 janvier 2010 --> 512 - 41 = 471M
+-----------------------------------
+
+Total (incl. mmap):
+system bytes     =   52133888
+in use bytes     =   41340320 : 41M
+max mmap regions =         72
+max mmap bytes   =   24625152
+----
+Total (incl. mmap):
+system bytes     =  520560640
+in use bytes     =  518735584 : 512M
+max mmap regions =         88
+max mmap bytes   =  198385664
+
+idem avec pool SMDS_MeshNodes --> 483 -33 = 450M
+-----------------------------
+Total (incl. mmap):
+system bytes     =   43696128
+in use bytes     =   32915184 : 33M 
+max mmap regions =         41
+max mmap bytes   =   16371712
+----
+Total (incl. mmap):
+system bytes     =  484806656
+in use bytes     =  482980992 : 483M
+max mmap regions =         58
+max mmap bytes   =  184557568
+
+idem ci-dessus + pool SMDS_VolumeVtkNodes --> 475 -33 = 442M (git: add ObjectPool.hxx)
+-----------------------------------------
+
+Total (incl. mmap):
+system bytes     =   43200512
+in use bytes     =   32908576 : 33M
+max mmap regions =         41
+max mmap bytes   =   16371712
+----
+Total (incl. mmap):
+system bytes     =  478068736
+in use bytes     =  475144400 : 475M
+max mmap regions =         59
+max mmap bytes   =  184692736
+
+remplacement SMDS_PositionPtr: (boost::shared_ptr<SMDS_Position> --> SMDS_Position*) --> 436 - 35 = 401M (git SMDS_Position)
+------------------------------------------------------------------------------------
+Total (incl. mmap):
+system bytes     =   45408256
+in use bytes     =   35097680 : 35M
+max mmap regions =         47
+max mmap bytes   =   18116608
+----
+Total (incl. mmap):
+system bytes     =  438935552
+in use bytes     =  436116560 : 436M
+max mmap regions =         65
+max mmap bytes   =  186437632
+
+simplification SMDS_SpacePosition (pas de double[3]) --> 418 -33 = 385M (git SMDS_SpacePosition)
+----------------------------------------------------
+Total (incl. mmap):
+system bytes     =   42582016
+in use bytes     =   32883552 : 33M
+max mmap regions =         41
+max mmap bytes   =   16371712
+----
+Total (incl. mmap):
+system bytes     =  421728256
+in use bytes     =  418378000 : 418M
+max mmap regions =         58
+max mmap bytes   =  183640064
+
diff --git a/src/SMDS/ObjectPool.hxx b/src/SMDS/ObjectPool.hxx
new file mode 100644 (file)
index 0000000..a4111b1
--- /dev/null
@@ -0,0 +1,105 @@
+
+#ifndef _OBJECTPOOL_HXX_
+#define _OBJECTPOOL_HXX_
+
+#include <vector>
+#include <stack>
+#include <iostream>
+
+template <class X> class ObjectPool
+{
+
+private:
+  std::vector<X*> _chunkList;
+  std::vector<bool> _freeList;
+  int _nextFree;
+  int _maxAvail;
+  int _chunkSize;
+
+  int getNextFree()
+  {
+    for (int i=_nextFree; i< _maxAvail; i++)
+      if (_freeList[i] == true)
+        {
+          return i;
+          break;
+        }
+    return _maxAvail;
+  }
+
+  void checkDelete(int chunkId)
+  {
+    int i0 = _chunkSize*chunkId;
+    int i1 =_chunkSize*(chunkId+1);
+    for (int i=i0; i < i1; i++)
+      if (_freeList[i] == false)
+        return;
+    std::cerr << "a chunk to delete" << std::endl;
+    // compactage des vecteurs un peu lourd, pas necessaire
+    //X* chunk = _chunkList[chunkId];
+    //delete [] chunk;
+  }
+
+public:
+  ObjectPool(int nblk)
+  {
+    _chunkSize = nblk;
+    _nextFree = 0;
+    _maxAvail = 0;
+    _chunkList.clear();
+    _freeList.clear();
+  }
+
+  virtual ~ObjectPool()
+  {
+    for (int i=0; i<_chunkList.size(); i++)
+      delete [] _chunkList[i];
+  }
+
+  X* getNew()
+  {
+    X *obj = 0;
+    _nextFree = getNextFree();
+    if (_nextFree == _maxAvail)
+      {
+        X* newChunk = new X[_chunkSize];
+        _chunkList.push_back(newChunk);
+        _freeList.insert(_freeList.end(), _chunkSize, true);
+        _maxAvail += _chunkSize;
+        _freeList[_nextFree] = false;
+        obj = newChunk; // &newChunk[0];
+      }
+    else
+      {
+        int chunkId = _nextFree/_chunkSize;
+        int rank = _nextFree - chunkId*_chunkSize;
+        _freeList[_nextFree] = false;
+        obj = _chunkList[chunkId] + rank; // &_chunkList[chunkId][rank];
+      }
+    //obj->init();
+    return obj;
+  }
+
+  void destroy(X* obj)
+  {
+    long adrobj = (long)(obj);
+    for (int i=0; i< _chunkList.size(); i++)
+    {
+      X* chunk = _chunkList[i];
+      long adrmin = (long)(chunk);
+      if (adrobj < adrmin) continue;
+      long adrmax = (long)(chunk + _chunkSize);
+      if (adrobj >= adrmax) continue;
+      int rank = (adrobj -adrmin)/sizeof(X);
+      int toFree = i*_chunkSize + rank;
+      _freeList[toFree] = true;
+      if (toFree < _nextFree) _nextFree = toFree;
+      //obj->clean();
+      //checkDelete(i); compactage non fait
+      break;
+    }
+  }
+
+};
+
+#endif
index 693fd38fd1ba6b49005e98998d067654873a7615..cd0196c3cd954c6a12859e90965186fd8c4eaf13 100644 (file)
@@ -51,7 +51,8 @@ using namespace std;
 #define CHECKMEMORY_INTERVAL 1000
 
 vector<SMDS_Mesh*> SMDS_Mesh::_meshList = vector<SMDS_Mesh*>();
-int SMDS_Mesh::chunkSize = 1000;
+int SMDS_Mesh::chunkSize = 1024;
+
 
 //================================================================================
 /*!
@@ -113,15 +114,21 @@ SMDS_Mesh::SMDS_Mesh()
          myElementIDFactory(new SMDS_MeshElementIDFactory()),
          myHasConstructionEdges(false), myHasConstructionFaces(false),
          myHasInverseElements(true),
-         myNodeMin(0), myNodeMax(0), myCellLinksSize(0)
+         myNodeMin(0), myNodeMax(0), myCellLinksSize(0),
+         myNodePool(0), myVolumePool(0)
 {
   myMeshId = _meshList.size();         // --- index of the mesh to push back in the vector
   MESSAGE("myMeshId=" << myMeshId);
   myNodeIDFactory->SetMesh(this);
   myElementIDFactory->SetMesh(this);
   _meshList.push_back(this);
+  myNodePool = new ObjectPool<SMDS_MeshNode>(SMDS_Mesh::chunkSize);
+  myVolumePool = new ObjectPool<SMDS_VolumeVtkNodes>(SMDS_Mesh::chunkSize);
+
   myNodes.clear();
   myCells.clear();
+  myIDElements.clear();
+  myVtkIndex.clear();
   myGrid = vtkUnstructuredGrid::New();
   myGrid->Initialize();
   myGrid->Allocate();
@@ -139,9 +146,11 @@ SMDS_Mesh::SMDS_Mesh()
 ///////////////////////////////////////////////////////////////////////////////
 SMDS_Mesh::SMDS_Mesh(SMDS_Mesh * parent)
         :myParent(parent), myNodeIDFactory(parent->myNodeIDFactory),
-        myElementIDFactory(parent->myElementIDFactory),
-        myHasConstructionEdges(false), myHasConstructionFaces(false),
-        myHasInverseElements(true)
+         myElementIDFactory(parent->myElementIDFactory),
+         myHasConstructionEdges(false), myHasConstructionFaces(false),
+         myHasInverseElements(true),
+         myNodePool(parent->myNodePool),
+         myVolumePool(parent->myVolumePool)
 {
 }
 
@@ -178,7 +187,9 @@ SMDS_MeshNode * SMDS_Mesh::AddNodeWithID(double x, double y, double z, int ID)
   const SMDS_MeshElement *node = myNodeIDFactory->MeshElement(ID);
   if(!node){
     //if ( myNodes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
-    SMDS_MeshNode * node=new SMDS_MeshNode(ID, myMeshId, -1, x, y, z);
+    //SMDS_MeshNode * node=new SMDS_MeshNode(ID, myMeshId, -1, x, y, z);
+    SMDS_MeshNode * node = myNodePool->getNew();
+    node->init(ID, myMeshId, -1, x, y, z);
     if (ID >= myNodes.size())
     {
         myNodes.resize(ID+SMDS_Mesh::chunkSize, 0);
@@ -842,13 +853,27 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
     return NULL;
   }
   else {
-//    volume=new SMDS_HexahedronOfNodes(n1,n2,n3,n4,n5,n6,n7,n8);
-    volume=new SMDS_VolumeOfNodes(n1,n2,n3,n4,n5,n6,n7,n8);
+    // --- retreive nodes ID
+    vector<vtkIdType> nodeIds;
+    nodeIds.clear();
+    nodeIds.push_back(n1->getId());
+    nodeIds.push_back(n2->getId());
+    nodeIds.push_back(n3->getId());
+    nodeIds.push_back(n4->getId());
+    nodeIds.push_back(n5->getId());
+    nodeIds.push_back(n6->getId());
+    nodeIds.push_back(n7->getId());
+    nodeIds.push_back(n8->getId());
+
+    //volume = new SMDS_VolumeVtkNodes(nodeIds, this);
+    SMDS_VolumeVtkNodes *volvtk = myVolumePool->getNew();
+    volvtk->init(nodeIds, this);
+    volume = volvtk;
     adjustmyCellsCapacity(ID);
     myCells[ID] = volume;
     myInfo.myNbHexas++;
   }
-
   if (!registerElement(ID, volume)) {
     RemoveElement(volume, false);
     volume = NULL;
@@ -1130,14 +1155,42 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolume
 ///////////////////////////////////////////////////////////////////////////////
 /// Registers element with the given ID, maintains inverse connections
 ///////////////////////////////////////////////////////////////////////////////
-bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement * element)
+bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement* element)
 {
-    //MESSAGE("registerElement " << ID)
-  if (myElementIDFactory->BindID(ID, element)) {
-    return true;
+  //MESSAGE("registerElement " << ID)
+  if ((ID < myIDElements.size()) && myIDElements[ID] >= 0) // --- already bound
+  {
+    MESSAGE(" --------------------------------- already bound "<< ID << " " << myIDElements[ID]);
+    return false;
   }
-  MESSAGE("BindID " << ID << " false!---------------");
-  return false;
+
+  element->myID = ID;
+  element->myMeshId = myMeshId;
+
+  SMDS_MeshCell *cell = dynamic_cast<SMDS_MeshCell*>(element);
+  assert(cell);
+  int vtkId = cell->getVtkId();  
+  if (vtkId == -1)
+    vtkId = myElementIDFactory->SetInVtkGrid(element);
+  
+  if (ID >= myIDElements.size()) // --- resize local vector
+  {
+    MESSAGE(" ------------------- resize myIDElements " << ID << " --> " << ID + SMDS_Mesh::chunkSize);
+    myIDElements.resize(ID + SMDS_Mesh::chunkSize, -1); // fill new elements with -1
+  }
+
+  myIDElements[ID] = vtkId;
+  //MESSAGE("smds:" << ID << " vtk:" << cellId );
+
+  if (vtkId >= myVtkIndex.size()) // --- resize local vector
+  {
+    MESSAGE(" --------------------- resize myVtkIndex " << vtkId << " --> " << vtkId + SMDS_Mesh::chunkSize);
+    myVtkIndex.resize(vtkId + SMDS_Mesh::chunkSize, -1);
+  }
+  myVtkIndex[vtkId] = ID;
+
+  myElementIDFactory->updateMinMax(ID);
+  return true;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -3405,3 +3458,23 @@ void SMDS_Mesh::updateNodeMinMax()
   while (!myNodes[myNodeMax] && (myNodeMin>=0))
     myNodeMin--;
 }
+
+void SMDS_Mesh::incrementNodesCapacity(int nbNodes)
+{
+  int val = myIDElements.size();
+  MESSAGE(" ------------------- resize myIDElements " << val << " --> " << val + nbNodes);
+  myIDElements.resize(val + nbNodes, -1); // fill new elements with -1
+  val = myNodes.size();
+  MESSAGE(" ------------------- resize myNodes " << val << " --> " << val + nbNodes);
+  myNodes.resize(val +nbNodes, 0);
+}
+
+void SMDS_Mesh::incrementCellsCapacity(int nbCells)
+{
+  int val = myVtkIndex.size();
+  MESSAGE(" ------------------- resize myVtkIndex " << val << " --> " << val + nbCells);
+  myVtkIndex.resize(val + nbCells, -1); // fill new elements with -1
+  val = myCells.size();
+  MESSAGE(" ------------------- resize myCells " << val << " --> " << val + nbCells);
+  myNodes.resize(val +nbCells, 0);
+}
index db64ab7823f8f9a06bb1e76cef828295bdae2b6e..203ec83f3dccc5e9dcb33d6edff5581bd0e89076 100644 (file)
@@ -37,6 +37,8 @@
 #include "SMDS_MeshElementIDFactory.hxx"
 #include "SMDS_MeshInfo.hxx"
 #include "SMDS_ElemIterator.hxx"
+#include "SMDS_VolumeOfNodes.hxx"
+#include "ObjectPool.hxx"
 
 #include <boost/shared_ptr.hpp>
 #include <set>
@@ -48,7 +50,9 @@ class vtkUnstructuredGrid;
 
 class SMDS_EXPORT SMDS_Mesh:public SMDS_MeshObject{
 public:
-
+  friend class SMDS_MeshElementIDFactory;
+  friend class SMDS_MeshVolumeVtkNodes;
+  
   static std::vector<SMDS_Mesh*> _meshList;    // --- to find the SMDS_mesh from its elements
 
   SMDS_Mesh();
@@ -549,8 +553,11 @@ public:
   typedef std::vector<SMDS_MeshCell *> SetOfCells;
 
   void updateNodeMinMax();
-  int fromVtkToSmds(int vtkid) { return myElementIDFactory->fromVtkToSmds(vtkid); };
+  int fromVtkToSmds(int vtkid) { return myVtkIndex[vtkid]; };
 
+  void incrementNodesCapacity(int nbNodes);
+  void incrementCellsCapacity(int nbCells);
+  
   int myCellLinksSize;
 
   static int chunkSize;
@@ -595,14 +602,12 @@ private:
   int myMeshId;                           // --- index for this mesh in the vector
   vtkUnstructuredGrid*      myGrid;
 
-
+  ObjectPool<SMDS_MeshNode>* myNodePool;
+  ObjectPool<SMDS_VolumeVtkNodes>* myVolumePool;
   SetOfNodes             myNodes;
   SetOfCells             myCells;
-
-//   SetOf0DElements        my0DElements;
-//   SetOfEdges             myEdges;
-//   SetOfFaces             myFaces;
-//   SetOfVolumes           myVolumes;
+  std::vector<int>       myIDElements; // index = ID client, value = ID vtk
+  std::vector<int>       myVtkIndex;   // index = ID vtk, value = ID client
 
   SMDS_Mesh *            myParent;
   std::list<SMDS_Mesh *> myChildren;
index 5f16698859141299412367615a6251e3a8b85b2c..fdbeffd86f0a1c19959efe7003c119ec48407b26 100644 (file)
@@ -34,7 +34,9 @@
 
 using namespace std;
 
-SMDS_MeshElement::SMDS_MeshElement(int ID):myID(ID)
+int SMDS_MeshCell::nbCells = 0;
+
+SMDS_MeshElement::SMDS_MeshElement(int ID):myID(ID), myMeshId(-1), myShapeId(-1)
 {
 }
 
@@ -246,5 +248,11 @@ int SMDS_MeshElement::GetNodeIndex( const SMDS_MeshNode* node ) const
 
 SMDS_MeshCell::SMDS_MeshCell()
 {
-    myVtkID = -1;
-};
\ No newline at end of file
+  nbCells++;
+  myVtkID = -1;
+};
+
+SMDS_MeshCell::~SMDS_MeshCell()
+{
+  nbCells--;
+}
\ No newline at end of file
index eb0179ccc2eed4ba0bdd0decef677847fb128a84..94e92223967cb720b2d691f11dfc7c090e37a157 100644 (file)
@@ -41,7 +41,8 @@ typedef short ShortType;
 
 class SMDS_MeshNode;
 class SMDS_MeshEdge;
-class SMDS_MeshFace;   
+class SMDS_MeshFace;
+class SMDS_Mesh;
 
 // ============================================================
 /*!
@@ -73,7 +74,8 @@ public:
   virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
 
   friend SMDS_EXPORT std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *);
-  friend SMDS_EXPORT bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement*elem);
+  friend SMDS_EXPORT bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement* elem);
+  friend class SMDS_Mesh;
 
   // ===========================
   //  Access to nodes by index
@@ -119,7 +121,7 @@ public:
    */
   int GetNodeIndex( const SMDS_MeshNode* node ) const;
 
-  inline int getId() {return myID; };
+  inline int getId() const {return myID; };
   inline UShortType getMeshId() {return myMeshId; };
   inline ShortType getshapeId() {return myShapeId; };
   inline void setShapeId(UShortType shapeId) {myShapeId = shapeId; };
@@ -130,7 +132,7 @@ protected:
   virtual void Print(std::ostream & OS) const;
 
   int myID;        // --- element index 
-  UShortType myMeshId;
+  ShortType myMeshId;
   ShortType myShapeId;
 };
 
@@ -144,8 +146,10 @@ class SMDS_EXPORT SMDS_MeshCell:public SMDS_MeshElement
 {
 public:
     SMDS_MeshCell();
-    inline void setVtkId(int vtkId) { myVtkID = vtkId; };
+    virtual ~SMDS_MeshCell();
+   inline void setVtkId(int vtkId) { myVtkID = vtkId; };
     inline int getVtkId() const {return myVtkID; };
+    static int nbCells;
 protected:
     int myVtkID;
 };
index 58658c5b26a4db3356374d154b06198db22f61bf..f5f3c37c71faeeec3bc5fc1ac66e5d566f4481de 100644 (file)
@@ -46,8 +46,8 @@ using namespace std;
 SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory():
   SMDS_MeshNodeIDFactory()
 {
-    myIDElements.clear();
-    myVtkIndex.clear();
+//    myIDElements.clear();
+//    myVtkIndex.clear();
     myVtkCellTypes.clear();
     myVtkCellTypes.reserve(SMDSEntity_Last);
     myVtkCellTypes[SMDSEntity_Node]            = VTK_VERTEX;
@@ -72,25 +72,9 @@ SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory():
     myVtkCellTypes[SMDSEntity_Quad_Polyhedra]  = VTK_CONVEX_POINT_SET;
 }
 
-//=======================================================================
-//function : BindID
-//purpose  : 
-//=======================================================================
-bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem)
+int SMDS_MeshElementIDFactory::SetInVtkGrid(SMDS_MeshElement * elem)
 {
-  if ((ID < myIDElements.size()) && myIDElements[ID] >= 0) // --- already bound
-  {
-    MESSAGE(" --------------------------------- already bound "<< ID << " " << myIDElements[ID]);
-      return false;
-  }
-
-  if (ID >= myIDElements.size()) // --- resize local vector
-  {
-    //MESSAGE(" ------------------- resize myIDElements " << ID << " --> " << ID+SMDS_Mesh::chunkSize);
-    myIDElements.resize(ID+SMDS_Mesh::chunkSize,-1); // fill new elements with -1
-  }
-
-  // --- retreive nodes ID
+   // --- retreive nodes ID
 
   vector<vtkIdType> nodeIds;
   SMDS_ElemIteratorPtr it = elem->nodesIterator();
@@ -106,25 +90,23 @@ bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem)
   vtkUnstructuredGrid * grid = myMesh->getGrid();
   int typ = GetVtkCellType(elem->GetType());
   int cellId = grid->InsertNextLinkedCell(typ, nodeIds.size(), &nodeIds[0]);
-
-  // --- fill local vector
-
-  myIDElements[ID] = cellId;
-  //MESSAGE("smds:" << ID << " vtk:" << cellId );
-
-  if (cellId >= myVtkIndex.size()) // --- resize local vector
-  {
-    //MESSAGE(" --------------------- resize myVtkIndex " << cellId << " --> " << cellId+SMDS_Mesh::chunkSize);
-    myVtkIndex.resize(cellId+SMDS_Mesh::chunkSize, -1);
-  }
-  myVtkIndex[cellId] = ID;
-
-  elem->myID=ID;
   SMDS_MeshCell *cell = dynamic_cast<SMDS_MeshCell*>(elem);
   assert(cell);
-  cell->setVtkId(cellId);
-  updateMinMax (ID);
-  return true;
+  cell->setVtkId(cellId); 
+  //MESSAGE("SMDS_MeshElementIDFactory::SetInVtkGrid " << cellId);
+  return cellId;
+}
+
+//=======================================================================
+//function : BindID
+//purpose  : 
+//=======================================================================
+
+bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem)
+{
+  MESSAGE("SMDS_MeshElementIDFactory::BindID " << ID);
+  SetInVtkGrid(elem);
+  return myMesh->registerElement(ID, elem);
 }
 
 //=======================================================================
@@ -133,7 +115,7 @@ bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem)
 //=======================================================================
 SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID)
 {
-  if ((ID<0) || (ID>myMax) || (myIDElements[ID]<0))
+  if ((ID<0) || (ID>myMax) || (myMesh->myIDElements[ID]<0))
     return NULL;
   const SMDS_MeshElement* elem = GetMesh()->FindElement(ID);
   return (SMDS_MeshElement*)(elem);
@@ -145,7 +127,7 @@ SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID)
 //=======================================================================
 void SMDS_MeshElementIDFactory::ReleaseID(const int ID)
 {
-  myIDElements[ID] = -1;
+  myMesh->myIDElements[ID] = -1;
   SMDS_MeshIDFactory::ReleaseID(ID);
   if (ID == myMax)
     myMax = 0;
@@ -162,8 +144,8 @@ void SMDS_MeshElementIDFactory::updateMinMax() const
 {
   myMin = IntegerLast();
   myMax = 0;
-  for (int i=0; i<myIDElements.size(); i++)
-      if (int id=myIDElements[i] >=0)
+  for (int i=0; i<myMesh->myIDElements.size(); i++)
+      if (int id=myMesh->myIDElements[i] >=0)
       {
         if (id > myMax) myMax = id;
         if (id < myMin) myMin = id;
@@ -184,7 +166,7 @@ SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const
 
 void SMDS_MeshElementIDFactory::Clear()
 {
-  myIDElements.clear();
+  myMesh->myIDElements.clear();
   myMin = myMax = 0;
   SMDS_MeshIDFactory::Clear();
 }
index bebac0973e3f6408817925c938c67823ae57d642..e55da180f236a43009cac0bbc2ef195d04020c9a 100644 (file)
 #include <vector>
 
 class SMDS_MeshElement;
+class SMDS_Mesh;
 
 class SMDS_EXPORT SMDS_MeshElementIDFactory:public SMDS_MeshNodeIDFactory
 {
 public:
+  friend class SMDS_Mesh;
+  
   SMDS_MeshElementIDFactory();
   bool BindID(int ID, SMDS_MeshElement * elem);
+  int SetInVtkGrid(SMDS_MeshElement * elem);
   SMDS_MeshElement * MeshElement(int ID);
   virtual void ReleaseID(int ID);
   SMDS_ElemIteratorPtr elementsIterator() const;
   virtual void Clear();
   int GetVtkCellType(int SMDSType);
-  int fromVtkToSmds(int vtkid) { return myVtkIndex[vtkid]; };
 
 protected:
   void updateMinMax() const;
@@ -54,8 +57,6 @@ protected:
     if (id < myMin) myMin = id;
   }
 
-  std::vector<int> myIDElements; // index = ID client, value = ID vtk
-  std::vector<int> myVtkIndex;   // index = ID vtk, value = ID client
   std::vector<int> myVtkCellTypes;
 
 };
index 5b6f517fdfaffcb4718c2d9b3198ab090c9435d1..55a90c5cc1b21207493f113f392d49e5797f5da0 100644 (file)
 
 using namespace std;
 
+int SMDS_MeshNode::nbNodes =0;
+
 //=======================================================================
 //function : SMDS_MeshNode
 //purpose  : 
 //=======================================================================
+SMDS_MeshNode::SMDS_MeshNode() :
+  SMDS_MeshElement(-1, -1, -1),
+  myPosition(SMDS_SpacePosition::originSpacePosition())
+{
+}
 
 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())
 {
+  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;
   //MESSAGE("Node " << myID << " (" << x << ", " << y << ", " << z << ")");
   SMDS_Mesh* mesh = SMDS_Mesh::_meshList[myMeshId];
   vtkUnstructuredGrid * grid = mesh->getGrid();
@@ -90,6 +106,11 @@ SMDS_MeshNode::SMDS_MeshNode(int id, int meshId, int shapeId, double x, double y
   //setXYZ(x, y, z);
 }
 
+SMDS_MeshNode::~SMDS_MeshNode()
+{
+  nbNodes--;
+}
+
 //=======================================================================
 //function : RemoveInverseElement
 //purpose  : 
index 64ecc0847df17ef24fe04d26555664142685d2c6..ffe1c499e05bd3311f807b84425321bb0f086e65 100644 (file)
@@ -36,8 +36,12 @@ class SMDS_EXPORT SMDS_MeshNode:public SMDS_MeshElement
 {
 
 public:
+  SMDS_MeshNode();
   SMDS_MeshNode(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0);
+  virtual ~SMDS_MeshNode();
 
+  void init(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0);
+  
   double* getCoord() const;
 
   void Print(std::ostream & OS) const;
@@ -64,7 +68,7 @@ public:
    * \retval const SMDS_MeshNode* - the node
    */
   virtual const SMDS_MeshNode* GetNode(const int) const { return this; }
-
+  static int nbNodes;
 protected:
   SMDS_ElemIteratorPtr
   elementsIterator(SMDSAbs_ElementType type) const;
index 687bc098ebcf97c90ddd81023773089ae6245df2..a92f4648fbef923a49a36f074c7ea1e9d4fd1648 100644 (file)
@@ -32,7 +32,8 @@
 #include <boost/shared_ptr.hpp>
 
 class SMDS_Position;
-typedef boost::shared_ptr<SMDS_Position> SMDS_PositionPtr;
+//typedef boost::shared_ptr<SMDS_Position> SMDS_PositionPtr;
+typedef SMDS_Position* SMDS_PositionPtr;
 
 class SMDS_EXPORT SMDS_Position
 {
index 09532f3476bce08f60fbf6bade8028391ebeff6d..5647c1e95b416728674a2f6d454fbf59925a7cfb 100644 (file)
 //  Author : Jean-Michel BOULCOURT
 //  Module : SMESH
 //
+
 #include "SMDS_SpacePosition.hxx"
 
-//=======================================================================
-//function : SMDS_SpacePosition
-//purpose  : 
-//=======================================================================
+SMDS_SpacePosition* SMDS_SpacePosition::_originPosition = new SMDS_SpacePosition();
 
 SMDS_SpacePosition::SMDS_SpacePosition(double x, double y, double z):
-       SMDS_Position(0)
+  SMDS_Position(0)
 {
-       myCoords[0]=x;
-       myCoords[1]=y;
-       myCoords[2]=z;
 }
 
-/**
-*/
-SMDS_TypeOfPosition SMDS_SpacePosition::GetTypeOfPosition() const
+const double* SMDS_SpacePosition::Coords() const
 {
-       return SMDS_TOP_3DSPACE;
+  static double origin[]={0,0,0};
+  return origin;
 }
 
-const double * SMDS_SpacePosition::Coords() const
+SMDS_TypeOfPosition SMDS_SpacePosition::GetTypeOfPosition() const
 {
-       return myCoords;
+  return SMDS_TOP_3DSPACE;
 }
 
 SMDS_PositionPtr SMDS_SpacePosition::originSpacePosition()
 {
-  static SMDS_PositionPtr staticpos (new SMDS_SpacePosition());
-  return staticpos;
+  return _originPosition;
 }
index f80f3210af374672a29b5d29caf29c38134f8da7..e8cde06a54b22a6588a9ae2fc552a1b78dbb9bdd 100644 (file)
 class SMDS_EXPORT SMDS_SpacePosition:public SMDS_Position
 {
 
-  public:
-       SMDS_SpacePosition(double x=0, double y=0, double z=0);
-       const virtual double * Coords() const;
-       virtual inline SMDS_TypeOfPosition GetTypeOfPosition() const;
-       inline void SetCoords(const double x, const double y, const double z);
-        static SMDS_PositionPtr originSpacePosition();
-  private:
-       double myCoords[3];     
+public:
+  SMDS_SpacePosition(double x=0, double y=0, double z=0);
+  const virtual double * Coords() const;
+  virtual inline SMDS_TypeOfPosition GetTypeOfPosition() const;
+  static SMDS_PositionPtr originSpacePosition();
+private:
+  static SMDS_SpacePosition* _originPosition;
 };
 
 #endif
index b44bae07cb3c8aeebaae955d50d13c0cddfd3b41..449212df28c2ae1df6c6b6654bb7c54fa4942758 100644 (file)
 #include "SMDS_MeshNode.hxx"
 #include "SMDS_SetIterator.hxx"
 #include "SMDS_VolumeTool.hxx"
+#include "SMDS_Mesh.hxx"
 #include "utilities.h"
 
+#include <vtkCell.h>
+
 #include <vector>
 
 using namespace std;
@@ -258,6 +261,17 @@ SMDS_VolumeVtkNodes::SMDS_VolumeVtkNodes()
 {
 }
 
+SMDS_VolumeVtkNodes::SMDS_VolumeVtkNodes(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
+{
+  init(nodeIds, mesh);
+}
+
+void SMDS_VolumeVtkNodes::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
+{
+  vtkUnstructuredGrid* grid = mesh->getGrid();
+  myVtkID = grid->InsertNextLinkedCell(GetType(), nodeIds.size(), &nodeIds[0]);
+}
+
 bool SMDS_VolumeVtkNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
                                      const int            nbNodes)
 {
@@ -289,7 +303,9 @@ int SMDS_VolumeVtkNodes::NbFaces() const
 
 int SMDS_VolumeVtkNodes::NbNodes() const
 {
-        return 0;
+  vtkUnstructuredGrid* grid =SMDS_Mesh::_meshList[myMeshId]->getGrid();
+  int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
+  return nbPoints;
 }
 
 int SMDS_VolumeVtkNodes::NbEdges() const
index 9c2aa7129e3c54c9cdfa50c7e08a15c0ac434d89..2aabf9fc336c7e1f93d45bae35e6e5a29d7cd769 100644 (file)
@@ -29,6 +29,8 @@
 #include "SMESH_SMDS.hxx"
 
 #include "SMDS_MeshVolume.hxx"
+#include <vtkUnstructuredGrid.h>
+#include <vector>
 
 class SMDS_EXPORT SMDS_VolumeOfNodes:public SMDS_MeshVolume
 {
@@ -90,10 +92,12 @@ class SMDS_EXPORT SMDS_VolumeOfNodes:public SMDS_MeshVolume
 class SMDS_EXPORT SMDS_VolumeVtkNodes:public SMDS_MeshVolume
 {
 public:
-       SMDS_VolumeVtkNodes();
+        SMDS_VolumeVtkNodes();
+       SMDS_VolumeVtkNodes(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
+        ~SMDS_VolumeVtkNodes();
+        void init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
         bool ChangeNodes(const SMDS_MeshNode* nodes[],
                          const int            nbNodes);
-        ~SMDS_VolumeVtkNodes();
 
        void Print(std::ostream & OS) const;
        int NbFaces() const;
index 8aad675b4c95c08c564c938edf1681c8331b3e88..579d5ad413f05a44888d2e02978bc7a43748b3c9 100644 (file)
@@ -223,7 +223,7 @@ bool SMESH_Algo::IsReversedSubMesh (const TopoDS_Face&  theFace,
         const SMDS_PositionPtr& pos = node->GetPosition();
         if ( !pos ) continue;
         if ( pos->GetTypeOfPosition() == SMDS_TOP_FACE ) {
-          fPos = dynamic_cast< const SMDS_FacePosition* >( pos.get() );
+          fPos = dynamic_cast< const SMDS_FacePosition* >( pos );
         }
         else if ( pos->GetTypeOfPosition() == SMDS_TOP_VERTEX ) {
           vID = pos->GetShapeId();
@@ -334,7 +334,7 @@ bool SMESH_Algo::GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
       if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
         return false;
       const SMDS_EdgePosition* epos =
-        static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+        static_cast<const SMDS_EdgePosition*>(node->GetPosition());
       if ( !paramSet.insert( epos->GetUParameter() ).second )
         return false; // equal parameters
     }
@@ -401,7 +401,7 @@ bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh*                   theM
       if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
         return false;
       const SMDS_EdgePosition* epos =
-        static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+        static_cast<const SMDS_EdgePosition*>(node->GetPosition());
       theNodes.insert( make_pair( epos->GetUParameter(), node ));
       ++nbNodes;
     }
index 742a6ae620d4e9c2e8708a78bc41dd2bac7bca08..314bbb2062509fdd951a527a6fb04dbc89353f3d 100644 (file)
@@ -304,6 +304,8 @@ bool SMESH_Gen::Compute(SMESH_Mesh &          aMesh,
       total +=  subMesh->getSize();
     }
   cerr << "total elements and nodes in submesh sets:" << total << endl;
+  cerr << "Number of node objects " << SMDS_MeshNode::nbNodes << endl;
+  cerr << "Number of cell objects " << SMDS_MeshCell::nbCells << endl;
   return ret;
 }
 
index 32dcba79617af5fe50d493ec38cb1ac2a5ea7c56..851108365593725e2d1f9d01ca315750d5ea3c22 100644 (file)
@@ -337,7 +337,7 @@ int SMESH_MeshEditor::FindShape (const SMDS_MeshElement * theElem)
   if ( theElem->GetType() == SMDSAbs_Node ) {
     const SMDS_PositionPtr& aPosition =
       static_cast<const SMDS_MeshNode*>( theElem )->GetPosition();
-    if ( aPosition.get() )
+    if ( aPosition )
       return aPosition->GetShapeId();
     else
       return 0;
@@ -348,7 +348,7 @@ int SMESH_MeshEditor::FindShape (const SMDS_MeshElement * theElem)
   while ( nodeIt->more() ) {
     const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
     const SMDS_PositionPtr& aPosition = node->GetPosition();
-    if ( aPosition.get() ) {
+    if ( aPosition ) {
       int aShapeID = aPosition->GetShapeId();
       SMESHDS_SubMesh * sm = aMesh->MeshElements( aShapeID );
       if ( sm ) {
@@ -2345,7 +2345,7 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet &          theElems,
       while ( nn++ < nbn ) {
         node = static_cast<const SMDS_MeshNode*>( itN->next() );
         const SMDS_PositionPtr& pos = node->GetPosition();
-        posType = pos.get() ? pos->GetTypeOfPosition() : SMDS_TOP_3DSPACE;
+        posType = pos ? pos->GetTypeOfPosition() : SMDS_TOP_3DSPACE;
         if (posType != SMDS_TOP_EDGE &&
             posType != SMDS_TOP_VERTEX &&
             theFixedNodes.find( node ) == theFixedNodes.end())
@@ -2403,11 +2403,11 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet &          theElems,
         node = *n;
         gp_XY uv( 0, 0 );
         const SMDS_PositionPtr& pos = node->GetPosition();
-        posType = pos.get() ? pos->GetTypeOfPosition() : SMDS_TOP_3DSPACE;
+        posType = pos ? pos->GetTypeOfPosition() : SMDS_TOP_3DSPACE;
         // get existing UV
         switch ( posType ) {
         case SMDS_TOP_FACE: {
-          SMDS_FacePosition* fPos = ( SMDS_FacePosition* ) pos.get();
+          SMDS_FacePosition* fPos = ( SMDS_FacePosition* ) pos;
           uv.SetCoord( fPos->GetUParameter(), fPos->GetVParameter() );
           break;
         }
@@ -2417,7 +2417,7 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet &          theElems,
           if ( !S.IsNull() && S.ShapeType() == TopAbs_EDGE )
             pcurve = BRep_Tool::CurveOnSurface( TopoDS::Edge( S ), face, f,l );
           if ( !pcurve.IsNull() ) {
-            double u = (( SMDS_EdgePosition* ) pos.get() )->GetUParameter();
+            double u = (( SMDS_EdgePosition* ) pos )->GetUParameter();
             uv = pcurve->Value( u ).XY();
           }
           break;
@@ -4020,7 +4020,7 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet &   theElements,
     while ( aItN->more() ) {
       const SMDS_MeshNode* pNode = aItN->next();
       const SMDS_EdgePosition* pEPos =
-        static_cast<const SMDS_EdgePosition*>( pNode->GetPosition().get() );
+        static_cast<const SMDS_EdgePosition*>( pNode->GetPosition() );
       double aT = pEPos->GetUParameter();
       aPrms.push_back( aT );
     }
@@ -4064,7 +4064,7 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet &   theElements,
         while ( aItN->more() ) {
           const SMDS_MeshNode* pNode = aItN->next();
           const SMDS_EdgePosition* pEPos =
-            static_cast<const SMDS_EdgePosition*>( pNode->GetPosition().get() );
+            static_cast<const SMDS_EdgePosition*>( pNode->GetPosition() );
           double aT = pEPos->GetUParameter();
           aPrms.push_back( aT );
         }
@@ -4192,7 +4192,7 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet &   theElements,
       const SMDS_MeshNode* pNode = aItN->next();
       if( pNode==aN1 || pNode==aN2 ) continue;
       const SMDS_EdgePosition* pEPos =
-        static_cast<const SMDS_EdgePosition*>( pNode->GetPosition().get() );
+        static_cast<const SMDS_EdgePosition*>( pNode->GetPosition() );
       double aT = pEPos->GetUParameter();
       aPrms.push_back( aT );
     }
@@ -4239,7 +4239,7 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet &   theElements,
         while ( aItN->more() ) {
           const SMDS_MeshNode* pNode = aItN->next();
           const SMDS_EdgePosition* pEPos =
-            static_cast<const SMDS_EdgePosition*>( pNode->GetPosition().get() );
+            static_cast<const SMDS_EdgePosition*>( pNode->GetPosition() );
           double aT = pEPos->GetUParameter();
           aPrms.push_back( aT );
         }
index 0ca91a4d34df1f06ae08723e1962fa872b99a56b..829f5e324e9109c561c6e29d26b2b4ea05c6b286 100644 (file)
@@ -343,7 +343,7 @@ gp_XY SMESH_MesherHelper::GetNodeUV(const TopoDS_Face&   F,
   {
     // node has position on face
     const SMDS_FacePosition* fpos =
-      static_cast<const SMDS_FacePosition*>(n->GetPosition().get());
+      static_cast<const SMDS_FacePosition*>(n->GetPosition());
     uv.SetCoord(fpos->GetUParameter(),fpos->GetVParameter());
     uvOK = CheckNodeUV( F, n, uv.ChangeCoord(), BRep_Tool::Tolerance( F ));
   }
@@ -353,7 +353,7 @@ gp_XY SMESH_MesherHelper::GetNodeUV(const TopoDS_Face&   F,
     // corresponding edge from face, get pcurve for this
     // edge and retrieve value from this pcurve
     const SMDS_EdgePosition* epos =
-      static_cast<const SMDS_EdgePosition*>(n->GetPosition().get());
+      static_cast<const SMDS_EdgePosition*>(n->GetPosition());
     int edgeID = Pos->GetShapeId();
     TopoDS_Edge E = TopoDS::Edge(GetMeshDS()->IndexToShape(edgeID));
     double f, l, u = epos->GetUParameter();
@@ -548,7 +548,7 @@ double SMESH_MesherHelper::GetNodeU(const TopoDS_Edge&   E,
   const SMDS_PositionPtr Pos = n->GetPosition();
   if(Pos->GetTypeOfPosition()==SMDS_TOP_EDGE) {
     const SMDS_EdgePosition* epos =
-      static_cast<const SMDS_EdgePosition*>(n->GetPosition().get());
+      static_cast<const SMDS_EdgePosition*>(n->GetPosition());
     param =  epos->GetUParameter();
   }
   else if(Pos->GetTypeOfPosition()==SMDS_TOP_VERTEX) {
@@ -1176,7 +1176,7 @@ bool SMESH_MesherHelper::LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap,
     if(IsMedium(node, SMDSAbs_Edge))
       continue;
     const SMDS_EdgePosition* pos =
-      dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
+      dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition() );
     if ( !pos ) {
       return false;
     }
@@ -1198,7 +1198,7 @@ bool SMESH_MesherHelper::LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap,
     if(IsMedium(node))
       continue;
     const SMDS_EdgePosition* pos =
-      dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
+      dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition() );
     if ( !pos ) {
       return false;
     }
index 834003e8c8ed3573d75bc785b139aa9e5be108ea..ae63f672e0d3dcd9f42fa36ead294a6064a119b9 100644 (file)
@@ -733,7 +733,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh*        theMesh,
         {
           const SMDS_MeshNode* node = smdsNode( nIt->next() );
           const SMDS_EdgePosition* epos =
-            static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+            static_cast<const SMDS_EdgePosition*>(node->GetPosition());
           double u = epos->GetUParameter();
           paramNodeMap.insert( make_pair( u, node ));
         }
@@ -850,7 +850,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh*        theMesh,
           p->myInitUV = project( node, projector );
         else {
           const SMDS_FacePosition* pos =
-            static_cast<const SMDS_FacePosition*>(node->GetPosition().get());
+            static_cast<const SMDS_FacePosition*>(node->GetPosition());
           p->myInitUV.SetCoord( pos->GetUParameter(), pos->GetVParameter() );
         }
         p->myInitXYZ.SetCoord( p->myInitUV.X(), p->myInitUV.Y(), 0 );
@@ -3208,7 +3208,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh*         theMesh,
       {
         const SMDS_MeshNode* node = smdsNode( nIt->next() );
         const SMDS_EdgePosition* epos =
-          static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+          static_cast<const SMDS_EdgePosition*>(node->GetPosition());
         double u = ( epos->GetUParameter() - f ) / ( l - f );
         (*pIt)->myInitXYZ.SetCoord( iCoord, isForward ? u : 1 - u );
       }
index 146df73d178df2878557d67edf523c87a3820ed0..f14bb5a73cccea0e0bd6e4fea6ed2f05d79165d2 100644 (file)
@@ -325,14 +325,14 @@ void SMESHDS_SubMesh::Clear()
 
 int SMESHDS_SubMesh::getSize()
 {
-  int a = sizeof(myElements);
-  int b = sizeof(myNodes);
+//  int a = sizeof(myElements);
+//  int b = sizeof(myNodes);
   int c = NbNodes();
   int d = NbElements();
   cerr << "SMESHDS_SubMesh::NbNodes " << c << endl;
   cerr << "SMESHDS_SubMesh::NbElements " << d << endl;
-  cerr << "SMESHDS_SubMesh::myNodes " << b << endl;
-  cerr << "SMESHDS_SubMesh::myElements " << a << endl;
+//  cerr << "SMESHDS_SubMesh::myNodes " << b << endl;
+//  cerr << "SMESHDS_SubMesh::myElements " << a << endl;
   return c+d;
 }
 
index d74457f357bea764bd28ba8c0f58ccf97726f381..a2258d6b4af3791cb03f9e77c2e344af236a9da0 100644 (file)
@@ -109,6 +109,7 @@ libSMESHEngine_la_CPPFLAGS = \
 libSMESHEngine_la_LDFLAGS  = \
        ../../idl/libSalomeIDLSMESH.la \
        ../SMESH/libSMESHimpl.la \
+       ../SMDS/libSMDS.la \
        ../Controls/libSMESHControls.la \
        $(KERNEL_LDFLAGS) \
        -lSalomeContainer \
index 9e041d5897b2fdc52962f5db306f5a6749d103d6..488accd76f7bed5e763e041a701c66d45ddc2ba1 100644 (file)
@@ -2983,7 +2983,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
                       const SMDS_PositionPtr pos = node->GetPosition();
                       if ( onFace ) { // on FACE
                         const SMDS_FacePosition* fPos =
-                          dynamic_cast<const SMDS_FacePosition*>( pos.get() );
+                          dynamic_cast<const SMDS_FacePosition*>( pos );
                         if ( fPos ) {
                           aUPos[ iNode ] = fPos->GetUParameter();
                           aVPos[ iNode ] = fPos->GetVParameter();
@@ -2994,7 +2994,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
                       }
                       else { // on EDGE
                         const SMDS_EdgePosition* ePos =
-                          dynamic_cast<const SMDS_EdgePosition*>( pos.get() );
+                          dynamic_cast<const SMDS_EdgePosition*>( pos );
                         if ( ePos ) {
                           aUPos[ iNode ] = ePos->GetUParameter();
                           iNode++;
@@ -3973,7 +3973,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
                 // not fixed bugs in SMDS_MeshInfo
                 if ( aPos->GetTypeOfPosition() == SMDS_TOP_FACE ) {
                   SMDS_FacePosition* fPos = const_cast<SMDS_FacePosition*>
-                    ( static_cast<const SMDS_FacePosition*>( aPos.get() ));
+                    ( static_cast<const SMDS_FacePosition*>( aPos ));
                   fPos->SetUParameter( aUPos[ iNode ]);
                   fPos->SetVParameter( aVPos[ iNode ]);
                 }
@@ -3982,7 +3982,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
                 // ASSERT( aPos->GetTypeOfPosition() == SMDS_TOP_EDGE );-- issue 20182
                 if ( aPos->GetTypeOfPosition() == SMDS_TOP_EDGE ) {
                   SMDS_EdgePosition* fPos = const_cast<SMDS_EdgePosition*>
-                    ( static_cast<const SMDS_EdgePosition*>( aPos.get() ));
+                    ( static_cast<const SMDS_EdgePosition*>( aPos ));
                   fPos->SetUParameter( aUPos[ iNode ]);
                 }
               }
index 6b6d8220b47cbcc80455afddaebb38e69e9cb689..3f5ccd71888174f824960b8d402d82f42f2159c5 100644 (file)
@@ -2949,15 +2949,15 @@ SMESH::NodePosition* SMESH_Mesh_i::GetNodePosition(CORBA::Long NodeID)
         aNodePosition->shapeType = GEOM::EDGE;
         aNodePosition->params.length(1);
         aNodePosition->params[0] =
-          static_cast<SMDS_EdgePosition*>( pos.get() )->GetUParameter();
+          static_cast<SMDS_EdgePosition*>( pos )->GetUParameter();
         break;
       case SMDS_TOP_FACE:
         aNodePosition->shapeType = GEOM::FACE;
         aNodePosition->params.length(2);
         aNodePosition->params[0] =
-          static_cast<SMDS_FacePosition*>( pos.get() )->GetUParameter();
+          static_cast<SMDS_FacePosition*>( pos )->GetUParameter();
         aNodePosition->params[1] =
-          static_cast<SMDS_FacePosition*>( pos.get() )->GetVParameter();
+          static_cast<SMDS_FacePosition*>( pos )->GetVParameter();
         break;
       case SMDS_TOP_VERTEX:
         aNodePosition->shapeType = GEOM::VERTEX;
index c677973be2bf2aca288bd974c04e7b18b00e2276..f34def73472a6283aace8030e2c18b82822804ea 100644 (file)
@@ -238,7 +238,7 @@ const vector<UVPtStruct>& StdMeshers_FaceSide::GetUVPtStruct(bool   isXConst,
         if ( myIgnoreMediumNodes && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Edge ))
           continue;
         const SMDS_EdgePosition* epos =
-          static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+          static_cast<const SMDS_EdgePosition*>(node->GetPosition());
         double u = epos->GetUParameter();
         // paramSize is signed so orientation is taken into account
         double normPar = prevNormPar + r * ( u - myFirst[i] ) / paramSize;
@@ -288,7 +288,7 @@ const vector<UVPtStruct>& StdMeshers_FaceSide::GetUVPtStruct(bool   isXConst,
         paramSize = myNormPar[ EdgeIndex ] - prevNormPar;
       }
       const SMDS_EdgePosition* epos =
-        dynamic_cast<const SMDS_EdgePosition*>(uvPt.node->GetPosition().get());
+        dynamic_cast<const SMDS_EdgePosition*>(uvPt.node->GetPosition());
       if ( epos ) {
         uvPt.param = epos->GetUParameter();
       }
index 42b5488ecda855a7827d137409381fd7629e361e..7e1c49a357259265b155ea5f0b39fd0c15571251 100644 (file)
@@ -161,7 +161,7 @@ inline bool isCloser(const int i, const int j, const int nbhoriz,
 static bool findIJ (const SMDS_MeshNode* node, const FaceQuadStruct * quad, int& I, int& J)
 {
   const SMDS_FacePosition* fpos =
-    static_cast<const SMDS_FacePosition*>(node->GetPosition().get());
+    static_cast<const SMDS_FacePosition*>(node->GetPosition());
   if ( ! fpos ) return false;
   gp_Pnt2d uv( fpos->GetUParameter(), fpos->GetVParameter() );
 
@@ -206,9 +206,9 @@ static bool findIJ (const SMDS_MeshNode* node, const FaceQuadStruct * quad, int&
  * -0.  - shape and face mesh verification
  * -1.  - identify faces and vertices of the "cube"
  * -2.  - Algorithm from:
- * "Application de l'interpolation transfinie à la création de maillages
+ * "Application de l'interpolation transfinie a la creation de maillages
  *  C0 ou G1 continus sur des triangles, quadrangles, tetraedres, pentaedres
- *  et hexaedres déformés."
+ *  et hexaedres deformes."
  * Alain PERONNET - 8 janvier 1999
  */
 //=============================================================================
@@ -407,6 +407,9 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh &         aMesh,
 
   int i1, j1, nbxyz = nbx * nby * nbz;
   Point3DStruct *np = new Point3DStruct[nbxyz];
+  
+  aMesh.GetMeshDS()->incrementNodesCapacity(nbx * nby * nbz);
+  aMesh.GetMeshDS()->incrementCellsCapacity((nbx-1) * (nby-1) * (nbz-1));
 
   // 1.9 - store node indexes of faces
 
index ca1ef9e11f6bae347de3ed8a7b4339c47a7dee02..f4ef0198d114575598259d6a3759533eec7cac06 100644 (file)
@@ -511,7 +511,7 @@ static bool fixCommonVertexUV (R2 &                 theUV,
         if ( theCreateQuadratic && SMESH_MesherHelper::IsMedium( node, SMDSAbs_Edge ))
           continue;
         const SMDS_EdgePosition* epos =
-          static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+          static_cast<const SMDS_EdgePosition*>(node->GetPosition());
         double u = epos->GetUParameter();
         if ( u < umin )
           umin = u;
index 7ae2e3a5400b2a8fcf0f2219d321d6ada5116e4e..a12a3f0880ade3ade835e202b4a912cac40ae8b5 100644 (file)
@@ -234,7 +234,7 @@ void StdMeshers_Penta_3D::MakeNodes()
       //
       if ( SMESH_Block::IsEdgeID (aSID)) {
         const SMDS_EdgePosition* epos =
-          static_cast<const SMDS_EdgePosition*>(aNode->GetPosition().get());
+          static_cast<const SMDS_EdgePosition*>(aNode->GetPosition());
         myBlock.ComputeParameters( epos->GetUParameter(), aS, aCoords );
       }
       else {
@@ -1470,7 +1470,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
     if(myTool->IsMedium(node))
       continue;
     const SMDS_EdgePosition* pos =
-      dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
+      dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition() );
     if ( !pos ) {
       return false;
     }
@@ -1493,7 +1493,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
     if(myTool->IsMedium(node))
       continue;
     const SMDS_EdgePosition* pos =
-      dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
+      dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition() );
     if ( !pos ) {
       return false;
     }
index a4d4fdfbc5bbdc71f516d1847ce5fc063323d070..a964b99c9177c3088272860037139b0c5291f149 100644 (file)
@@ -1750,7 +1750,7 @@ FindMatchingNodesOnFaces( const TopoDS_Face&     face1,
       while ( nIt->more() ) {
         const SMDS_MeshNode* node = nIt->next();
         const SMDS_EdgePosition* pos =
-          static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+          static_cast<const SMDS_EdgePosition*>(node->GetPosition());
         pos2nodes.insert( make_pair( pos->GetUParameter(), node ));
       }
       if ( pos2nodes.size() != edgeSM->NbNodes() )
index a433e2dc3ab469e2a8977c265b4650c0b9573fd5..63b843d32971aba0d31736e917c69dfcbacc01e5 100644 (file)
@@ -339,7 +339,7 @@ namespace {
           RETURN_BAD_RESULT("Bad node position type: node " << node->GetID() <<
                             " pos type " << node->GetPosition()->GetTypeOfPosition());
         const SMDS_EdgePosition* pos =
-          static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+          static_cast<const SMDS_EdgePosition*>(node->GetPosition());
         u2nodes.insert( make_pair( pos->GetUParameter(), node ));
         seamNodes.insert( node );
       }
@@ -644,7 +644,7 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape&
       }
       case  SMDS_TOP_EDGE:   {
         const SMDS_EdgePosition* pos =
-          static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+          static_cast<const SMDS_EdgePosition*>(node->GetPosition());
         pos2nodes.insert( make_pair( pos->GetUParameter(), node ));
         break;
       }