Salome HOME
Merge from BR_imps_2013 14/01/2014
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.cxx
index 9ad1a47fc5ae4d4a5ae928f3d6d315ce80107e92..eb0a30ed7404c011882de86d866b5829cf0bf8d9 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -40,6 +40,7 @@
 #include <GEOM_SelectionFilter.h>
 #include <GEOMBase.h>
 #include <GeometryGUI.h>
+#include <GEOM_wrap.hxx>
 
 // SALOME GUI includes
 #include <SalomeApp_Tools.h>
@@ -56,6 +57,8 @@
 // SALOME KERNEL includes
 #include <SALOMEDS_SComponent.hxx>
 #include <SALOMEDS_SObject.hxx>
+#include <SALOMEDS_Study.hxx>
+#include <SALOMEDS_wrap.hxx>
 
 // Qt includes
 #include <QStringList>
 #include <SALOMEconfig.h>
 #include CORBA_CLIENT_HEADER(SMESH_Gen)
 
-//To disable automatic genericobj management, the following line should be commented.
-//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
-#define WITHGENERICOBJ
-
 //================================================================================
 /*!
  * \brief Constructor
@@ -96,6 +95,7 @@ SMESHGUI_MeshOp::SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh )
   if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
     GeometryGUI::InitGeomGen();
   myIsOnGeometry = true;
+  myMaxShapeDim = -1;
 }
 
 //================================================================================
@@ -212,14 +212,13 @@ void SMESHGUI_MeshOp::startOperation()
     }
     connect( myDlg, SIGNAL( hypoSet( const QString& )), SLOT( onHypoSet( const QString& )));
     connect( myDlg, SIGNAL( geomSelectionByMesh( bool )), SLOT( onGeomSelectionByMesh( bool )));
-
+    connect( myDlg, SIGNAL( selectMeshType( const int, const int ) ), SLOT( onAlgoSetByMeshType( const int, const int)));
     if ( myToCreate )
       if ( myIsMesh ) myHelpFileName = "constructing_meshes_page.html";
       else myHelpFileName = "constructing_submeshes_page.html";
     else myHelpFileName = "editing_meshes_page.html";
   }
   SMESHGUI_SelectionOp::startOperation();
-
   // iterate through dimensions and get available algoritms, set them to the dialog
   _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
   for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ )
@@ -246,6 +245,11 @@ void SMESHGUI_MeshOp::startOperation()
     myDlg->activateObject( SMESHGUI_MeshDlg::Obj );
 
   myDlg->setCurrentTab( SMESH::DIM_3D );
+
+  QStringList TypeMeshList;
+  createMeshTypeList( TypeMeshList );
+  setAvailableMeshType( TypeMeshList );
+
   myDlg->show();
   myDlg->setGeomPopupEnabled(false);
   selectionDone();
@@ -297,9 +301,9 @@ SUIT_SelectionFilter* SMESHGUI_MeshOp::createFilter( const int theId ) const
     return new GEOM_SelectionFilter( (SalomeApp_Study*)study(), true );
   }
   else if ( theId == SMESHGUI_MeshDlg::Obj && !myToCreate )
-    return new SMESH_TypeFilter( MESHorSUBMESH );
+    return new SMESH_TypeFilter( SMESH::MESHorSUBMESH );
   else if ( theId == SMESHGUI_MeshDlg::Mesh )
-    return new SMESH_TypeFilter( MESH );
+    return new SMESH_TypeFilter( SMESH::MESH );
   else
     return 0;
 }
@@ -336,8 +340,7 @@ bool SMESHGUI_MeshOp::isSubshapeOk() const
     _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
     if (geomGen->_is_nil() || !aStudy) return false;
 
-    GEOM::GEOM_IGroupOperations_var op =
-        geomGen->GetIGroupOperations(aStudy->StudyId());
+    GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(aStudy->StudyId());
     if (op->_is_nil()) return false;
 
     // check all selected shapes
@@ -352,18 +355,18 @@ bool SMESHGUI_MeshOp::isSubshapeOk() const
       if (aSubGeomVar->_is_nil()) return false;
 
       // skl for NPAL14695 - implementation of searching of mainObj
-      GEOM::GEOM_Object_var mainObj = op->GetMainShape(aSubGeomVar);
-      //if (mainObj->_is_nil() ||
-      //    string(mainObj->GetEntry()) != string(mainGeom->GetEntry())) return false;
+      GEOM::GEOM_Object_var mainObj = op->GetMainShape(aSubGeomVar); /* _var not _wrap as
+                                                                        mainObj already exists! */
       while(1) {
         if (mainObj->_is_nil())
           return false;
-        if (std::string(mainObj->GetEntry()) == std::string(mainGeom->GetEntry()))
+        CORBA::String_var entry1 = mainObj->GetEntry();
+        CORBA::String_var entry2 = mainGeom->GetEntry();
+        if (std::string( entry1.in() ) == entry2.in() )
           return true;
         mainObj = op->GetMainShape(mainObj);
       }
     }
