From 44b3e0b7658811abab99d7329fa7dfe21f53bd85 Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 10 Mar 2009 16:35:12 +0000 Subject: [PATCH] 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 --- src/SMESHDS/SMESHDS_SubMesh.cxx | 33 ++++++--------------------------- src/SMESHDS/SMESHDS_SubMesh.hxx | 13 +++++++++---- 2 files changed, 15 insertions(+), 31 deletions(-) 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,27 +116,14 @@ 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()) + MySetIterator(const TSet& s):TFather(s.begin(),s.end()) { } - - bool more() - { - return myIt!=mySet.end(); - } - const T* next() - { - 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