Fixed filtering in create mesh dialog box

This commit is contained in:
imn 2015-09-02 13:13:46 +03:00
parent 1dd2f82c6d
commit 859219d598
2 changed files with 242 additions and 233 deletions

View File

@ -859,6 +859,60 @@ static bool isCompatible(const HypothesisData* theAlgoData,
return ( SMESH::IsAvailableHypothesis( theAlgoData, theHypData->TypeName, isOptional )); return ( SMESH::IsAvailableHypothesis( theAlgoData, theHypData->TypeName, isOptional ));
} }
//================================================================================
/*!
* \brief check compatibility of the geometry
* \param theAlgoData - to select hypos able to be used by this algo
* \param theCurrentGeomToSelect - the current name of the selected geometry
* \param theGeomVar - currently selected geometry
* \retval bool - check result
*/
//================================================================================
bool SMESHGUI_MeshOp::isCompatibleToGeometry(HypothesisData* theAlgoData,
QString theCurrentGeomToSelect,
GEOM::GEOM_Object_var theGeomVar)
{
if ( theGeomVar->_is_nil() )
return true;
bool isApplicable = false;
if ( theCurrentGeomToSelect == myLastGeomToSelect && !theCurrentGeomToSelect.isEmpty() ) {
THypLabelIsAppMap::const_iterator iter = myHypMapIsApplicable.find( theAlgoData->Label );
if ( iter != myHypMapIsApplicable.end() && iter.key() == theAlgoData->Label ) {
isApplicable = iter.value();
return isApplicable;
}
}
bool toCheckIsApplicableToAll = !myIsMesh;
if ( toCheckIsApplicableToAll )
toCheckIsApplicableToAll = ( theGeomVar->GetType() == GEOM_GROUP );
isApplicable = SMESH::IsApplicable( theAlgoData->TypeName, theGeomVar, toCheckIsApplicableToAll );
myHypMapIsApplicable.insert( theAlgoData->Label, isApplicable );
return isApplicable;
}
//================================================================================
/*!
* \brief check compatibility of the mesh type
* \param theAlgoData - to select hypos able to be used by this algo
* \param theMeshType - type of mesh for filtering algorithms
* \retval bool - check result
*/
//================================================================================
bool SMESHGUI_MeshOp::isCompatibleToMeshType(HypothesisData* theAlgoData,
QString theMeshType)
{
bool isAvailableAlgo = ( theAlgoData->OutputTypes.count() == 0 );
QStringList::const_iterator inElemType = theAlgoData->OutputTypes.begin();
for ( ; inElemType != theAlgoData->OutputTypes.end(); inElemType++ ) {
if ( *inElemType == theMeshType ) {
isAvailableAlgo = true;
break;
}
}
return isAvailableAlgo;
}
//================================================================================ //================================================================================
/*! /*!
* \brief Gets available hypotheses or algorithms * \brief Gets available hypotheses or algorithms
@ -866,7 +920,9 @@ static bool isCompatible(const HypothesisData* theAlgoData,
* \param theHypType - specifies whether algorims or hypotheses or additional ones * \param theHypType - specifies whether algorims or hypotheses or additional ones
* are retrieved (possible values are in HypType enumeration) * are retrieved (possible values are in HypType enumeration)
* \param theHyps - Output list of hypotheses' names * \param theHyps - Output list of hypotheses' names
* \param theAlgoData - to select hypos able to be used by this algo (optional) * \param thePrevAlgoData - to select hypos able to be used by previously algo (optional)
* \param theNextAlgoData - to select hypos able to be used by next algo (optional)
* \param theMeshType - type of mesh for filtering algorithms (optional)
* *
* Gets available hypotheses or algorithm in accordance with input parameters * Gets available hypotheses or algorithm in accordance with input parameters
*/ */
@ -875,7 +931,9 @@ void SMESHGUI_MeshOp::availableHyps( const int theDim,
const int theHypType, const int theHypType,
QStringList& theHyps, QStringList& theHyps,
THypDataList& theDataList, THypDataList& theDataList,
HypothesisData* theAlgoData ) const HypothesisData* thePrevAlgoData,
HypothesisData* theNextAlgoData,
const QString& theMeshType)
{ {
theDataList.clear(); theDataList.clear();
theHyps.clear(); theHyps.clear();
@ -884,14 +942,35 @@ void SMESHGUI_MeshOp::availableHyps( const int theDim,
QStringList aHypTypeNameList = SMESH::GetAvailableHypotheses( isAlgo, theDim, isAux, myIsOnGeometry, !myIsMesh ); QStringList aHypTypeNameList = SMESH::GetAvailableHypotheses( isAlgo, theDim, isAux, myIsOnGeometry, !myIsMesh );
QStringList::const_iterator anIter; QStringList::const_iterator anIter;
GEOM::GEOM_Object_var aGeomVar;
QString aCurrentGeomToSelect;
if ( !theMeshType.isEmpty() ) {
aCurrentGeomToSelect = myDlg->selectedObject( myToCreate ? SMESHGUI_MeshDlg::Geom : SMESHGUI_MeshDlg::Obj );
if ( _PTR(SObject) so = studyDS()->FindObjectID( aCurrentGeomToSelect.toLatin1().data() )) {
aGeomVar = SMESH::GetGeom( so );
}
if ( aCurrentGeomToSelect != myLastGeomToSelect )
myHypMapIsApplicable.clear();
}
for ( anIter = aHypTypeNameList.begin(); anIter != aHypTypeNameList.end(); ++anIter ) for ( anIter = aHypTypeNameList.begin(); anIter != aHypTypeNameList.end(); ++anIter )
{ {
HypothesisData* aData = SMESH::GetHypothesisData( *anIter ); HypothesisData* aData = SMESH::GetHypothesisData( *anIter );
if ( isCompatible ( theAlgoData, aData, theHypType )) { if ( ( isCompatible ( thePrevAlgoData, aData, theHypType ) &&
isCompatible ( theNextAlgoData, aData, theHypType ) ) ||
( theMeshType == "ANY" && aData->InputTypes.isEmpty())) {
if ( !theMeshType.isEmpty() && theDim >= SMESH::DIM_2D &&
( ( theMeshType != "ANY" && !isCompatibleToMeshType( aData, theMeshType )) ||
!isCompatibleToGeometry( aData, aCurrentGeomToSelect, aGeomVar )))
continue;
theDataList.append( aData ); theDataList.append( aData );
theHyps.append( aData->Label ); theHyps.append( aData->Label );
} }
} }
if ( !theMeshType.isEmpty() && !aCurrentGeomToSelect.isEmpty() &&
myLastGeomToSelect != aCurrentGeomToSelect )
myLastGeomToSelect = aCurrentGeomToSelect;
} }
//================================================================================ //================================================================================
@ -1421,47 +1500,49 @@ void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
// check that tab enabled of one less dimension // check that tab enabled of one less dimension
if ( aDim > SMESH::DIM_0D ) if ( aDim > SMESH::DIM_0D )
{ {
if ( isAccessibleDim( aDim - 1 ) ) if ( isAccessibleDim( aDim - 1 ) ) {
{ if ( algoData && myIsOnGeometry ) {
if (( myDlg->currentMeshType() != MT_ANY ) && for (int i = aDim - 1; i >= SMESH::DIM_0D; i--) {
( !algoData || ( myIsOnGeometry && algoData->InputTypes.isEmpty() )))
for (int i = aDim - 1; i >= SMESH::DIM_0D; i--)
if ( isAccessibleDim( i ) ) { if ( isAccessibleDim( i ) ) {
myDlg->disableTab( i ); myDlg->disableTab( i );
setCurrentHyp(i, Algo, -1); setCurrentHyp(i, Algo, -1);
} }
} }
else if ( algoData && myIsOnGeometry && !algoData->InputTypes.isEmpty() ) }
{ }
if ( algoData && myIsOnGeometry && !algoData->InputTypes.isEmpty() ) {
myDlg->enableTab( aDim - 1 ); myDlg->enableTab( aDim - 1 );
} }
if ( !algoData ) {
if ( aDim != SMESH::DIM_2D || ( aDim == SMESH::DIM_2D &&
currentHyp( SMESH::DIM_2D, Algo ) < 0) ) {
for (int i = aDim - 1; i >= SMESH::DIM_0D; i--)
myDlg->enableTab( i );
}
else {
for (int i = aDim - 1; i >= SMESH::DIM_0D; i--)
myDlg->disableTab( i );
}
}
} }
// check that algorithms of other dimentions are compatible with int algoDim = aDim;
// the selected one HypothesisData* a3DAlgo = 0;
if ( !algoData ) { // all algos becomes available
if (myDlg->currentMeshType() == MT_ANY || aDim == SMESH::DIM_1D || aDim == SMESH::DIM_0D)
availableHyps( aDim, Algo, anAvailable, myAvailableHypData[ aDim ][ Algo ]);
else{
anAvailable.clear();
for (int i = 0; i < myFilteredAlgoData[aDim].count(); ++i) {
HypothesisData* aCurAlgo = myFilteredAlgoData[aDim][ i ];
anAvailable.append( aCurAlgo->Label );
}
}
myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailable );
}
// 2 loops: backward and forward from algo dimension // 2 loops: backward and forward from algo dimension
for ( int forward = false; forward <= true; ++forward ) for ( int forward = 0; forward <= 1; ++forward )
{ {
int dim = aDim + 1, lastDim = SMESH::DIM_3D, dir = 1; int dim = algoDim + 1, lastDim = SMESH::DIM_3D, dir = 1;
if ( !forward ) { if ( !forward ) {
dim = aDim - 1; lastDim = SMESH::DIM_0D; dir = -1; dim = algoDim - 1; lastDim = SMESH::DIM_0D; dir = -1;
} }
HypothesisData* prevAlgo = algoData; HypothesisData* prevAlgo = algoData;
bool noCompatible = false; bool noCompatible = false;
for ( ; dim * dir <= lastDim * dir; dim += dir) for ( ; dim * dir <= lastDim * dir; dim += dir)
{ {
HypothesisData* nextAlgo = 0;
if ( myMaxShapeDim == SMESH::DIM_3D && a3DAlgo && dim == SMESH::DIM_2D ) {
nextAlgo = a3DAlgo;
}
if ( !isAccessibleDim( dim )) if ( !isAccessibleDim( dim ))
continue; continue;
if ( noCompatible ) { // the selected algo has no compatible ones if ( noCompatible ) { // the selected algo has no compatible ones
@ -1479,57 +1560,37 @@ void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
curAlgo = 0; curAlgo = 0;
} }
// set new available algoritms // set new available algoritms
if (myDlg->currentMeshType() == MT_ANY || dim == SMESH::DIM_1D || dim == SMESH::DIM_0D)
availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], prevAlgo ); QString anCompareType = currentMeshTypeName(myDlg->currentMeshType());
else{ QString anCurrentCompareType = "";
anAvailable.clear(); if ( dim == SMESH::DIM_3D || anCompareType == "ANY" )
myAvailableHypData[dim][Algo].clear(); anCurrentCompareType = anCompareType;
for (int i = 0; i < myFilteredAlgoData[dim].count(); ++i) { else if ( dim == SMESH::DIM_2D ) {
HypothesisData* aCurAlgo = myFilteredAlgoData[dim][ i ]; anCurrentCompareType = (anCompareType == "HEXA" || anCompareType == "QUAD") ? "QUAD" : "TRIA";
if ( isCompatible ( prevAlgo, aCurAlgo, Algo )) { nextAlgo = 0;
anAvailable.append( aCurAlgo->Label );
myAvailableHypData[dim][Algo].append( aCurAlgo );
}
}
} }
availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], prevAlgo, nextAlgo, anCurrentCompareType);
HypothesisData* soleCompatible = 0; HypothesisData* soleCompatible = 0;
if ( anAvailable.count() == 1 ) if ( anAvailable.count() == 1 )
soleCompatible = myAvailableHypData[dim][Algo][0]; soleCompatible = myAvailableHypData[dim][Algo][0];
if ( dim == aTopDim && prevAlgo ) {// all available algoritms should be selectable any way
if (aTopDim == SMESH::DIM_2D && myFilteredAlgoData[dim].count() > 0) {
anAvailable.clear();
for (int i = 0; i < myFilteredAlgoData[dim].count(); ++i) {
HypothesisData* aCurAlgo = myFilteredAlgoData[dim][ i ];
anAvailable.append( aCurAlgo->Label );
}
}
if (aTopDim == SMESH::DIM_3D && myDlg->currentMeshType() == MT_ANY)
availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], 0 );
}
myDlg->tab( dim )->setAvailableHyps( Algo, anAvailable ); myDlg->tab( dim )->setAvailableHyps( Algo, anAvailable );
noCompatible = anAvailable.isEmpty(); noCompatible = anAvailable.isEmpty();
// restore previously selected algo
if (dim == aTopDim && prevAlgo && aTopDim == SMESH::DIM_2D && myFilteredAlgoData[dim].count() > 0) {
algoIndex = myFilteredAlgoData[dim].indexOf( curAlgo );
setCurrentHyp( dim, Algo, algoIndex);
if (algoIndex >= 0)
prevAlgo = algoByDim[ dim ] = myFilteredAlgoData[dim][algoIndex];
else
prevAlgo = algoByDim[ dim ] = 0;
continue;
}
else {
algoIndex = myAvailableHypData[dim][Algo].indexOf( curAlgo ); algoIndex = myAvailableHypData[dim][Algo].indexOf( curAlgo );
} if ( !isSubmesh && algoIndex < 0 && soleCompatible && !forward && dim != SMESH::DIM_0D) {
if ( !isSubmesh && algoIndex < 0 && soleCompatible && !forward && dim != SMESH::DIM_0D)
// select the sole compatible algo // select the sole compatible algo
algoIndex = myAvailableHypData[dim][Algo].indexOf( soleCompatible ); algoIndex = myAvailableHypData[dim][Algo].indexOf( soleCompatible );
}
setCurrentHyp( dim, Algo, algoIndex); setCurrentHyp( dim, Algo, algoIndex);
// remember current algo // remember current algo
prevAlgo = algoByDim[ dim ] = hypData( dim, Algo, algoIndex ); prevAlgo = algoByDim[ dim ] = hypData( dim, Algo, algoIndex );
} }
if ( myMaxShapeDim == SMESH::DIM_3D && forward && algoDim == SMESH::DIM_1D ) {
algoDim = SMESH::DIM_3D;
forward = -1;
a3DAlgo = prevAlgo;
continue;
}
} }
// set hypotheses corresponding to the found algoritms // set hypotheses corresponding to the found algoritms
@ -2608,99 +2669,47 @@ void SMESHGUI_MeshOp::onAlgoSetByMeshType( const int theTabIndex, const int theI
//================================================================================ //================================================================================
void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theIndex) void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theIndex)
{ {
int aDim;
THypDataList anAvailableAlgsData;
QStringList anAvailableAlgs; QStringList anAvailableAlgs;
QString anCompareType = ""; QString anCompareType = currentMeshTypeName( theIndex );
bool isAvailableChoiceAlgo = false; int anCurrentAvailableAlgo = -1;
int anCurrentAvailableAlgo = 0;
bool isNone = true; bool isNone = true;
switch ( theIndex ) { int aDim = SMESH::DIM_3D;
case MT_ANY: if ( theIndex == MT_TRIANGULAR || theIndex == MT_QUADRILATERAL)
anCompareType = "ANY";
aDim = SMESH::DIM_3D;
break;
case MT_TRIANGULAR:
aDim = SMESH::DIM_2D; 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:;
}
bool toCheckIsApplicableToAll = !myIsMesh;
GEOM::GEOM_Object_var aGeomVar;
QString anEntry =
myDlg->selectedObject( myToCreate ? SMESHGUI_MeshDlg::Geom : SMESHGUI_MeshDlg::Obj );
if ( _PTR(SObject) so = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
{
aGeomVar = SMESH::GetGeom( so );
if ( !aGeomVar->_is_nil() && toCheckIsApplicableToAll )
toCheckIsApplicableToAll = ( aGeomVar->GetType() == GEOM_GROUP );
}
if ( anCompareType == "ANY" ) if ( anCompareType == "ANY" )
{ {
bool isReqDisBound = false;
int aReqDim = SMESH::DIM_3D;
for ( int dim = SMESH::DIM_3D; dim >= SMESH::DIM_2D; dim-- ) for ( int dim = SMESH::DIM_3D; dim >= SMESH::DIM_2D; dim-- )
{ {
anCurrentAvailableAlgo = -1;
isNone = currentHyp( dim, Algo ) < 0; 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 and set new algorithm list //return current algo in current tab and set new algorithm list
HypothesisData* algoCur; HypothesisData* algoCur;
if ( !isNone && !myAvailableHypData[dim][Algo].empty() ) { if ( !isNone && !myAvailableHypData[dim][Algo].empty() ) {
algoCur = myAvailableHypData[dim][Algo].at( currentHyp( dim, Algo ) ); algoCur = myAvailableHypData[dim][Algo].at( currentHyp( dim, Algo ) );
} }
myAvailableHypData[dim][Algo].clear(); HypothesisData* prevAlgo = 0;
myFilteredAlgoData[dim].clear(); HypothesisData* nextAlgo = 0;
anAvailableAlgs.clear(); if ( dim == SMESH::DIM_2D ) {
if ( dim != SMESH::DIM_2D || currentHyp( SMESH::DIM_3D, Algo ) < 0 || prevAlgo = hypData( SMESH::DIM_1D, Algo, currentHyp( SMESH::DIM_1D, Algo ) );
myAvailableHypData[SMESH::DIM_3D][Algo].empty() || if ( aDim == SMESH::DIM_3D )
!myAvailableHypData[SMESH::DIM_3D][Algo].at( currentHyp( SMESH::DIM_3D, Algo ) )->InputTypes.isEmpty() ) nextAlgo = hypData( SMESH::DIM_3D, Algo, currentHyp( SMESH::DIM_3D, Algo ) );
{
for (int i = 0 ; i < anAvailableAlgsData.count(); i++)
{
HypothesisData* curAlgo = anAvailableAlgsData.at(i);
if ( aGeomVar->_is_nil() ||
SMESH::IsApplicable( curAlgo->TypeName, aGeomVar, toCheckIsApplicableToAll ))
{
anAvailableAlgs.append( curAlgo->Label );
myAvailableHypData[dim][Algo].append( curAlgo );
myFilteredAlgoData[dim].append( curAlgo );
} }
} // retrieves a list of available algorithms from resources
if ( !isNone && algoCur ) { availableHyps( dim, Algo, anAvailableAlgs, myAvailableHypData[dim][Algo], prevAlgo, nextAlgo, anCompareType);
for (int i = 0 ; i < myAvailableHypData[dim][Algo].count(); i++) anCurrentAvailableAlgo = myAvailableHypData[dim][Algo].indexOf( algoCur );
{ myDlg->tab( dim )->setAvailableHyps( Algo, anAvailableAlgs );
HypothesisData* algoAny = myAvailableHypData[dim][Algo].at(i); setCurrentHyp( dim, Algo, anCurrentAvailableAlgo );
if ( algoAny->Label == algoCur->Label ){ if ( anCurrentAvailableAlgo > -1 )
isAvailableChoiceAlgo = true; isReqDisBound = algoCur->InputTypes.isEmpty();
anCurrentAvailableAlgo = i; else if ( dim != SMESH::DIM_3D && currentHyp( SMESH::DIM_3D, Algo ) >= 0 )
isReqDisBound = true;
if ( isReqDisBound ) {
aReqDim = dim;
break; break;
} }
} }
}
else if ( !isNone ) {
isAvailableChoiceAlgo = true;
anCurrentAvailableAlgo = currentHyp( dim, Algo );
}
}
myDlg->tab( dim )->setAvailableHyps( Algo, anAvailableAlgs );
if ( isAvailableChoiceAlgo )
setCurrentHyp( dim, Algo, anCurrentAvailableAlgo );
}
if ( !myIsOnGeometry ) if ( !myIsOnGeometry )
for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ ) { for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ ) {
if ( i < SMESH::DIM_3D ) myDlg->disableTab( i ); if ( i < SMESH::DIM_3D ) myDlg->disableTab( i );
@ -2708,79 +2717,48 @@ void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theI
} }
else else
for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ ) { for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ ) {
if ( i > myMaxShapeDim ) myDlg->disableTab( i ); if ( i > myMaxShapeDim || ( isReqDisBound && i < aReqDim ) ) myDlg->disableTab( i );
else myDlg->enableTab( i ); else myDlg->enableTab( i );
} }
myDlg->setCurrentTab( theTabIndex ); myDlg->setCurrentTab( theTabIndex );
} }
else else
{ {
QString anCurrentAlgo; HypothesisData* anCurrentAlgo;
bool isReqDisBound = true; bool isReqDisBound = true;
QString anCurrentCompareType = anCompareType; QString anCurrentCompareType = anCompareType;
isNone = currentHyp( aDim, Algo ) < 0; isNone = currentHyp( aDim, Algo ) < 0;
if ( !isNone && !myAvailableHypData[aDim][Algo].empty() && if ( !isNone && !myAvailableHypData[aDim][Algo].empty() )
myAvailableHypData[aDim][Algo].count() != anAvailableAlgsData.count() )
isReqDisBound = myAvailableHypData[aDim][Algo].at( currentHyp( aDim, Algo ) )->InputTypes.isEmpty(); isReqDisBound = myAvailableHypData[aDim][Algo].at( currentHyp( aDim, Algo ) )->InputTypes.isEmpty();
else if ( !isNone )
isReqDisBound = anAvailableAlgsData.at( currentHyp( aDim, Algo ) )->InputTypes.isEmpty();
for ( int dim = aDim; dim >= SMESH::DIM_2D; dim-- ) for ( int dim = aDim; dim >= SMESH::DIM_2D; dim-- )
{ {
bool isNoneAlg = currentHyp( dim, Algo ) < 0; bool isNoneAlg = currentHyp( dim, Algo ) < 0;
isAvailableChoiceAlgo = false; anCurrentAvailableAlgo = -1;
// retrieves a list of available algorithms from resources HypothesisData* prevAlgo = 0;
availableHyps( dim, Algo, anAvailableAlgs, anAvailableAlgsData ); HypothesisData* nextAlgo = 0;
if ( dim == SMESH::DIM_2D ) {
prevAlgo = hypData( SMESH::DIM_1D, Algo, currentHyp( SMESH::DIM_1D, Algo ) );
if ( aDim == SMESH::DIM_3D )
nextAlgo = hypData( SMESH::DIM_3D, Algo, currentHyp( SMESH::DIM_3D, Algo ) );
}
// finding algorithm which is selected // finding algorithm which is selected
if ( !isNoneAlg && !myAvailableHypData[dim][Algo].empty() && if ( !isNoneAlg ) {
myAvailableHypData[dim][Algo].count() != anAvailableAlgsData.count() ) anCurrentAlgo = myAvailableHypData[dim][Algo].at( currentHyp( dim, Algo ) );
anCurrentAlgo = myAvailableHypData[dim][Algo].at( currentHyp( dim, Algo ) )->Label; }
else if ( !isNoneAlg ) // retrieves a list of available algorithms from resources
anCurrentAlgo = anAvailableAlgsData.at( currentHyp( dim, Algo ) )->Label; availableHyps( dim, Algo, anAvailableAlgs, myAvailableHypData[dim][Algo], prevAlgo, nextAlgo, anCurrentCompareType );
anAvailableAlgs.clear();
myAvailableHypData[dim][Algo].clear();
myFilteredAlgoData[dim].clear();
// finding and adding algorithm depending on the type mesh // finding and adding algorithm depending on the type mesh
for ( int i = 0 ; i < anAvailableAlgsData.count(); i++ ) anCurrentAvailableAlgo = myAvailableHypData[dim][Algo].indexOf( anCurrentAlgo );
{
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 == anCurrentCompareType ) {
isAvailableAlgo = true;
break;
}
}
if ( isAvailableAlgo || algoIn->OutputTypes.count()==0 ) {
if ( aGeomVar->_is_nil() || myMaxShapeDim != dim ||
SMESH::IsApplicable( algoIn->TypeName, aGeomVar, toCheckIsApplicableToAll ))
{
anAvailableAlgs.append( algoIn->Label );
myAvailableHypData[dim][Algo].append( algoIn );
myFilteredAlgoData[dim].append( algoIn );
}
}
//algorithm will be active, if the chosen algorithm available in the current mesh type
if ( !isNoneAlg && isAvailableAlgo && algoIn->Label == anCurrentAlgo ) {
isAvailableChoiceAlgo = true;
anCurrentAvailableAlgo = anAvailableAlgs.count() - 1 ;
}
}
//set new algorithm list and select the current algorithm //set new algorithm list and select the current algorithm
myDlg->tab( dim )->setAvailableHyps( Algo, anAvailableAlgs ); myDlg->tab( dim )->setAvailableHyps( Algo, anAvailableAlgs );
anCurrentCompareType = ( anCompareType == "HEXA" ) ? "QUAD" : "TRIA"; anCurrentCompareType = ( anCompareType == "HEXA" || anCompareType == "QUAD" ) ? "QUAD" : "TRIA";
if ( isAvailableChoiceAlgo )
setCurrentHyp( dim, Algo, anCurrentAvailableAlgo ); setCurrentHyp( dim, Algo, anCurrentAvailableAlgo );
else
setCurrentHyp( dim, Algo, -1 );
} }
if ( isNone || isReqDisBound ) { if ( isNone || isReqDisBound ) {
for ( int i = SMESH::DIM_0D; i <= myMaxShapeDim; i++ ) { for ( int i = SMESH::DIM_0D; i <= myMaxShapeDim; i++ ) {
if ( aDim != i ) { if ( aDim != i ) {
myDlg->disableTab( i ); myDlg->disableTab( i );
setCurrentHyp(i, Algo, -1);
} }
} }
} }
@ -2789,65 +2767,86 @@ void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theI
myDlg->disableTab( SMESH::DIM_3D ); myDlg->disableTab( SMESH::DIM_3D );
setCurrentHyp( SMESH::DIM_3D, Algo, -1); setCurrentHyp( SMESH::DIM_3D, Algo, -1);
} }
for ( int i = myMaxShapeDim; i > SMESH::DIM_0D; i-- ) for ( int i = myMaxShapeDim; i > SMESH::DIM_0D; i-- ) {
{ bool isNoneAlg = currentHyp( i, Algo ) < 0;
isReqDisBound = ( currentHyp( i, Algo ) < 0 ) ? true : if ( !isNoneAlg )
myAvailableHypData[i][Algo].at( currentHyp( i, Algo ) )->InputTypes.isEmpty(); isReqDisBound = myAvailableHypData[i][Algo].at( currentHyp( i, Algo ) )->InputTypes.isEmpty();
if ( isReqDisBound ) { else
isReqDisBound = true;
if ( isReqDisBound && isNoneAlg ) {
for (int j = i - 1; j >= SMESH::DIM_0D; j--) { for (int j = i - 1; j >= SMESH::DIM_0D; j--) {
if ( j < aDim && currentHyp( j+1, Algo ) < 0 ) {
myDlg->disableTab( j ); myDlg->disableTab( j );
setCurrentHyp( j , Algo, -1 ); setCurrentHyp( j , Algo, -1 );
} }
}
break; break;
} }
else if ( isNoneAlg ) {
myDlg->disableTab( i );
}
} }
} }
myDlg->enableTab( aDim ); myDlg->enableTab( aDim );
myDlg->setCurrentTab( aDim ); myDlg->setCurrentTab( aDim );
} }
THypDataList anAvailableAlgsData;
QStringList aHypothesesSetsList = SMESH::GetHypothesesSets( aDim ); QStringList aHypothesesSetsList = SMESH::GetHypothesesSets( aDim );
QStringList aFilteredHypothesesSetsList; QStringList aFilteredHypothesesSetsList;
aFilteredHypothesesSetsList.clear(); aFilteredHypothesesSetsList.clear();
QStringList::const_iterator inHypoSetName = aHypothesesSetsList.begin(); QStringList::const_iterator inHypoSetName = aHypothesesSetsList.begin();
for ( ; inHypoSetName != aHypothesesSetsList.end(); ++inHypoSetName ) for ( ; inHypoSetName != aHypothesesSetsList.end(); ++inHypoSetName ) {
{
HypothesesSet* currentHypoSet = SMESH::GetHypothesesSet( *inHypoSetName ); HypothesesSet* currentHypoSet = SMESH::GetHypothesesSet( *inHypoSetName );
bool isAvailable = false; bool isAvailable = false;
currentHypoSet->init( true ); currentHypoSet->init( true );
while ( currentHypoSet->next(), currentHypoSet->more() ) while ( currentHypoSet->next(), currentHypoSet->more() ) {
{
isAvailable = false; isAvailable = false;
if ( HypothesisData* algoDataIn = SMESH::GetHypothesisData( currentHypoSet->current() )) if ( HypothesisData* algoDataIn = SMESH::GetHypothesisData( currentHypoSet->current() )) {
{ for (int i = SMESH::DIM_0D; i <= myMaxShapeDim; i++) {
for (int i = SMESH::DIM_0D; i <= myMaxShapeDim; i++) int anCurrentAvailableAlgo = myAvailableHypData[i][Algo].indexOf( algoDataIn );
{ if ( anCurrentAvailableAlgo > -1 ) {
if ( myAvailableHypData[i][Algo].count() == 0 ) {
availableHyps( i, Algo, anAvailableAlgs, anAvailableAlgsData );
for ( int j = 0 ; j < anAvailableAlgsData.count(); j++ )
{
HypothesisData* aCurAlgo = anAvailableAlgsData.at( j );
if ( aCurAlgo->Label == algoDataIn->Label ){
isAvailable = true; isAvailable = true;
break; break;
} }
} }
} if ( !isAvailable )
else {
for (int j = 0; j < myAvailableHypData[i][Algo].count(); ++j) {
HypothesisData* aCurAlgo = hypData( i, Algo, j );
if ( aCurAlgo->Label == algoDataIn->Label ){
isAvailable = true;
break; break;
} }
} }
}
if ( isAvailable ) break;
}
if ( !isAvailable ) break;
}
}
if ( isAvailable ) if ( isAvailable )
aFilteredHypothesesSetsList.append( *inHypoSetName ); aFilteredHypothesesSetsList.append( *inHypoSetName );
} }
myDlg->setHypoSets( aFilteredHypothesesSetsList ); myDlg->setHypoSets( aFilteredHypothesesSetsList );
} }
//================================================================================
/*!
* \brief Get current name types of mesh
* \param theIndex - current index types of mesh
* \retval QString - result
*/
//================================================================================
QString SMESHGUI_MeshOp::currentMeshTypeName( const int theIndex ) const
{
QString aMeshType = "";
switch ( theIndex ) {
case MT_ANY:
aMeshType = "ANY";
break;
case MT_TRIANGULAR:
aMeshType = "TRIA";
break;
case MT_QUADRILATERAL:
aMeshType = "QUAD";
break;
case MT_TETRAHEDRAL:
aMeshType = "TETRA";
break;
case MT_HEXAHEDRAL:
aMeshType = "HEXA";
break;
default:;
}
return aMeshType;
}

