From 7724b590e3c4ad76edbac5e36395234b6c1c57d9 Mon Sep 17 00:00:00 2001 From: prascle Date: Wed, 6 Jan 2010 19:01:21 +0000 Subject: [PATCH] SMESHDS_Mesh structures --- src/SMDS/Notes | 28 ++++++++++ src/SMDS/SMDS_Mesh.cxx | 7 +++ src/SMDS/SMDS_MeshElement.cxx | 10 ++-- src/SMDS/SMDS_MeshElement.hxx | 22 ++++++-- src/SMESHDS/SMESHDS_Script.cxx | 5 +- src/SMESHDS/SMESHDS_SubMesh.cxx | 97 ++++++++++++++++++++++++--------- src/SMESHDS/SMESHDS_SubMesh.hxx | 11 +++- 7 files changed, 139 insertions(+), 41 deletions(-) diff --git a/src/SMDS/Notes b/src/SMDS/Notes index a0e3eef8c..c0bcbd15c 100644 --- a/src/SMDS/Notes +++ b/src/SMDS/Notes @@ -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 diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index cd0196c3c..d147b6672 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -36,6 +36,7 @@ #include "SMDS_QuadraticEdge.hxx" #include "SMDS_QuadraticFaceOfNodes.hxx" #include "SMDS_QuadraticVolumeOfNodes.hxx" +#include "SMDS_SpacePosition.hxx" #include @@ -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); diff --git a/src/SMDS/SMDS_MeshElement.cxx b/src/SMDS/SMDS_MeshElement.cxx index fdbeffd86..f309847d1 100644 --- a/src/SMDS/SMDS_MeshElement.cxx +++ b/src/SMDS/SMDS_MeshElement.cxx @@ -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 +} diff --git a/src/SMDS/SMDS_MeshElement.hxx b/src/SMDS/SMDS_MeshElement.hxx index 94e922239..30950ad8b 100644 --- a/src/SMDS/SMDS_MeshElement.hxx +++ b/src/SMDS/SMDS_MeshElement.hxx @@ -36,7 +36,7 @@ #include #include -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; }; // ============================================================ diff --git a/src/SMESHDS/SMESHDS_Script.cxx b/src/SMESHDS/SMESHDS_Script.cxx index 3d379c4b0..a377b4e9e 100644 --- a/src/SMESHDS/SMESHDS_Script.cxx +++ b/src/SMESHDS/SMESHDS_Script.cxx @@ -26,6 +26,7 @@ // $Header: // #include "SMESHDS_Script.hxx" +#include using namespace std; @@ -35,7 +36,9 @@ using namespace std; //======================================================================= SMESHDS_Script::SMESHDS_Script(bool theIsEmbeddedMode): myIsEmbeddedMode(theIsEmbeddedMode) -{} +{ + cerr << "=========================== myIsEmbeddedMode " << myIsEmbeddedMode << endl; +} //======================================================================= //function : Destructor diff --git a/src/SMESHDS/SMESHDS_SubMesh.cxx b/src/SMESHDS/SMESHDS_SubMesh.cxx index f14bb5a73..d8c4d1eae 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.cxx +++ b/src/SMESHDS/SMESHDS_SubMesh.cxx @@ -30,9 +30,18 @@ #include "utilities.h" #include "SMDS_SetIterator.hxx" #include +#include 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_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_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; } diff --git a/src/SMESHDS/SMESHDS_SubMesh.hxx b/src/SMESHDS/SMESHDS_SubMesh.hxx index df5c32619..90ed79e20 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.hxx +++ b/src/SMESHDS/SMESHDS_SubMesh.hxx @@ -30,6 +30,7 @@ #include "SMDS_Mesh.hxx" #include +#include class SMESHDS_SubMesh; typedef SMDS_Iterator 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 TElemSet; - TElemSet myElements, myNodes; + typedef std::vector TElemSet; + + TElemSet myElements; + TElemSet myNodes; + + int myUnusedIdNodes; + int myUnusedIdElements; std::set mySubMeshes; };