Salome HOME
22364: EDF SMESH: Create Mesh dialog box improvement: hide inapplicable algorithms...
authoreap <eap@opencascade.com>
Tue, 11 Mar 2014 15:46:54 +0000 (19:46 +0400)
committereap <eap@opencascade.com>
Tue, 11 Mar 2014 15:46:54 +0000 (19:46 +0400)
  1) Some fixes
  2) pass toCheckAll=true to IsApplicable() only if a shape is geom group

src/SMESHGUI/SMESHGUI_MeshOp.cxx
src/SMESH_SWIG/smeshBuilder.py
src/SMESH_SWIG/smesh_algorithm.py

index 626081091cb9276978771eee3155646d58cdae48..5a3702c6438178afd84ee654d72abf7175c01c52 100644 (file)
@@ -41,6 +41,7 @@
 #include <GEOMBase.h>
 #include <GeometryGUI.h>
 #include <GEOM_wrap.hxx>
 #include <GEOMBase.h>
 #include <GeometryGUI.h>
 #include <GEOM_wrap.hxx>
+#include <GEOMImpl_Types.hxx>
 
 // SALOME GUI includes
 #include <SalomeApp_Tools.h>
 
 // SALOME GUI includes
 #include <SalomeApp_Tools.h>
@@ -2535,33 +2536,40 @@ void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theI
   int anCurrentAvailableAlgo = 0;
   bool isNone = true;
   switch ( theIndex ) {
   int anCurrentAvailableAlgo = 0;
   bool isNone = true;
   switch ( theIndex ) {
-  case MT_ANY:{
+  case MT_ANY:
     anCompareType = "ANY";
     aDim = SMESH::DIM_3D;
     anCompareType = "ANY";
     aDim = SMESH::DIM_3D;
-  }
-  break;
-  case MT_TRIANGULAR:{
+    break;
+  case MT_TRIANGULAR:
     aDim = SMESH::DIM_2D;
     anCompareType = "TRIA";
     aDim = SMESH::DIM_2D;
     anCompareType = "TRIA";
-  }
-  break;
-  case MT_QUADRILATERAL:{
+    break;
+  case MT_QUADRILATERAL:
     aDim = SMESH::DIM_2D;
     anCompareType = "QUAD";
     aDim = SMESH::DIM_2D;
     anCompareType = "QUAD";
-  }
-  break;
-  case MT_TETRAHEDRAL:{
+    break;
+  case MT_TETRAHEDRAL:
     aDim = SMESH::DIM_3D;
     anCompareType = "TETRA";
     aDim = SMESH::DIM_3D;
     anCompareType = "TETRA";
-  }
-  break;
-  case MT_HEXAHEDRAL:{
+    break;
+  case MT_HEXAHEDRAL:
     aDim = SMESH::DIM_3D;
     anCompareType = "HEXA";
     aDim = SMESH::DIM_3D;
     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" )
   {
     for ( int dim = SMESH::DIM_2D; dim <= SMESH::DIM_3D; dim++ )
   if ( anCompareType == "ANY" )
   {
     for ( int dim = SMESH::DIM_2D; dim <= SMESH::DIM_3D; dim++ )
@@ -2572,7 +2580,7 @@ void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theI
       availableHyps( dim, Algo, anAvailableAlgs, anAvailableAlgsData );
       //return current algo in current tab and set new algorithm list
       HypothesisData* algoCur;
       availableHyps( dim, Algo, anAvailableAlgs, anAvailableAlgsData );
       //return current algo in current tab and set new algorithm list
       HypothesisData* algoCur;
-      if ( !isNone && !myAvailableHypData[dim][Algo].empty() ){
+      if ( !isNone && !myAvailableHypData[dim][Algo].empty() ) {
         algoCur = myAvailableHypData[dim][Algo].at( currentHyp( dim, Algo ) );
       }
       myAvailableHypData[dim][Algo].clear();
         algoCur = myAvailableHypData[dim][Algo].at( currentHyp( dim, Algo ) );
       }
       myAvailableHypData[dim][Algo].clear();
@@ -2580,19 +2588,14 @@ void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theI
       for (int i = 0 ; i < anAvailableAlgsData.count(); i++)
       {
         HypothesisData* curAlgo = anAvailableAlgsData.at(i);
       for (int i = 0 ; i < anAvailableAlgsData.count(); 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 );
           myAvailableHypData[dim][Algo].append( curAlgo );
         }
       }
           anAvailableAlgs.append( curAlgo->Label );
           myAvailableHypData[dim][Algo].append( curAlgo );
         }
       }
-      if ( !isNone && algoCur ){
+      if ( !isNone && algoCur ) {
         for (int i = 0 ; i < myAvailableHypData[dim][Algo].count(); i++)
         {
           HypothesisData* algoAny = myAvailableHypData[dim][Algo].at(i);
         for (int i = 0 ; i < myAvailableHypData[dim][Algo].count(); i++)
         {
           HypothesisData* algoAny = myAvailableHypData[dim][Algo].at(i);
@@ -2603,7 +2606,7 @@ void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theI
           }
         }
       }
           }
         }
       }
