+ // find or create algorithm
+ bool toDelete = false, toAdd = true;
+ SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( dim );
+ if ( anAlgoVar->_is_nil() ) {
+ toAdd = false;
+ }
+ if ( myObjHyps[ dim ][ Algo ].count() > 0 ) {
+ SMESH::SMESH_Hypothesis_var anOldAlgo = myObjHyps[ dim ][ Algo ].first();
+ if ( toAdd ) {
+ if ( strcmp(anOldAlgo->GetName(), anAlgoVar->GetName()) == 0 ) {
+ toAdd = false;
+ } else {
+ toDelete = true;
+ }
+ } else {
+ toDelete = true;
+ }
+ }
+ // remove old algorithm
+ if ( toDelete )
+ SMESH::RemoveHypothesisOrAlgorithmOnMesh
+ ( pObj, myObjHyps[ dim ][ Algo ].first() );
+
+ // assign new algorithm
+ if ( toAdd ) {
+ SMESH::SMESH_Mesh_var aMeshVar =
+ SMESH::SMESH_Mesh::_narrow( _CAST(SObject,pObj)->GetObject() );
+ bool isMesh = !aMeshVar->_is_nil();
+ if ( isMesh ) {
+ SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar );
+ } else {
+ SMESH::SMESH_subMesh_var aVar =
+ SMESH::SMESH_subMesh::_narrow( _CAST(SObject,pObj)->GetObject() );
+ if ( !aVar->_is_nil() )
+ SMESH::AddHypothesisOnSubMesh( aVar, anAlgoVar );
+ }
+ }
+