+ if ( IsComplexSubmesh() )
+ return SMDS_NodeIteratorPtr( new MyNodeIterator( mySubMeshes ));
+
+ PNode const * node1st =
+ reinterpret_cast< PNode const* >( & my1stElemNode[ ind1st( SMDSAbs_Node )] );
+ if ( myNbNodes < 2 )
+ {
+ return boost::make_shared< NArrayIterator >( node1st, node1st + myNbNodes );
+ }
+
+ return myParent->shapeNodesIterator( myIndex, myNbNodes, *node1st );
+}
+
+//=======================================================================
+//function : Contains
+//purpose : check if elem or node is in
+//=======================================================================
+
+bool SMESHDS_SubMesh::Contains(const SMDS_MeshElement * ME) const
+{
+ if ( !ME || ME->IsNull() )
+ return false;
+
+ if ( IsComplexSubmesh() )
+ {
+ TSubMeshSet::const_iterator aSubIt = mySubMeshes.begin();
+ for (; aSubIt != mySubMeshes.end(); aSubIt++)
+ if ((*aSubIt)->Contains(ME))
+ return true;
+ return false;
+ }
+ return ME->getshapeId() == myIndex;
+}
+
+//=======================================================================
+//function : IsQuadratic
+//purpose : Return true if my 1st element is quadratic
+//=======================================================================
+
+bool SMESHDS_SubMesh::IsQuadratic() const
+{
+ if ( IsComplexSubmesh() )
+ {
+ TSubMeshSet::const_iterator aSubIt = mySubMeshes.begin();
+ for (; aSubIt != mySubMeshes.end(); aSubIt++)
+ if ((*aSubIt)->IsQuadratic())
+ return true;
+ return false;
+ }
+
+ if ( myNbElements == 0 )
+ return false;
+
+ SMDS_ElemIteratorPtr it = GetElements();
+ return it->more() && it->next()->IsQuadratic();
+}
+
+//=======================================================================
+//function : AddSubMesh
+//purpose :
+//=======================================================================
+
+void SMESHDS_SubMesh::AddSubMesh( const SMESHDS_SubMesh* theSubMesh )
+{
+ ASSERT( theSubMesh );
+ mySubMeshes.insert( theSubMesh );
+}
+
+//=======================================================================
+//function : RemoveSubMesh
+//purpose :
+//=======================================================================
+
+bool SMESHDS_SubMesh::RemoveSubMesh( const SMESHDS_SubMesh* theSubMesh )
+{
+ return mySubMeshes.erase( theSubMesh );
+}
+
+//=======================================================================
+//function : RemoveAllSubmeshes
+//purpose :
+//=======================================================================
+
+void SMESHDS_SubMesh::RemoveAllSubmeshes()
+{
+ mySubMeshes.clear();
+}
+
+//=======================================================================
+//function : ContainsSubMesh
+//purpose :
+//=======================================================================
+
+bool SMESHDS_SubMesh::ContainsSubMesh( const SMESHDS_SubMesh* theSubMesh ) const
+{
+ return mySubMeshes.find( theSubMesh ) != mySubMeshes.end();
+}
+
+//=======================================================================
+//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();
+ }
+ }