-      else if ( !isNone ){
+      else if ( !isNone ) {
         isAvailableChoiceAlgo = true;
         anCurrentAvailableAlgo = currentHyp( dim, Algo );
       }
         isAvailableChoiceAlgo = true;
         anCurrentAvailableAlgo = currentHyp( dim, Algo );
       }
@@ -2657,27 +2660,22 @@ void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theI
         QStringList::const_iterator inElemType = algoIn->OutputTypes.begin();
         for ( ; inElemType != algoIn->OutputTypes.end(); inElemType++ )
         {
         QStringList::const_iterator inElemType = algoIn->OutputTypes.begin();
         for ( ; inElemType != algoIn->OutputTypes.end(); inElemType++ )
         {
-          if ( *inElemType == anCurrentCompareType ){
+          if ( *inElemType == anCurrentCompareType ) {
             isAvailableAlgo = true;
             break;
           }
         }
             isAvailableAlgo = true;
             break;
           }
         }
-        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 ( isAvailableAlgo || algoIn->OutputTypes.count()==0 ) {
           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 );
             myAvailableHypData[dim][Algo].append( algoIn );
             myFilteredAlgoData[dim].append( algoIn );
           }
         }
         //algorithm will be active, if the chosen algorithm available in the current mesh type
             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 ){
+        if ( !isNoneAlg &&  isAvailableAlgo && algoIn->Label == anCurrentAlgo ) {
           isAvailableChoiceAlgo = true;
           anCurrentAvailableAlgo = anAvailableAlgs.count() - 1 ;
         }
           isAvailableChoiceAlgo = true;
           anCurrentAvailableAlgo = anAvailableAlgs.count() - 1 ;
         }
@@ -2700,7 +2698,7 @@ void SMESHGUI_MeshOp::setFilteredAlgoData( const int theTabIndex, const int theI
         }
       }
     }
         }
       }
     }
-    else if ( !isNone ){
+    else if ( !isNone ) {
       if ( aDim == SMESH::DIM_2D){
         myDlg->disableTab( SMESH::DIM_3D );
         setCurrentHyp( SMESH::DIM_3D, Algo, -1);
       if ( aDim == SMESH::DIM_2D){
         myDlg->disableTab( SMESH::DIM_3D );
         setCurrentHyp( SMESH::DIM_3D, Algo, -1);
index 7c4acfad49e67aa0dc5f2b692c91a7cdd0351267..222e4f9dcfb23434cf9008289cab08e9fb4466f6 100644 (file)
@@ -1563,25 +1563,24 @@ class Mesh:
             if not geom:
                 geom = self.mesh.GetShapeToMesh()
             pass
             if not geom:
                 geom = self.mesh.GetShapeToMesh()
             pass
-        hyp_name = GetName( hyp )
-        geom_name = ""
-        if geom:
-            geom_name = geom.GetName()
         isApplicable = True
         if self.mesh.HasShapeToMesh():
             hyp_type     = hyp.GetName()
             lib_name     = hyp.GetLibName()
             isSubMesh    = ( not geom.IsSame( self.mesh.GetShapeToMesh() ))
         isApplicable = True
         if self.mesh.HasShapeToMesh():
             hyp_type     = hyp.GetName()
             lib_name     = hyp.GetLibName()
             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:
             AssureGeomPublished( self, geom, "shape for %s" % hyp.GetName())
             status = self.mesh.AddHypothesis(geom, hyp)
         if isApplicable:
             AssureGeomPublished( self, geom, "shape for %s" % hyp.GetName())
             status = self.mesh.AddHypothesis(geom, hyp)
-            isAlgo = hyp._narrow( SMESH_Algo )
-            TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
-            return status
         else:
         else:
-            TreatHypoStatus( HYP_BAD_GEOMETRY, hyp_name, geom_name, isAlgo )
-            return HYP_BAD_GEOMETRY
+            status = HYP_BAD_GEOMETRY
+        hyp_name = GetName( hyp )
+        geom_name = ""
+        if geom:
+            geom_name = geom.GetName()
+        isAlgo = hyp._narrow( SMESH_Algo )
+        TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
+        return status
 
     ## Return True if an algorithm of hypothesis is assigned to a given shape
     #  @param hyp a hypothesis to check
 
     ## Return True if an algorithm of hypothesis is assigned to a given shape
     #  @param hyp a hypothesis to check
index a0c368a0aa21fb5f924edf56b8d739e5be9c4025..cac705e124f8778b75257cd2bf081447e05d7e61 100644 (file)
@@ -195,17 +195,11 @@ class Mesh_Algorithm:
         if geom is None and mesh.mesh.HasShapeToMesh():
             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
         self.mesh = mesh
         if geom is None and mesh.mesh.HasShapeToMesh():
             raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
         self.mesh = mesh
-        name = ""
         if not geom or geom.IsSame( mesh.geom ):
             self.geom = mesh.geom
         else:
             self.geom = geom
             AssureGeomPublished( mesh, geom )
         if not geom or geom.IsSame( mesh.geom ):
             self.geom = mesh.geom
         else:
             self.geom = geom
             AssureGeomPublished( mesh, geom )
-            try:
-                name = GetName(geom)
-                pass
-            except:
-                pass
             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
         self.algo = algo
         status = mesh.AddHypothesis(self.algo, self.geom)
             self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
         self.algo = algo
         status = mesh.AddHypothesis(self.algo, self.geom)