Salome HOME
SMESHDS_Mesh structures
authorprascle <prascle>
Wed, 6 Jan 2010 19:01:21 +0000 (19:01 +0000)
committerprascle <prascle>
Wed, 6 Jan 2010 19:01:21 +0000 (19:01 +0000)
src/SMDS/Notes
src/SMDS/SMDS_Mesh.cxx
src/SMDS/SMDS_MeshElement.cxx
src/SMDS/SMDS_MeshElement.hxx
src/SMESHDS/SMESHDS_Script.cxx
src/SMESHDS/SMESHDS_SubMesh.cxx
src/SMESHDS/SMESHDS_SubMesh.hxx

index a0e3eef8c4ac24f46e652f92212b2d3f979db3d1..c0bcbd15c6f43cf7b7fa722c6efd1542de0b8886 100644 (file)
@@ -147,3 +147,31 @@ in use bytes     =  418378000 : 418M
 max mmap regions =         58
 max mmap bytes   =  183640064
 
+sizeof(SMDS_MeshElement) 16
+sizeof(SMDS_MeshNode) 24
+sizeof(SMDS_MeshCell) 24
+sizeof(SMDS_VolumeVtkNodes) 24
+sizeof(SMDS_Position) 16
+sizeof(SMDS_SpacePosition) 16
+
+impact d'un int en plus dans SMDS_MeshElement --> 426 - 33 = 393M
+---------------------------------------------
+
+sizeof(SMDS_MeshElement) 24
+sizeof(SMDS_MeshNode) 32       --> on retrouve bien les 8M
+sizeof(SMDS_MeshCell) 24
+sizeof(SMDS_VolumeVtkNodes) 24
+sizeof(SMDS_Position) 16
+sizeof(SMDS_SpacePosition) 16
+
+Total (incl. mmap):
+system bytes     =   43192320
+in use bytes     =   32681088 : 33M
+max mmap regions =         41
+max mmap bytes   =   16371712
+----
+Total (incl. mmap):
+system bytes     =  429334528
+in use bytes     =  426424576 : 426M
+max mmap regions =         59
+max mmap bytes   =  184692736
index cd0196c3cd954c6a12859e90965186fd8c4eaf13..d147b6672c0ba52d7dfa6e4ae09faa93c875fa71 100644 (file)
@@ -36,6 +36,7 @@
 #include "SMDS_QuadraticEdge.hxx"
 #include "SMDS_QuadraticFaceOfNodes.hxx"
 #include "SMDS_QuadraticVolumeOfNodes.hxx"
+#include "SMDS_SpacePosition.hxx"
 
 #include <vtkUnstructuredGrid.h>
 
@@ -119,6 +120,12 @@ SMDS_Mesh::SMDS_Mesh()
 {
   myMeshId = _meshList.size();         // --- index of the mesh to push back in the vector
   MESSAGE("myMeshId=" << myMeshId);
+  MESSAGE("sizeof(SMDS_MeshElement) " << sizeof(SMDS_MeshElement) );
+  MESSAGE("sizeof(SMDS_MeshNode) " << sizeof(SMDS_MeshNode) );
+  MESSAGE("sizeof(SMDS_MeshCell) " << sizeof(SMDS_MeshCell) );
+  MESSAGE("sizeof(SMDS_VolumeVtkNodes) " << sizeof(SMDS_VolumeVtkNodes) );
+  MESSAGE("sizeof(SMDS_Position) " << sizeof(SMDS_Position) );
+  MESSAGE("sizeof(SMDS_SpacePosition) " << sizeof(SMDS_SpacePosition) );
   myNodeIDFactory->SetMesh(this);
   myElementIDFactory->SetMesh(this);
   _meshList.push_back(this);
index fdbeffd86f0a1c19959efe7003c119ec48407b26..f309847d171df8dde2cac977276c1b38dabf2809 100644 (file)
@@ -36,12 +36,12 @@ using namespace std;
 
 int SMDS_MeshCell::nbCells = 0;
 
-SMDS_MeshElement::SMDS_MeshElement(int ID):myID(ID), myMeshId(-1), myShapeId(-1)
+SMDS_MeshElement::SMDS_MeshElement(int ID):myID(ID), myMeshId(-1), myShapeId(-1), myIdInShape(-1)
 {
 }
 
-SMDS_MeshElement::SMDS_MeshElement(int id, UShortType meshId, ShortType shapeId):
-  myID(id), myMeshId(meshId), myShapeId(shapeId)
+SMDS_MeshElement::SMDS_MeshElement(int id, ShortType meshId, ShortType shapeId):
+  myID(id), myMeshId(meshId), myShapeId(shapeId), myIdInShape(-1)
 {
 }
 
@@ -246,7 +246,7 @@ int SMDS_MeshElement::GetNodeIndex( const SMDS_MeshNode* node ) const
   return -1;
 }
 