-    //return true;
   }
 
   return false;
@@ -584,7 +587,8 @@ void SMESHGUI_MeshOp::selectionDone()
         onAlgoSelected(-1, i);
       }
       myDlg->setMaxHypoDim( shapeDim );
-      myDlg->setHypoSets( SMESH::GetHypothesesSets( shapeDim ));
+      myMaxShapeDim = shapeDim;
+      myDlg->setHypoSets( SMESH::GetHypothesesSets( shapeDim, "" ));
 
       if (!myToCreate) // edition: read hypotheses
       {
@@ -671,12 +675,16 @@ void SMESHGUI_MeshOp::selectionDone()
       for (int i = SMESH::DIM_0D;i < SMESH::DIM_3D; ++i) {
         myDlg->disableTab(i);
       }
+      myMaxShapeDim = -1;
       //Hide labels and fields (Mesh ang Geometry)
       myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, false );
       myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, false );
       myDlg->adjustSize();
       readMesh();
     }
+    QStringList TypeMeshList;
+    createMeshTypeList( TypeMeshList );
+    setAvailableMeshType( TypeMeshList );
   }
   catch ( const SALOME::SALOME_Exception& S_ex )
   {
@@ -735,7 +743,14 @@ bool SMESHGUI_MeshOp::isValid( QString& theMess ) const
     if ( aGeomEntry == "" )
     {
       theMess = tr( "GEOMETRY_OBJECT_IS_NOT_DEFINED" );
-      return false;
+      dlg()->show();
+      if ( SUIT_MessageBox::warning( myDlg, tr( "SMESH_WRN_WARNING" ), theMess,
+           SUIT_MessageBox::Yes, SUIT_MessageBox::No ) == SUIT_MessageBox::No )
+      {
+        theMess = "";
+        return false;
+      }
+      return true;
     }
     _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() );
     if ( !pGeom || GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() )->_is_nil() )
