+ if ( myIgnoreAlgoSelection )
+ return;
+
+ int curDim = getTabDim( sender(), myDlg );
+ int aDim = theDim < 0 ? curDim : theDim;
+ if (aDim == -1)
+ return;
+
+ const bool isSubmesh = ( myToCreate ? !myIsMesh : myDlg->isObjectShown( SMESHGUI_MeshDlg::Mesh ));
+
+ HypothesisData* algoData = hypData( aDim, Algo, theIndex );
+ HypothesisData* algoByDim[4];
+ algoByDim[ aDim ] = algoData;
+
+ QStringList anAvailable;
+ const int algoDim = aDim;
+
+ // 2 loops: backward and forward from algo dimension (forward == to higher dimension)
+ for ( int forward = 1; forward >= 0; --forward )
+ {
+ int dim = algoDim, lastDim = SMESH::DIM_3D, dir = 1;
+ if ( !forward ) {
+ dim = algoDim - 1; lastDim = SMESH::DIM_0D; dir = -1;
+ }
+ //bool noCompatible = false;
+ for ( ; dim * dir <= lastDim * dir; dim += dir)
+ {
+ // if ( noCompatible ) // the selected algo has no compatible ones (like 1D2D3D algo)
+ // {
+ // anAvailable.clear();
+ // myDlg->tab( dim )->setAvailableHyps( Algo, anAvailable );
+ // myAvailableHypData[dim][Algo].clear();
+ // algoByDim[ dim ] = 0;
+ // }
+ // else
+ {
+ int algoIndex = currentHyp( dim, Algo );
+ HypothesisData *curAlgo = hypData( dim, Algo, algoIndex );
+
+ // set new available algorithms
+ HypothesisData *prevAlgo = 0;
+ if ( dim != algoDim )
+ for ( int prevDim = dim + 1; prevDim <=3 && !prevAlgo; ++prevDim )
+ prevAlgo = hypData( prevDim, Algo, currentHyp( prevDim, Algo ));
+ availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], prevAlgo );
+ myDlg->tab( dim )->setAvailableHyps( Algo, anAvailable );
+
+ //noCompatible = ( prevAlgo && !forward && anAvailable.isEmpty() );
+
+ // set current algo
+ algoIndex = myAvailableHypData[dim][Algo].indexOf( curAlgo );
+ setCurrentHyp( dim, Algo, algoIndex, /*updateHyps=*/true );
+
+ algoByDim[ dim ] = hypData( dim, Algo, algoIndex );
+ }
+
+ // activate tabs according to algorithms availability
+ if ( anAvailable.isEmpty() ) myDlg->disableTab( dim );
+ else myDlg->enableTab( dim );
+
+ } // loop on dims
+ } // loops backward and forward
+
+
+ // set hypotheses corresponding to the found algorithms
+
+ _PTR(SObject) pComp = SMESH::getStudy()->FindComponent("SMESH");
+
+ for ( int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++ )
+ {
+ if ( !isAccessibleDim( dim ))
+ continue;
+
+ // get indices of selected hyps
+ const int nbTypes = nbDlgHypTypes(dim);
+ std::vector<int> hypIndexByType( nbTypes, -1 );
+ for ( int dlgType = MainHyp; dlgType < nbTypes; dlgType++ )
+ {
+ hypIndexByType[ dlgType ] = currentHyp( dim, dlgType );
+ }
+
+ // update hyps
+ for ( int dlgType = MainHyp; dlgType < nbTypes; dlgType++ )
+ {
+ const int type = Min( dlgType, AddHyp );
+ myAvailableHypData[ dim ][ type ].clear();
+ QStringList anAvailable, anExisting;
+
+ HypothesisData* curAlgo = algoByDim[ dim ];
+ int hypIndex = hypIndexByType[ dlgType ];
+
+ SMESH::SMESH_Hypothesis_var curHyp;
+ QString curHypType;
+ HypothesisData* hypData = 0;
+ if ( hypIndex >= 0 && hypIndex < myExistingHyps[ dim ][ type ].count() )
+ {
+ curHyp = myExistingHyps[ dim ][ type ][ hypIndex ].first;
+ if ( !curHyp->_is_nil() )
+ {
+ curHypType = SMESH::toQStr( curHyp->GetName() );
+ hypData = SMESH::GetHypothesisData( curHypType );
+ }
+ }
+ if ( !myToCreate && !curAlgo && !curHyp->_is_nil() ) // edition, algo not selected
+ {
+ // try to find algo by selected hypothesis in order to keep it selected
+ bool algoDeselectedByUser = ( theDim < 0 && aDim == dim );
+ if ( !algoDeselectedByUser &&
+ myObjHyps[ dim ][ type ].count() > 0 &&
+ curHypType == SMESH::toQStr( myObjHyps[ dim ][ type ].first().first->GetName()) )
+ {
+ for ( int i = 0; i < myAvailableHypData[ dim ][ Algo ].count(); ++i )
+ {
+ curAlgo = myAvailableHypData[ dim ][ Algo ][ i ];
+ if ( curAlgo && hypData && isCompatible( curAlgo, hypData, type ))
+ break;
+ else
+ curAlgo = 0;
+ }
+ }
+ }
+
+ // get hyps compatible with curAlgo
+ bool defaulHypAvlbl = false;
+ if ( curAlgo )
+ {
+ if ( hypData && !isCompatible( curAlgo, hypData, type ))
+ curHyp = SMESH::SMESH_Hypothesis::_nil();
+ availableHyps( dim, type, anAvailable, myAvailableHypData[ dim ][ type ], curAlgo );
+ existingHyps ( dim, type, pComp, anExisting, myExistingHyps[ dim ][ type ], curAlgo );
+ defaulHypAvlbl = ( type == MainHyp && !curAlgo->IsAuxOrNeedHyp );
+ }
+ // set list of hypotheses
+ if ( dlgType <= AddHyp )
+ {
+ myDlg->tab( dim )->setAvailableHyps( type, anAvailable );
+ myDlg->tab( dim )->setExistingHyps( type, anExisting, defaulHypAvlbl );
+ }
+ // set current existing hypothesis
+ if ( !curHyp->_is_nil() && !anExisting.isEmpty() )
+ hypIndex = this->find( curHyp, myExistingHyps[ dim ][ type ]);
+ else
+ hypIndex = -1;
+ if ( !isSubmesh && myToCreate && hypIndex < 0 && anExisting.count() == 1 && dim == curDim )
+ {
+ // none is yet selected => select the sole existing if it is not optional
+ CORBA::String_var hypTypeName = myExistingHyps[ dim ][ type ].first().first->GetName();
+ bool isOptional = true;
+ if ( algoByDim[ dim ] &&
+ SMESH::IsAvailableHypothesis( algoByDim[ dim ], hypTypeName.in(), isOptional ) &&
+ !isOptional )
+ hypIndex = 0;
+ }
+ setCurrentHyp( dim, dlgType, hypIndex );
+ }
+ }
+ return;
+}
+
+//================================================================================
+/*!
+ * \brief Create a sub-mesh on internal edges in the case where the global algorithm
+ * is of type 1D-2D[-3D] so that the internal edges would remain not meshed.
+ */
+//================================================================================
+
+void SMESHGUI_MeshOp::createSubMeshOnInternalEdges( SMESH::SMESH_Mesh_ptr theMesh,
+ GEOM::GEOM_Object_ptr theMainShape )
+{
+ if ( theMesh->_is_nil() || theMainShape->_is_nil() )
+ return;
+
+ if ( isAccessibleDim( 1 ))
+ return; // global 1D algorithm is/can be assigned
+
+ const HypothesesSet::SetType internSet = HypothesesSet::INTERN;
+ bool toCreate = true;
+ bool toCreateMandatory = ( myHypoSet &&
+ myAverageSize > 0 &&
+ ( myHypoSet->init( /*algo=*/ true, internSet ), myHypoSet->more()) &&
+ ( myHypoSet->init( /*algo=*/false, internSet ), myHypoSet->more()));
+ if ( !toCreateMandatory ) // ask the user
+ toCreate = false; // can't pass both mesh and geometry to Create Submesh operation (so far?)
+ // toCreate = SUIT_MessageBox::warning( SMESHGUI::desktop(),
+ // QObject::tr("SMESH_WRN_WARNING"),
+ // QObject::tr("SMESH_CREATE_SUBMESH_ON_INTERNAL_EDGES"),
+ // QObject::tr("SMESH_BUT_YES"),
+ // QObject::tr("SMESH_BUT_NO"), 1, 0);
+ if ( !toCreate )
+ return;
+
+ TopoDS_Shape shape;
+ if ( !GEOMBase::GetShape( theMainShape, shape ))
+ return;