+ }
+
+ return ConvertHypothesisStatus(status);
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Hypothesis::Hypothesis_Status
+ SMESH_Mesh_i::addHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
+ SMESH::SMESH_Hypothesis_ptr anHyp)
+{
+ MESSAGE("addHypothesis");
+ // **** proposer liste de subShape (selection multiple)
+
+ GEOM::GEOM_Shape_var mySubShape = GEOM::GEOM_Shape::_narrow(aSubShape);
+ if (CORBA::is_nil(mySubShape))
+ THROW_SALOME_CORBA_EXCEPTION("bad subShape reference",
+ SALOME::BAD_PARAM);
+
+ SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(anHyp);
+ if (CORBA::is_nil(myHyp))
+ THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference",
+ SALOME::BAD_PARAM);
+
+ SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK;
+ try
+ {
+ TopoDS_Shape myLocSubShape =
+ _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), mySubShape);
+ int hypId = myHyp->GetId();
+ status = _impl->AddHypothesis(myLocSubShape, hypId);
+ if ( !SMESH_Hypothesis::IsStatusFatal(status) )
+ _mapHypo[hypId] = myHyp;
+ }
+ catch(SALOME_Exception & S_ex)
+ {
+ THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+ }
+ return status;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Shape_ptr aSubShape,
+ SMESH::SMESH_Hypothesis_ptr anHyp)
+ throw(SALOME::SALOME_Exception)
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ SMESH_Hypothesis::Hypothesis_Status status = removeHypothesis( aSubShape, anHyp );
+
+ if ( !SMESH_Hypothesis::IsStatusFatal(status) ) {
+ SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+
+ if ( !aStudy->_is_nil() ) {
+ // Detect whether <aSubShape> refers to this mesh or its sub-mesh
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ SALOMEDS::SObject_var aMeshSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ) ) );
+ if ( aMeshSO->_is_nil() )
+ return SMESH::HYP_UNKNOWN_FATAL;
+
+ SALOMEDS::SObject_var aMorSM, aRef;
+ CORBA::String_var aShapeIOR = CORBA::string_dup( SMESH_Gen_i::GetORB()->object_to_string( aSubShape ) );
+ SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator( aMeshSO );
+
+ for ( it->InitEx( true ); it->More(); it->Next() ) {
+ SALOMEDS::SObject_var anObj = it->Value();
+ if ( anObj->ReferencedObject( aRef ) ) {
+ if ( aRef->FindAttribute( anAttr, "AttributeIOR" ) ) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
+ if ( strcmp( anIOR->Value(), aShapeIOR ) == 0 ) {
+ aMorSM = anObj->GetFather();
+ break;
+ }
+ }
+ }
+ }
+
+ bool aIsAlgo = !SMESH::SMESH_Algo::_narrow( anHyp )->_is_nil();
+ SALOMEDS::SObject_var aHypSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( anHyp ) ) ) );
+ if ( !aMorSM->_is_nil() && !aHypSO->_is_nil() ) {
+ // Remove a refernce to hypothesis or algorithm
+ SALOMEDS::SObject_var AHR;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeSelectable_var aSelAttr;
+ SALOMEDS::AttributePixMap_var aPixmap;
+ SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
+ CORBA::String_var aHypIOR = CORBA::string_dup( SMESH_Gen_i::GetORB()->object_to_string( anHyp ) );
+ long aTag = aIsAlgo ? SMESH_Gen_i::GetRefOnAppliedAlgorithmsTag() : SMESH_Gen_i::GetRefOnAppliedHypothesisTag();
+
+ if ( aMorSM->FindSubObject( aTag, AHR ) ) {
+ SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator( AHR );
+ for ( ; it->More(); it->Next() ) {
+ SALOMEDS::SObject_var anObj = it->Value();
+ if ( anObj->ReferencedObject( aRef ) ) {
+ if ( aRef->FindAttribute( anAttr, "AttributeIOR" ) ) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ if ( strcmp( anIOR->Value(), aHypIOR ) == 0 ) {
+ aBuilder->RemoveObject( anObj );
+ break;
+ }
+ }
+ }
+ }
+ }
+ }