@@ -896,7 +911,8 @@ void SMESHGUI_MeshOp::existingHyps( const int theDim,
           SMESH::SMESH_Hypothesis_var aHypVar = SMESH::SMESH_Hypothesis::_narrow( aVar );
           if ( !aHypVar->_is_nil() )
           {
-            HypothesisData* aData = SMESH::GetHypothesisData( aHypVar->GetName() );
+            CORBA::String_var hypType = aHypVar->GetName();
+            HypothesisData* aData = SMESH::GetHypothesisData( hypType.in() );
             if ( !aData) continue;
             if ( ( theDim == -1 || aData->Dim.contains( theDim ) ) &&
                  ( isCompatible ( theAlgoData, aData, theHypType )) &&
@@ -1100,14 +1116,10 @@ void SMESHGUI_MeshOp::createHypothesis(const int theDim,
     // Call hypothesis creation server method (without GUI)
     SMESH::SMESH_Hypothesis_var aHyp =
       SMESH::CreateHypothesis(theTypeName, aHypName, false);
-#ifdef WITHGENERICOBJ
-    if (!CORBA::is_nil(aHyp))
-      aHyp->UnRegister();
-#endif
-  } else {
+    aHyp.out();
+  }
+  else {
     // Get hypotheses creator client (GUI)
-    // BUG 0020378
-    //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName);
     SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName);
 
     // Create hypothesis
@@ -1176,10 +1188,7 @@ void SMESHGUI_MeshOp::createHypothesis(const int theDim,
     else {
      SMESH::SMESH_Hypothesis_var aHyp =
        SMESH::CreateHypothesis(theTypeName, aHypName, false);
-#ifdef WITHGENERICOBJ
-     if (!CORBA::is_nil(aHyp))
-       aHyp->UnRegister();
-#endif
+     aHyp.out();
     }
   }
 
@@ -1381,7 +1390,19 @@ void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
     availableHyps( aDim, Algo, anAvailable, myAvailableHypData[ aDim ][ Algo ]);
     myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailable );
   }
-
+  // check that tab enable, if algorithm building needed algo is one less than dimension
+  if ( algoData && myIsOnGeometry && !algoData->InputTypes.isEmpty() &&
+     ( aDim > SMESH::DIM_0D ) && !isAccessibleDim( aDim - 1 ) ){
+    myDlg->enableTab( aDim - 1 );
+  }
+  if ( (myDlg->currentMeshType() != MT_ANY) &&
+          (( !algoData && ( aDim > SMESH::DIM_0D ) && isAccessibleDim( aDim - 1 )) ||
+       ( algoData && myIsOnGeometry && algoData->InputTypes.isEmpty() &&
+       ( aDim > SMESH::DIM_0D ) && isAccessibleDim( aDim - 1 ) ) ) ){
+    for (int i = aDim - 1; i >= SMESH::DIM_0D; i--){
+      if ( isAccessibleDim( i ) ) myDlg->disableTab( i );
+    }
+  }
   // check that algorithms of other dimentions are compatible with
   // the selected one
 
@@ -1609,6 +1630,23 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess, QStringList& theEntryList )
 
   QStringList aList;
   myDlg->selectedObject( SMESHGUI_MeshDlg::Geom, aList );
+  if ( aList.isEmpty() )
+  {
+    SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
+    if ( aSMESHGen->_is_nil() )
+      return false;
+
+    SMESH::SMESH_Mesh_var aMeshVar= aSMESHGen->CreateEmptyMesh();
+    if ( aMeshVar->_is_nil() )
+      return false;
+
+    _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar.in() );
+    if ( aMeshSO ) {
+      SMESH::SetName( aMeshSO, myDlg->objectText( SMESHGUI_MeshDlg::Obj ) );
+      theEntryList.append( aMeshSO->GetID().c_str() );
+    }
+    return true;
+  }
   QStringList::Iterator it = aList.begin();
   for ( ; it!=aList.end(); it++)
   {
@@ -1650,13 +1688,6 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess, QStringList& theEntryList )
       if ( !anAlgoVar->_is_nil() )
         SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar );
     }
-#ifdef WITHGENERICOBJ
-    // obj has been published in study. Its refcount has been incremented.
-    // It is safe to decrement its refcount
-    // so that it will be destroyed when the entry in study will be removed
-    if (aMeshSO)
-      aMeshVar->UnRegister();
-#endif
   }
   return true;
 }
@@ -1710,7 +1741,7 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList
     GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
     _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
     if (!geomGen->_is_nil() && aStudy) {
-      GEOM::GEOM_IGroupOperations_var op =
+      GEOM::GEOM_IGroupOperations_wrap op =
         geomGen->GetIGroupOperations(aStudy->StudyId());
       if (!op->_is_nil()) {
         // check and add all selected GEOM objects: they must be
@@ -1735,18 +1766,20 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList
           aSeq[iSubSh] = aSubGeomVar;
         }
         // create a group
-        GEOM::GEOM_Object_var aGroupVar = op->CreateGroup(mainGeom, aGroupType);
+        GEOM::GEOM_Object_wrap aGroupVar = op->CreateGroup(mainGeom, aGroupType);
         op->UnionList(aGroupVar, aSeq);
 
-        if (op->IsDone()) {
-          aGeomVar = aGroupVar;
+        if (op->IsDone())
+        {
+          aGeomVar = GEOM::GEOM_Object::_duplicate( aGroupVar.in() );
 
           // publish the GEOM group in study
           QString aNewGeomGroupName ("Auto_group_for_");
           aNewGeomGroupName += aName;
-          SALOMEDS::SObject_var aNewGroupSO =
-            geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGeomVar,
-                                aNewGeomGroupName.toLatin1().data(), mainGeom);
+          SALOMEDS::Study_var aStudyVar = _CAST(Study, aStudy)->GetStudy();
+          SALOMEDS::SObject_wrap aNewGroupSO =
+            geomGen->AddInStudy( aStudyVar, aGeomVar,
+                                 aNewGeomGroupName.toLatin1().data(), mainGeom);
         }
       }
     }
