+ else if ( aShapesId )
+ aShapesId->insert( smToCompute->GetId() );
+ }
+ //aMesh.GetMeshDS()->Modified();
+ return ret;
+ }
+ else
+ {
+ // ================================================================
+ // Apply algos that do NOT require discreteized boundaries
+ // ("all-dimensional") and do NOT support sub-meshes, starting from
+ // the most complex shapes and collect sub-meshes with algos that
+ // DO support sub-meshes
+ // ================================================================
+
+ list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes[4]; // for each dim
+
+ // map to sort sm with same dim algos according to dim of
+ // the shape the algo assigned to (issue 0021217).
+ // Other issues influenced the algo applying order:
+ // 21406, 21556, 21893, 20206
+ multimap< int, SMESH_subMesh* > shDim2sm;
+ multimap< int, SMESH_subMesh* >::reverse_iterator shDim2smIt;
+ TopoDS_Shape algoShape;
+ int prevShapeDim = -1, aShapeDim;
+
+ smIt = shapeSM->getDependsOnIterator(includeSelf, complexShapeFirst);
+ while ( smIt->more() )
+ {
+ SMESH_subMesh* smToCompute = smIt->next();
+ if ( smToCompute->GetComputeState() != SMESH_subMesh::READY_TO_COMPUTE )
+ continue;
+
+ const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
+ aShapeDim = GetShapeDim( aSubShape );
+ if ( aShapeDim < 1 ) break;
+
+ // check for preview dimension limitations
+ if ( aShapesId && aShapeDim > (int)aDim )
+ continue;
+
+ SMESH_Algo* algo = GetAlgo( smToCompute, &algoShape );
+ if ( algo && !algo->NeedDiscreteBoundary() )
+ {
+ if ( algo->SupportSubmeshes() )
+ {
+ // reload sub-meshes from shDim2sm into smWithAlgoSupportingSubmeshes
+ // so that more local algos to go first
+ if ( prevShapeDim != aShapeDim )
+ {
+ prevShapeDim = aShapeDim;
+ for ( shDim2smIt = shDim2sm.rbegin(); shDim2smIt != shDim2sm.rend(); ++shDim2smIt )
+ if ( shDim2smIt->first == globalAlgoDim )
+ smWithAlgoSupportingSubmeshes[ aShapeDim ].push_back( shDim2smIt->second );
+ else
+ smWithAlgoSupportingSubmeshes[ aShapeDim ].push_front( shDim2smIt->second );
+ shDim2sm.clear();
+ }
+ // add smToCompute to shDim2sm map
+ if ( algoShape.IsSame( aMesh.GetShapeToMesh() ))
+ {
+ aShapeDim = globalAlgoDim; // to compute last
+ }
+ else
+ {
+ aShapeDim = GetShapeDim( algoShape );
+ if ( algoShape.ShapeType() == TopAbs_COMPOUND )
+ {
+ TopoDS_Iterator it( algoShape );
+ aShapeDim += GetShapeDim( it.Value() );
+ }
+ }
+ shDim2sm.insert( make_pair( aShapeDim, smToCompute ));
+ }
+ else // Compute w/o support of sub-meshes
+ {
+ if (_compute_canceled)
+ return false;
+ smToCompute->SetAllowedSubShapes( fillAllowed( shapeSM, aShapeOnly, allowedSubShapes ));
+ setCurrentSubMesh( smToCompute );
+ smToCompute->ComputeStateEngine( computeEvent );
+ setCurrentSubMesh( nullptr );
+ smToCompute->SetAllowedSubShapes( nullptr );
+ if ( aShapesId )
+ aShapesId->insert( smToCompute->GetId() );
+ }