+ //================================================================================
+ /*!
+ * \brief sets a sub-mesh event listener to clear sub-meshes of sub-shapes of
+ * the main shape when sub-mesh of the main shape is cleared,
+ * for example to clear sub-meshes of FACEs when sub-mesh of a SOLID
+ * is cleared
+ */
+ //================================================================================
+
+ void ToClearSubWithMain( SMESH_subMesh* sub, const TopoDS_Shape& main)
+ {
+ SMESH_subMesh* mainSM = sub->GetFather()->GetSubMesh( main );
+ SMESH_subMeshEventListenerData* data =
+ mainSM->GetEventListenerData( _ShrinkShapeListener::Get());
+ if ( data )
+ {
+ if ( find( data->mySubMeshes.begin(), data->mySubMeshes.end(), sub ) ==
+ data->mySubMeshes.end())
+ data->mySubMeshes.push_back( sub );
+ }
+ else
+ {
+ data = SMESH_subMeshEventListenerData::MakeData( /*dependent=*/sub );
+ sub->SetEventListener( _ShrinkShapeListener::Get(), data, /*whereToListenTo=*/mainSM );
+ }
+ }