Salome HOME
0020452: EDF 1056 SMESH : 2D Projection Issue
[modules/smesh.git] / src / SMESH / SMESH_subMesh.cxx
index 6c484c80a20e6d9eff3ddef37a83010a4532a7c4..efd05b9c1c94bd64d7eb07f3dc25736a56db8f8a 100644 (file)
@@ -23,7 +23,6 @@
 //  File   : SMESH_subMesh.cxx
 //  Author : Paul RASCLE, EDF
 //  Module : SMESH
-//  $Header$
 //
 #include "SMESH_subMesh.hxx"
 
@@ -609,6 +608,7 @@ SMESH_Hypothesis::Hypothesis_Status
 
   int oldAlgoState = _algoState;
   bool modifiedHyp = (event == MODIF_HYP);  // if set to true, force event MODIF_ALGO_STATE
+  bool needFullClean = false;
 
   bool isApplicableHyp = IsApplicableHypotesis( anHyp );
 
@@ -625,6 +625,15 @@ SMESH_Hypothesis::Hypothesis_Status
     // ----------------------
     if (isApplicableHyp && !_father->IsNotConformAllowed() && !IsConform( algo ))
       return SMESH_Hypothesis::HYP_NOTCONFORM;
+
+    // check if all-dimensional algo is hidden by other local one
+    if ( event == ADD_ALGO ) {
+      SMESH_HypoFilter filter( SMESH_HypoFilter::HasType( algo->GetType() ));
+      filter.Or( SMESH_HypoFilter::HasType( algo->GetType()+1 ));
+      filter.Or( SMESH_HypoFilter::HasType( algo->GetType()+2 ));
+      if ( SMESH_Algo * curAlgo = (SMESH_Algo*) _father->GetHypothesis( _subShape, filter, true ))
+        needFullClean = ( !curAlgo->NeedDescretBoundary() );
+    }
   }
 
   // ----------------------------------
@@ -658,10 +667,7 @@ SMESH_Hypothesis::Hypothesis_Status
         // clean all mesh in the tree of the current submesh;
         // we must perform it now because later
         // we will have no information about the type of the removed algo
-        CleanDependants();
-       ComputeStateEngine( CLEAN );
-        CleanDependsOn();
-        ComputeSubMeshStateEngine( CHECK_COMPUTE_STATE );
+        needFullClean = true;
       }
     }
   }
@@ -1012,6 +1018,13 @@ SMESH_Hypothesis::Hypothesis_Status
     }
   }
 
+  if ( needFullClean ) {
+    // added or removed algo is all-dimensional
+    ComputeStateEngine( CLEAN );
+    CleanDependsOn();
+    ComputeSubMeshStateEngine( CHECK_COMPUTE_STATE );
+  }
+
   if (stateChange || modifiedHyp)
     ComputeStateEngine(MODIF_ALGO_STATE);
 
@@ -1564,6 +1577,47 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
   return ret;
 }
 
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_subMesh::Evaluate(MapShapeNbElems& aResMap)
+{
+  _computeError.reset();
+
+  bool ret = true;
+
+  if (_subShape.ShapeType() == TopAbs_VERTEX) {
+    std::vector<int> aVec(17);
+    aVec[0] = 1;
+    for(int i=1; i<17; i++) aVec[i] = 0;
+    aResMap.insert(std::make_pair(this,aVec));
+    return ret;
+  }
+
+  SMESH_Gen *gen = _father->GetGen();
+  SMESH_Algo *algo = 0;
+  SMESH_Hypothesis::Hypothesis_Status hyp_status;
+
+  algo = gen->GetAlgo((*_father), _subShape);
+  if(algo) {
+    ret = algo->CheckHypothesis((*_father), _subShape, hyp_status);
+    if (!ret) return false;
+
+    TopoDS_Shape shape = _subShape;
+
+    _computeError = SMESH_ComputeError::New(COMPERR_OK,"",algo);
+
+    ret = algo->Evaluate((*_father), shape, aResMap);
+  }
+
+  return ret;
+}
+
+
 //=======================================================================
 /*!
  * \brief Update compute_state by _computeError and send proper events to