-SMDS_MeshCell::SMDS_MeshCell()
+SMDS_MeshCell::SMDS_MeshCell() : SMDS_MeshElement(-1)
 {
   nbCells++;
   myVtkID = -1;
@@ -255,4 +255,4 @@ SMDS_MeshCell::SMDS_MeshCell()
 SMDS_MeshCell::~SMDS_MeshCell()
 {
   nbCells--;
-}
\ No newline at end of file
+}
index 94e92223967cb720b2d691f11dfc7c090e37a157..30950ad8b54362f8491afc4335d40784fff8c632 100644 (file)
@@ -36,7 +36,7 @@
 #include <vector>
 #include <iostream>
 
-typedef unsigned short UShortType;
+//typedef unsigned short UShortType;
 typedef short ShortType;
 
 class SMDS_MeshNode;
@@ -122,18 +122,28 @@ public:
   int GetNodeIndex( const SMDS_MeshNode* node ) const;
 
   inline int getId() const {return myID; };
-  inline UShortType getMeshId() {return myMeshId; };
-  inline ShortType getshapeId() {return myShapeId; };
-  inline void setShapeId(UShortType shapeId) {myShapeId = shapeId; };
+  inline ShortType getMeshId() const {return myMeshId; };
+  inline ShortType getshapeId() const {return myShapeId; };
+  inline void setShapeId(ShortType shapeId) {myShapeId = shapeId; };
+  inline int getIdInShape() const { return myIdInShape; };
+  inline void setIdInShape(int id) { myIdInShape = id; };
 
 protected:
   SMDS_MeshElement(int ID=-1);
-  SMDS_MeshElement(int id, UShortType meshId, ShortType shapeId=-1);
+  SMDS_MeshElement(int id, ShortType meshId, ShortType shapeId=-1);
   virtual void Print(std::ostream & OS) const;
 
-  int myID;        // --- element index 
+  //! Element index in vector SMDS_Mesh::myNodes or SMDS_Mesh::myCells
+  int myID;
+
+  //! SMDS_Mesh identification in SMESH
   ShortType myMeshId;
+
+  //! SubShape and SubMesh identification in SMESHDS (not in use?)
   ShortType myShapeId;
+
+  //! Element index in SMESHDS_SubMesh vector
+  int myIdInShape;
 };
 
 // ============================================================
index 3d379c4b0dda621eb7d273fec1c112627e7958b5..a377b4e9e5cad3d4630f9d5fd237343e2fcf41e5 100644 (file)
@@ -26,6 +26,7 @@
 //  $Header: 
 //
 #include "SMESHDS_Script.hxx"
+#include <iostream>
 
 using namespace std;
 
@@ -35,7 +36,9 @@ using namespace std;
 //=======================================================================
 SMESHDS_Script::SMESHDS_Script(bool theIsEmbeddedMode):
   myIsEmbeddedMode(theIsEmbeddedMode)
-{}
+{
+  cerr << "=========================== myIsEmbeddedMode " << myIsEmbeddedMode << endl;
+}
 
 //=======================================================================
 //function : Destructor
index f14bb5a73cccea0e0bd6e4fea6ed2f05d79165d2..d8c4d1eaee0d2c88bb02e6f8482bd96819250fe5 100644 (file)
 #include "utilities.h"
 #include "SMDS_SetIterator.hxx"
 #include <iostream>
+#include <cassert>
 
 using namespace std;
 
+SMESHDS_SubMesh::SMESHDS_SubMesh()
+{
+  myElements.clear();
+  myNodes.clear();
+  myUnusedIdNodes = 0;
+  myUnusedIdElements = 0;
+}
+
 //=======================================================================
 //function : AddElement
 //purpose  : 
@@ -40,7 +49,13 @@ using namespace std;
 void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
 {
   if ( !IsComplexSubmesh() )
-    myElements.insert(ME);
+    {
+      int idInSubShape = ME->getIdInShape();
+      assert(idInSubShape == -1);
+      SMDS_MeshElement* elem = (SMDS_MeshElement*)(ME);
+      elem->setIdInShape(myElements.size());
+      myElements.push_back(ME);
+    }
 }
 
 //=======================================================================