@@ -1914,32 +1947,25 @@ SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim )
     if (aHypData)
     {
       QString aClientLibName = aHypData->ClientLibName;
-      if (aClientLibName == "")
+      if ( aClientLibName.isEmpty() )
       {
         // Call hypothesis creation server method (without GUI)
         SMESH::SMESH_Hypothesis_var aHyp =
           SMESH::CreateHypothesis(aHypName, aHypName, true);
-#ifdef WITHGENERICOBJ
-        if (!CORBA::is_nil(aHyp))
-          aHyp->UnRegister();
-#endif
+        aHyp.out();
       }
       else
       {
         // Get hypotheses creator client (GUI)
-        // BUG 0020378
         SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypName);
 
         // Create algorithm
         if (aCreator)
-          aCreator->create(true, aHypName, myDlg, 0, QString::null );
+          aCreator->create( true, aHypName, myDlg, 0, QString::null );
         else {
           SMESH::SMESH_Hypothesis_var aHyp =
             SMESH::CreateHypothesis(aHypName, aHypName, true);
-#ifdef WITHGENERICOBJ
-          if (!CORBA::is_nil(aHyp))
-            aHyp->UnRegister();
-#endif
+          aHyp.out();
         }
       }
       QStringList tmpList;
@@ -1965,10 +1991,9 @@ SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim )
 
 //================================================================================
 /*!
- * \brief Reads parameters of edited mesh and assigns them to the dialog
+ * \brief Reads parameters of an edited mesh and assigns them to the dialog
  *
- * Reads parameters of edited mesh and assigns them to the dialog (called when
- * mesh is edited only)
+ * Called when mesh is edited only.
  */
 //================================================================================
 void SMESHGUI_MeshOp::readMesh()
@@ -2005,8 +2030,8 @@ void SMESHGUI_MeshOp::readMesh()
 
   // Get hypotheses and algorithms assigned to the mesh/sub-mesh
   QStringList anExisting;
-  const int aDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D;
-  for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
+  const int lastDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D;
+  for ( int dim = SMESH::DIM_3D; dim >= lastDim; --dim )
   {
     // get algorithm
     existingHyps( dim, Algo, pObj, anExisting, myObjHyps[ dim ][ Algo ] );
@@ -2030,7 +2055,7 @@ void SMESHGUI_MeshOp::readMesh()
 
   // get hypotheses
   bool hypWithoutAlgo = false;
-  for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
+  for ( int dim = SMESH::DIM_3D; dim >= lastDim; --dim )
   {
     for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ )
     {
@@ -2340,3 +2365,193 @@ void SMESHGUI_MeshOp::selectObject( _PTR(SObject) theSObj ) const
     sm->setSelectedObjects( anIOList, false );
   }
 }
