From: eap Date: Tue, 10 Mar 2009 16:35:12 +0000 (+0000) Subject: 0020200: EDF SMESH 983: changing algo of a mesh and switching back to original algo... X-Git-Tag: V4_1_5rc1~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=44b3e0b7658811abab99d7329fa7dfe21f53bd85;p=modules%2Fsmesh.git 0020200: EDF SMESH 983: changing algo of a mesh and switching back to original algo leads to different result than original sort nodes and elements by ID --- diff --git a/src/SMESHDS/SMESHDS_SubMesh.cxx b/src/SMESHDS/SMESHDS_SubMesh.cxx index 127c5c2d9..360d1161f 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.cxx +++ b/src/SMESHDS/SMESHDS_SubMesh.cxx @@ -87,11 +87,7 @@ int SMESHDS_SubMesh::NbElements() const return myElements.size(); int nbElems = 0; -#ifndef WNT - set::iterator it = mySubMeshes.begin(); -#else set::const_iterator it = mySubMeshes.begin(); -#endif for ( ; it != mySubMeshes.end(); it++ ) nbElems += (*it)->NbElements(); @@ -109,11 +105,7 @@ int SMESHDS_SubMesh::NbNodes() const return myNodes.size(); int nbElems = 0; -#ifndef WNT - set::iterator it = mySubMeshes.begin(); -#else set::const_iterator it = mySubMeshes.begin(); -#endif for ( ; it != mySubMeshes.end(); it++ ) nbElems += (*it)->NbNodes(); @@ -124,26 +116,13 @@ int SMESHDS_SubMesh::NbNodes() const // class MySetIterator // ===================== -template class MySetIterator:public SMDS_Iterator +template class MySetIterator: public SMDS_SetIterator { - typedef const set TSet; - typename TSet::const_iterator myIt; - TSet& mySet; - + typedef SMDS_SetIterator TFather; public: - MySetIterator(const set& s):mySet(s), myIt(s.begin()) - { - } - - bool more() - { - return myIt!=mySet.end(); - } - const T* next() + MySetIterator(const TSet& s):TFather(s.begin(),s.end()) { - const T* t=*myIt; - myIt++; - return t; } }; @@ -222,7 +201,7 @@ SMDS_ElemIteratorPtr SMESHDS_SubMesh::GetElements() const if ( IsComplexSubmesh() ) return SMDS_ElemIteratorPtr( new MyElemIterator( mySubMeshes )); - return SMDS_ElemIteratorPtr(new MySetIterator(myElements)); + return SMDS_ElemIteratorPtr(new MySetIterator(myElements)); } //======================================================================= @@ -235,7 +214,7 @@ SMDS_NodeIteratorPtr SMESHDS_SubMesh::GetNodes() const if ( IsComplexSubmesh() ) return SMDS_NodeIteratorPtr( new MyNodeIterator( mySubMeshes )); - return SMDS_NodeIteratorPtr(new MySetIterator(myNodes)); + return SMDS_NodeIteratorPtr(new MySetIterator(myNodes)); } //======================================================================= diff --git a/src/SMESHDS/SMESHDS_SubMesh.hxx b/src/SMESHDS/SMESHDS_SubMesh.hxx index 7b2eaa416..f9ce541fa 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.hxx +++ b/src/SMESHDS/SMESHDS_SubMesh.hxx @@ -65,9 +65,14 @@ class SMESHDS_EXPORT SMESHDS_SubMesh void Clear(); private: - //const SMDS_Mesh * myMesh; - std::set myElements; - std::set myNodes; - std::set mySubMeshes; + struct TIDCompare { // to have nodes and elements sorted by ID + bool operator () (const SMDS_MeshElement* e1, const SMDS_MeshElement* e2) const + { return e1->GetID() < e2->GetID(); } + }; + typedef std::set TElemSet; + typedef std::set TNodeSet; + TElemSet myElements; + TNodeSet myNodes; + std::set mySubMeshes; }; #endif