bool SMESH_Gen::GetAlgoState(SMESH_Mesh& theMesh, const TopoDS_Shape& theShape, list< TAlgoStateError > & theErrors) { //MESSAGE("SMESH_Gen::CheckAlgoState"); bool ret = true; bool hasAlgo = false; SMESH_subMesh* sm = theMesh.GetSubMesh(theShape); const SMESHDS_Mesh* meshDS = theMesh.GetMeshDS(); TopoDS_Shape mainShape = meshDS->ShapeToMesh(); // ----------------- // get global algos // ----------------- const SMESH_Algo* aGlobAlgoArr[] = {0,0,0,0}; const list<const SMESHDS_Hypothesis*>& listHyp = meshDS->GetHypothesis( mainShape ); list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin(); for ( ; it != listHyp.end(); it++) { const SMESHDS_Hypothesis * aHyp = *it; if (aHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO) continue; const SMESH_Algo* algo = dynamic_cast<const SMESH_Algo*> (aHyp); ASSERT ( algo ); int dim = algo->GetDim(); aGlobAlgoArr[ dim ] = algo; hasAlgo = true; } // -------------------------------------------------------- // info on algos that will be ignored because of ones that // don't NeedDiscreteBoundary() attached to super-shapes, // check that a conform mesh will be produced // -------------------------------------------------------- // find a global algo possibly hiding sub-algos int dim; const SMESH_Algo* aGlobIgnoAlgo = 0; for (dim = 3; dim > 0; dim--) { if (aGlobAlgoArr[ dim ] && !aGlobAlgoArr[ dim ]->NeedDiscreteBoundary() /*&& !aGlobAlgoArr[ dim ]->SupportSubmeshes()*/ ) { aGlobIgnoAlgo = aGlobAlgoArr[ dim ]; break; } } set<SMESH_subMesh*> aCheckedSubs; bool checkConform = ( !theMesh.IsNotConformAllowed() ); // loop on theShape and its sub-shapes SMESH_subMeshIteratorPtr revItSub = sm->getDependsOnIterator( /*includeSelf=*/true, /*complexShapeFirst=*/true); while ( revItSub->more() ) { SMESH_subMesh* smToCheck = revItSub->next(); if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX) break; if ( aCheckedSubs.insert( smToCheck ).second ) // not yet checked if (!checkConformIgnoredAlgos (theMesh, smToCheck, aGlobIgnoAlgo, 0, checkConform, aCheckedSubs, theErrors)) ret = false; if ( smToCheck->GetAlgoState() != SMESH_subMesh::NO_ALGO ) hasAlgo = true; } // ---------------------------------------------------------------- // info on missing hypothesis and find out if all needed algos are // well defined // ---------------------------------------------------------------- //MESSAGE( "---info on missing hypothesis and find out if all needed algos are"); // find max dim of global algo int aTopAlgoDim = 0; for (dim = 3; dim > 0; dim--) { if (aGlobAlgoArr[ dim ]) { aTopAlgoDim = dim; break; } } bool checkNoAlgo = theMesh.HasShapeToMesh() ? bool( aTopAlgoDim ) : false; bool globalChecked[] = { false, false, false, false }; // loop on theShape and its sub-shapes aCheckedSubs.clear(); revItSub = sm->getDependsOnIterator( /*includeSelf=*/true, /*complexShapeFirst=*/true); while ( revItSub->more() ) { SMESH_subMesh* smToCheck = revItSub->next(); if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX) break; if (!checkMissing (this, theMesh, smToCheck, aTopAlgoDim, globalChecked, checkNoAlgo, aCheckedSubs, theErrors)) { ret = false; if (smToCheck->GetAlgoState() == SMESH_subMesh::NO_ALGO ) checkNoAlgo = false; } } if ( !hasAlgo ) { ret = false; theErrors.push_back( TAlgoStateError() ); theErrors.back().Set( SMESH_Hypothesis::HYP_MISSING, theMesh.HasShapeToMesh() ? 1 : 3, true ); } return ret; }