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();
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();
// 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())
- {
- }
-
- 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;
}
};
if ( IsComplexSubmesh() )
return SMDS_ElemIteratorPtr( new MyElemIterator( mySubMeshes ));
- return SMDS_ElemIteratorPtr(new MySetIterator<SMDS_MeshElement>(myElements));
+ return SMDS_ElemIteratorPtr(new MySetIterator<TElemSet>(myElements));
}
//=======================================================================
if ( IsComplexSubmesh() )
return SMDS_NodeIteratorPtr( new MyNodeIterator( mySubMeshes ));
- return SMDS_NodeIteratorPtr(new MySetIterator<SMDS_MeshNode>(myNodes));
+ return SMDS_NodeIteratorPtr(new MySetIterator<TNodeSet>(myNodes));
}
//=======================================================================
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