22364: EDF SMESH: Create Mesh dialog box improvement: hide inapplicable algorithms/hypotheses

1) Some fixes
  2) pass toCheckAll=true to IsApplicable() only if a shape is geom group
This commit is contained in:
eap 2014-03-11 19:46:54 +04:00
parent 28140bb1c8
commit 395112afac
3 changed files with 43 additions and 52 deletions

View File

@ -41,6 +41,7 @@
#include <GEOMBase.h> #include <GEOMBase.h>
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOM_wrap.hxx> #include <GEOM_wrap.hxx>
#include <GEOMImpl_Types.hxx>
// SALOME GUI includes // SALOME GUI includes
#include <SalomeApp_Tools.h> #include <SalomeApp_Tools.h>
@ -2535,33 +2536,40 @@ void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theI
int anCurrentAvailableAlgo = 0; int anCurrentAvailableAlgo = 0;
bool isNone = true; bool isNone = true;
switch ( theIndex ) { switch ( theIndex ) {
case MT_ANY:{ case MT_ANY:
anCompareType = "ANY"; anCompareType = "ANY";
aDim = SMESH::DIM_3D; aDim = SMESH::DIM_3D;
}
break; break;
case MT_TRIANGULAR:{ case MT_TRIANGULAR:
aDim = SMESH::DIM_2D; aDim = SMESH::DIM_2D;
anCompareType = "TRIA"; anCompareType = "TRIA";
}
break; break;
case MT_QUADRILATERAL:{ case MT_QUADRILATERAL:
aDim = SMESH::DIM_2D; aDim = SMESH::DIM_2D;
anCompareType = "QUAD"; anCompareType = "QUAD";
}
break; break;
case MT_TETRAHEDRAL:{ case MT_TETRAHEDRAL:
aDim = SMESH::DIM_3D; aDim = SMESH::DIM_3D;
anCompareType = "TETRA"; anCompareType = "TETRA";
}
break; break;
case MT_HEXAHEDRAL:{ case MT_HEXAHEDRAL:
aDim = SMESH::DIM_3D; aDim = SMESH::DIM_3D;
anCompareType = "HEXA"; anCompareType = "HEXA";
}
break; break;
default:; default:;
} }
bool toCheckIsApplicableToAll = !myIsMesh;
GEOM::GEOM_Object_var aGeomVar;
QString anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
if ( _PTR(SObject) so = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
{
CORBA::Object_var obj = _CAST( SObject,so )->GetObject();
aGeomVar = GEOM::GEOM_Object::_narrow( obj );
if ( !aGeomVar->_is_nil() && toCheckIsApplicableToAll )
toCheckIsApplicableToAll = ( aGeomVar->GetType() == GEOM_GROUP );
}
if ( anCompareType == "ANY" ) if ( anCompareType == "ANY" )
{ {
for ( int dim = SMESH::DIM_2D; dim <= SMESH::DIM_3D; dim++ ) for ( int dim = SMESH::DIM_2D; dim <= SMESH::DIM_3D; dim++ )
@ -2580,14 +2588,9 @@ void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theI
for (int i = 0 ; i < anAvailableAlgsData.count(); i++) for (int i = 0 ; i < anAvailableAlgsData.count(); i++)
{ {
HypothesisData* curAlgo = anAvailableAlgsData.at(i); HypothesisData* curAlgo = anAvailableAlgsData.at(i);
QString anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();
if ( _PTR(SObject) pGeom = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
{
aGeomVar= GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
}
if ( aGeomVar->_is_nil() || if ( aGeomVar->_is_nil() ||
( !aGeomVar->_is_nil() && SMESH::IsApplicable( curAlgo->TypeName, aGeomVar, !myIsMesh ))){ SMESH::IsApplicable( curAlgo->TypeName, aGeomVar, toCheckIsApplicableToAll ))
{
anAvailableAlgs.append( curAlgo->Label ); anAvailableAlgs.append( curAlgo->Label );
myAvailableHypData[dim][Algo].append( curAlgo ); myAvailableHypData[dim][Algo].append( curAlgo );
} }
@ -2663,14 +2666,9 @@ void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theI
} }
} }
if ( isAvailableAlgo || algoIn->OutputTypes.count()==0 ) { if ( isAvailableAlgo || algoIn->OutputTypes.count()==0 ) {
QString anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();
if ( _PTR(SObject) pGeom = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
{
aGeomVar= GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
}
if ( aGeomVar->_is_nil() || myMaxShapeDim != dim || if ( aGeomVar->_is_nil() || myMaxShapeDim != dim ||
( !aGeomVar->_is_nil() && SMESH::IsApplicable( algoIn->TypeName, aGeomVar, !myIsMesh ))){ SMESH::IsApplicable( algoIn->TypeName, aGeomVar, toCheckIsApplicableToAll ))
{
anAvailableAlgs.append( algoIn->Label ); anAvailableAlgs.append( algoIn->Label );
myAvailableHypData[dim][Algo].append( algoIn ); myAvailableHypData[dim][Algo].append( algoIn );
myFilteredAlgoData[dim].append( algoIn ); myFilteredAlgoData[dim].append( algoIn );

View File

@ -1563,25 +1563,24 @@ class Mesh:
if not geom: if not geom:
geom = self.mesh.GetShapeToMesh() geom = self.mesh.GetShapeToMesh()
pass pass
hyp_name = GetName( hyp )
geom_name = ""
if geom:
geom_name = geom.GetName()
isApplicable = True isApplicable = True
if self.mesh.HasShapeToMesh(): if self.mesh.HasShapeToMesh():
hyp_type = hyp.GetName() hyp_type = hyp.GetName()
lib_name = hyp.GetLibName() lib_name = hyp.GetLibName()
isSubMesh = ( not geom.IsSame( self.mesh.GetShapeToMesh() )) isSubMesh = ( not geom.IsSame( self.mesh.GetShapeToMesh() ))
isApplicable = self.smeshpyD.IsApplicable(hyp_name, lib_name, geom, isSubMesh) isApplicable = self.smeshpyD.IsApplicable(hyp_type, lib_name, geom, isSubMesh)
if isApplicable: if isApplicable:
AssureGeomPublished( self, geom, "shape for %s" % hyp.GetName()) AssureGeomPublished( self, geom, "shape for %s" % hyp.GetName())
status = self.mesh.AddHypothesis(geom, hyp) status = self.mesh.AddHypothesis(geom, hyp)
else:
status = HYP_BAD_GEOMETRY
hyp_name = GetName( hyp )
geom_name = ""
if geom:
geom_name = geom.GetName()
isAlgo = hyp._narrow( SMESH_Algo ) isAlgo = hyp._narrow( SMESH_Algo )
TreatHypoStatus( status, hyp_name, geom_name, isAlgo ) TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
return status return status
else:
TreatHypoStatus( HYP_BAD_GEOMETRY, hyp_name, geom_name, isAlgo )
return HYP_BAD_GEOMETRY
## Return True if an algorithm of hypothesis is assigned to a given shape ## Return True if an algorithm of hypothesis is assigned to a given shape
# @param hyp a hypothesis to check # @param hyp a hypothesis to check

View File

@ -195,17 +195,11 @@ class Mesh_Algorithm:
if geom is None and mesh.mesh.HasShapeToMesh(): if geom is None and mesh.mesh.HasShapeToMesh():
raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape" raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
self.mesh = mesh self.mesh = mesh
name = ""
if not geom or geom.IsSame( mesh.geom ): if not geom or geom.IsSame( mesh.geom ):
self.geom = mesh.geom self.geom = mesh.geom
else: else:
self.geom = geom self.geom = geom
AssureGeomPublished( mesh, geom ) AssureGeomPublished( mesh, geom )
try:
name = GetName(geom)
pass
except:
pass
self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName()) self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
self.algo = algo self.algo = algo
status = mesh.AddHypothesis(self.algo, self.geom) status = mesh.AddHypothesis(self.algo, self.geom)