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
This commit is contained in:
eap 2009-03-10 16:32:02 +00:00
parent 2534543b1e
commit 59b7f3d704
2 changed files with 15 additions and 31 deletions

View File

@ -87,11 +87,7 @@ int SMESHDS_SubMesh::NbElements() const
return myElements.size();
int nbElems = 0;
#ifndef WNT
set<const SMESHDS_SubMesh*>::iterator it = mySubMeshes.begin();
#else
set<const SMESHDS_SubMesh*>::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<const SMESHDS_SubMesh*>::iterator it = mySubMeshes.begin();
#else
set<const SMESHDS_SubMesh*>::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<typename T> class MySetIterator:public SMDS_Iterator<const T*>
template<typename TSet> class MySetIterator: public SMDS_SetIterator<typename TSet::key_type,
typename TSet::const_iterator >
{
typedef const set<const T*> TSet;
typename TSet::const_iterator myIt;
TSet& mySet;
typedef SMDS_SetIterator<typename TSet::key_type, typename TSet::const_iterator > TFather;
public:
MySetIterator(const set<const T*>& 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<SMDS_MeshElement>(myElements));
return SMDS_ElemIteratorPtr(new MySetIterator<TElemSet>(myElements));
}
//=======================================================================
@ -235,7 +214,7 @@ SMDS_NodeIteratorPtr SMESHDS_SubMesh::GetNodes() const
if ( IsComplexSubmesh() )
return SMDS_NodeIteratorPtr( new MyNodeIterator( mySubMeshes ));
return SMDS_NodeIteratorPtr(new MySetIterator<SMDS_MeshNode>(myNodes));
return SMDS_NodeIteratorPtr(new MySetIterator<TNodeSet>(myNodes));
}
//=======================================================================

View File

@ -65,9 +65,14 @@ class SMESHDS_EXPORT SMESHDS_SubMesh
void Clear();
private:
//const SMDS_Mesh * myMesh;
std::set<const SMDS_MeshElement*> myElements;
std::set<const SMDS_MeshNode*> myNodes;
std::set<const SMESHDS_SubMesh*> 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<const SMDS_MeshElement*, TIDCompare > TElemSet;
typedef std::set<const SMDS_MeshNode* , TIDCompare> TNodeSet;
TElemSet myElements;
TNodeSet myNodes;
std::set<const SMESHDS_SubMesh*> mySubMeshes;
};
#endif