+//================================================================================
+/*!
+ * \brief Create available list types of mesh
+  * \param theTypeMesh - Output list of available types of mesh
+ */
+//================================================================================
+void SMESHGUI_MeshOp::createMeshTypeList( QStringList& theTypeMesh)
+{
+  theTypeMesh.clear();
+  theTypeMesh.append( tr( "MT_ANY" ) );
+  if ( myIsOnGeometry &&  ( myMaxShapeDim >= 2 || myMaxShapeDim == -1 ) )
+  {
+    theTypeMesh.append( tr( "MT_TRIANGULAR" ) );
+    theTypeMesh.append( tr( "MT_QUADRILATERAL" ) );
+  }
+  if ( myIsOnGeometry && ( myMaxShapeDim == 3 || myMaxShapeDim == -1 ) )
+  {
+    theTypeMesh.append( tr( "MT_TETRAHEDRAL" ) );
+    theTypeMesh.append( tr( "MT_HEXAHEDRAL" ) );
+  }
+
+}
+//================================================================================
+/*!
+ * \brief Set available types of mesh
+  * \param theTypeMesh - List of available types of mesh
+ */
+//================================================================================
+void SMESHGUI_MeshOp::setAvailableMeshType( const QStringList& theTypeMesh )
+{
+  myDlg->setAvailableMeshType( theTypeMesh );
+}
+
+//================================================================================
+/*!
+ * \brief SLOT. Is called when the user select type of mesh
+  * \param theTabIndex - Index of current active tab
+  * \param theIndex - Index of current type of mesh
+ */
+//================================================================================
+void SMESHGUI_MeshOp::onAlgoSetByMeshType( const int theTabIndex, const int theIndex)
+{
+  int aDim;
+  if ( !myIsOnGeometry ) return;
+  THypDataList anAvailableAlgsData;
+  QStringList anAvailableAlgs;
+  QString anCompareType = "ANY";
+  bool isAvailableChoiceAlgo = false;
+  int anCurrentAvailableAlgo = 0;
+  bool isNone = true;
+  switch ( theIndex ) {
+    case MT_ANY:
+    {
+      for ( int dim = SMESH::DIM_2D; dim <= SMESH::DIM_3D; dim++ )
+      {
+        isNone = currentHyp( dim, Algo ) < 0;
+        isAvailableChoiceAlgo = false;
+        // retrieves a list of available algorithms from resources
+        availableHyps( dim, Algo, anAvailableAlgs, anAvailableAlgsData );
+        //return current algo in current tab
+        if ( !isNone && !myAvailableHypData[dim][Algo].empty() ){
+          for (int i = 0 ; i < anAvailableAlgsData.count(); i++)
+          {
+            HypothesisData* algoAny = anAvailableAlgsData.at(i);
+            HypothesisData* algoCur = myAvailableHypData[dim][Algo].at( currentHyp( dim, Algo ) );
+            QString tem = algoAny->Label;
+            if ( algoAny->Label == algoCur->Label ){
+              isAvailableChoiceAlgo = true;
+              anCurrentAvailableAlgo = i;
+              break;
+            }
+          }
+        }
+        else if ( !isNone ){
+          isAvailableChoiceAlgo = true;
+          anCurrentAvailableAlgo = currentHyp( dim, Algo );
+        }
+        //set new algorithm list and select the current algorithm
+        myAvailableHypData[dim][Algo] = anAvailableAlgsData;
+        myDlg->tab( dim )->setAvailableHyps( Algo, anAvailableAlgs );
+        if ( isAvailableChoiceAlgo )
+          setCurrentHyp( dim, Algo, anCurrentAvailableAlgo );
+      }
+      int aMaxShapeDim = ( myMaxShapeDim == -1 ) ? SMESH::DIM_3D : myMaxShapeDim;
+      for ( int i = SMESH::DIM_0D; i <= aMaxShapeDim; i++ ) {
+        myDlg->enableTab( i );
+      }
+      myDlg->setCurrentTab( theTabIndex );
+      myDlg->setHypoSets( SMESH::GetHypothesesSets( aMaxShapeDim, "" ) );
+    }
+    break;
+    case MT_TRIANGULAR:{
+      aDim = SMESH::DIM_2D;
+      anCompareType = "TRIA";
+    }
+    break;
+    case MT_QUADRILATERAL:{
+      aDim = SMESH::DIM_2D;
+      anCompareType = "QUAD";
+    }
+    break;
+    case MT_TETRAHEDRAL:{
+      aDim = SMESH::DIM_3D;
+      anCompareType = "TETRA";
+    }
+    break;
+    case MT_HEXAHEDRAL:{
+      aDim = SMESH::DIM_3D;
+      anCompareType = "HEXA";
+    }
+    break;
+    default:;
+  }
+  if ( anCompareType != "ANY" )
+  {
+    QString anCurrentAlgo;
+    bool isReqDisBound = true;
+    isNone = currentHyp( aDim, Algo ) < 0;
+    // retrieves a list of available algorithms from resources
+    availableHyps( aDim, Algo, anAvailableAlgs, anAvailableAlgsData );
+    // finding algorithm which is selected
+    if ( !isNone && !myAvailableHypData[aDim][Algo].empty() &&
+         myAvailableHypData[aDim][Algo].count() != anAvailableAlgsData.count() ){
+      anCurrentAlgo = myAvailableHypData[aDim][Algo].at( currentHyp( aDim, Algo ) )->Label;
+      isReqDisBound = myAvailableHypData[aDim][Algo].at( currentHyp( aDim, Algo ) )->InputTypes.isEmpty();
+    }
+    else if ( !isNone ){
+      anCurrentAlgo = anAvailableAlgsData.at( currentHyp( aDim, Algo ) )->Label;
+      isReqDisBound = anAvailableAlgsData.at( currentHyp( aDim, Algo ) )->InputTypes.isEmpty();
+    }
+    anAvailableAlgs.clear();
+    myAvailableHypData[aDim][Algo].clear();
+    // finding and adding algorithm depending on the type mesh
+    for ( int i = 0 ; i < anAvailableAlgsData.count(); i++ )
+    {
+      HypothesisData* algoIn = anAvailableAlgsData.at( i );
+      bool isAvailableAlgo = ( algoIn->OutputTypes.count() == 0 );
+      QStringList::const_iterator inElemType = algoIn->OutputTypes.begin();
+      for ( ; inElemType != algoIn->OutputTypes.end(); inElemType++ )
+      {
+        if ( *inElemType == anCompareType ){
+          isAvailableAlgo = true;
+          break;
+        }
+      }
+      if ( isAvailableAlgo || algoIn->OutputTypes.count()==0 ){
+        anAvailableAlgs.append( algoIn->Label );
+        myAvailableHypData[aDim][Algo].append( algoIn );
+      }
+      //algorithm will be active, if the chosen algorithm available in the current mesh type
+      if ( !isNone &&  isAvailableAlgo && algoIn->Label == anCurrentAlgo ){
+        isAvailableChoiceAlgo = true;
+        anCurrentAvailableAlgo = anAvailableAlgs.count() - 1 ;
+      }
+    }
+    //set new algorithm list and select the current algorithm
+    myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailableAlgs );
+    if ( isAvailableChoiceAlgo )
+      setCurrentHyp( aDim, Algo, anCurrentAvailableAlgo );
+    int aMaxShapeDim = ( myMaxShapeDim == -1 ) ? SMESH::DIM_3D : myMaxShapeDim;
+    if ( isNone || isReqDisBound || !isAvailableChoiceAlgo ) {
+      for ( int i = SMESH::DIM_0D; i <= aMaxShapeDim; i++ ) {
+        if ( aDim != i ) {
+          myDlg->disableTab( i );
+          setCurrentHyp(i, Algo, -1);
+        }
+      }
+    }
+    else if ( !isNone ){
+      if ( aDim == SMESH::DIM_2D){
+        myDlg->disableTab( SMESH::DIM_3D );
+        setCurrentHyp( SMESH::DIM_3D, Algo, -1);
+      }
+      for ( int i = aMaxShapeDim; i > SMESH::DIM_0D; i-- )
+      {
+        isReqDisBound = ( currentHyp( i, Algo ) < 0 ) ? true : myAvailableHypData[i][Algo].at( currentHyp( i, Algo ) )->InputTypes.isEmpty();
+        if ( aMaxShapeDim != i && isReqDisBound) {
+          for (int j = i - 1; j >= SMESH::DIM_0D; j--){
+            myDlg->disableTab( j );
+            setCurrentHyp( j , Algo, -1 );
+          }
+          break;
+        }
+      }
+    }
+    myDlg->setHypoSets( SMESH::GetHypothesesSets( aDim, anCompareType ) );
+    myDlg->enableTab( aDim );
+    myDlg->setCurrentTab( aDim );
+  }
+}