+ SMESH_subMeshIteratorPtr smIt = getDependsOnIterator(false,
+ /*complexShapeFirst=*/true);
+ if ( _father->NbNodes() == 0 )
+ {
+ while ( smIt->more() )
+ smIt->next()->ComputeStateEngine(CHECK_COMPUTE_STATE);
+ }
+ else if ( !algoRequiringCleaning || !algoRequiringCleaning->SupportSubmeshes() )
+ {
+ while ( smIt->more() )
+ smIt->next()->ComputeStateEngine(CLEAN);
+ }
+ else if ( algoRequiringCleaning && algoRequiringCleaning->SupportSubmeshes() )
+ {
+ // find sub-meshes to keep elements on
+ set< SMESH_subMesh* > smToKeep;
+ TopAbs_ShapeEnum prevShapeType = TopAbs_SHAPE;
+ bool toKeepPrevShapeType = false;
+ while ( smIt->more() )
+ {
+ SMESH_subMesh* sm = smIt->next();
+ sm->ComputeStateEngine(CHECK_COMPUTE_STATE);
+ if ( !sm->IsEmpty() )
+ {
+ const bool sameShapeType = ( prevShapeType == sm->GetSubShape().ShapeType() );
+ bool keepSubMeshes = ( sameShapeType && toKeepPrevShapeType );
+ if ( !sameShapeType )
+ {
+ // check if the algo allows presence of global algos of dimension the algo
+ // can generate it-self;
+ // always keep a node on VERTEX, as this node can be shared by segments
+ // lying on EDGEs not shared by the VERTEX of sm, due to MergeNodes (PAL23068)
+ int shapeDim = SMESH_Gen::GetShapeDim( sm->GetSubShape() );
+ keepSubMeshes = ( algoRequiringCleaning->NeedLowerHyps( shapeDim ) || shapeDim == 0 );
+ prevShapeType = sm->GetSubShape().ShapeType();
+ toKeepPrevShapeType = keepSubMeshes;
+ }
+ if ( !keepSubMeshes )
+ {
+ // look for a local algo used to mesh sm
+ TopoDS_Shape algoShape = SMESH_MesherHelper::GetShapeOfHypothesis
+ ( algoRequiringCleaning, _subShape, _father );
+ SMESH_HypoFilter moreLocalAlgo;
+ moreLocalAlgo.Init( SMESH_HypoFilter::IsMoreLocalThan( algoShape, *_father ));
+ moreLocalAlgo.And ( SMESH_HypoFilter::IsAlgo() );
+ bool localAlgoFound = _father->GetHypothesis( sm->_subShape, moreLocalAlgo, true );
+ keepSubMeshes = localAlgoFound;
+ }
+ // remember all sub-meshes of sm
+ if ( keepSubMeshes )
+ {
+ SMESH_subMeshIteratorPtr smIt2 = sm->getDependsOnIterator(true);
+ while ( smIt2->more() )
+ smToKeep.insert( smIt2->next() );
+ }
+ }
+ }
+ // remove elements
+ SMESH_subMeshIteratorPtr smIt = getDependsOnIterator(false,true);
+ while ( smIt->more() )
+ {
+ SMESH_subMesh* sm = smIt->next();
+ if ( !smToKeep.count( sm ))
+ sm->ComputeStateEngine(CLEAN);
+ }
+ }