+
+//=======================================================================
+//function : GetSubMeshIterator
+//purpose :
+//=======================================================================
+
+SMESHDS_SubMeshIteratorPtr SMESHDS_SubMesh::GetSubMeshIterator() const
+{
+ typedef SMDS_SetIterator< const SMESHDS_SubMesh*, TSubMeshSet::const_iterator > TIterator;
+ return boost::make_shared< TIterator >( mySubMeshes.begin(), mySubMeshes.end());
+}
+
+//=======================================================================
+//function : Clear
+//purpose : remove the contents
+//=======================================================================
+
+void SMESHDS_SubMesh::Clear()
+{
+ if ( myParent && myParent->NbNodes() > 0 )
+ {
+ if ( myNbElements > 0 )
+ for ( SMDS_ElemIteratorPtr it = GetElements(); it->more(); )
+ {
+ const SMDS_MeshElement * elem = it->next();
+ elem->setShapeID( 0 );
+ }
+ if ( myNbNodes > 0 )
+ for ( SMDS_NodeIteratorPtr it = GetNodes(); it->more(); )
+ {
+ const SMDS_MeshNode * elem = it->next();
+ elem->setShapeID( 0 );
+ }
+ }
+
+ myNbElements = 0;
+ myNbNodes = 0;
+ my1stElemNode[0] = my1stElemNode[1] = 0;
+
+ if ( NbSubMeshes() > 0 )
+ {
+ SMESHDS_SubMeshIteratorPtr sub = GetSubMeshIterator();
+ while ( sub->more() ) {
+ if ( SMESHDS_SubMesh* sm = (SMESHDS_SubMesh*) sub->next())
+ sm->Clear();
+ }
+ }
+}
+
+//=======================================================================
+//function : getElements
+//purpose : Return iterator on all elements and nodes during compacting
+//=======================================================================
+
+SMDS_ElemIteratorPtr SMESHDS_SubMesh::getElements()
+{
+ if ( IsComplexSubmesh() ) // return nothing
+ boost::make_shared< EArrayIterator >( & my1stElemNode[0], & my1stElemNode[0] );
+
+ typedef std::vector< SMDS_ElemIteratorPtr > TIterVec;
+ TIterVec iterVec(2);
+ iterVec[0] = GetElements();
+ iterVec[1].reset( new _MyElemIteratorFromNodeIterator( GetNodes() ));
+
+ return boost::make_shared< SMDS_IteratorOnIterators< PElem, TIterVec > >( iterVec );
+}
+
+//=======================================================================
+//function : tmpClear
+//purpose : clean up after compacting
+//=======================================================================
+
+void SMESHDS_SubMesh::tmpClear()
+{
+ my1stElemNode[0] = my1stElemNode[1] = 0;
+}
+
+//=======================================================================
+//function : add
+//purpose : update my1stElemNode
+//=======================================================================
+
+void SMESHDS_SubMesh::add( const SMDS_MeshElement* elem )
+{
+ const SMDS_MeshElement* & oldElem = my1stElemNode[ ind1st( elem->GetType() )];
+ if ( !oldElem || oldElem->GetID() > elem->GetID() )
+ oldElem = elem;
+}