+// =====================
+// class MySetIterator
+// =====================
+
+template<class ELEM, typename TSET> class MySetIterator:
+ public SMDS_SetIterator<ELEM, typename TSET::const_iterator >
+{
+ typedef SMDS_SetIterator<ELEM, typename TSET::const_iterator > TFather;
+ public:
+ MySetIterator(const TSET& s):TFather(s.begin(),s.end())
+ {
+ }
+};
+
+// =====================
+// class MyIterator
+// =====================
+
+template<typename VALUE> class MyIterator : public SMDS_Iterator<VALUE>
+{
+ public:
+ MyIterator (const set<const SMESHDS_SubMesh*>& theSubMeshes)
+ : mySubIt( theSubMeshes.begin() ), mySubEnd( theSubMeshes.end() ), myMore(false)
+ {}
+ bool more()
+ {
+ while (( !myElemIt.get() || !myElemIt->more() ) && mySubIt != mySubEnd)
+ {
+ myElemIt = getElements(*mySubIt);
+ mySubIt++;
+ }
+ myMore = myElemIt.get() && myElemIt->more();
+ return myMore;
+ }
+ VALUE next()
+ {
+ VALUE elem = 0;
+ if ( myMore )
+ elem = myElemIt->next();
+ return elem;
+ }
+ protected:
+ virtual boost::shared_ptr< SMDS_Iterator<VALUE> >
+ getElements(const SMESHDS_SubMesh*) const = 0;
+
+ private:
+ bool myMore;
+ set<const SMESHDS_SubMesh*>::const_iterator mySubIt, mySubEnd;
+ boost::shared_ptr< SMDS_Iterator<VALUE> > myElemIt;
+};
+
+// =====================
+// class MyElemIterator
+// =====================
+
+class MyElemIterator: public MyIterator<const SMDS_MeshElement*>
+{
+ public:
+ MyElemIterator (const set<const SMESHDS_SubMesh*>& theSubMeshes)
+ :MyIterator<const SMDS_MeshElement*>( theSubMeshes ) {}
+ SMDS_ElemIteratorPtr getElements(const SMESHDS_SubMesh* theSubMesh) const
+ { return theSubMesh->GetElements(); }
+};
+
+// =====================
+// class MyNodeIterator
+// =====================
+
+class MyNodeIterator: public MyIterator<const SMDS_MeshNode*>
+{
+ public:
+ MyNodeIterator (const set<const SMESHDS_SubMesh*>& theSubMeshes)
+ :MyIterator<const SMDS_MeshNode*>( theSubMeshes ) {}
+ SMDS_NodeIteratorPtr getElements(const SMESHDS_SubMesh* theSubMesh) const
+ { return theSubMesh->GetNodes(); }
+};
+