+//=======================================================================
+//function : clearMesh
+//purpose : clear mesh elements existing on myShape in theMesh
+//=======================================================================
+
+void SMESH_Pattern::clearMesh(SMESH_Mesh* theMesh) const
+{
+
+ if ( !myShape.IsNull() )
+ {
+ if ( SMESH_subMesh * aSubMesh = theMesh->GetSubMesh/*Containing*/( myShape ))
+ {
+ aSubMesh->ComputeStateEngine( SMESH_subMesh::CLEANDEP );
+ }
+ else {
+ SMESHDS_Mesh* aMeshDS = theMesh->GetMeshDS();
+ if ( SMESHDS_SubMesh* aSubMeshDS = aMeshDS->MeshElements( myShape ))
+ {
+ SMDS_ElemIteratorPtr eIt = aSubMeshDS->GetElements();
+ while ( eIt->more() )
+ aMeshDS->RemoveElement( eIt->next() );
+ SMDS_NodeIteratorPtr nIt = aSubMeshDS->GetNodes();
+ while ( nIt->more() )
+ aMeshDS->RemoveNode( static_cast<const SMDS_MeshNode*>( nIt->next() ));
+ }
+ }
+ }
+}
+