View File

@ -89,13 +89,21 @@ protected slots:
private: private:
typedef QList<HypothesisData*> THypDataList; // typedef: list of hypothesis data typedef QList<HypothesisData*> THypDataList; // typedef: list of hypothesis data
typedef QMap<QString, bool> THypLabelIsAppMap; // typedef: map of hypothesis is applicable
bool isValid( QString& ) const; bool isValid( QString& ) const;
bool isCompatibleToGeometry( HypothesisData* ,
QString,
GEOM::GEOM_Object_var);
bool isCompatibleToMeshType( HypothesisData* ,
QString);
void availableHyps( const int, void availableHyps( const int,
const int, const int,
QStringList&, QStringList&,
THypDataList&, THypDataList&,
HypothesisData* = 0 ) const; HypothesisData* = 0,
HypothesisData* = 0,
const QString& = "");
void existingHyps( const int, void existingHyps( const int,
const int, const int,
_PTR(SObject), _PTR(SObject),
@ -137,6 +145,7 @@ private:
void createMeshTypeList( QStringList& ); void createMeshTypeList( QStringList& );
void setAvailableMeshType( const QStringList& ); void setAvailableMeshType( const QStringList& );
void setFilteredAlgoData( const int, const int ); void setFilteredAlgoData( const int, const int );
QString currentMeshTypeName( const int ) const;
private: private:
@ -152,7 +161,8 @@ private:
// edited mesh/sub-mesh // edited mesh/sub-mesh
// hypdata corresponding to hypotheses present in myDlg // hypdata corresponding to hypotheses present in myDlg
THypDataList myAvailableHypData[4][NbHypTypes]; THypDataList myAvailableHypData[4][NbHypTypes];
THypDataList myFilteredAlgoData[4]; QString myLastGeomToSelect;
THypLabelIsAppMap myHypMapIsApplicable;
bool myIgnoreAlgoSelection; bool myIgnoreAlgoSelection;
HypothesesSet* myHypoSet; HypothesesSet* myHypoSet;
int myDim, myType, myMaxShapeDim; int myDim, myType, myMaxShapeDim;