@@ -49,18 +64,27 @@ void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
 //=======================================================================
 bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME, bool isElemDeleted)
 {
-  if ( !IsComplexSubmesh() && NbElements() ) {
+//  if ( !IsComplexSubmesh() && NbElements() ) {
 
     if (!isElemDeleted) // alive element has valid ID and can be found
-      return myElements.erase(ME);
-
-    TElemSet::iterator e = myElements.begin(), eEnd = myElements.end();
-    for ( ; e != eEnd; ++e )
-      if ( ME == *e ) {
-        myElements.erase( e );
+      {
+        int idInSubShape = ME->getIdInShape();
+        assert(idInSubShape >= 0);
+        assert(idInSubShape < myElements.size());
+        myElements[idInSubShape] = 0; // this vector entry is no more used
+        myUnusedIdElements++;
         return true;
       }
-  }
+
+    
+// --- strange ?
+//     TElemSet::iterator e = myElements.begin(), eEnd = myElements.end();
+//     for ( ; e != eEnd; ++e )
+//       if ( ME == *e ) {
+//         myElements.erase( e );
+//         return true;
+//       }
+//   }
   
   return false;
 }
@@ -72,7 +96,13 @@ bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME, bool isElemDele
 void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
 {
   if ( !IsComplexSubmesh() )
-    myNodes.insert(N);
+    {
+      int idInSubShape = N->getIdInShape();
+      assert(idInSubShape == -1);
+      SMDS_MeshNode* node = (SMDS_MeshNode*)(N);
+      node->setIdInShape(myNodes.size());
+      myNodes.push_back(N);
+    }
 }
 
 //=======================================================================
@@ -82,18 +112,26 @@ void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
 
 bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N, bool isNodeDeleted)
 {
-  if ( !IsComplexSubmesh() && NbNodes() ) {
+//   if ( !IsComplexSubmesh() && NbNodes() ) {
 
     if (!isNodeDeleted) // alive node has valid ID and can be found
-      return myNodes.erase(N);
-
-    TElemSet::iterator e = myNodes.begin(), eEnd = myNodes.end();
-    for ( ; e != eEnd; ++e )
-      if ( N == *e ) {
-        myNodes.erase( e );
+      {
+        int idInSubShape = N->getIdInShape();
+        assert(idInSubShape >= 0);
+        assert(idInSubShape < myNodes.size());
+        myNodes[idInSubShape] = 0; // this vector entry is no more used
+        myUnusedIdNodes++;
         return true;
       }
-  }
+
+// --- strange ?
+//     TElemSet::iterator e = myNodes.begin(), eEnd = myNodes.end();
+//     for ( ; e != eEnd; ++e )
+//       if ( N == *e ) {
+//         myNodes.erase( e );
+//         return true;
+//       }
+//   }
 
   return false;
 }
@@ -105,7 +143,7 @@ bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N, bool isNodeDeleted)
 int SMESHDS_SubMesh::NbElements() const
 {
   if ( !IsComplexSubmesh() )
-    return myElements.size();
+    return myElements.size() - myUnusedIdElements;
 
   int nbElems = 0;
   set<const SMESHDS_SubMesh*>::const_iterator it = mySubMeshes.begin();
@@ -123,7 +161,7 @@ int SMESHDS_SubMesh::NbElements() const
 int SMESHDS_SubMesh::NbNodes() const
 {
  if ( !IsComplexSubmesh() )
-   return myNodes.size()
+   return myNodes.size() - myUnusedIdNodes;
 
   int nbElems = 0;
   set<const SMESHDS_SubMesh*>::const_iterator it = mySubMeshes.begin();
@@ -258,9 +296,18 @@ bool SMESHDS_SubMesh::Contains(const SMDS_MeshElement * ME) const
   }
 
   if ( ME->GetType() == SMDSAbs_Node )
-    return ( myNodes.find( ME ) != myNodes.end() );
-
-  return ( myElements.find( ME ) != myElements.end() );
+    {
+      int idInShape = ME->getIdInShape();
+      if ((idInShape >= 0) && (idInShape < myNodes.size()))
+       if (myNodes[idInShape] == ME) return true;
+    }
+  else
+    {
+      int idInShape = ME->getIdInShape();
+      if ((idInShape >= 0) && (idInShape < myElements.size()))
+       if (myElements[idInShape] == ME) return true;
+    }
+    return false;
 }
 
 //=======================================================================
@@ -325,14 +372,10 @@ void SMESHDS_SubMesh::Clear()
 
 int SMESHDS_SubMesh::getSize()
 {
-//  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;
   return c+d;
 }
 
index df5c3261902614d390f8750cf07786a3c5204116..90ed79e203e8ece8ed5503f052b9df87480d33ea 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "SMDS_Mesh.hxx"
 #include <set>
+#include <vector>
 
 class SMESHDS_SubMesh;
 typedef SMDS_Iterator<const SMESHDS_SubMesh*> SMESHDS_SubMeshIterator;
@@ -38,6 +39,7 @@ typedef boost::shared_ptr< SMESHDS_SubMeshIterator > SMESHDS_SubMeshIteratorPtr;
 class SMESHDS_EXPORT SMESHDS_SubMesh
 {
  public:
+  SMESHDS_SubMesh();
 
   bool IsComplexSubmesh() const { return !mySubMeshes.empty(); }
 
@@ -67,8 +69,13 @@ class SMESHDS_EXPORT SMESHDS_SubMesh
 
  private:
 
-  typedef std::set<const SMDS_MeshElement*, TIDCompare > TElemSet;
-  TElemSet myElements, myNodes;
+  typedef std::vector<const SMDS_MeshElement*> TElemSet;
+
+  TElemSet myElements;
+  TElemSet myNodes;
+
+  int myUnusedIdNodes;
+  int myUnusedIdElements;
 
   std::set<const SMESHDS_SubMesh*> mySubMeshes;
 };