Salome HOME
SALOME PAL V1_4_1
[modules/smesh.git] / src / SMESH / SMESH_Algo.cxx
index 234b7ecce8e0a661b71e2f94d35c738fea1574ad..cef1ea89c70ad30bd520ac6fefa25a5cc81cf69a 100644 (file)
@@ -26,7 +26,6 @@
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
 using namespace std;
 #include "SMESH_Algo.hxx"
 #include "SMESH_Gen.hxx"
@@ -39,6 +38,8 @@ using namespace std;
 #include "utilities.h"
 
 #include <algorithm>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
 
 //=============================================================================
 /*!
@@ -52,6 +53,8 @@ SMESH_Algo::SMESH_Algo(int hypId, int studyId,
 //   _compatibleHypothesis.push_back("hypothese_bidon");
        _type = ALGO;
        gen->_mapAlgo[hypId] = this;
+
+        _onlyUnaryInput = _requireDescretBoundary = true;
 }
 
 //=============================================================================
@@ -75,77 +78,6 @@ const vector < string > &SMESH_Algo::GetCompatibleHypothesis()
        return _compatibleHypothesis;
 }
 
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-ostream & SMESH_Algo::SaveTo(ostream & save)
-{
-       return save << this;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-istream & SMESH_Algo::LoadFrom(istream & load)
-{
-       return load >> (*this);
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-ostream & operator <<(ostream & save, SMESH_Algo & hyp)
-{
-       return save;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-istream & operator >>(istream & load, SMESH_Algo & hyp)
-{
-       return load;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-bool SMESH_Algo::CheckHypothesis(SMESH_Mesh & aMesh,
-       const TopoDS_Shape & aShape)
-{
-       MESSAGE("SMESH_Algo::CheckHypothesis");
-       ASSERT(0);                                      // use method from derived classes
-       return false;
-}
-
-//=============================================================================
-/*!
- *  
- */
-//=============================================================================
-
-bool SMESH_Algo::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
-{
-       MESSAGE("SMESH_Algo::Compute");
-       ASSERT(0);                                      // use method from derived classes
-       return false;
-}
-
 //=============================================================================
 /*!
  *  List the hypothesis used by the algorithm associated to the shape.
@@ -164,12 +96,21 @@ const list <const SMESHDS_Hypothesis *> & SMESH_Algo::GetUsedHypothesis(
        int nbHyp = _usedHypList.size();
        if (nbHyp == 0)
        {
-               TopoDS_Shape mainShape = aMesh.GetMeshDS()->ShapeToMesh();
-               if (!mainShape.IsSame(aShape))
-               {
-                       _usedHypList = GetAppliedHypothesis(aMesh, mainShape);  // copy
-                       nbHyp = _usedHypList.size();
-               }
+          TopTools_ListIteratorOfListOfShape ancIt( aMesh.GetAncestors( aShape ));
+          for (; ancIt.More(); ancIt.Next())
+          {
+            const TopoDS_Shape& ancestor = ancIt.Value();
+            _usedHypList = GetAppliedHypothesis(aMesh, ancestor);      // copy
+            nbHyp = _usedHypList.size();
+            if (nbHyp == 1)
+              break;
+          }
+//             TopoDS_Shape mainShape = aMesh.GetMeshDS()->ShapeToMesh();
+//             if (!mainShape.IsSame(aShape))
+//             {
+//                     _usedHypList = GetAppliedHypothesis(aMesh, mainShape);  // copy
+//                     nbHyp = _usedHypList.size();
+//             }
        }
        if (nbHyp > 1)
                _usedHypList.clear();   //only one compatible hypothesis allowed