Salome HOME
Update to match the change of SMDS (new DS).
authorjrt <jrt>
Thu, 4 Sep 2003 09:21:41 +0000 (09:21 +0000)
committerjrt <jrt>
Thu, 4 Sep 2003 09:21:41 +0000 (09:21 +0000)
13 files changed:
src/SMESH/SMESH_Algo.cxx
src/SMESH/SMESH_Algo.hxx
src/SMESH/SMESH_Gen.cxx
src/SMESH/SMESH_Gen.hxx
src/SMESH/SMESH_Hexa_3D.cxx
src/SMESH/SMESH_MEFISTO_2D.cxx
src/SMESH/SMESH_MaxElementArea.hxx
src/SMESH/SMESH_Mesh.cxx
src/SMESH/SMESH_Mesh.hxx
src/SMESH/SMESH_Quadrangle_2D.cxx
src/SMESH/SMESH_Regular_1D.cxx
src/SMESH/SMESH_subMesh.cxx
src/SMESH/SMESH_subMesh.hxx

index b35793e..234b7ec 100644 (file)
@@ -32,9 +32,6 @@ using namespace std;
 #include "SMESH_Gen.hxx"
 #include "SMESH_Mesh.hxx"
 
-#include "SMESHDS_ListOfPtrHypothesis.hxx"
-#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
-
 #include <GeomAdaptor_Curve.hxx>
 #include <BRep_Tool.hxx>
 #include <GCPnts_AbscissaPoint.hxx>
@@ -49,12 +46,12 @@ using namespace std;
  */
 //=============================================================================
 
-SMESH_Algo::SMESH_Algo(int hypId, int studyId, SMESH_Gen* gen)
-  SMESH_Hypothesis(hypId, studyId, gen)
+SMESH_Algo::SMESH_Algo(int hypId, int studyId,
+       SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen)
 {
 //   _compatibleHypothesis.push_back("hypothese_bidon");
-  _type = ALGO;
-  gen->_mapAlgo[hypId] = this;
+       _type = ALGO;
+       gen->_mapAlgo[hypId] = this;
 }
 
 //=============================================================================
@@ -73,9 +70,9 @@ SMESH_Algo::~SMESH_Algo()
  */
 //=============================================================================
 
-const vector<string> &  SMESH_Algo::GetCompatibleHypothesis()
+const vector < string > &SMESH_Algo::GetCompatibleHypothesis()
 {
-  return _compatibleHypothesis;
+       return _compatibleHypothesis;
 }
 
 //=============================================================================
@@ -86,7 +83,7 @@ const vector<string> &  SMESH_Algo::GetCompatibleHypothesis()
 
 ostream & SMESH_Algo::SaveTo(ostream & save)
 {
-  return save << this;
+       return save << this;
 }
 
 //=============================================================================
@@ -97,7 +94,7 @@ ostream & SMESH_Algo::SaveTo(ostream & save)
 
 istream & SMESH_Algo::LoadFrom(istream & load)
 {
-  return load >> (*this);
+       return load >> (*this);
 }
 
 //=============================================================================
@@ -106,9 +103,9 @@ istream & SMESH_Algo::LoadFrom(istream & load)
  */
 //=============================================================================
 
-ostream& operator << (ostream & save, SMESH_Algo & hyp)
+ostream & operator <<(ostream & save, SMESH_Algo & hyp)
 {
-  return save;
+       return save;
 }
 
 //=============================================================================
@@ -117,9 +114,9 @@ ostream& operator << (ostream & save, SMESH_Algo & hyp)
  */
 //=============================================================================
 
-istream& operator >> (istream & load, SMESH_Algo & hyp)
+istream & operator >>(istream & load, SMESH_Algo & hyp)
 {
-  return load;
+       return load;
 }
 
 //=============================================================================
@@ -128,12 +125,12 @@ istream& operator >> (istream & load, SMESH_Algo & hyp)
  */
 //=============================================================================
 
-bool SMESH_Algo::CheckHypothesis(SMESH_Mesh& aMesh,
-                                const TopoDS_Shape& aShape)
+bool SMESH_Algo::CheckHypothesis(SMESH_Mesh & aMesh,
+       const TopoDS_Shape & aShape)
 {
-  MESSAGE("SMESH_Algo::CheckHypothesis");
-  ASSERT(0); // use method from derived classes
-  return false;
+       MESSAGE("SMESH_Algo::CheckHypothesis");
+       ASSERT(0);                                      // use method from derived classes
+       return false;
 }
 
 //=============================================================================
@@ -142,12 +139,11 @@ bool SMESH_Algo::CheckHypothesis(SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-bool SMESH_Algo::Compute(SMESH_Mesh& aMesh,
-                        const TopoDS_Shape& aShape)
+bool SMESH_Algo::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
 {
-  MESSAGE("SMESH_Algo::Compute");
-  ASSERT(0); // use method from derived classes
-  return false;
+       MESSAGE("SMESH_Algo::Compute");
+       ASSERT(0);                                      // use method from derived classes
+       return false;
 }
 
 //=============================================================================
@@ -160,24 +156,24 @@ bool SMESH_Algo::Compute(SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-const list<SMESHDS_Hypothesis*>&
-SMESH_Algo::GetUsedHypothesis(SMESH_Mesh& aMesh,
-                             const TopoDS_Shape& aShape)
+const list <const SMESHDS_Hypothesis *> & SMESH_Algo::GetUsedHypothesis(
+       SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
 {
-  _usedHypList.clear();
-  _usedHypList = GetAppliedHypothesis(aMesh, aShape); // copy
-  int nbHyp = _usedHypList.size();
-  if (nbHyp == 0)
-    {
-      TopoDS_Shape mainShape = aMesh.GetMeshDS()->ShapeToMesh();
-      if (!mainShape.IsSame(aShape))
+       _usedHypList.clear();
+       _usedHypList = GetAppliedHypothesis(aMesh, aShape);     // copy
+       int nbHyp = _usedHypList.size();
+       if (nbHyp == 0)
        {
-         _usedHypList  = GetAppliedHypothesis(aMesh, mainShape); // copy
-         nbHyp = _usedHypList.size();
+               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
-  return _usedHypList;
+       if (nbHyp > 1)
+               _usedHypList.clear();   //only one compatible hypothesis allowed
+       return _usedHypList;
 }
 
 //=============================================================================
@@ -188,56 +184,54 @@ SMESH_Algo::GetUsedHypothesis(SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-const list<SMESHDS_Hypothesis*>&
-SMESH_Algo::GetAppliedHypothesis(SMESH_Mesh& aMesh,
-                                const TopoDS_Shape& aShape)
+const list<const SMESHDS_Hypothesis *> & SMESH_Algo::GetAppliedHypothesis(
+       SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
 {
-  const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
-  const SMESHDS_ListOfPtrHypothesis& listHyp = meshDS->GetHypothesis(aShape);
-  SMESHDS_ListIteratorOfListOfPtrHypothesis it(listHyp);
-
-  int hypType;
-  string hypName;
-
-  _appliedHypList.clear();
-  while (it.More())
-    {
-      SMESHDS_Hypothesis* anHyp = it.Value();
-      hypType = anHyp->GetType();
-      //SCRUTE(hypType);
-      if (hypType == SMESHDS_Hypothesis::PARAM_ALGO)
+       const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+       const list<const SMESHDS_Hypothesis*> & listHyp = meshDS->GetHypothesis(aShape);
+       list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
+
+       int hypType;
+       string hypName;
+
+       _appliedHypList.clear();
+       while (it!=listHyp.end())
        {
-         hypName = anHyp->GetName();
-         vector<string>::iterator ith = find(_compatibleHypothesis.begin(),
-                                             _compatibleHypothesis.end(),
-                                             hypName);
-         if (ith != _compatibleHypothesis.end()) // count only relevant 
-           {
-             _appliedHypList.push_back(anHyp);
-             //SCRUTE(hypName);
-           }
+               const SMESHDS_Hypothesis *anHyp = *it;
+               hypType = anHyp->GetType();
+               //SCRUTE(hypType);
+               if (hypType == SMESHDS_Hypothesis::PARAM_ALGO)
+               {
+                       hypName = anHyp->GetName();
+                       vector < string >::iterator ith =
+                               find(_compatibleHypothesis.begin(), _compatibleHypothesis.end(),
+                               hypName);
+                       if (ith != _compatibleHypothesis.end()) // count only relevant 
+                       {
+                               _appliedHypList.push_back(anHyp);
+                               //SCRUTE(hypName);
+                       }
+               }
+               it++;
        }
-      it.Next();
-    }
-  return _appliedHypList;
+       return _appliedHypList;
 }
 
-
 //=============================================================================
 /*!
  *  Compute length of an edge
  */
 //=============================================================================
 
-double SMESH_Algo::EdgeLength(const TopoDS_Edge& E)
+double SMESH_Algo::EdgeLength(const TopoDS_Edge & E)
 {
-  double UMin = 0, UMax = 0;
-  TopLoc_Location L;
-  if (BRep_Tool::Degenerated(E)) return 0;
-  Handle (Geom_Curve) C = BRep_Tool::Curve(E, L, UMin, UMax);
-  GeomAdaptor_Curve AdaptCurve(C);
-  GCPnts_AbscissaPoint gabs;
-  double length = gabs.Length(AdaptCurve, UMin, UMax);
-  return length;
+       double UMin = 0, UMax = 0;
+       TopLoc_Location L;
+       if (BRep_Tool::Degenerated(E))
+               return 0;
+       Handle(Geom_Curve) C = BRep_Tool::Curve(E, L, UMin, UMax);
+       GeomAdaptor_Curve AdaptCurve(C);
+       GCPnts_AbscissaPoint gabs;
+       double length = gabs.Length(AdaptCurve, UMin, UMax);
+       return length;
 }
-
index ebfbbc1..53a0fbd 100644 (file)
 #include <string>
 #include <vector>
 #include <list>
+using namespace std;
 
 class SMESH_gen;
 class SMESH_Mesh;
 
-class SMESH_Algo:
-  public SMESH_Hypothesis
+class SMESH_Algo:public SMESH_Hypothesis
 {
-public:
-  SMESH_Algo(int hypId, int studyId, SMESH_Gen* gen);
-  virtual ~SMESH_Algo();
+  public:
+       SMESH_Algo(int hypId, int studyId, SMESH_Gen * gen);
+         virtual ~ SMESH_Algo();
 
-  const vector<string> & GetCompatibleHypothesis();
-  virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
-                              const TopoDS_Shape& aShape);
+       const vector < string > &GetCompatibleHypothesis();
+       virtual bool CheckHypothesis(SMESH_Mesh & aMesh,
+               const TopoDS_Shape & aShape);
 
-  virtual bool Compute(SMESH_Mesh& aMesh,
-                      const TopoDS_Shape& aShape);
+       virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
 
-  virtual const list<SMESHDS_Hypothesis*>&
-  GetUsedHypothesis(SMESH_Mesh& aMesh,
-                   const TopoDS_Shape& aShape);
+       virtual const list <const SMESHDS_Hypothesis *> &
+               GetUsedHypothesis(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
 
-  const list<SMESHDS_Hypothesis*>&
-  GetAppliedHypothesis(SMESH_Mesh& aMesh,
-                      const TopoDS_Shape& aShape);
+       const list <const SMESHDS_Hypothesis *> &
+               GetAppliedHypothesis(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
 
-  static double EdgeLength(const TopoDS_Edge& E);
+       static double EdgeLength(const TopoDS_Edge & E);
 
-  virtual ostream & SaveTo(ostream & save);
-  virtual istream & LoadFrom(istream & load);
-  friend ostream& operator << (ostream & save, SMESH_Algo & hyp);
-  friend istream& operator >> (istream & load, SMESH_Algo & hyp);
+       virtual ostream & SaveTo(ostream & save);
+       virtual istream & LoadFrom(istream & load);
+       friend ostream & operator <<(ostream & save, SMESH_Algo & hyp);
+       friend istream & operator >>(istream & load, SMESH_Algo & hyp);
 
-protected:
-  vector<string> _compatibleHypothesis;
-  list<SMESHDS_Hypothesis*> _appliedHypList;
-  list<SMESHDS_Hypothesis*> _usedHypList;
+  protected:
+         vector<string> _compatibleHypothesis;
+         list<const SMESHDS_Hypothesis *> _appliedHypList;
+         list<const SMESHDS_Hypothesis *> _usedHypList;
 };
 
 #endif
index a3fb26a..ec40c71 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
-using namespace std;
 #include "SMESH_Gen.hxx"
-
 #include "SMESH_subMesh.hxx"
-
-#include "SMESHDS_ListOfPtrHypothesis.hxx"
-#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
 #include "SMDS_MeshElement.hxx"
 #include "SMDS_MeshNode.hxx"
 
@@ -51,9 +45,9 @@ using namespace std;
 
 SMESH_Gen::SMESH_Gen()
 {
-  MESSAGE("SMESH_Gen::SMESH_Gen");
-  _localId = 0;
-  _hypothesisFactory.SetGen(this);
+       MESSAGE("SMESH_Gen::SMESH_Gen");
+       _localId = 0;
+       _hypothesisFactory.SetGen(this);
 }
 
 //=============================================================================
@@ -64,7 +58,7 @@ SMESH_Gen::SMESH_Gen()
 
 SMESH_Gen::~SMESH_Gen()
 {
-  MESSAGE("SMESH_Gen::~SMESH_Gen");
+       MESSAGE("SMESH_Gen::~SMESH_Gen");
 }
 
 //=============================================================================
@@ -73,27 +67,27 @@ SMESH_Gen::~SMESH_Gen()
  */
 //=============================================================================
 
-SMESH_Hypothesis* SMESH_Gen::CreateHypothesis(const char* anHyp,
-                                             int studyId)
-  throw (SALOME_Exception)
+SMESH_Hypothesis *SMESH_Gen::CreateHypothesis(const char *anHyp, int studyId)
+       throw(SALOME_Exception)
 {
-  MESSAGE("SMESH_Gen::CreateHypothesis");
 
-  // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
+       MESSAGE("CreateHypothesis("<<anHyp<<","<<studyId<<")");
+       // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
 
-  StudyContextStruct* myStudyContext = GetStudyContext(studyId);
+       StudyContextStruct *myStudyContext = GetStudyContext(studyId);
 
-  // create a new hypothesis object, store its ref. in studyContext
+       // create a new hypothesis object, store its ref. in studyContext
 
-  SMESH_Hypothesis* myHypothesis = _hypothesisFactory.Create(anHyp, studyId);
-  int hypId = myHypothesis->GetID();
-  myStudyContext->mapHypothesis[hypId] = myHypothesis;
-  SCRUTE(studyId);
-  SCRUTE(hypId);
+       SMESH_Hypothesis *myHypothesis = _hypothesisFactory.Create(anHyp, studyId);
+       int hypId = myHypothesis->GetID();
+       myStudyContext->mapHypothesis[hypId] = myHypothesis;
+       SCRUTE(studyId);
+       SCRUTE(hypId);
 
-  // store hypothesis in SMESHDS document
+       // store hypothesis in SMESHDS document
 
-  myStudyContext->myDocument->AddHypothesis(myHypothesis);
+       myStudyContext->myDocument->AddHypothesis(myHypothesis);
+       return myHypothesis;
 }
 
 //=============================================================================
@@ -102,32 +96,32 @@ SMESH_Hypothesis* SMESH_Gen::CreateHypothesis(const char* anHyp,
  */
 //=============================================================================
 
-SMESH_Mesh* SMESH_Gen::Init(int studyId, const TopoDS_Shape& aShape)
-  throw (SALOME_Exception)
+SMESH_Mesh *SMESH_Gen::Init(int studyId, const TopoDS_Shape & aShape)
+throw(SALOME_Exception)
 {
-  MESSAGE("SMESH_Gen::Init");
+       MESSAGE("SMESH_Gen::Init");
 //   if (aShape.ShapeType() == TopAbs_COMPOUND)
 //     {
 //       INFOS("Mesh Compound not yet implemented!");
 //       throw(SALOME_Exception(LOCALIZED("Mesh Compound not yet implemented!")));
 //     }
 
-  // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
+       // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
 
-  StudyContextStruct* myStudyContext = GetStudyContext(studyId);
+       StudyContextStruct *myStudyContext = GetStudyContext(studyId);
 
-  // create a new SMESH_mesh object 
+       // create a new SMESH_mesh object 
 
-  SMESH_Mesh* mesh = new SMESH_Mesh(_localId++,
-                                   studyId,
-                                   this,
-                                   myStudyContext->myDocument);
-  myStudyContext->mapMesh[_localId] = mesh;
+       SMESH_Mesh *mesh = new SMESH_Mesh(_localId++,
+               studyId,
+               this,
+               myStudyContext->myDocument);
+       myStudyContext->mapMesh[_localId] = mesh;
 
-  // associate a TopoDS_Shape to the mesh
+       // associate a TopoDS_Shape to the mesh
 
-  mesh->ShapeToMesh(aShape);
-  return mesh;
+       mesh->ShapeToMesh(aShape);
+       return mesh;
 }
 
 //=============================================================================
@@ -136,10 +130,10 @@ SMESH_Mesh* SMESH_Gen::Init(int studyId, const TopoDS_Shape& aShape)
  */
 //=============================================================================
 
-bool SMESH_Gen::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
-  throw (SALOME_Exception)
+bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
+throw(SALOME_Exception)
 {
-  MESSAGE("SMESH_Gen::Compute");
+       MESSAGE("SMESH_Gen::Compute");
 //   bool isDone = false;
 /* 
 Algo : s'appuie ou non sur une geometrie
@@ -150,49 +144,46 @@ Face, Shell, collection de Face et Shells : 2D
 Solid, Collection de Solid : 3D
 */
 // *** corriger commentaires
-  // check hypothesis associated to the mesh :
-  // - only one algo : type compatible with the type of the shape
-  // - hypothesis = compatible with algo
-  //    - check if hypothesis are applicable to this algo
-  //    - check contradictions within hypothesis
-  //    (test if enough hypothesis is done further)
+       // check hypothesis associated to the mesh :
+       // - only one algo : type compatible with the type of the shape
+       // - hypothesis = compatible with algo
+       //    - check if hypothesis are applicable to this algo
+       //    - check contradictions within hypothesis
+       //    (test if enough hypothesis is done further)
 
-  bool ret = true;
+       bool ret = true;
 
-  SMESH_subMesh* sm = aMesh.GetSubMesh(aShape);
+       SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
 //   SCRUTE(sm);
-  SMESH_subMesh* smToCompute = sm->GetFirstToCompute();
-  while (smToCompute)
-    {
-      TopoDS_Shape subShape = smToCompute->GetSubShape();
-      int dim = GetShapeDim(subShape);
-      //SCRUTE(dim);
-      if (dim > 0)
-       {
-         bool ret1 = smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
-         ret = ret && ret1;
-       }
-      else
+       SMESH_subMesh *smToCompute = sm->GetFirstToCompute();
+       while (smToCompute)
        {
-         ASSERT(dim == 0);
-         ASSERT(smToCompute->_vertexSet == false);
-         TopoDS_Vertex V1 = TopoDS::Vertex(subShape);
-         gp_Pnt P1 = BRep_Tool::Pnt(V1);
-         const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
-         int nodeId = meshDS->AddNode(P1.X(), P1.Y(), P1.Z());
-         //MESSAGE("point "<<nodeId<<" "<<P1.X()<<" "<<P1.Y()<<" "<<P1.Z());
-         Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
-         Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
-         meshDS->SetNodeOnVertex(node, V1);
-         const Handle(SMESHDS_SubMesh)& subMeshDS
-           = smToCompute->GetSubMeshDS();
-         smToCompute->_vertexSet = true;
-         bool ret1 = smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
+               TopoDS_Shape subShape = smToCompute->GetSubShape();
+               int dim = GetShapeDim(subShape);
+               //SCRUTE(dim);
+               if (dim > 0)
+               {
+                       bool ret1 = smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
+                       ret = ret && ret1;
+               }
+               else
+               {
+                       ASSERT(dim == 0);
+                       ASSERT(smToCompute->_vertexSet == false);
+                       TopoDS_Vertex V1 = TopoDS::Vertex(subShape);
+                       gp_Pnt P1 = BRep_Tool::Pnt(V1);
+                       SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+                       //MESSAGE("point "<<nodeId<<" "<<P1.X()<<" "<<P1.Y()<<" "<<P1.Z());
+                       SMDS_MeshNode * node = meshDS->AddNode(P1.X(), P1.Y(), P1.Z());
+                       meshDS->SetNodeOnVertex(node, V1);
+                       smToCompute->GetSubMeshDS();
+                       smToCompute->_vertexSet = true;
+                       smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
+               }
+               smToCompute = sm->GetFirstToCompute();
        }
-      smToCompute = sm->GetFirstToCompute();
-    }
 
-  return ret;
+       return ret;
 }
 
 //=============================================================================
@@ -201,83 +192,90 @@ Solid, Collection de Solid : 3D
  */
 //=============================================================================
 
-SMESH_Algo* SMESH_Gen::GetAlgo(SMESH_Mesh& aMesh,
-                              const TopoDS_Shape& aShape)
+SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
 {
-  //MESSAGE("SMESH_Gen::GetAlgo");
-
-  SMESHDS_Hypothesis* theHyp = NULL;
-  SMESH_Algo* algo = NULL;
-  const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
-  int hypType;
-  int hypId;
-  int algoDim;
+       //MESSAGE("SMESH_Gen::GetAlgo");
 
-  // try shape first, then main shape
+       const SMESHDS_Hypothesis *theHyp = NULL;
+       SMESH_Algo *algo = NULL;
+       const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+       int hypType;
+       int hypId;
+       int algoDim;
 
-  TopoDS_Shape mainShape = meshDS->ShapeToMesh();
-  const TopoDS_Shape* shapeToTry[2] = {&aShape, &mainShape};
+       // try shape first, then main shape
 
-  for (int iShape=0; iShape<2; iShape++)
-    {
-      TopoDS_Shape tryShape = (*shapeToTry[iShape]);
+       TopoDS_Shape mainShape = meshDS->ShapeToMesh();
+       const TopoDS_Shape *shapeToTry[2] = { &aShape, &mainShape };
 
-      const SMESHDS_ListOfPtrHypothesis& listHyp
-       = meshDS->GetHypothesis(tryShape);
-      SMESHDS_ListIteratorOfListOfPtrHypothesis it(listHyp);
+       for (int iShape = 0; iShape < 2; iShape++)
+       {
+               TopoDS_Shape tryShape = (*shapeToTry[iShape]);
 
-      int nb_algo = 0;
-      int shapeDim = GetShapeDim(aShape);
-      int typeOfShape = aShape.ShapeType();
+               const list<const SMESHDS_Hypothesis*>& listHyp =
+                       meshDS->GetHypothesis(tryShape);
+               list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
+               
+               int nb_algo = 0;
+               int shapeDim = GetShapeDim(aShape);
+               int typeOfShape = aShape.ShapeType();
 
-      while (it.More())
-       {
-         SMESHDS_Hypothesis* anHyp = it.Value();
-         hypType = anHyp->GetType();
-//       SCRUTE(hypType);
-         if (hypType > SMESHDS_Hypothesis::PARAM_ALGO)
-           {
-             switch (hypType)
+               while (it!=listHyp.end())
                {
-               case SMESHDS_Hypothesis::ALGO_1D: algoDim=1; break;
-               case SMESHDS_Hypothesis::ALGO_2D: algoDim=2; break;
-               case SMESHDS_Hypothesis::ALGO_3D: algoDim=3; break;
-               default: algoDim=0; break;
+                       const SMESHDS_Hypothesis *anHyp = *it;
+                       hypType = anHyp->GetType();
+                       //SCRUTE(hypType);
+                       if (hypType > SMESHDS_Hypothesis::PARAM_ALGO)
+                       {
+                               switch (hypType)
+                               {
+                               case SMESHDS_Hypothesis::ALGO_1D:
+                                       algoDim = 1;
+                                       break;
+                               case SMESHDS_Hypothesis::ALGO_2D:
+                                       algoDim = 2;
+                                       break;
+                               case SMESHDS_Hypothesis::ALGO_3D:
+                                       algoDim = 3;
+                                       break;
+                               default:
+                                       algoDim = 0;
+                                       break;
+                               }
+                               //SCRUTE(algoDim);
+                               //SCRUTE(shapeDim);
+                               //SCRUTE(typeOfShape);
+                               if (shapeDim == algoDim)        // count only algos of shape dim.
+                               {                               // discard algos for subshapes
+                                       hypId = anHyp->GetID(); // (of lower dim.)
+                                       ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
+                                       SMESH_Algo *anAlgo = _mapAlgo[hypId];
+                                       //SCRUTE(anAlgo->GetShapeType());
+                                       //if (anAlgo->GetShapeType() == typeOfShape)
+                                       if ((anAlgo->GetShapeType()) & (1 << typeOfShape))
+                                       {                       // only specific TopoDS_Shape
+                                               nb_algo++;
+                                               theHyp = anHyp;
+                                       }
+                               }
+                       }
+                       if (nb_algo > 1) return NULL;   // more than one algo
+                       it++;
                }
-//           SCRUTE(algoDim);
-//           SCRUTE(shapeDim);
-//           SCRUTE(typeOfShape);
-             if (shapeDim == algoDim)        // count only algos of shape dim.
-               {                             // discard algos for subshapes
-                 hypId = anHyp->GetID();     // (of lower dim.)
-                 ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
-                 SMESH_Algo* anAlgo = _mapAlgo[hypId];
-                 //SCRUTE(anAlgo->GetShapeType());
-//               if (anAlgo->GetShapeType() == typeOfShape)
-                 if ((anAlgo->GetShapeType()) & (1 << typeOfShape))
-                   {                         // only specific TopoDS_Shape
-                     nb_algo++;                  
-                     theHyp = anHyp;
-                   }
-               }
-           }
-         if (nb_algo > 1) return NULL;  // more than one algo
-         it.Next();
+               if (nb_algo == 1)               // one algo found : OK
+                       break;                          // do not try a parent shape
        }
-      if (nb_algo == 1)                  // one algo found : OK
-       break;                           // do not try a parent shape
-    }
 
-  if (!theHyp) return NULL;              // no algo found
+       if (!theHyp)
+               return NULL;                    // no algo found
 
-  hypType = theHyp->GetType();
-  hypId = theHyp->GetID();
+       hypType = theHyp->GetType();
+       hypId = theHyp->GetID();
 
-  ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
-  algo = _mapAlgo[hypId];
-  const char* algoName = algo->GetName();
-  //MESSAGE("Algo found " << algoName << " Id " << hypId);
-  return algo;
+       ASSERT(_mapAlgo.find(hypId) != _mapAlgo.end());
+       algo = _mapAlgo[hypId];
+       //MESSAGE("Algo found " << algo->GetName() << " Id " << hypId);
+       return algo;
 }
 
 //=============================================================================
@@ -286,18 +284,18 @@ SMESH_Algo* SMESH_Gen::GetAlgo(SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-StudyContextStructSMESH_Gen::GetStudyContext(int studyId)
+StudyContextStruct *SMESH_Gen::GetStudyContext(int studyId)
 {
-  // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
-
-  if (_mapStudyContext.find(studyId) == _mapStudyContext.end())
-    {
-      _mapStudyContext[studyId] = new StudyContextStruct;
-      _mapStudyContext[studyId]->myDocument = new SMESHDS_Document(studyId);
-    }
-  StudyContextStruct* myStudyContext = _mapStudyContext[studyId];
+       // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
+
+       if (_mapStudyContext.find(studyId) == _mapStudyContext.end())
+       {
+               _mapStudyContext[studyId] = new StudyContextStruct;
+               _mapStudyContext[studyId]->myDocument = new SMESHDS_Document(studyId);
+       }
+       StudyContextStruct *myStudyContext = _mapStudyContext[studyId];
 //   ASSERT(_mapStudyContext.find(studyId) != _mapStudyContext.end());
-  return myStudyContext;
+       return myStudyContext;
 }
 
 //=============================================================================
@@ -318,7 +316,7 @@ void SMESH_Gen::Save(int studyId, const char *aUrlOfFile)
 
 void SMESH_Gen::Load(int studyId, const char *aUrlOfFile)
 {
-} 
+}
 
 //=============================================================================
 /*!
@@ -329,26 +327,25 @@ void SMESH_Gen::Load(int studyId, const char *aUrlOfFile)
 void SMESH_Gen::Close(int studyId)
 {
 }
+
 //=============================================================================
 /*!
  * 
  */
 //=============================================================================
 
-const charSMESH_Gen::ComponentDataType()
+const char *SMESH_Gen::ComponentDataType()
 {
 }
 
-
 //=============================================================================
 /*!
  * 
  */
 //=============================================================================
 
-const char* SMESH_Gen::IORToLocalPersistentID(const char* IORString,
-                                             bool& IsAFile)
+const char *SMESH_Gen::IORToLocalPersistentID(const char *IORString,
+       bool & IsAFile)
 {
 }
 
@@ -358,7 +355,7 @@ const char* SMESH_Gen::IORToLocalPersistentID(const char* IORString,
  */
 //=============================================================================
 
-const char* SMESH_Gen::LocalPersistentIDToIOR(const char* aLocalPersistentID)
+const char *SMESH_Gen::LocalPersistentIDToIOR(const char *aLocalPersistentID)
 {
 }
 
@@ -368,42 +365,42 @@ const char* SMESH_Gen::LocalPersistentIDToIOR(const char* aLocalPersistentID)
  */
 //=============================================================================
 
-int SMESH_Gen::GetShapeDim(const TopoDS_Shape& aShape)
+int SMESH_Gen::GetShapeDim(const TopoDS_Shape & aShape)
 {
-  int shapeDim = -1;              // Shape dimension: 0D, 1D, 2D, 3D
-  int type = aShape.ShapeType();
-  switch (type)
-    {
+       int shapeDim = -1;                      // Shape dimension: 0D, 1D, 2D, 3D
+       int type = aShape.ShapeType();
+       switch (type)
+       {
 //     case TopAbs_COMPOUND:
 //       {
-//     break;
+//  break;
 //       }
-    case TopAbs_COMPOUND:
-    case TopAbs_COMPSOLID:
-    case TopAbs_SOLID:
-    case TopAbs_SHELL:
-      {
-       shapeDim = 3;
-       break;
-      }
-      //    case TopAbs_SHELL:
-    case TopAbs_FACE:
-      {
-       shapeDim = 2;
-       break;
-      }
-    case TopAbs_WIRE:
-    case TopAbs_EDGE:
-      {
-       shapeDim = 1;
-       break;
-      }
-    case TopAbs_VERTEX:
-      {
-       shapeDim = 0;
-       break;
-      }
-    }
+       case TopAbs_COMPOUND:
+       case TopAbs_COMPSOLID:
+       case TopAbs_SOLID:
+       case TopAbs_SHELL:
+       {
+               shapeDim = 3;
+               break;
+       }
+               //    case TopAbs_SHELL:
+       case TopAbs_FACE:
+       {
+               shapeDim = 2;
+               break;
+       }
+       case TopAbs_WIRE:
+       case TopAbs_EDGE:
+       {
+               shapeDim = 1;
+               break;
+       }
+       case TopAbs_VERTEX:
+       {
+               shapeDim = 0;
+               break;
+       }
+       }
 //   SCRUTE(shapeDim);
-  return shapeDim;
+       return shapeDim;
 }
index 891cd87..5443c0e 100644 (file)
 #include <TopoDS_Shape.hxx>
 
 #include <map>
+using namespace std;
 
 typedef struct studyContextStruct
 {
-  map<int, SMESH_Hypothesis*> mapHypothesis;
-  map<int, SMESH_Mesh*> mapMesh;
-  Handle (SMESHDS_Document) myDocument;
-} StudyContextStruct ;
+       map < int, SMESH_Hypothesis * >mapHypothesis;
+         map < int, SMESH_Mesh * >mapMesh;
+         SMESHDS_Document * myDocument;
+} StudyContextStruct;
 
 class SMESH_Gen
 {
-public:
-  SMESH_Gen();
-  ~SMESH_Gen();
-
-  SMESH_Hypothesis* CreateHypothesis(const char* anHyp, int studyId)
-    throw (SALOME_Exception);
-  SMESH_Mesh* Init(int studyId, const TopoDS_Shape& aShape)
-    throw (SALOME_Exception);
-  bool Compute(::SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
-    throw (SALOME_Exception);
-  StudyContextStruct* GetStudyContext(int studyId);
-
-  static int GetShapeDim(const TopoDS_Shape& aShape);
-  SMESH_Algo* GetAlgo(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
-
-  // inherited methods from SALOMEDS::Driver
-
-  void Save(int studyId, const char *aUrlOfFile);
-  void Load(int studyId, const char *aUrlOfFile); 
-  void Close(int studyId); 
-  const char* ComponentDataType();
-
-  const char* IORToLocalPersistentID(const char* IORString, bool& IsAFile);
-  const char* LocalPersistentIDToIOR(const char* aLocalPersistentID);
-
-  SMESH_HypothesisFactory _hypothesisFactory;
-
-  map<int, SMESH_Algo*> _mapAlgo;
-  map<int, SMESH_1D_Algo*> _map1D_Algo;
-  map<int, SMESH_2D_Algo*> _map2D_Algo;
-  map<int, SMESH_3D_Algo*> _map3D_Algo;
-
-private:
-  int _localId; // unique Id of created objects, within SMESH_Gen entity
-  map<int, StudyContextStruct*> _mapStudyContext;
-  map<int, SMESH_Hypothesis*> _mapHypothesis;
+  public:
+       SMESH_Gen();
+       ~SMESH_Gen();
+
+       SMESH_Hypothesis *CreateHypothesis(const char *anHyp, int studyId)
+               throw(SALOME_Exception);
+       SMESH_Mesh *Init(int studyId, const TopoDS_Shape & aShape)
+               throw(SALOME_Exception);
+       bool Compute(::SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
+               throw(SALOME_Exception);
+       StudyContextStruct *GetStudyContext(int studyId);
+
+       static int GetShapeDim(const TopoDS_Shape & aShape);
+       SMESH_Algo *GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
+
+       // inherited methods from SALOMEDS::Driver
+
+       void Save(int studyId, const char *aUrlOfFile);
+       void Load(int studyId, const char *aUrlOfFile);
+       void Close(int studyId);
+       const char *ComponentDataType();
+
+       const char *IORToLocalPersistentID(const char *IORString, bool & IsAFile);
+       const char *LocalPersistentIDToIOR(const char *aLocalPersistentID);
+
+       SMESH_HypothesisFactory _hypothesisFactory;
+
+         map < int, SMESH_Algo * >_mapAlgo;
+         map < int, SMESH_1D_Algo * >_map1D_Algo;
+         map < int, SMESH_2D_Algo * >_map2D_Algo;
+         map < int, SMESH_3D_Algo * >_map3D_Algo;
+
+  private:
+       int _localId;                           // unique Id of created objects, within SMESH_Gen entity
+         map < int, StudyContextStruct * >_mapStudyContext;
+         map < int, SMESH_Hypothesis * >_mapHypothesis;
 };
 
 #endif
index 11c34a8..65d2d2a 100644 (file)
@@ -27,7 +27,6 @@
 //  $Header$
 
 using namespace std;
-using namespace std;
 #include "SMESH_Hexa_3D.hxx"
 #include "SMESH_Quadrangle_2D.hxx"
 #include "SMESH_Gen.hxx"
@@ -52,7 +51,6 @@ using namespace std;
 
 #include "utilities.h"
 
-
 //=============================================================================
 /*!
  *  
@@ -60,15 +58,15 @@ using namespace std;
 //=============================================================================
 
 SMESH_Hexa_3D::SMESH_Hexa_3D(int hypId, int studyId,
-                            SMESH_Gen* gen)
-  : SMESH_3D_Algo(hypId, studyId, gen)
+       SMESH_Gen * gen):SMESH_3D_Algo(hypId, studyId, gen)
 {
-  MESSAGE("SMESH_Hexa_3D::SMESH_Hexa_3D");
-  _name = "Hexa_3D";
+       MESSAGE("SMESH_Hexa_3D::SMESH_Hexa_3D");
+       _name = "Hexa_3D";
 //   _shapeType = TopAbs_SOLID;
-  _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type
+       _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit /shape type
 //   MESSAGE("_shapeType octal " << oct << _shapeType);
-  for (int i=0; i<6; i++) _quads[i] = 0;
+       for (int i = 0; i < 6; i++)
+               _quads[i] = 0;
 }
 
 //=============================================================================
@@ -79,7 +77,7 @@ SMESH_Hexa_3D::SMESH_Hexa_3D(int hypId, int studyId,
 
 SMESH_Hexa_3D::~SMESH_Hexa_3D()
 {
-  MESSAGE("SMESH_Hexa_3D::~SMESH_Hexa_3D");
+       MESSAGE("SMESH_Hexa_3D::~SMESH_Hexa_3D");
 }
 
 //=============================================================================
@@ -88,16 +86,16 @@ SMESH_Hexa_3D::~SMESH_Hexa_3D()
  */
 //=============================================================================
 
-bool SMESH_Hexa_3D::CheckHypothesis(SMESH_Mesh& aMesh,
-                                   const TopoDS_Shape& aShape)
+bool SMESH_Hexa_3D::CheckHypothesis(SMESH_Mesh & aMesh,
+       const TopoDS_Shape & aShape)
 {
-  MESSAGE("SMESH_Hexa_3D::CheckHypothesis");
+       MESSAGE("SMESH_Hexa_3D::CheckHypothesis");
 
-  bool isOk = true;
+       bool isOk = true;
 
-  // nothing to check
+       // nothing to check
 
-  return isOk;
+       return isOk;
 }
 
 //=============================================================================
@@ -113,619 +111,611 @@ bool SMESH_Hexa_3D::CheckHypothesis(SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
-                           const TopoDS_Shape& aShape)
-  throw (SALOME_Exception)
+bool SMESH_Hexa_3D::Compute(SMESH_Mesh & aMesh,
+       const TopoDS_Shape & aShape)throw(SALOME_Exception)
 {
-  MESSAGE("SMESH_Hexa_3D::Compute");
-
-  bool isOk = false;
-  const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
-  SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape);
-  //const Handle(SMESHDS_SubMesh)& subMeshDS = theSubMesh->GetSubMeshDS();
-
-  // 0.  - shape and face mesh verification
-  // 0.1 - shape must be a solid (or a shell) with 6 faces
-  MESSAGE("---");
-
-  vector<SMESH_subMesh*> meshFaces;
-  for (TopExp_Explorer exp(aShape,TopAbs_FACE);exp.More();exp.Next())
-    {
-      SMESH_subMesh* aSubMesh = aMesh.GetSubMeshContaining(exp.Current());
-      ASSERT (aSubMesh);
-      meshFaces.push_back(aSubMesh);
-    }
-  if (meshFaces.size() != 6)
-    {
-      SCRUTE(meshFaces.size());
-      ASSERT(0);
-      return false;
-    }
-
-  // 0.2 - is each face meshed with Quadrangle_2D? (so, with a wire of 4 edges)
-  MESSAGE("---");
-
-  for (int i=0; i<6; i++)
-    {
-      TopoDS_Shape aShape = meshFaces[i]->GetSubShape();
-      SMESH_Algo* algo = _gen->GetAlgo(aMesh, aShape);
-      string algoName = algo->GetName();
-      if (algoName != "Quadrangle_2D")
+       MESSAGE("SMESH_Hexa_3D::Compute");
+
+       bool isOk = false;
+       SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+       SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
+       //const SMESHDS_SubMesh *& subMeshDS = theSubMesh->GetSubMeshDS();
+
+       // 0.  - shape and face mesh verification
+       // 0.1 - shape must be a solid (or a shell) with 6 faces
+       MESSAGE("---");
+
+       vector < SMESH_subMesh * >meshFaces;
+       for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next())
        {
-         // *** delete _quads
-         SCRUTE(algoName);
-         ASSERT(0);
-         return false;
+               SMESH_subMesh *aSubMesh = aMesh.GetSubMeshContaining(exp.Current());
+               ASSERT(aSubMesh);
+               meshFaces.push_back(aSubMesh);
        }
-      SMESH_Quadrangle_2D* quadAlgo =dynamic_cast<SMESH_Quadrangle_2D*> (algo);
-      ASSERT(quadAlgo);
-      try
+       if (meshFaces.size() != 6)
        {
-         _quads[i] = quadAlgo->CheckAnd2Dcompute(aMesh, aShape);
-         // *** to delete after usage
+               SCRUTE(meshFaces.size());
+               ASSERT(0);
+               return false;
        }
-      catch (SALOME_Exception& S_ex)
+
+       // 0.2 - is each face meshed with Quadrangle_2D? (so, with a wire of 4 edges)
+       MESSAGE("---");
+
+       for (int i = 0; i < 6; i++)
        {
-         // *** delete _quads
-         // *** throw exception
-         ASSERT(0);
+               TopoDS_Shape aShape = meshFaces[i]->GetSubShape();
+               SMESH_Algo *algo = _gen->GetAlgo(aMesh, aShape);
+               string algoName = algo->GetName();
+               if (algoName != "Quadrangle_2D")
+               {
+                       // *** delete _quads
+                       SCRUTE(algoName);
+                       ASSERT(0);
+                       return false;
+               }
+               SMESH_Quadrangle_2D *quadAlgo =
+                       dynamic_cast < SMESH_Quadrangle_2D * >(algo);
+               ASSERT(quadAlgo);
+               try
+               {
+                       _quads[i] = quadAlgo->CheckAnd2Dcompute(aMesh, aShape);
+                       // *** to delete after usage
+               }
+               catch(SALOME_Exception & S_ex)
+               {
+                       // *** delete _quads
+                       // *** throw exception
+                       ASSERT(0);
+               }
        }
-    }
-
-  // 1.  - identify faces and vertices of the "cube"
-  // 1.1 - ancestor maps vertex->edges in the cube
-  MESSAGE("---");
-
-  TopTools_IndexedDataMapOfShapeListOfShape MS;
-  TopExp::MapShapesAndAncestors(aShape, TopAbs_VERTEX, TopAbs_EDGE, MS);
-
-  // 1.2 - first face is choosen as face Y=0 of the unit cube
-  MESSAGE("---");
-
-  const TopoDS_Shape& aFace = meshFaces[0]->GetSubShape();
-  const TopoDS_Face& F = TopoDS::Face(aFace);
-
-  // 1.3 - identify the 4 vertices of the face Y=0: V000, V100, V101, V001
-  MESSAGE("---");
-
-  int i = 0;
-  TopoDS_Edge E = _quads[0]->edge[i]; //edge will be Y=0,Z=0 on unit cube
-  double f,l;
-  Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
-  TopoDS_Vertex VFirst, VLast;
-  TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
-  bool isForward = (((l-f)*(_quads[0]->last[i] - _quads[0]->first[i])) > 0);
-
-  if (isForward)
-    {
-      _cube.V000 = VFirst; // will be (0,0,0) on the unit cube
-      _cube.V100 = VLast;  // will be (1,0,0) on the unit cube
-    }
-  else
-    {
-      _cube.V000 = VLast;
-      _cube.V100 = VFirst;
-    }
-  
-  i = 1;
-  E = _quads[0]->edge[i];
-  C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
-  TopExp::Vertices(E, VFirst, VLast);
-  isForward = (((l-f)*(_quads[0]->last[i] - _quads[0]->first[i])) > 0);
-  if (isForward) _cube.V101 = VLast;  // will be (1,0,1) on the unit cube
-  else _cube.V101 = VFirst;
-
-  i = 2;
-  E = _quads[0]->edge[i];
-  C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
-  TopExp::Vertices(E, VFirst, VLast);
-  isForward = (((l-f)*(_quads[0]->last[i] - _quads[0]->first[i])) > 0);
-  if (isForward) _cube.V001 = VLast;  // will be (0,0,1) on the unit cube
-  else _cube.V001 = VFirst;
-
-  // 1.4 - find edge X=0, Z=0 (ancestor of V000 not in face Y=0)
-  //     - find edge X=1, Z=0 (ancestor of V100 not in face Y=0)
-  //     - find edge X=1, Z=1 (ancestor of V101 not in face Y=0) 
-  //     - find edge X=0, Z=1 (ancestor of V001 not in face Y=0)
-  MESSAGE("---");
-
-  TopoDS_Edge E_0Y0 = EdgeNotInFace(aMesh, aShape, F, _cube.V000, MS);
-  ASSERT(! E_0Y0.IsNull());
-
-  TopoDS_Edge E_1Y0 = EdgeNotInFace(aMesh, aShape, F, _cube.V100, MS);
-  ASSERT(! E_1Y0.IsNull());
-  
-  TopoDS_Edge E_1Y1 = EdgeNotInFace(aMesh, aShape, F, _cube.V101, MS);
-  ASSERT(! E_1Y1.IsNull());
-
-  TopoDS_Edge E_0Y1 = EdgeNotInFace(aMesh, aShape, F, _cube.V001, MS);
-  ASSERT(! E_0Y1.IsNull());
-  
-  // 1.5 - identify the 4 vertices in face Y=1: V010, V110, V111, V011
-  MESSAGE("---");
-
-  TopExp::Vertices(E_0Y0, VFirst, VLast);
-  if (VFirst.IsSame(_cube.V000)) _cube.V010 = VLast;
-  else _cube.V010 = VFirst;
-
-  TopExp::Vertices(E_1Y0, VFirst, VLast);
-  if (VFirst.IsSame(_cube.V100)) _cube.V110 = VLast;
-  else _cube.V110 = VFirst;
-
-  TopExp::Vertices(E_1Y1, VFirst, VLast);
-  if (VFirst.IsSame(_cube.V101)) _cube.V111 = VLast;
-  else _cube.V111 = VFirst;
-
-  TopExp::Vertices(E_0Y1, VFirst, VLast);
-  if (VFirst.IsSame(_cube.V001)) _cube.V011 = VLast;
-  else _cube.V011 = VFirst;
-
-  // 1.6 - find remaining faces given 4 vertices
-  MESSAGE("---");
-
-  _indY0 = 0;
-  _cube.quad_Y0 = _quads[_indY0];
-
-  _indY1 = GetFaceIndex(aMesh, aShape, meshFaces,
-                       _cube.V010,_cube.V011,_cube.V110,_cube.V111);
-  _cube.quad_Y1 = _quads[_indY1];
-
-  _indZ0 = GetFaceIndex(aMesh, aShape, meshFaces,
-                       _cube.V000,_cube.V010,_cube.V100,_cube.V110);
-  _cube.quad_Z0 = _quads[_indZ0];
-
-  _indZ1 = GetFaceIndex(aMesh, aShape, meshFaces,
-                 _cube.V001,_cube.V011,_cube.V101,_cube.V111);
-  _cube.quad_Z1 = _quads[_indZ1];
-
-  _indX0 = GetFaceIndex(aMesh, aShape, meshFaces,
-                       _cube.V000,_cube.V001,_cube.V010,_cube.V011);
-  _cube.quad_X0 = _quads[_indX0];
-
-  _indX1 = GetFaceIndex(aMesh, aShape, meshFaces,
-                       _cube.V100,_cube.V101,_cube.V110,_cube.V111);
-  _cube.quad_X1 = _quads[_indX1];
-
-  MESSAGE("---");
-
-  // 1.7 - get convertion coefs from face 2D normalized to 3D normalized
-
-  Conv2DStruct cx0; // for face X=0
-  Conv2DStruct cx1; // for face X=1
-  Conv2DStruct cy0;
-  Conv2DStruct cy1;
-  Conv2DStruct cz0;
-  Conv2DStruct cz1;
-
-  GetConv2DCoefs(*_cube.quad_X0, meshFaces[_indX0]->GetSubShape(),
-                _cube.V000,_cube.V010,_cube.V011,_cube.V001,
-                cx0);
-  GetConv2DCoefs(*_cube.quad_X1, meshFaces[_indX1]->GetSubShape(),
-                _cube.V100,_cube.V110,_cube.V111,_cube.V101,
-                cx1);
-  GetConv2DCoefs(*_cube.quad_Y0, meshFaces[_indY0]->GetSubShape(),
-                _cube.V000,_cube.V100,_cube.V101,_cube.V001,
-                cy0);
-  GetConv2DCoefs(*_cube.quad_Y1, meshFaces[_indY1]->GetSubShape(),
-                _cube.V010,_cube.V110,_cube.V111,_cube.V011,
-                cy1);
-  GetConv2DCoefs(*_cube.quad_Z0, meshFaces[_indZ0]->GetSubShape(),
-                _cube.V000,_cube.V100,_cube.V110,_cube.V010,
-                cz0);
-  GetConv2DCoefs(*_cube.quad_Z1, meshFaces[_indZ1]->GetSubShape(),
-                _cube.V001,_cube.V101,_cube.V111,_cube.V011,
-                cz1);
-
-  // 1.8 - create a 3D structure for normalized values
-
-  MESSAGE("---");
-  int nbx = _cube.quad_Y0->nbPts[0];
-  int nby = _cube.quad_Y0->nbPts[1];
-  int nbz;
-  if (cx0.a1 != 0) nbz = _cube.quad_X0->nbPts[1];
-  else  nbz = _cube.quad_X0->nbPts[0];
-  //SCRUTE(nbx);
-  //SCRUTE(nby);
-  //SCRUTE(nbz);
-  int nbxyz= nbx*nby*nbz;
-  Point3DStruct* np = new Point3DStruct[nbxyz];
-
-  // 1.9 - store node indexes of faces
-
-  {
-    const TopoDS_Face& F = TopoDS::Face(meshFaces[_indX0]->GetSubShape());
-    const TColStd_ListOfInteger& indElt
-      = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
-    TColStd_ListIteratorOfListOfInteger itf(indElt);
-
-    faceQuadStruct* quad = _cube.quad_X0;
-    int i=0; // j = x/face , k = y/face
-    int nbdown = quad->nbPts[0];
-    int nbright = quad->nbPts[1];
-
-    for (; itf.More(); itf.Next())
-      {
-       int nodeId = itf.Value();
-       Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
-       Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
-       Handle (SMDS_FacePosition) fpos
-         = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
-       double ri = fpos->GetUParameter();
-       double rj = fpos->GetVParameter();
-       int i1 = int(ri);
-       int j1 = int(rj);
-       int ij1 = j1*nbdown +i1;
-       quad->uv_grid[ij1].nodeId = nodeId;
-      }
-
-    for (int i1=0; i1<nbdown; i1++)
-      for (int j1=0; j1<nbright; j1++)
+
+       // 1.  - identify faces and vertices of the "cube"
+       // 1.1 - ancestor maps vertex->edges in the cube
+       MESSAGE("---");
+
+       TopTools_IndexedDataMapOfShapeListOfShape MS;
+       TopExp::MapShapesAndAncestors(aShape, TopAbs_VERTEX, TopAbs_EDGE, MS);
+
+       // 1.2 - first face is choosen as face Y=0 of the unit cube
+       MESSAGE("---");
+
+       const TopoDS_Shape & aFace = meshFaces[0]->GetSubShape();
+       const TopoDS_Face & F = TopoDS::Face(aFace);
+
+       // 1.3 - identify the 4 vertices of the face Y=0: V000, V100, V101, V001
+       MESSAGE("---");
+
+       int i = 0;
+       TopoDS_Edge E = _quads[0]->edge[i];     //edge will be Y=0,Z=0 on unit cube
+       double f, l;
+       Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
+       TopoDS_Vertex VFirst, VLast;
+       TopExp::Vertices(E, VFirst, VLast);     // corresponds to f and l
+       bool isForward =
+               (((l - f) * (_quads[0]->last[i] - _quads[0]->first[i])) > 0);
+
+       if (isForward)
        {
-         int ij1 = j1*nbdown +i1;
-         int j = cx0.ia*i1 + cx0.ib*j1 + cx0.ic; // j = x/face
-         int k = cx0.ja*i1 + cx0.jb*j1 + cx0.jc; // k = y/face
-         int ijk = k*nbx*nby + j*nbx + i;
-         //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
-         np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
-         //SCRUTE(np[ijk].nodeId);
+               _cube.V000 = VFirst;    // will be (0,0,0) on the unit cube
+               _cube.V100 = VLast;             // will be (1,0,0) on the unit cube
        }
-  }
-
-  {
-    const TopoDS_Face& F = TopoDS::Face(meshFaces[_indX1]->GetSubShape());
-    const TColStd_ListOfInteger& indElt
-      = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
-    TColStd_ListIteratorOfListOfInteger itf(indElt);
-
-    faceQuadStruct* quad = _cube.quad_X1;
-    int i=nbx-1; // j = x/face , k = y/face
-    int nbdown = quad->nbPts[0];
-    int nbright = quad->nbPts[1];
-
-    for (; itf.More(); itf.Next())
-      {
-       int nodeId = itf.Value();
-       Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
-       Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
-       Handle (SMDS_FacePosition) fpos
-         = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
-       double ri = fpos->GetUParameter();
-       double rj = fpos->GetVParameter();
-       int i1 = int(ri);
-       int j1 = int(rj);
-       int ij1 = j1*nbdown +i1;
-       quad->uv_grid[ij1].nodeId = nodeId;
-      }
-
-    for (int i1=0; i1<nbdown; i1++)
-      for (int j1=0; j1<nbright; j1++)
+       else
        {
-         int ij1 = j1*nbdown +i1;
-         int j = cx1.ia*i1 + cx1.ib*j1 + cx1.ic; // j = x/face
-         int k = cx1.ja*i1 + cx1.jb*j1 + cx1.jc; // k = y/face
-         int ijk = k*nbx*nby + j*nbx + i;
-         //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
-         np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
-         //SCRUTE(np[ijk].nodeId);
+               _cube.V000 = VLast;
+               _cube.V100 = VFirst;
        }
-  }
-
-  {
-    const TopoDS_Face& F = TopoDS::Face(meshFaces[_indY0]->GetSubShape());
-    const TColStd_ListOfInteger& indElt
-      = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
-    TColStd_ListIteratorOfListOfInteger itf(indElt);
-
-    faceQuadStruct* quad = _cube.quad_Y0;
-    int j=0; // i = x/face , k = y/face
-    int nbdown = quad->nbPts[0];
-    int nbright = quad->nbPts[1];
-
-    for (; itf.More(); itf.Next())
-      {
-       int nodeId = itf.Value();
-       Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
-       Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
-       Handle (SMDS_FacePosition) fpos
-         = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
-       double ri = fpos->GetUParameter();
-       double rj = fpos->GetVParameter();
-       int i1 = int(ri);
-       int j1 = int(rj);
-       int ij1 = j1*nbdown +i1;
-       quad->uv_grid[ij1].nodeId = nodeId;
-      }
-
-    for (int i1=0; i1<nbdown; i1++)
-      for (int j1=0; j1<nbright; j1++)
+
+       i = 1;
+       E = _quads[0]->edge[i];
+       C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
+       TopExp::Vertices(E, VFirst, VLast);
+       isForward = (((l - f) * (_quads[0]->last[i] - _quads[0]->first[i])) > 0);
+       if (isForward)
+               _cube.V101 = VLast;             // will be (1,0,1) on the unit cube
+       else
+               _cube.V101 = VFirst;
+
+       i = 2;
+       E = _quads[0]->edge[i];
+       C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
+       TopExp::Vertices(E, VFirst, VLast);
+       isForward = (((l - f) * (_quads[0]->last[i] - _quads[0]->first[i])) > 0);
+       if (isForward)
+               _cube.V001 = VLast;             // will be (0,0,1) on the unit cube
+       else
+               _cube.V001 = VFirst;
+
+       // 1.4 - find edge X=0, Z=0 (ancestor of V000 not in face Y=0)
+       //     - find edge X=1, Z=0 (ancestor of V100 not in face Y=0)
+       //     - find edge X=1, Z=1 (ancestor of V101 not in face Y=0) 
+       //     - find edge X=0, Z=1 (ancestor of V001 not in face Y=0)
+       MESSAGE("---");
+
+       TopoDS_Edge E_0Y0 = EdgeNotInFace(aMesh, aShape, F, _cube.V000, MS);
+       ASSERT(!E_0Y0.IsNull());
+
+       TopoDS_Edge E_1Y0 = EdgeNotInFace(aMesh, aShape, F, _cube.V100, MS);
+       ASSERT(!E_1Y0.IsNull());
+
+       TopoDS_Edge E_1Y1 = EdgeNotInFace(aMesh, aShape, F, _cube.V101, MS);
+       ASSERT(!E_1Y1.IsNull());
+
+       TopoDS_Edge E_0Y1 = EdgeNotInFace(aMesh, aShape, F, _cube.V001, MS);
+       ASSERT(!E_0Y1.IsNull());
+
+       // 1.5 - identify the 4 vertices in face Y=1: V010, V110, V111, V011
+       MESSAGE("---");
+
+       TopExp::Vertices(E_0Y0, VFirst, VLast);
+       if (VFirst.IsSame(_cube.V000))
+               _cube.V010 = VLast;
+       else
+               _cube.V010 = VFirst;
+
+       TopExp::Vertices(E_1Y0, VFirst, VLast);
+       if (VFirst.IsSame(_cube.V100))
+               _cube.V110 = VLast;
+       else
+               _cube.V110 = VFirst;
+
+       TopExp::Vertices(E_1Y1, VFirst, VLast);
+       if (VFirst.IsSame(_cube.V101))
+               _cube.V111 = VLast;
+       else
+               _cube.V111 = VFirst;
+
+       TopExp::Vertices(E_0Y1, VFirst, VLast);
+       if (VFirst.IsSame(_cube.V001))
+               _cube.V011 = VLast;
+       else
+               _cube.V011 = VFirst;
+
+       // 1.6 - find remaining faces given 4 vertices
+       MESSAGE("---");
+
+       _indY0 = 0;
+       _cube.quad_Y0 = _quads[_indY0];
+
+       _indY1 = GetFaceIndex(aMesh, aShape, meshFaces,
+               _cube.V010, _cube.V011, _cube.V110, _cube.V111);
+       _cube.quad_Y1 = _quads[_indY1];
+
+       _indZ0 = GetFaceIndex(aMesh, aShape, meshFaces,
+               _cube.V000, _cube.V010, _cube.V100, _cube.V110);
+       _cube.quad_Z0 = _quads[_indZ0];
+
+       _indZ1 = GetFaceIndex(aMesh, aShape, meshFaces,
+               _cube.V001, _cube.V011, _cube.V101, _cube.V111);
+       _cube.quad_Z1 = _quads[_indZ1];
+
+       _indX0 = GetFaceIndex(aMesh, aShape, meshFaces,
+               _cube.V000, _cube.V001, _cube.V010, _cube.V011);
+       _cube.quad_X0 = _quads[_indX0];
+
+       _indX1 = GetFaceIndex(aMesh, aShape, meshFaces,
+               _cube.V100, _cube.V101, _cube.V110, _cube.V111);
+       _cube.quad_X1 = _quads[_indX1];
+
+       MESSAGE("---");
+
+       // 1.7 - get convertion coefs from face 2D normalized to 3D normalized
+
+       Conv2DStruct cx0;                       // for face X=0
+       Conv2DStruct cx1;                       // for face X=1
+       Conv2DStruct cy0;
+       Conv2DStruct cy1;
+       Conv2DStruct cz0;
+       Conv2DStruct cz1;
+
+       GetConv2DCoefs(*_cube.quad_X0, meshFaces[_indX0]->GetSubShape(),
+               _cube.V000, _cube.V010, _cube.V011, _cube.V001, cx0);
+       GetConv2DCoefs(*_cube.quad_X1, meshFaces[_indX1]->GetSubShape(),
+               _cube.V100, _cube.V110, _cube.V111, _cube.V101, cx1);
+       GetConv2DCoefs(*_cube.quad_Y0, meshFaces[_indY0]->GetSubShape(),
+               _cube.V000, _cube.V100, _cube.V101, _cube.V001, cy0);
+       GetConv2DCoefs(*_cube.quad_Y1, meshFaces[_indY1]->GetSubShape(),
+               _cube.V010, _cube.V110, _cube.V111, _cube.V011, cy1);
+       GetConv2DCoefs(*_cube.quad_Z0, meshFaces[_indZ0]->GetSubShape(),
+               _cube.V000, _cube.V100, _cube.V110, _cube.V010, cz0);
+       GetConv2DCoefs(*_cube.quad_Z1, meshFaces[_indZ1]->GetSubShape(),
+               _cube.V001, _cube.V101, _cube.V111, _cube.V011, cz1);
+
+       // 1.8 - create a 3D structure for normalized values
+
+       MESSAGE("---");
+       int nbx = _cube.quad_Y0->nbPts[0];
+       int nby = _cube.quad_Y0->nbPts[1];
+       int nbz;
+       if (cx0.a1 != 0)
+               nbz = _cube.quad_X0->nbPts[1];
+       else
+               nbz = _cube.quad_X0->nbPts[0];
+       //SCRUTE(nbx);
+       //SCRUTE(nby);
+       //SCRUTE(nbz);
+       int nbxyz = nbx * nby * nbz;
+       Point3DStruct *np = new Point3DStruct[nbxyz];
+
+       // 1.9 - store node indexes of faces
+
        {
-         int ij1 = j1*nbdown +i1;
-         int i = cy0.ia*i1 + cy0.ib*j1 + cy0.ic; // i = x/face
-         int k = cy0.ja*i1 + cy0.jb*j1 + cy0.jc; // k = y/face
-         int ijk = k*nbx*nby + j*nbx + i;
-         //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
-         np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
-         //SCRUTE(np[ijk].nodeId);
+               const TopoDS_Face & F = TopoDS::Face(meshFaces[_indX0]->GetSubShape());
+               const vector<int> & indElt
+                       = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
+
+               faceQuadStruct *quad = _cube.quad_X0;
+               int i = 0;                              // j = x/face , k = y/face
+               int nbdown = quad->nbPts[0];
+               int nbright = quad->nbPts[1];
+
+               for (int itf=0; itf<indElt.size(); itf++)
+               {
+                       int nodeId = indElt[itf];
+                       const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
+                       const SMDS_FacePosition* fpos
+                               = static_cast<const SMDS_FacePosition*>(node->GetPosition());
+                       double ri = fpos->GetUParameter();
+                       double rj = fpos->GetVParameter();
+                       int i1 = int (ri);
+                       int j1 = int (rj);
+                       int ij1 = j1 * nbdown + i1;
+                       quad->uv_grid[ij1].nodeId = nodeId;
+               }
+
+               for (int i1 = 0; i1 < nbdown; i1++)
+                       for (int j1 = 0; j1 < nbright; j1++)
+                       {
+                               int ij1 = j1 * nbdown + i1;
+                               int j = cx0.ia * i1 + cx0.ib * j1 + cx0.ic;     // j = x/face
+                               int k = cx0.ja * i1 + cx0.jb * j1 + cx0.jc;     // k = y/face
+                               int ijk = k * nbx * nby + j * nbx + i;
+                               //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
+                               np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
+                               //SCRUTE(np[ijk].nodeId);
+                       }
        }
-  }
-
-  {
-    const TopoDS_Face& F = TopoDS::Face(meshFaces[_indY1]->GetSubShape());
-    const TColStd_ListOfInteger& indElt
-      = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
-    TColStd_ListIteratorOfListOfInteger itf(indElt);
-
-    faceQuadStruct* quad = _cube.quad_Y1;
-    int j=nby-1; // i = x/face , k = y/face
-    int nbdown = quad->nbPts[0];
-    int nbright = quad->nbPts[1];
-
-    for (; itf.More(); itf.Next())
-      {
-       int nodeId = itf.Value();
-       Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
-       Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
-       Handle (SMDS_FacePosition) fpos
-         = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
-       double ri = fpos->GetUParameter();
-       double rj = fpos->GetVParameter();
-       int i1 = int(ri);
-       int j1 = int(rj);
-       int ij1 = j1*nbdown +i1;
-       quad->uv_grid[ij1].nodeId = nodeId;
-      }
-
-    for (int i1=0; i1<nbdown; i1++)
-      for (int j1=0; j1<nbright; j1++)
+
        {
-         int ij1 = j1*nbdown +i1;
-         int i = cy1.ia*i1 + cy1.ib*j1 + cy1.ic; // i = x/face
-         int k = cy1.ja*i1 + cy1.jb*j1 + cy1.jc; // k = y/face
-         int ijk = k*nbx*nby + j*nbx + i;
-         //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
-         np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
-         //SCRUTE(np[ijk].nodeId);
+               const TopoDS_Face & F = TopoDS::Face(meshFaces[_indX1]->GetSubShape());
+               const vector<int> & indElt
+                       = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
+
+               faceQuadStruct *quad = _cube.quad_X1;
+               int i = nbx - 1;                // j = x/face , k = y/face
+               int nbdown = quad->nbPts[0];
+               int nbright = quad->nbPts[1];
+
+               for (int itf=0; itf<indElt.size(); itf++)
+               {
+                       int nodeId = indElt[itf];
+                       const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
+                       const SMDS_FacePosition* fpos
+                               = static_cast<const SMDS_FacePosition*>(node->GetPosition());
+                       double ri = fpos->GetUParameter();
+                       double rj = fpos->GetVParameter();
+                       int i1 = int (ri);
+                       int j1 = int (rj);
+                       int ij1 = j1 * nbdown + i1;
+                       quad->uv_grid[ij1].nodeId = nodeId;
+               }
+
+               for (int i1 = 0; i1 < nbdown; i1++)
+                       for (int j1 = 0; j1 < nbright; j1++)
+                       {
+                               int ij1 = j1 * nbdown + i1;
+                               int j = cx1.ia * i1 + cx1.ib * j1 + cx1.ic;     // j = x/face
+                               int k = cx1.ja * i1 + cx1.jb * j1 + cx1.jc;     // k = y/face
+                               int ijk = k * nbx * nby + j * nbx + i;
+                               //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
+                               np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
+                               //SCRUTE(np[ijk].nodeId);
+                       }
        }
-  }
-
-  {
-    const TopoDS_Face& F = TopoDS::Face(meshFaces[_indZ0]->GetSubShape());
-    const TColStd_ListOfInteger& indElt
-      = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
-    TColStd_ListIteratorOfListOfInteger itf(indElt);
-
-    faceQuadStruct* quad = _cube.quad_Z0;
-    int k=0; // i = x/face , j = y/face
-    int nbdown = quad->nbPts[0];
-    int nbright = quad->nbPts[1];
-
-    for (; itf.More(); itf.Next())
-      {
-       int nodeId = itf.Value();
-       Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
-       Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
-       Handle (SMDS_FacePosition) fpos
-         = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
-       double ri = fpos->GetUParameter();
-       double rj = fpos->GetVParameter();
-       int i1 = int(ri);
-       int j1 = int(rj);
-       int ij1 = j1*nbdown +i1;
-       quad->uv_grid[ij1].nodeId = nodeId;
-      }
-
-    for (int i1=0; i1<nbdown; i1++)
-      for (int j1=0; j1<nbright; j1++)
+
        {
-         int ij1 = j1*nbdown +i1;
-         int i = cz0.ia*i1 + cz0.ib*j1 + cz0.ic; // i = x/face
-         int j = cz0.ja*i1 + cz0.jb*j1 + cz0.jc; // j = y/face
-         int ijk = k*nbx*nby + j*nbx + i;
-         //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
-         np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
-         //SCRUTE(np[ijk].nodeId);
+               const TopoDS_Face & F = TopoDS::Face(meshFaces[_indY0]->GetSubShape());
+               const vector<int> & indElt
+                       = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
+
+               faceQuadStruct *quad = _cube.quad_Y0;
+               int j = 0;                              // i = x/face , k = y/face
+               int nbdown = quad->nbPts[0];
+               int nbright = quad->nbPts[1];
+
+               for (int itf=0; itf<indElt.size(); itf++)
+               {
+                       int nodeId = indElt[itf];
+                       const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
+                       const SMDS_FacePosition * fpos
+                               = static_cast<const SMDS_FacePosition*>(node->GetPosition());
+                       double ri = fpos->GetUParameter();
+                       double rj = fpos->GetVParameter();
+                       int i1 = int (ri);
+                       int j1 = int (rj);
+                       int ij1 = j1 * nbdown + i1;
+                       quad->uv_grid[ij1].nodeId = nodeId;
+               }
+
+               for (int i1 = 0; i1 < nbdown; i1++)
+                       for (int j1 = 0; j1 < nbright; j1++)
+                       {
+                               int ij1 = j1 * nbdown + i1;
+                               int i = cy0.ia * i1 + cy0.ib * j1 + cy0.ic;     // i = x/face
+                               int k = cy0.ja * i1 + cy0.jb * j1 + cy0.jc;     // k = y/face
+                               int ijk = k * nbx * nby + j * nbx + i;
+                               //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
+                               np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
+                               //SCRUTE(np[ijk].nodeId);
+                       }
        }
-  }
-
-  {
-    const TopoDS_Face& F = TopoDS::Face(meshFaces[_indZ1]->GetSubShape());
-    const TColStd_ListOfInteger& indElt
-      = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
-    TColStd_ListIteratorOfListOfInteger itf(indElt);
-
-    faceQuadStruct* quad = _cube.quad_Z1;
-    int k=nbz-1; // i = x/face , j = y/face
-    int nbdown = quad->nbPts[0];
-    int nbright = quad->nbPts[1];
-
-    for (; itf.More(); itf.Next())
-      {
-       int nodeId = itf.Value();
-       Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
-       Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
-       Handle (SMDS_FacePosition) fpos
-         = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
-       double ri = fpos->GetUParameter();
-       double rj = fpos->GetVParameter();
-       int i1 = int(ri);
-       int j1 = int(rj);
-       int ij1 = j1*nbdown +i1;
-       quad->uv_grid[ij1].nodeId = nodeId;
-      }
-
-    for (int i1=0; i1<nbdown; i1++)
-      for (int j1=0; j1<nbright; j1++)
+
        {
-         int ij1 = j1*nbdown +i1;
-         int i = cz1.ia*i1 + cz1.ib*j1 + cz1.ic; // i = x/face
-         int j = cz1.ja*i1 + cz1.jb*j1 + cz1.jc; // j = y/face
-         int ijk = k*nbx*nby + j*nbx + i;
-         //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
-         np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
-         //SCRUTE(np[ijk].nodeId);
+               const TopoDS_Face & F = TopoDS::Face(meshFaces[_indY1]->GetSubShape());
+               const vector<int> & indElt
+                       = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
+
+               faceQuadStruct *quad = _cube.quad_Y1;
+               int j = nby - 1;                // i = x/face , k = y/face
+               int nbdown = quad->nbPts[0];
+               int nbright = quad->nbPts[1];
+
+               for (int itf=0; itf<indElt.size(); itf++)
+               {
+                       int nodeId = indElt[itf];
+                       const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
+                       const SMDS_FacePosition* fpos =
+                               static_cast<const SMDS_FacePosition *>(node->GetPosition());
+                       double ri = fpos->GetUParameter();
+                       double rj = fpos->GetVParameter();
+                       int i1 = int (ri);
+                       int j1 = int (rj);
+                       int ij1 = j1 * nbdown + i1;
+                       quad->uv_grid[ij1].nodeId = nodeId;
+               }
+
+               for (int i1 = 0; i1 < nbdown; i1++)
+                       for (int j1 = 0; j1 < nbright; j1++)
+                       {
+                               int ij1 = j1 * nbdown + i1;
+                               int i = cy1.ia * i1 + cy1.ib * j1 + cy1.ic;     // i = x/face
+                               int k = cy1.ja * i1 + cy1.jb * j1 + cy1.jc;     // k = y/face
+                               int ijk = k * nbx * nby + j * nbx + i;
+                               //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
+                               np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
+                               //SCRUTE(np[ijk].nodeId);
+                       }
        }
-  }
-
-  // 2.0 - for each node of the cube:
-  //       - get the 8 points 3D = 8 vertices of the cube
-  //       - get the 12 points 3D on the 12 edges of the cube
-  //       - get the 6 points 3D on the 6 faces with their ID
-  //       - compute the point 3D
-  //       - store the point 3D in SMESHDS, store its ID in 3D structure
-
-  TopoDS_Shell aShell;
-  TopExp_Explorer exp(aShape,TopAbs_SHELL);
-  if (exp.More())
-    {
-      aShell = TopoDS::Shell(exp.Current());
-    }
-  else
-    {
-      MESSAGE("no shell...");
-      ASSERT(0);
-    }
-
-  MESSAGE("---");
-  Pt3 p000, p001, p010, p011, p100, p101, p110, p111;
-  Pt3 px00, px01, px10, px11;
-  Pt3 p0y0, p0y1, p1y0, p1y1;
-  Pt3 p00z, p01z, p10z, p11z;
-  Pt3 pxy0, pxy1, px0z, px1z, p0yz, p1yz;
-
-  GetPoint(p000,     0,     0,     0, nbx, nby, nbz, np, meshDS);
-  GetPoint(p001,     0,     0, nbz-1, nbx, nby, nbz, np, meshDS);
-  GetPoint(p010,     0, nby-1,     0, nbx, nby, nbz, np, meshDS);
-  GetPoint(p011,     0, nby-1, nbz-1, nbx, nby, nbz, np, meshDS);
-  GetPoint(p100, nbx-1,     0,     0, nbx, nby, nbz, np, meshDS);
-  GetPoint(p101, nbx-1,     0, nbz-1, nbx, nby, nbz, np, meshDS);
-  GetPoint(p110, nbx-1, nby-1,     0, nbx, nby, nbz, np, meshDS);
-  GetPoint(p111, nbx-1, nby-1, nbz-1, nbx, nby, nbz, np, meshDS);
-
-  for (int i=1; i<nbx-1; i++)
-    {
-      for (int j=1; j<nby-1; j++)
+
        {
-         for (int k=1; k<nbz-1; k++)
-           {
-             // *** seulement maillage regulier
-             // 12 points on edges
-             GetPoint(px00,     i,     0,     0, nbx, nby, nbz, np, meshDS);
-             GetPoint(px01,     i,     0, nbz-1, nbx, nby, nbz, np, meshDS);
-             GetPoint(px10,     i, nby-1,     0, nbx, nby, nbz, np, meshDS);
-             GetPoint(px11,     i, nby-1, nbz-1, nbx, nby, nbz, np, meshDS);
-
-             GetPoint(p0y0,     0,     j,     0, nbx, nby, nbz, np, meshDS);
-             GetPoint(p0y1,     0,     j, nbz-1, nbx, nby, nbz, np, meshDS);
-             GetPoint(p1y0, nbx-1,     j,     0, nbx, nby, nbz, np, meshDS);
-             GetPoint(p1y1, nbx-1,     j, nbz-1, nbx, nby, nbz, np, meshDS);
-
-             GetPoint(p00z,     0,     0,     k, nbx, nby, nbz, np, meshDS);
-             GetPoint(p01z,     0, nby-1,     k, nbx, nby, nbz, np, meshDS);
-             GetPoint(p10z, nbx-1,     0,     k, nbx, nby, nbz, np, meshDS);
-             GetPoint(p11z, nbx-1, nby-1,     k, nbx, nby, nbz, np, meshDS);
-
-             // 12 points on faces
-             GetPoint(pxy0,     i,     j,     0, nbx, nby, nbz, np, meshDS);
-             GetPoint(pxy1,     i,     j, nbz-1, nbx, nby, nbz, np, meshDS);
-             GetPoint(px0z,     i,     0,     k, nbx, nby, nbz, np, meshDS);
-             GetPoint(px1z,     i, nby-1,     k, nbx, nby, nbz, np, meshDS);
-             GetPoint(p0yz,     0,     j,     k, nbx, nby, nbz, np, meshDS);
-             GetPoint(p1yz, nbx-1,     j,     k, nbx, nby, nbz, np, meshDS);
-
-             int ijk = k*nbx*nby + j*nbx + i;
-             double x = double(i)/double(nbx-1); // *** seulement
-             double y = double(j)/double(nby-1); // *** maillage
-             double z = double(k)/double(nbz-1); // *** regulier
-
-             Pt3 X;
-             for (int i=0; i<3; i++)
+               const TopoDS_Face & F = TopoDS::Face(meshFaces[_indZ0]->GetSubShape());
+               const vector<int> & indElt
+                       = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
+
+               faceQuadStruct *quad = _cube.quad_Z0;
+               int k = 0;                              // i = x/face , j = y/face
+               int nbdown = quad->nbPts[0];
+               int nbright = quad->nbPts[1];
+
+               for (int itf=0; itf<indElt.size(); itf++)
                {
-                 X[i] =
-                    (1-x)*p0yz[i] + x*p1yz[i]
-                   +(1-y)*px0z[i] + y*px1z[i]
-                   +(1-z)*pxy0[i] + z*pxy1[i]
-                   -(1-x)*((1-y)*p00z[i] + y*p01z[i])
-                   -   x *((1-y)*p10z[i] + y*p11z[i])
-                   -(1-y)*((1-z)*px00[i] + z*px01[i])
-                   -   y *((1-z)*px10[i] + z*px11[i])
-                   -(1-z)*((1-x)*p0y0[i] + x*p1y0[i])
-                   -   z *((1-x)*p0y1[i] + x*p1y1[i])
-                   +(1-x)*( (1-y)*((1-z)*p000[i] + z*p001[i])
-                           +   y *((1-z)*p010[i] + z*p011[i]))
-                   +   x *( (1-y)*((1-z)*p100[i] + z*p101[i])
-                           +   y *((1-z)*p110[i] + z*p111[i]));
+                       int nodeId = indElt[itf];
+                       const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
+                       const SMDS_FacePosition * fpos
+                               = static_cast<const SMDS_FacePosition*>(node->GetPosition());
+                       double ri = fpos->GetUParameter();
+                       double rj = fpos->GetVParameter();
+                       int i1 = int (ri);
+                       int j1 = int (rj);
+                       int ij1 = j1 * nbdown + i1;
+                       quad->uv_grid[ij1].nodeId = nodeId;
                }
 
+               for (int i1 = 0; i1 < nbdown; i1++)
+                       for (int j1 = 0; j1 < nbright; j1++)
+                       {
+                               int ij1 = j1 * nbdown + i1;
+                               int i = cz0.ia * i1 + cz0.ib * j1 + cz0.ic;     // i = x/face
+                               int j = cz0.ja * i1 + cz0.jb * j1 + cz0.jc;     // j = y/face
+                               int ijk = k * nbx * nby + j * nbx + i;
+                               //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
+                               np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
+                               //SCRUTE(np[ijk].nodeId);
+                       }
+       }
+
+       {
+               const TopoDS_Face & F = TopoDS::Face(meshFaces[_indZ1]->GetSubShape());
+               const vector<int> & indElt
+                       = aMesh.GetSubMesh(F)->GetSubMeshDS()->GetIDNodes();
 
-             int myNodeId = meshDS->AddNode(X[0],X[1],X[2]);
-             //MESSAGE("point "<<myNodeId<<" "<<X[0]<<" "<<X[1]<<" "<<X[2]);
-             np[ijk].nodeId = myNodeId;
-             Handle (SMDS_MeshElement) elt = meshDS->FindNode(myNodeId);
-             Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
+               faceQuadStruct *quad = _cube.quad_Z1;
+               int k = nbz - 1;                // i = x/face , j = y/face
+               int nbdown = quad->nbPts[0];
+               int nbright = quad->nbPts[1];
 
-             //meshDS->SetNodeInVolume(node, TopoDS::Solid(aShape));
-             meshDS->SetNodeInVolume(node, aShell);
-           }
+               for(int itf=0; itf<indElt.size(); itf++)
+               {
+                       int nodeId = indElt[itf];
+                       const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
+                       const SMDS_FacePosition* fpos
+                               = static_cast<const SMDS_FacePosition*>(node->GetPosition());
+                       double ri = fpos->GetUParameter();
+                       double rj = fpos->GetVParameter();
+                       int i1 = int (ri);
+                       int j1 = int (rj);
+                       int ij1 = j1 * nbdown + i1;
+                       quad->uv_grid[ij1].nodeId = nodeId;
+               }
+
+               for (int i1 = 0; i1 < nbdown; i1++)
+                       for (int j1 = 0; j1 < nbright; j1++)
+                       {
+                               int ij1 = j1 * nbdown + i1;
+                               int i = cz1.ia * i1 + cz1.ib * j1 + cz1.ic;     // i = x/face
+                               int j = cz1.ja * i1 + cz1.jb * j1 + cz1.jc;     // j = y/face
+                               int ijk = k * nbx * nby + j * nbx + i;
+                               //MESSAGE(" "<<ij1<<" "<<i<<" "<<j<<" "<<ijk);
+                               np[ijk].nodeId = quad->uv_grid[ij1].nodeId;
+                               //SCRUTE(np[ijk].nodeId);
+                       }
        }
-    }
 
-  //2.1 - for each node of the cube (less 3 *1 Faces):
-  //      - store hexahedron in SMESHDS
+       // 2.0 - for each node of the cube:
+       //       - get the 8 points 3D = 8 vertices of the cube
+       //       - get the 12 points 3D on the 12 edges of the cube
+       //       - get the 6 points 3D on the 6 faces with their ID
+       //       - compute the point 3D
+       //       - store the point 3D in SMESHDS, store its ID in 3D structure
 
-  for (int i=0; i<nbx-1; i++)
-    for (int j=0; j<nby-1; j++)
-      for (int k=0; k<nbz-1; k++)
+       TopoDS_Shell aShell;
+       TopExp_Explorer exp(aShape, TopAbs_SHELL);
+       if (exp.More())
+       {
+               aShell = TopoDS::Shell(exp.Current());
+       }
+       else
        {
-         int n1 =    k *nbx*nby +    j *nbx + i;
-         int n2 =    k *nbx*nby +    j *nbx + i+1;
-         int n3 =    k *nbx*nby + (j+1)*nbx + i+1;
-         int n4 =    k *nbx*nby + (j+1)*nbx + i;
-         int n5 = (k+1)*nbx*nby +    j *nbx + i;
-         int n6 = (k+1)*nbx*nby +    j *nbx + i+1;
-         int n7 = (k+1)*nbx*nby + (j+1)*nbx + i+1;
-         int n8 = (k+1)*nbx*nby + (j+1)*nbx + i;
-
-//       MESSAGE(" "<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<" "<<n6<<" "<<n7<<" "<<n8);
-         //MESSAGE(" "<<np[n1].nodeId<<" "<<np[n2].nodeId<<" "<<np[n3].nodeId<<" "<<np[n4].nodeId<<" "<<np[n5].nodeId<<" "<<np[n6].nodeId<<" "<<np[n7].nodeId<<" "<<np[n8].nodeId);
-
-         int hexa = meshDS->AddVolume(np[n1].nodeId,
-                                      np[n2].nodeId,
-                                      np[n3].nodeId,
-                                      np[n4].nodeId,
-                                      np[n5].nodeId,
-                                      np[n6].nodeId,
-                                      np[n7].nodeId,
-                                      np[n8].nodeId);
-         Handle (SMDS_MeshElement) elt = meshDS->FindElement(hexa);
-         meshDS->SetMeshElementOnShape(elt, aShell);
-
-         // *** 5 tetrahedres ... verifier orientations,
-         //     mettre en coherence &vec quadrangles-> triangles
-         //     choisir afficher 1 parmi edges, face et volumes
-//       int tetra1 = meshDS->AddVolume(np[n1].nodeId,
-//                                      np[n2].nodeId,
-//                                      np[n4].nodeId,
-//                                      np[n5].nodeId);
-//       int tetra2 = meshDS->AddVolume(np[n2].nodeId,
-//                                      np[n3].nodeId,
-//                                      np[n4].nodeId,
-//                                      np[n7].nodeId);
-//       int tetra3 = meshDS->AddVolume(np[n5].nodeId,
-//                                      np[n6].nodeId,
-//                                      np[n7].nodeId,
-//                                      np[n2].nodeId);
-//       int tetra4 = meshDS->AddVolume(np[n5].nodeId,
-//                                      np[n7].nodeId,
-//                                      np[n8].nodeId,
-//                                      np[n4].nodeId);
-//       int tetra5 = meshDS->AddVolume(np[n5].nodeId,
-//                                      np[n7].nodeId,
-//                                      np[n2].nodeId,
-//                                      np[n4].nodeId);
+               MESSAGE("no shell...");
+               ASSERT(0);
+       }
 
+       Pt3 p000, p001, p010, p011, p100, p101, p110, p111;
+       Pt3 px00, px01, px10, px11;
+       Pt3 p0y0, p0y1, p1y0, p1y1;
+       Pt3 p00z, p01z, p10z, p11z;
+       Pt3 pxy0, pxy1, px0z, px1z, p0yz, p1yz;
+
+       GetPoint(p000, 0, 0, 0, nbx, nby, nbz, np, meshDS);
+       GetPoint(p001, 0, 0, nbz - 1, nbx, nby, nbz, np, meshDS);
+       GetPoint(p010, 0, nby - 1, 0, nbx, nby, nbz, np, meshDS);
+       GetPoint(p011, 0, nby - 1, nbz - 1, nbx, nby, nbz, np, meshDS);
+       GetPoint(p100, nbx - 1, 0, 0, nbx, nby, nbz, np, meshDS);
+       GetPoint(p101, nbx - 1, 0, nbz - 1, nbx, nby, nbz, np, meshDS);
+       GetPoint(p110, nbx - 1, nby - 1, 0, nbx, nby, nbz, np, meshDS);
+       GetPoint(p111, nbx - 1, nby - 1, nbz - 1, nbx, nby, nbz, np, meshDS);
+
+       for (int i = 1; i < nbx - 1; i++)
+       {
+               for (int j = 1; j < nby - 1; j++)
+               {
+                       for (int k = 1; k < nbz - 1; k++)
+                       {
+                               // *** seulement maillage regulier
+                               // 12 points on edges
+                               GetPoint(px00, i, 0, 0, nbx, nby, nbz, np, meshDS);
+                               GetPoint(px01, i, 0, nbz - 1, nbx, nby, nbz, np, meshDS);
+                               GetPoint(px10, i, nby - 1, 0, nbx, nby, nbz, np, meshDS);
+                               GetPoint(px11, i, nby - 1, nbz - 1, nbx, nby, nbz, np, meshDS);
+
+                               GetPoint(p0y0, 0, j, 0, nbx, nby, nbz, np, meshDS);
+                               GetPoint(p0y1, 0, j, nbz - 1, nbx, nby, nbz, np, meshDS);
+                               GetPoint(p1y0, nbx - 1, j, 0, nbx, nby, nbz, np, meshDS);
+                               GetPoint(p1y1, nbx - 1, j, nbz - 1, nbx, nby, nbz, np, meshDS);
+
+                               GetPoint(p00z, 0, 0, k, nbx, nby, nbz, np, meshDS);
+                               GetPoint(p01z, 0, nby - 1, k, nbx, nby, nbz, np, meshDS);
+                               GetPoint(p10z, nbx - 1, 0, k, nbx, nby, nbz, np, meshDS);
+                               GetPoint(p11z, nbx - 1, nby - 1, k, nbx, nby, nbz, np, meshDS);
+
+                               // 12 points on faces
+                               GetPoint(pxy0, i, j, 0, nbx, nby, nbz, np, meshDS);
+                               GetPoint(pxy1, i, j, nbz - 1, nbx, nby, nbz, np, meshDS);
+                               GetPoint(px0z, i, 0, k, nbx, nby, nbz, np, meshDS);
+                               GetPoint(px1z, i, nby - 1, k, nbx, nby, nbz, np, meshDS);
+                               GetPoint(p0yz, 0, j, k, nbx, nby, nbz, np, meshDS);
+                               GetPoint(p1yz, nbx - 1, j, k, nbx, nby, nbz, np, meshDS);
+
+                               int ijk = k * nbx * nby + j * nbx + i;
+                               double x = double (i) / double (nbx - 1);       // *** seulement
+                               double y = double (j) / double (nby - 1);       // *** maillage
+                               double z = double (k) / double (nbz - 1);       // *** regulier
+
+                               Pt3 X;
+                               for (int i = 0; i < 3; i++)
+                               {
+                                       X[i] =
+                                               (1 - x) * p0yz[i] + x * p1yz[i]
+                                               + (1 - y) * px0z[i] + y * px1z[i]
+                                               + (1 - z) * pxy0[i] + z * pxy1[i]
+                                               - (1 - x) * ((1 - y) * p00z[i] + y * p01z[i])
+                                               - x * ((1 - y) * p10z[i] + y * p11z[i])
+                                               - (1 - y) * ((1 - z) * px00[i] + z * px01[i])
+                                               - y * ((1 - z) * px10[i] + z * px11[i])
+                                               - (1 - z) * ((1 - x) * p0y0[i] + x * p1y0[i])
+                                               - z * ((1 - x) * p0y1[i] + x * p1y1[i])
+                                               + (1 - x) * ((1 - y) * ((1 - z) * p000[i] + z * p001[i])
+                                               + y * ((1 - z) * p010[i] + z * p011[i]))
+                                               + x * ((1 - y) * ((1 - z) * p100[i] + z * p101[i])
+                                               + y * ((1 - z) * p110[i] + z * p111[i]));
+                               }
+
+                               SMDS_MeshNode * node = meshDS->AddNode(X[0], X[1], X[2]);
+                               np[ijk].nodeId = node->GetID();
+                               //meshDS->SetNodeInVolume(node, TopoDS::Solid(aShape));
+                               meshDS->SetNodeInVolume(node, aShell);
+                       }
+               }
        }
-  
-  return true;
+
+       //2.1 - for each node of the cube (less 3 *1 Faces):
+       //      - store hexahedron in SMESHDS
+       MESSAGE("Storing hexahedron into the DS");
+       for (int i = 0; i < nbx - 1; i++)
+               for (int j = 0; j < nby - 1; j++)
+                       for (int k = 0; k < nbz - 1; k++)
+                       {
+                               int n1 = k * nbx * nby + j * nbx + i;
+                               int n2 = k * nbx * nby + j * nbx + i + 1;
+                               int n3 = k * nbx * nby + (j + 1) * nbx + i + 1;
+                               int n4 = k * nbx * nby + (j + 1) * nbx + i;
+                               int n5 = (k + 1) * nbx * nby + j * nbx + i;
+                               int n6 = (k + 1) * nbx * nby + j * nbx + i + 1;
+                               int n7 = (k + 1) * nbx * nby + (j + 1) * nbx + i + 1;
+                               int n8 = (k + 1) * nbx * nby + (j + 1) * nbx + i;
+
+//    MESSAGE(" "<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<" "<<n6<<" "<<n7<<" "<<n8);
+                               //MESSAGE(" "<<np[n1].nodeId<<" "<<np[n2].nodeId<<" "<<np[n3].nodeId<<" "<<np[n4].nodeId<<" "<<np[n5].nodeId<<" "<<np[n6].nodeId<<" "<<np[n7].nodeId<<" "<<np[n8].nodeId);
+
+                               SMDS_MeshVolume * elt = meshDS->AddVolume(np[n1].nodeId,
+                                       np[n2].nodeId,
+                                       np[n3].nodeId,
+                                       np[n4].nodeId,
+                                       np[n5].nodeId,
+                                       np[n6].nodeId,
+                                       np[n7].nodeId,
+                                       np[n8].nodeId);
+                                ;
+                               meshDS->SetMeshElementOnShape(elt, aShell);
+
+                               // *** 5 tetrahedres ... verifier orientations,
+                               //     mettre en coherence &vec quadrangles-> triangles
+                               //     choisir afficher 1 parmi edges, face et volumes
+//    int tetra1 = meshDS->AddVolume(np[n1].nodeId,
+//                   np[n2].nodeId,
+//                   np[n4].nodeId,
+//                   np[n5].nodeId);
+//    int tetra2 = meshDS->AddVolume(np[n2].nodeId,
+//                   np[n3].nodeId,
+//                   np[n4].nodeId,
+//                   np[n7].nodeId);
+//    int tetra3 = meshDS->AddVolume(np[n5].nodeId,
+//                   np[n6].nodeId,
+//                   np[n7].nodeId,
+//                   np[n2].nodeId);
+//    int tetra4 = meshDS->AddVolume(np[n5].nodeId,
+//                   np[n7].nodeId,
+//                   np[n8].nodeId,
+//                   np[n4].nodeId);
+//    int tetra5 = meshDS->AddVolume(np[n5].nodeId,
+//                   np[n7].nodeId,
+//                   np[n2].nodeId,
+//                   np[n4].nodeId);
+
+                       }
+
+       MESSAGE("End of SMESH_Hexa_3D::Compute()");
+       return true;
 }
 
 //=============================================================================
@@ -734,20 +724,15 @@ bool SMESH_Hexa_3D::Compute(SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-void SMESH_Hexa_3D::GetPoint(Pt3 p,
-                            int i, int j, int k,
-                            int nbx, int nby, int nbz,
-                            Point3DStruct *np,
-                            const Handle(SMESHDS_Mesh)& meshDS)
+void SMESH_Hexa_3D::GetPoint(Pt3 p, int i, int j, int k, int nbx, int nby,
+       int nbz, Point3DStruct * np, const SMESHDS_Mesh * meshDS)
 {
-  int ijk = k*nbx*nby + j*nbx + i;
-  int nodeId = np[ijk].nodeId;
-  Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
-  Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
-  p[0] = node->X();
-  p[1] = node->Y();
-  p[2] = node->Z();
-  //MESSAGE(" "<<i<<" "<<j<<" "<<k<<" "<<p[0]<<" "<<p[1]<<" "<<p[2]);
+       int ijk = k * nbx * nby + j * nbx + i;
+       const SMDS_MeshNode * node = meshDS->FindNode(np[ijk].nodeId);
+       p[0] = node->X();
+       p[1] = node->Y();
+       p[2] = node->Z();
+       //MESSAGE(" "<<i<<" "<<j<<" "<<k<<" "<<p[0]<<" "<<p[1]<<" "<<p[2]);
 }
 
 //=============================================================================
@@ -756,36 +741,36 @@ void SMESH_Hexa_3D::GetPoint(Pt3 p,
  */
 //=============================================================================
 
-int SMESH_Hexa_3D::GetFaceIndex(SMESH_Mesh& aMesh,
-                               const TopoDS_Shape& aShape,
-                               const vector<SMESH_subMesh*>& meshFaces,
-                               const TopoDS_Vertex& V0,
-                               const TopoDS_Vertex& V1,
-                               const TopoDS_Vertex& V2,
-                               const TopoDS_Vertex& V3)
+int SMESH_Hexa_3D::GetFaceIndex(SMESH_Mesh & aMesh,
+       const TopoDS_Shape & aShape,
+       const vector < SMESH_subMesh * >&meshFaces,
+       const TopoDS_Vertex & V0,
+       const TopoDS_Vertex & V1,
+       const TopoDS_Vertex & V2, const TopoDS_Vertex & V3)
 {
-  MESSAGE("SMESH_Hexa_3D::GetFaceIndex");
-  int faceIndex = -1;
-  for (int i=1; i<6; i++)
-    {
-      const TopoDS_Shape& aFace = meshFaces[i]->GetSubShape();
-      //const TopoDS_Face& F = TopoDS::Face(aFace);
-      TopTools_IndexedMapOfShape M;
-      TopExp::MapShapes(aFace, TopAbs_VERTEX, M);
-      bool verticesInShape = false;
-      if (M.Contains(V0))
-       if (M.Contains(V1))
-         if (M.Contains(V2))
-           if (M.Contains(V3)) verticesInShape = true;
-      if (verticesInShape)
+       MESSAGE("SMESH_Hexa_3D::GetFaceIndex");
+       int faceIndex = -1;
+       for (int i = 1; i < 6; i++)
        {
-         faceIndex = i;
-         break;
+               const TopoDS_Shape & aFace = meshFaces[i]->GetSubShape();
+               //const TopoDS_Face& F = TopoDS::Face(aFace);
+               TopTools_IndexedMapOfShape M;
+               TopExp::MapShapes(aFace, TopAbs_VERTEX, M);
+               bool verticesInShape = false;
+               if (M.Contains(V0))
+                       if (M.Contains(V1))
+                               if (M.Contains(V2))
+                                       if (M.Contains(V3))
+                                               verticesInShape = true;
+               if (verticesInShape)
+               {
+                       faceIndex = i;
+                       break;
+               }
        }
-    }
-  ASSERT(faceIndex>0);
-  SCRUTE(faceIndex);
-  return faceIndex;
+       ASSERT(faceIndex > 0);
+       SCRUTE(faceIndex);
+       return faceIndex;
 }
 
 //=============================================================================
@@ -795,46 +780,46 @@ int SMESH_Hexa_3D::GetFaceIndex(SMESH_Mesh& aMesh,
 //=============================================================================
 
 TopoDS_Edge
-SMESH_Hexa_3D::EdgeNotInFace(SMESH_Mesh& aMesh,
-                            const TopoDS_Shape& aShape,
-                            const TopoDS_Face& aFace,
-                            const TopoDS_Vertex& aVertex,
-                            const TopTools_IndexedDataMapOfShapeListOfShape& MS)
+       SMESH_Hexa_3D::EdgeNotInFace(SMESH_Mesh & aMesh,
+       const TopoDS_Shape & aShape,
+       const TopoDS_Face & aFace,
+       const TopoDS_Vertex & aVertex,
+       const TopTools_IndexedDataMapOfShapeListOfShape & MS)
 {
-  MESSAGE("SMESH_Hexa_3D::EdgeNotInFace");
-  TopTools_IndexedDataMapOfShapeListOfShape MF;
-  TopExp::MapShapesAndAncestors(aFace, TopAbs_VERTEX, TopAbs_EDGE, MF);
-  const TopTools_ListOfShape& ancestorsInSolid = MS.FindFromKey(aVertex);
-  const TopTools_ListOfShape& ancestorsInFace  = MF.FindFromKey(aVertex);
-  SCRUTE(ancestorsInSolid.Extent());
-  SCRUTE(ancestorsInFace.Extent());
-  ASSERT(ancestorsInSolid.Extent() == 6); // 6 (edges doublees)
-  ASSERT(ancestorsInFace.Extent() == 2);
-  
-  TopoDS_Edge E;
-  E.Nullify();    
-  TopTools_ListIteratorOfListOfShape its(ancestorsInSolid);
-  for ( ; its.More();its.Next())
-  {
-    TopoDS_Shape ancestor = its.Value();
-    TopTools_ListIteratorOfListOfShape itf(ancestorsInFace);
-    bool isInFace = false;
-    for ( ; itf.More();itf.Next())
-      {
-       TopoDS_Shape ancestorInFace = itf.Value();
-       if (ancestorInFace.IsSame(ancestor))
-         {
-           isInFace = true;
-           break;
-         }
-      }
-    if (! isInFace)
-      {
-       E = TopoDS::Edge(ancestor);
-       break;
-      }
-  }
-  return E;
+       MESSAGE("SMESH_Hexa_3D::EdgeNotInFace");
+       TopTools_IndexedDataMapOfShapeListOfShape MF;
+       TopExp::MapShapesAndAncestors(aFace, TopAbs_VERTEX, TopAbs_EDGE, MF);
+       const TopTools_ListOfShape & ancestorsInSolid = MS.FindFromKey(aVertex);
+       const TopTools_ListOfShape & ancestorsInFace = MF.FindFromKey(aVertex);
+       SCRUTE(ancestorsInSolid.Extent());
+       SCRUTE(ancestorsInFace.Extent());
+       ASSERT(ancestorsInSolid.Extent() == 6); // 6 (edges doublees)
+       ASSERT(ancestorsInFace.Extent() == 2);
+
+       TopoDS_Edge E;
+       E.Nullify();
+       TopTools_ListIteratorOfListOfShape its(ancestorsInSolid);
+       for (; its.More(); its.Next())
+       {
+               TopoDS_Shape ancestor = its.Value();
+               TopTools_ListIteratorOfListOfShape itf(ancestorsInFace);
+               bool isInFace = false;
+               for (; itf.More(); itf.Next())
+               {
+                       TopoDS_Shape ancestorInFace = itf.Value();
+                       if (ancestorInFace.IsSame(ancestor))
+                       {
+                               isInFace = true;
+                               break;
+                       }
+               }
+               if (!isInFace)
+               {
+                       E = TopoDS::Edge(ancestor);
+                       break;
+               }
+       }
+       return E;
 }
 
 //=============================================================================
@@ -843,95 +828,133 @@ SMESH_Hexa_3D::EdgeNotInFace(SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-  void SMESH_Hexa_3D::GetConv2DCoefs(const faceQuadStruct& quad,
-                                    const TopoDS_Shape& aShape,
-                                    const TopoDS_Vertex& V0,
-                                    const TopoDS_Vertex& V1,
-                                    const TopoDS_Vertex& V2,
-                                    const TopoDS_Vertex& V3,
-                                    Conv2DStruct& conv)
+void SMESH_Hexa_3D::GetConv2DCoefs(const faceQuadStruct & quad,
+       const TopoDS_Shape & aShape,
+       const TopoDS_Vertex & V0,
+       const TopoDS_Vertex & V1,
+       const TopoDS_Vertex & V2, const TopoDS_Vertex & V3, Conv2DStruct & conv)
 {
-  MESSAGE("SMESH_Hexa_3D::GetConv2DCoefs");
-  const TopoDS_Face& F = TopoDS::Face(aShape);
-  TopoDS_Edge E = quad.edge[0];
-  double f,l;
-  Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
-  TopoDS_Vertex VFirst, VLast;
-  TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
-  bool isForward = (((l-f)*(quad.last[0] - quad.first[0])) > 0);
-  TopoDS_Vertex VA, VB;
-  if (isForward)
-    {
-      VA = VFirst; VB = VLast;
-    }
-  else
-    {
-     VA = VLast; VB = VFirst;
-    }
-  int a1,b1,c1,a2,b2,c2;
-  if (VA.IsSame(V0))
-    if (VB.IsSame(V1))
-      {
-       a1= 1; b1= 0; c1= 0; // x
-       a2= 0; b2= 1; c2= 0; // y
-      }
-    else
-      {
-       ASSERT(VB.IsSame(V3));
-       a1= 0; b1= 1; c1= 0; // y
-       a2= 1; b2= 0; c2= 0; // x
-      }
-  if (VA.IsSame(V1))
-    if (VB.IsSame(V2))
-      {
-       a1= 0; b1=-1; c1= 1; // 1-y
-       a2= 1; b2= 0; c2= 0; // x
-      }
-    else
-      {
-       ASSERT(VB.IsSame(V0));
-       a1=-1; b1= 0; c1= 1; // 1-x
-       a2= 0; b2= 1; c2= 0; // y
-      }
-  if (VA.IsSame(V2))
-    if (VB.IsSame(V3))
-      {
-       a1=-1; b1= 0; c1= 1; // 1-x
-       a2= 0; b2=-1; c2= 1; // 1-y
-      }
-    else
-      {
-       ASSERT(VB.IsSame(V1));
-       a1= 0; b1=-1; c1= 1; // 1-y
-       a2=-1; b2= 0; c2= 1; // 1-x
-      }
-  if (VA.IsSame(V3))
-    if (VB.IsSame(V0))
-      {
-       a1= 0; b1= 1; c1= 0; // y
-       a2=-1; b2= 0; c2= 1; // 1-x
-      }
-    else
-      {
-       ASSERT(VB.IsSame(V2));
-       a1= 1; b1= 0; c1= 0;  // x
-       a2= 0; b2=-1; c2= 1;  // 1-y
-      }
-  MESSAGE("X = "<<c1<<"+ "<<a1<<"*x + "<<b1<<"*y");
-  MESSAGE("Y = "<<c2<<"+ "<<a2<<"*x + "<<b2<<"*y");
-  conv.a1=a1; conv.b1=b1; conv.c1=c1;
-  conv.a2=a2; conv.b2=b2; conv.c2=c2;
-
-  int nbdown = quad.nbPts[0];
-  int nbright = quad.nbPts[1];
-  conv.ia = int(a1);
-  conv.ib = int(b1);
-  conv.ic = int(c1*a1*a1)*(nbdown-1) + int(c1*b1*b1)*(nbright-1);
-  conv.ja = int(a2);
-  conv.jb = int(b2);
-  conv.jc = int(c2*a2*a2)*(nbdown-1) + int(c2*b2*b2)*(nbright-1);
-  MESSAGE("I "<<conv.ia<<" "<<conv.ib<<" "<<conv.ic);
-  MESSAGE("J "<<conv.ja<<" "<<conv.jb<<" "<<conv.jc);
+       MESSAGE("SMESH_Hexa_3D::GetConv2DCoefs");
+       const TopoDS_Face & F = TopoDS::Face(aShape);
+       TopoDS_Edge E = quad.edge[0];
+       double f, l;
+       Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
+       TopoDS_Vertex VFirst, VLast;
+       TopExp::Vertices(E, VFirst, VLast);     // corresponds to f and l
+       bool isForward = (((l - f) * (quad.last[0] - quad.first[0])) > 0);
+       TopoDS_Vertex VA, VB;
+       if (isForward)
+       {
+               VA = VFirst;
+               VB = VLast;
+       }
+       else
+       {
+               VA = VLast;
+               VB = VFirst;
+       }
+       int a1, b1, c1, a2, b2, c2;
+       if (VA.IsSame(V0))
+               if (VB.IsSame(V1))
+               {
+                       a1 = 1;
+                       b1 = 0;
+                       c1 = 0;                         // x
+                       a2 = 0;
+                       b2 = 1;
+                       c2 = 0;                         // y
+               }
+               else
+               {
+                       ASSERT(VB.IsSame(V3));
+                       a1 = 0;
+                       b1 = 1;
+                       c1 = 0;                         // y
+                       a2 = 1;
+                       b2 = 0;
+                       c2 = 0;                         // x
+               }
+       if (VA.IsSame(V1))
+               if (VB.IsSame(V2))
+               {
+                       a1 = 0;
+                       b1 = -1;
+                       c1 = 1;                         // 1-y
+                       a2 = 1;
+                       b2 = 0;
+                       c2 = 0;                         // x
+               }
+               else
+               {
+                       ASSERT(VB.IsSame(V0));
+                       a1 = -1;
+                       b1 = 0;
+                       c1 = 1;                         // 1-x
+                       a2 = 0;
+                       b2 = 1;
+                       c2 = 0;                         // y
+               }
+       if (VA.IsSame(V2))
+               if (VB.IsSame(V3))
+               {
+                       a1 = -1;
+                       b1 = 0;
+                       c1 = 1;                         // 1-x
+                       a2 = 0;
+                       b2 = -1;
+                       c2 = 1;                         // 1-y
+               }
+               else
+               {
+                       ASSERT(VB.IsSame(V1));
+                       a1 = 0;
+                       b1 = -1;
+                       c1 = 1;                         // 1-y
+                       a2 = -1;
+                       b2 = 0;
+                       c2 = 1;                         // 1-x
+               }
+       if (VA.IsSame(V3))
+               if (VB.IsSame(V0))
+               {
+                       a1 = 0;
+                       b1 = 1;
+                       c1 = 0;                         // y
+                       a2 = -1;
+                       b2 = 0;
+                       c2 = 1;                         // 1-x
+               }
+               else
+               {
+                       ASSERT(VB.IsSame(V2));
+                       a1 = 1;
+                       b1 = 0;
+                       c1 = 0;                         // x
+                       a2 = 0;
+                       b2 = -1;
+                       c2 = 1;                         // 1-y
+               }
+       MESSAGE("X = " << c1 << "+ " << a1 << "*x + " << b1 << "*y");
+       MESSAGE("Y = " << c2 << "+ " << a2 << "*x + " << b2 << "*y");
+       conv.a1 = a1;
+       conv.b1 = b1;
+       conv.c1 = c1;
+       conv.a2 = a2;
+       conv.b2 = b2;
+       conv.c2 = c2;
+
+       int nbdown = quad.nbPts[0];
+       int nbright = quad.nbPts[1];
+       conv.ia = int (a1);
+       conv.ib = int (b1);
+       conv.ic =
+               int (c1 * a1 * a1) * (nbdown - 1) + int (c1 * b1 * b1) * (nbright - 1);
+       conv.ja = int (a2);
+       conv.jb = int (b2);
+       conv.jc =
+               int (c2 * a2 * a2) * (nbdown - 1) + int (c2 * b2 * b2) * (nbright - 1);
+       MESSAGE("I " << conv.ia << " " << conv.ib << " " << conv.ic);
+       MESSAGE("J " << conv.ja << " " << conv.jb << " " << conv.jc);
 }
 
 //=============================================================================
@@ -942,7 +965,7 @@ SMESH_Hexa_3D::EdgeNotInFace(SMESH_Mesh& aMesh,
 
 ostream & SMESH_Hexa_3D::SaveTo(ostream & save)
 {
-  return save << this;
+       return save << this;
 }
 
 //=============================================================================
@@ -953,7 +976,7 @@ ostream & SMESH_Hexa_3D::SaveTo(ostream & save)
 
 istream & SMESH_Hexa_3D::LoadFrom(istream & load)
 {
-  return load >> (*this);
+       return load >> (*this);
 }
 
 //=============================================================================
@@ -962,9 +985,9 @@ istream & SMESH_Hexa_3D::LoadFrom(istream & load)
  */
 //=============================================================================
 
-ostream & operator << (ostream & save, SMESH_Hexa_3D & hyp)
+ostream & operator <<(ostream & save, SMESH_Hexa_3D & hyp)
 {
-  return save;
+       return save;
 }
 
 //=============================================================================
@@ -973,7 +996,7 @@ ostream & operator << (ostream & save, SMESH_Hexa_3D & hyp)
  */
 //=============================================================================
 
-istream & operator >> (istream & load, SMESH_Hexa_3D & hyp)
+istream & operator >>(istream & load, SMESH_Hexa_3D & hyp)
 {
-  return load;
+       return load;
 }
index 9aaf2b4..3a69f84 100644 (file)
@@ -27,7 +27,6 @@
 //  $Header$
 
 using namespace std;
-using namespace std;
 #include "SMESH_MEFISTO_2D.hxx"
 #include "SMESH_Gen.hxx"
 #include "SMESH_Mesh.hxx"
@@ -38,8 +37,6 @@ using namespace std;
 #include "Rn.h"
 #include "aptrte.h"
 
-#include "SMESHDS_ListOfPtrHypothesis.hxx"
-#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
 #include "SMDS_MeshElement.hxx"
 #include "SMDS_MeshNode.hxx"
 #include "SMDS_EdgePosition.hxx"
@@ -70,20 +67,20 @@ using namespace std;
  */
 //=============================================================================
 
-SMESH_MEFISTO_2D::SMESH_MEFISTO_2D(int hypId, int studyId, SMESH_Gen* gen)
-  SMESH_2D_Algo(hypId, studyId, gen)
+SMESH_MEFISTO_2D::SMESH_MEFISTO_2D(int hypId, int studyId,
+       SMESH_Gen * gen):SMESH_2D_Algo(hypId, studyId, gen)
 {
-  MESSAGE("SMESH_MEFISTO_2D::SMESH_MEFISTO_2D");
-  _name = "MEFISTO_2D";
+       MESSAGE("SMESH_MEFISTO_2D::SMESH_MEFISTO_2D");
+       _name = "MEFISTO_2D";
 //   _shapeType = TopAbs_FACE;
-  _shapeType = (1<<TopAbs_FACE);
-  _compatibleHypothesis.push_back("MaxElementArea");
-  _compatibleHypothesis.push_back("LengthFromEdges");
-
-  _edgeLength = 0;
-  _maxElementArea = 0;
-  _hypMaxElementArea = NULL;
-  _hypLengthFromEdges = NULL;
+       _shapeType = (1 << TopAbs_FACE);
+       _compatibleHypothesis.push_back("MaxElementArea");
+       _compatibleHypothesis.push_back("LengthFromEdges");
+
+       _edgeLength = 0;
+       _maxElementArea = 0;
+       _hypMaxElementArea = NULL;
+       _hypLengthFromEdges = NULL;
 }
 
 //=============================================================================
@@ -94,7 +91,7 @@ SMESH_MEFISTO_2D::SMESH_MEFISTO_2D(int hypId, int studyId, SMESH_Gen* gen)
 
 SMESH_MEFISTO_2D::~SMESH_MEFISTO_2D()
 {
-  MESSAGE("SMESH_MEFISTO_2D::~SMESH_MEFISTO_2D");
+       MESSAGE("SMESH_MEFISTO_2D::~SMESH_MEFISTO_2D");
 }
 
 //=============================================================================
@@ -103,65 +100,64 @@ SMESH_MEFISTO_2D::~SMESH_MEFISTO_2D()
  */
 //=============================================================================
 
-bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh& aMesh,
-                              const TopoDS_Shape& aShape)
+bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh & aMesh,
+       const TopoDS_Shape & aShape)
 {
-  //MESSAGE("SMESH_MEFISTO_2D::CheckHypothesis");
-
-  _hypMaxElementArea = NULL;
-  _hypLengthFromEdges = NULL;
-
-  list<SMESHDS_Hypothesis*>::const_iterator itl;
-  SMESHDS_Hypothesis* theHyp;
-
-  const list<SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape);
-  int nbHyp = hyps.size();
-  if (nbHyp != 1) return false;  // only one compatible hypothesis allowed
-
-  itl = hyps.begin();
-  theHyp = (*itl);
-
-  string hypName = theHyp->GetName();
-  int hypId = theHyp->GetID();
-  //SCRUTE(hypName);
-
-  bool isOk = false;
-
-  if (hypName == "MaxElementArea")
-    {
-      _hypMaxElementArea = dynamic_cast<SMESH_MaxElementArea*> (theHyp);
-      ASSERT(_hypMaxElementArea);
-      _maxElementArea = _hypMaxElementArea->GetMaxArea();
-      _edgeLength = 0;
-      isOk =true;
-    }
-
-  if (hypName == "LengthFromEdges")
-    {
-      _hypLengthFromEdges = dynamic_cast<SMESH_LengthFromEdges*> (theHyp);
-      ASSERT(_hypLengthFromEdges);
-      _edgeLength = 0;
-      _maxElementArea = 0;
-      isOk =true;
-    }
-
-
-  if (isOk)
-    {
-      isOk = false;
-      if (_maxElementArea > 0)
+       //MESSAGE("SMESH_MEFISTO_2D::CheckHypothesis");
+
+       _hypMaxElementArea = NULL;
+       _hypLengthFromEdges = NULL;
+
+       list <const SMESHDS_Hypothesis * >::const_iterator itl;
+       const SMESHDS_Hypothesis *theHyp;
+
+       const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
+       int nbHyp = hyps.size();
+       if (nbHyp != 1) return false;// only one compatible hypothesis allowed
+
+       itl = hyps.begin();
+       theHyp = (*itl);
+
+       string hypName = theHyp->GetName();
+       int hypId = theHyp->GetID();
+       //SCRUTE(hypName);
+
+       bool isOk = false;
+
+       if (hypName == "MaxElementArea")
        {
-         _edgeLength = 2*sqrt(_maxElementArea);  // triangles : minorant
-         isOk = true;
+               _hypMaxElementArea = static_cast<const SMESH_MaxElementArea *>(theHyp);
+               ASSERT(_hypMaxElementArea);
+               _maxElementArea = _hypMaxElementArea->GetMaxArea();
+               _edgeLength = 0;
+               isOk = true;
        }
-      else isOk = (_hypLengthFromEdges != NULL); // **** check mode
-    }
 
-  //SCRUTE(_edgeLength);
-  //SCRUTE(_maxElementArea);
-  return isOk;
-}
+       if (hypName == "LengthFromEdges")
+       {
+               _hypLengthFromEdges = static_cast<const SMESH_LengthFromEdges *>(theHyp);
+               ASSERT(_hypLengthFromEdges);
+               _edgeLength = 0;
+               _maxElementArea = 0;
+               isOk = true;
+       }
 
+       if (isOk)
+       {
+               isOk = false;
+               if (_maxElementArea > 0)
+               {
+                       _edgeLength = 2 * sqrt(_maxElementArea);        // triangles : minorant
+                       isOk = true;
+               }
+               else
+                       isOk = (_hypLengthFromEdges != NULL);   // **** check mode
+       }
+
+       //SCRUTE(_edgeLength);
+       //SCRUTE(_maxElementArea);
+       return isOk;
+}
 
 //=============================================================================
 /*!
@@ -169,81 +165,80 @@ bool SMESH_MEFISTO_2D::CheckHypothesis(SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh,
-                      const TopoDS_Shape& aShape)
+bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
 {
-  MESSAGE("SMESH_MEFISTO_2D::Compute");
-
-  if (_hypLengthFromEdges)
-    _edgeLength = ComputeEdgeElementLength(aMesh, aShape);
-
-  bool isOk = false;
-  const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
-  SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape);
-
-  const TopoDS_Face& FF = TopoDS::Face(aShape);
-  bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
-  TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
-
-  Z   nblf;        //nombre de lignes fermees (enveloppe en tete)
-  Z  *nudslf=NULL; //numero du dernier sommet de chaque ligne fermee
-  R2 *uvslf=NULL;
-  Z   nbpti=0;     //nombre points internes futurs sommets de la triangulation
-  R2 *uvpti=NULL;
-  
-  Z   nbst;
-  R2 *uvst=NULL;
-  Z   nbt;
-  Z  *nust=NULL;
-  Z  ierr=0;
-  
-  Z  nutysu=1;                 // 1: il existe un fonction areteideale_()
-  // Z  nutysu=0;              // 0: on utilise aretmx
-  R  aretmx=_edgeLength;       // longueur max aretes future triangulation
-  //SCRUTE(aretmx);
-
-  nblf =  NumberOfWires(F);
-  //SCRUTE(nblf);
-
-  nudslf = new Z[1+nblf];
-  nudslf[0] = 0;
-  int iw = 1;
-  int nbpnt = 0;
-
-  const TopoDS_Wire OW1 = BRepTools::OuterWire(F);
-  nbpnt += NumberOfPoints (aMesh, OW1);
-  nudslf [iw++] = nbpnt;
-  //SCRUTE(nbpnt);
-
-  for (TopExp_Explorer exp (F, TopAbs_WIRE); exp.More(); exp.Next())
-    {
-      const TopoDS_Wire& W = TopoDS::Wire(exp.Current());
-      if (!OW1.IsSame(W))
+       MESSAGE("SMESH_MEFISTO_2D::Compute");
+
+       if (_hypLengthFromEdges)
+               _edgeLength = ComputeEdgeElementLength(aMesh, aShape);
+
+       bool isOk = false;
+       const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+       SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
+
+       const TopoDS_Face & FF = TopoDS::Face(aShape);
+       bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
+       TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
+
+       Z nblf;                                         //nombre de lignes fermees (enveloppe en tete)
+       Z *nudslf = NULL;                       //numero du dernier sommet de chaque ligne fermee
+       R2 *uvslf = NULL;
+       Z nbpti = 0;                            //nombre points internes futurs sommets de la triangulation
+       R2 *uvpti = NULL;
+
+       Z nbst;
+       R2 *uvst = NULL;
+       Z nbt;
+       Z *nust = NULL;
+       Z ierr = 0;
+
+       Z nutysu = 1;                           // 1: il existe un fonction areteideale_()
+       // Z  nutysu=0;              // 0: on utilise aretmx
+       R aretmx = _edgeLength;         // longueur max aretes future triangulation
+       //SCRUTE(aretmx);
+
+       nblf = NumberOfWires(F);
+       //SCRUTE(nblf);
+
+       nudslf = new Z[1 + nblf];
+       nudslf[0] = 0;
+       int iw = 1;
+       int nbpnt = 0;
+
+       const TopoDS_Wire OW1 = BRepTools::OuterWire(F);
+       nbpnt += NumberOfPoints(aMesh, OW1);
+       nudslf[iw++] = nbpnt;
+       //SCRUTE(nbpnt);
+
+       for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
        {
-         nbpnt += NumberOfPoints (aMesh, W);
-         nudslf [iw++] = nbpnt;
-         //SCRUTE(nbpnt);
+               const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
+               if (!OW1.IsSame(W))
+               {
+                       nbpnt += NumberOfPoints(aMesh, W);
+                       nudslf[iw++] = nbpnt;
+                       //SCRUTE(nbpnt);
+               }
        }
-    }
-
-  uvslf = new R2[nudslf[nblf]];
-  //SCRUTE(nudslf[nblf]);
-  int m = 0;
-
-  map<int,int> mefistoToDS;  // correspondence mefisto index--> points IDNodes
-  TopoDS_Wire OW = BRepTools::OuterWire(F);
-  LoadPoints (aMesh, F, OW, uvslf, m, mefistoToDS);
-  //SCRUTE(m);
-  for (TopExp_Explorer exp (F, TopAbs_WIRE); exp.More(); exp.Next())
-    {
-      const TopoDS_Wire& W = TopoDS::Wire(exp.Current());
-      if (!OW.IsSame(W))
+
+       uvslf = new R2[nudslf[nblf]];
+       //SCRUTE(nudslf[nblf]);
+       int m = 0;
+
+       map < int, int >mefistoToDS;    // correspondence mefisto index--> points IDNodes
+       TopoDS_Wire OW = BRepTools::OuterWire(F);
+       LoadPoints(aMesh, F, OW, uvslf, m, mefistoToDS);
+       //SCRUTE(m);
+
+       for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
        {
-         LoadPoints (aMesh, F, W, uvslf, m, mefistoToDS);
-         //SCRUTE(m);
+               const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
+               if (!OW.IsSame(W))
+               {
+                       LoadPoints(aMesh, F, W, uvslf, m, mefistoToDS);
+                       //SCRUTE(m);
+               }
        }
-    }
 //   SCRUTE(nudslf[nblf]);
 //   for (int i=0; i<=nblf; i++)
 //     {
@@ -257,34 +252,35 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh,
 //   SCRUTE(aretmx);
 //   SCRUTE(nblf);
 
-  MESSAGE("MEFISTO triangulation ..."); 
-  uvst = NULL;
-  nust = NULL;
-  aptrte( nutysu, aretmx,
-         nblf, nudslf, uvslf,
-         nbpti, uvpti,
-         nbst, uvst, nbt, nust,
-         ierr );
-
-  if( ierr == 0 )
-    {
-      MESSAGE("... End Triangulation");
-      //SCRUTE(nbst);
-      //SCRUTE(nbt);
-      StoreResult (aMesh, nbst, uvst, nbt, nust, F,
-                  faceIsForward, mefistoToDS);
-      isOk = true;
-    }
-  else
-    {
-      MESSAGE("Error in Triangulation");
-      isOk = false;
-    }
-  if (nudslf != NULL) delete [] nudslf;
-  if (uvslf  != NULL) delete [] uvslf;
-  if (uvst   != NULL) delete [] uvst;
-  if (nust   != NULL) delete [] nust;
-  return isOk;
+       MESSAGE("MEFISTO triangulation ...");
+       uvst = NULL;
+       nust = NULL;
+       aptrte(nutysu, aretmx,
+               nblf, nudslf, uvslf, nbpti, uvpti, nbst, uvst, nbt, nust, ierr);
+
+       if (ierr == 0)
+       {
+               MESSAGE("... End Triangulation");
+               //SCRUTE(nbst);
+               //SCRUTE(nbt);
+               StoreResult(aMesh, nbst, uvst, nbt, nust, F,
+                       faceIsForward, mefistoToDS);
+               isOk = true;
+       }
+       else
+       {
+               MESSAGE("Error in Triangulation");
+               isOk = false;
+       }
+       if (nudslf != NULL)
+               delete[]nudslf;
+       if (uvslf != NULL)
+               delete[]uvslf;
+       if (uvst != NULL)
+               delete[]uvst;
+       if (nust != NULL)
+               delete[]nust;
+       return isOk;
 }
 
 //=============================================================================
@@ -293,125 +289,118 @@ bool SMESH_MEFISTO_2D::Compute(SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh,
-                                 const TopoDS_Face& FF, 
-                                 const TopoDS_Wire& WW,
-                                 R2* uvslf, 
-                                 int& m,
-                                 map<int,int>& mefistoToDS)
+void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
+       const TopoDS_Face & FF,
+       const TopoDS_Wire & WW, R2 * uvslf, int &m, map < int, int >&mefistoToDS)
 {
-  MESSAGE("SMESH_MEFISTO_2D::LoadPoints");
+       MESSAGE("SMESH_MEFISTO_2D::LoadPoints");
 
-  Handle (SMDS_Mesh) meshDS = aMesh.GetMeshDS();
+       SMDS_Mesh * meshDS = aMesh.GetMeshDS();
 
-  double scalex;
-  double scaley;
-  TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
-  ComputeScaleOnFace(aMesh, F, scalex, scaley);
+       double scalex;
+       double scaley;
+       TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
+       ComputeScaleOnFace(aMesh, F, scalex, scaley);
 
-  TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD));
-  BRepTools_WireExplorer wexp(W,F);    
-  for (wexp.Init(W,F);wexp.More(); wexp.Next())
-    {
-      const TopoDS_Edge& E = wexp.Current();
+       TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD));
+       BRepTools_WireExplorer wexp(W, F);
+       for (wexp.Init(W, F); wexp.More(); wexp.Next())
+       {
+               const TopoDS_Edge & E = wexp.Current();
 
-      // --- IDNodes of first and last Vertex
+               // --- IDNodes of first and last Vertex
 
-      TopoDS_Vertex VFirst, VLast;
-      TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
+               TopoDS_Vertex VFirst, VLast;
+               TopExp::Vertices(E, VFirst, VLast);     // corresponds to f and l
 
-      ASSERT(!VFirst.IsNull());
-      SMESH_subMesh* firstSubMesh = aMesh.GetSubMesh(VFirst);
-      const TColStd_ListOfInteger& lidf
-       = firstSubMesh->GetSubMeshDS()->GetIDNodes();
-      int idFirst= lidf.First();
+               ASSERT(!VFirst.IsNull());
+               SMESH_subMesh *firstSubMesh = aMesh.GetSubMesh(VFirst);
+               const vector<int> & lidf
+                       = firstSubMesh->GetSubMeshDS()->GetIDNodes();
+               int idFirst = lidf[0];
 //       SCRUTE(idFirst);
 
-      ASSERT(!VLast.IsNull());
-      SMESH_subMesh* lastSubMesh = aMesh.GetSubMesh(VLast);
-      const TColStd_ListOfInteger& lidl
-       = lastSubMesh->GetSubMeshDS()->GetIDNodes();
-      int idLast= lidl.First();
+               ASSERT(!VLast.IsNull());
+               SMESH_subMesh *lastSubMesh = aMesh.GetSubMesh(VLast);
+               const vector<int> & lidl
+                       = lastSubMesh->GetSubMeshDS()->GetIDNodes();
+               int idLast = lidl[0];
 //       SCRUTE(idLast);
 
-      // --- edge internal IDNodes (relies on good order storage, not checked)
-
-      int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
-      //SCRUTE(nbPoints);
-      
-      Standard_Real f,l;
-      Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
-    
-      const TColStd_ListOfInteger& indElt
-       = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes();
-      TColStd_ListIteratorOfListOfInteger ite(indElt);
-      //SCRUTE(nbPoints);
-      //SCRUTE(indElt.Extent());
-      ASSERT(nbPoints == indElt.Extent());
-      bool isForward = (E.Orientation() == TopAbs_FORWARD);
-      map<double,int> params;
-      for (; ite.More(); ite.Next())
-       {
-         int nodeId = ite.Value();
-         Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
-         Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
-         Handle (SMDS_EdgePosition) epos
-           = Handle (SMDS_EdgePosition)::DownCast(node->GetPosition());
-         double param = epos->GetUParameter();
-         params[param] = nodeId;
-//       MESSAGE(" " << param << " " << params[param]);
+               // --- edge internal IDNodes (relies on good order storage, not checked)
+
+               int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
+               //SCRUTE(nbPoints);
+
+               double f, l;
+               Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
+
+               const vector<int> & indElt
+                       = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes();
+
+               ASSERT(nbPoints == indElt.size());
+               bool isForward = (E.Orientation() == TopAbs_FORWARD);
+               map < double, int >params;
+               for (int ite=0; ite<indElt.size(); ite++)
+               {
+                       int nodeId = indElt[ite];
+                       const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
+                       const SMDS_EdgePosition* epos
+                               = static_cast<const SMDS_EdgePosition*>(node->GetPosition());
+                       double param = epos->GetUParameter();
+                       params[param] = nodeId;
+               }
+
+               // --- load 2D values into MEFISTO structure,
+               //     add IDNodes in mefistoToDS map
+
+               if (E.Orientation() == TopAbs_FORWARD)
+               {
+                       gp_Pnt2d p = C2d->Value(f);     // first point = Vertex Forward
+                       uvslf[m].x = scalex * p.X();
+                       uvslf[m].y = scaley * p.Y();
+                       mefistoToDS[m + 1] = idFirst;
+                       //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
+                       //MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+                       m++;
+                       map < double, int >::iterator itp = params.begin();
+                       for (int i = 1; i <= nbPoints; i++)     // nbPoints internal
+                       {
+                               double param = (*itp).first;
+                               gp_Pnt2d p = C2d->Value(param);
+                               uvslf[m].x = scalex * p.X();
+                               uvslf[m].y = scaley * p.Y();
+                               mefistoToDS[m + 1] = (*itp).second;
+//        MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
+//        MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+                               m++;
+                               itp++;
+                       }
+               }
+               else
+               {
+                       gp_Pnt2d p = C2d->Value(l);     // last point = Vertex Reversed
+                       uvslf[m].x = scalex * p.X();
+                       uvslf[m].y = scaley * p.Y();
+                       mefistoToDS[m + 1] = idLast;
+//    MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
+//    MESSAGE("__ l "<<l<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+                       m++;
+                       map < double, int >::reverse_iterator itp = params.rbegin();
+                       for (int i = nbPoints; i >= 1; i--)
+                       {
+                               double param = (*itp).first;
+                               gp_Pnt2d p = C2d->Value(param);
+                               uvslf[m].x = scalex * p.X();
+                               uvslf[m].y = scaley * p.Y();
+                               mefistoToDS[m + 1] = (*itp).second;
+//        MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
+//            MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+                               m++;
+                               itp++;
+                       }
+               }
        }
-
-      // --- load 2D values into MEFISTO structure,
-      //     add IDNodes in mefistoToDS map
-
-      if (E.Orientation() == TopAbs_FORWARD)
-       {
-         gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward
-         uvslf [m].x = scalex * p.X();
-         uvslf [m].y = scaley * p.Y();
-         mefistoToDS[m+1] = idFirst;
-         //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
-         //MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
-         m++;
-         map<double,int>::iterator itp = params.begin();
-         for (Standard_Integer i = 1; i<=nbPoints; i++) // nbPoints internal
-           {
-             double param = (*itp).first;
-             gp_Pnt2d p = C2d->Value(param);
-             uvslf [m].x = scalex * p.X();
-             uvslf [m].y = scaley * p.Y();
-             mefistoToDS[m+1] = (*itp).second;
-//           MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
-//           MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
-             m++;
-             itp++;
-           }
-       }
-      else 
-       {
-         gp_Pnt2d p = C2d->Value(l); // last point = Vertex Reversed
-         uvslf [m].x = scalex * p.X();
-         uvslf [m].y = scaley * p.Y();
-         mefistoToDS[m+1] = idLast;
-//       MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
-//       MESSAGE("__ l "<<l<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
-         m++;
-         map<double,int>::reverse_iterator itp = params.rbegin();
-         for (Standard_Integer i = nbPoints ; i >= 1; i--)
-           {
-             double param = (*itp).first;
-             gp_Pnt2d p = C2d->Value(param);
-             uvslf [m].x = scalex * p.X();
-             uvslf [m].y = scaley * p.Y();
-             mefistoToDS[m+1] = (*itp).second;
-//           MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
-//           MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
-             m++;
-             itp++;
-           }
-       }
-    }  
 }
 
 //=============================================================================
@@ -422,72 +411,74 @@ void SMESH_MEFISTO_2D::LoadPoints(SMESH_Mesh& aMesh,
 
 // **** a mettre dans SMESH_Algo ou SMESH_2D_Algo
 
-void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh& aMesh,
-                                         const TopoDS_Face& aFace,
-                                         double& scalex,
-                                         double& scaley)
+void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh & aMesh,
+       const TopoDS_Face & aFace, double &scalex, double &scaley)
 {
-  //MESSAGE("SMESH_MEFISTO_2D::ComputeScaleOnFace");
-  TopoDS_Face F = TopoDS::Face(aFace.Oriented(TopAbs_FORWARD));  
-  TopoDS_Wire W = BRepTools::OuterWire(F);
-
-  BRepTools_WireExplorer wexp(W,F);    
-
-  double xmin =  1.e300; // min & max of face 2D parametric coord.
-  double xmax = -1.e300;
-  double ymin =  1.e300;
-  double ymax = -1.e300;
-  int nbp = 50;
-  scalex = 1;
-  scaley = 1;
-  for (wexp.Init(W,F);wexp.More(); wexp.Next())
-    {
-      const TopoDS_Edge& E = wexp.Current();
-      double f,l;
-      Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
-      for (int i = 0; i<= nbp; i++)
+       //MESSAGE("SMESH_MEFISTO_2D::ComputeScaleOnFace");
+       TopoDS_Face F = TopoDS::Face(aFace.Oriented(TopAbs_FORWARD));
+       TopoDS_Wire W = BRepTools::OuterWire(F);
+
+       BRepTools_WireExplorer wexp(W, F);
+
+       double xmin = 1.e300;           // min & max of face 2D parametric coord.
+       double xmax = -1.e300;
+       double ymin = 1.e300;
+       double ymax = -1.e300;
+       int nbp = 50;
+       scalex = 1;
+       scaley = 1;
+       for (wexp.Init(W, F); wexp.More(); wexp.Next())
        {
-         double param = f + (double(i)/double(nbp))*(l-f);
-         gp_Pnt2d p = C2d->Value(param);
-         if (p.X() < xmin) xmin = p.X();
-         if (p.X() > xmax) xmax = p.X();
-         if (p.Y() < ymin) ymin = p.Y();
-         if (p.Y() > ymax) ymax = p.Y();
-//       MESSAGE(" "<< f<<" "<<l<<" "<<param<<" "<<xmin<<" "<<xmax<<" "<<ymin<<" "<<ymax);
+               const TopoDS_Edge & E = wexp.Current();
+               double f, l;
+               Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
+               for (int i = 0; i <= nbp; i++)
+               {
+                       double param = f + (double (i) / double (nbp))*(l - f);
+                       gp_Pnt2d p = C2d->Value(param);
+                       if (p.X() < xmin)
+                               xmin = p.X();
+                       if (p.X() > xmax)
+                               xmax = p.X();
+                       if (p.Y() < ymin)
+                               ymin = p.Y();
+                       if (p.Y() > ymax)
+                               ymax = p.Y();
+//    MESSAGE(" "<< f<<" "<<l<<" "<<param<<" "<<xmin<<" "<<xmax<<" "<<ymin<<" "<<ymax);
+               }
        }
-    }
 //   SCRUTE(xmin);
 //   SCRUTE(xmax);
 //   SCRUTE(ymin);
 //   SCRUTE(ymax);
-  double xmoy = (xmax + xmin)/2.; 
-  double ymoy = (ymax + ymin)/2.;
-
-  Handle(Geom_Surface) S = BRep_Tool::Surface(F); // 3D surface
-
-  double length_x = 0;
-  double length_y = 0;
-  gp_Pnt PX0 = S->Value(xmin, ymoy);
-  gp_Pnt PY0 = S->Value(xmoy, ymin);
-  for (Standard_Integer i = 1; i<= nbp; i++)
-    {
-      double x = xmin + (double(i)/double(nbp))*(xmax-xmin);
-      gp_Pnt PX = S->Value(x,ymoy);
-      double y = ymin + (double(i)/double(nbp))*(ymax-ymin);
-      gp_Pnt PY = S->Value(xmoy,y);
-      length_x += PX.Distance(PX0);
-      length_y += PY.Distance(PY0);
-      PX0.SetCoord(PX.X(),PX.Y(),PX.Z());
-      PY0.SetCoord(PY.X(),PY.Y(),PY.Z());
-    }
+       double xmoy = (xmax + xmin) / 2.;
+       double ymoy = (ymax + ymin) / 2.;
+
+       Handle(Geom_Surface) S = BRep_Tool::Surface(F); // 3D surface
+
+       double length_x = 0;
+       double length_y = 0;
+       gp_Pnt PX0 = S->Value(xmin, ymoy);
+       gp_Pnt PY0 = S->Value(xmoy, ymin);
+       for (int i = 1; i <= nbp; i++)
+       {
+               double x = xmin + (double (i) / double (nbp))*(xmax - xmin);
+               gp_Pnt PX = S->Value(x, ymoy);
+               double y = ymin + (double (i) / double (nbp))*(ymax - ymin);
+               gp_Pnt PY = S->Value(xmoy, y);
+               length_x += PX.Distance(PX0);
+               length_y += PY.Distance(PY0);
+               PX0.SetCoord(PX.X(), PX.Y(), PX.Z());
+               PY0.SetCoord(PY.X(), PY.Y(), PY.Z());
+       }
 //   SCRUTE(length_x);
 //   SCRUTE(length_y);
-  scalex = length_x/(xmax - xmin);
-  scaley = length_y/(ymax - ymin);
+       scalex = length_x / (xmax - xmin);
+       scaley = length_y / (ymax - ymin);
 //   SCRUTE(scalex);
 //   SCRUTE(scaley);
-  ASSERT(scalex);
-  ASSERT(scaley);
+       ASSERT(scalex);
+       ASSERT(scaley);
 }
 
 //=============================================================================
@@ -496,75 +487,69 @@ void SMESH_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-void SMESH_MEFISTO_2D::StoreResult (SMESH_Mesh& aMesh,
-                                   Z nbst, R2* uvst, Z nbt, Z* nust, 
-                                   const TopoDS_Face& F, bool faceIsForward,
-                                   map<int,int>& mefistoToDS)
+void SMESH_MEFISTO_2D::StoreResult(SMESH_Mesh & aMesh,
+       Z nbst, R2 * uvst, Z nbt, Z * nust,
+       const TopoDS_Face & F, bool faceIsForward, map < int, int >&mefistoToDS)
 {
-  double scalex;
-  double scaley;
-  ComputeScaleOnFace(aMesh, F, scalex, scaley);
-
-  Handle (SMESHDS_Mesh) meshDS = aMesh.GetMeshDS();
-
-  Z n,m;
-  Handle(Geom_Surface) S = BRep_Tool::Surface(F);
-  
-  for ( n=0; n<nbst; n++ )
-    {
-      double u = uvst[n][0]/scalex;
-      double v = uvst[n][1]/scaley;
-      gp_Pnt P = S->Value(u,v);
-    
-      if (mefistoToDS.find(n+1) == mefistoToDS.end())
-       {
-         int nodeId = meshDS->AddNode(P.X(), P.Y(), P.Z());
-         Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
-         Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
-         meshDS->SetNodeOnFace(node, F);
-         
-         //MESSAGE(nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z());
-         mefistoToDS[n+1] = nodeId;
-         //MESSAGE(" "<<n<<" "<<mefistoToDS[n+1]);
-         Handle (SMDS_FacePosition) fpos
-           = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
-         fpos->SetUParameter(u);
-         fpos->SetVParameter(v);
-       }
-    }
-  
-  m=0;
-  int mt=0;
-
-  //SCRUTE(faceIsForward);
-  for ( n=1; n<=nbt; n++ )
-    {
-      int inode1 = nust[m++];
-      int inode2 = nust[m++];
-      int inode3 = nust[m++];
-
-      int nodeId1 = mefistoToDS[inode1];
-      int nodeId2 = mefistoToDS[inode2];
-      int nodeId3 = mefistoToDS[inode3];
-      //MESSAGE("-- "<<inode1<<" "<<inode2<<" "<<inode3<<" ++ "<<nodeId1<<" "<<nodeId2<<" "<<nodeId3);
-
-      // triangle points must be in trigonometric order if face is Forward
-      // else they must be put clockwise
-
-      bool triangleIsWellOriented = faceIsForward;
-      int faceId;
-      if (triangleIsWellOriented)
+       double scalex;
+       double scaley;
+       ComputeScaleOnFace(aMesh, F, scalex, scaley);
+
+       SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+
+       Z n, m;
+       Handle(Geom_Surface) S = BRep_Tool::Surface(F);
+
+       for (n = 0; n < nbst; n++)
        {
-         faceId = meshDS->AddFace(nodeId1, nodeId2, nodeId3);
+               double u = uvst[n][0] / scalex;
+               double v = uvst[n][1] / scaley;
+               gp_Pnt P = S->Value(u, v);
+
+               if (mefistoToDS.find(n + 1) == mefistoToDS.end())
+               {
+                       SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
+                       meshDS->SetNodeOnFace(node, F);
+
+                       //MESSAGE(nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z());
+                       mefistoToDS[n + 1] = node->GetID();
+                       //MESSAGE(" "<<n<<" "<<mefistoToDS[n+1]);
+                       SMDS_FacePosition* fpos
+                               = static_cast<SMDS_FacePosition*>(node->GetPosition());
+                       fpos->SetUParameter(u);
+                       fpos->SetVParameter(v);
+               }
        }
-      else
+
+       m = 0;
+       int mt = 0;
+
+       //SCRUTE(faceIsForward);
+       for (n = 1; n <= nbt; n++)
        {
-         faceId = meshDS->AddFace(nodeId1, nodeId3, nodeId2);
+               int inode1 = nust[m++];
+               int inode2 = nust[m++];
+               int inode3 = nust[m++];
+
+               int nodeId1 = mefistoToDS[inode1];
+               int nodeId2 = mefistoToDS[inode2];
+               int nodeId3 = mefistoToDS[inode3];
+               //MESSAGE("-- "<<inode1<<" "<<inode2<<" "<<inode3<<" ++ "<<nodeId1<<" "<<nodeId2<<" "<<nodeId3);
+
+               // triangle points must be in trigonometric order if face is Forward
+               // else they must be put clockwise
+
+               bool triangleIsWellOriented = faceIsForward;
+
+        SMDS_MeshElement * elt;
+               if (triangleIsWellOriented)
+                       elt = meshDS->AddFace(nodeId1, nodeId2, nodeId3);
+               else
+                       elt = meshDS->AddFace(nodeId1, nodeId3, nodeId2);
+       
+               meshDS->SetMeshElementOnShape(elt, F);
+               m++;
        }
-      Handle (SMDS_MeshElement) elt = meshDS->FindElement(faceId);
-      meshDS->SetMeshElementOnShape(elt, F);
-      m++;
-    }
 }
 
 //=============================================================================
@@ -573,35 +558,35 @@ void SMESH_MEFISTO_2D::StoreResult (SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-double SMESH_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh& aMesh,
-                                                 const TopoDS_Shape& aShape)
+double SMESH_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh & aMesh,
+       const TopoDS_Shape & aShape)
 {
-  MESSAGE("SMESH_MEFISTO_2D::ComputeEdgeElementLength");
-  // **** a mettre dans SMESH_2D_Algo ?
-
-  const TopoDS_Face& FF = TopoDS::Face(aShape);
-  bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
-  TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
-
-  double meanElementLength = 100;
-  double wireLength =0;
-  int wireElementsNumber =0;
-  for (TopExp_Explorer exp (F, TopAbs_WIRE); exp.More(); exp.Next())
-    {
-      const TopoDS_Wire& W = TopoDS::Wire(exp.Current());
-      for (TopExp_Explorer expe(W,TopAbs_EDGE); expe.More(); expe.Next())
+       MESSAGE("SMESH_MEFISTO_2D::ComputeEdgeElementLength");
+       // **** a mettre dans SMESH_2D_Algo ?
+
+       const TopoDS_Face & FF = TopoDS::Face(aShape);
+       bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
+       TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
+
+       double meanElementLength = 100;
+       double wireLength = 0;
+       int wireElementsNumber = 0;
+       for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
        {
-         const TopoDS_Edge& E = TopoDS::Edge(expe.Current());
-         int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
-         double length = EdgeLength(E);
-         wireLength += length;
-         wireElementsNumber += nb;
+               const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
+               for (TopExp_Explorer expe(W, TopAbs_EDGE); expe.More(); expe.Next())
+               {
+                       const TopoDS_Edge & E = TopoDS::Edge(expe.Current());
+                       int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
+                       double length = EdgeLength(E);
+                       wireLength += length;
+                       wireElementsNumber += nb;
+               }
        }
-    }
-  if (wireElementsNumber)
-    meanElementLength = wireLength/wireElementsNumber;
-  //SCRUTE(meanElementLength);
-  return meanElementLength;
+       if (wireElementsNumber)
+               meanElementLength = wireLength / wireElementsNumber;
+       //SCRUTE(meanElementLength);
+       return meanElementLength;
 }
 
 //=============================================================================
@@ -612,7 +597,7 @@ double SMESH_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh& aMesh,
 
 ostream & SMESH_MEFISTO_2D::SaveTo(ostream & save)
 {
-  return save << this;
+       return save << this;
 }
 
 //=============================================================================
@@ -623,7 +608,7 @@ ostream & SMESH_MEFISTO_2D::SaveTo(ostream & save)
 
 istream & SMESH_MEFISTO_2D::LoadFrom(istream & load)
 {
-  return load >> (*this);
+       return load >> (*this);
 }
 
 //=============================================================================
@@ -632,9 +617,9 @@ istream & SMESH_MEFISTO_2D::LoadFrom(istream & load)
  */
 //=============================================================================
 
-ostream & operator << (ostream & save, SMESH_MEFISTO_2D & hyp)
+ostream & operator <<(ostream & save, SMESH_MEFISTO_2D & hyp)
 {
-  return save;
+       return save;
 }
 
 //=============================================================================
@@ -643,8 +628,7 @@ ostream & operator << (ostream & save, SMESH_MEFISTO_2D & hyp)
  */
 //=============================================================================
 
-istream & operator >> (istream & load, SMESH_MEFISTO_2D & hyp)
+istream & operator >>(istream & load, SMESH_MEFISTO_2D & hyp)
 {
-  return load;
+       return load;
 }
-
index 062a92f..cb60c66 100644 (file)
 #include "SMESH_Hypothesis.hxx"
 #include "Utils_SALOME_Exception.hxx"
 
-class SMESH_MaxElementArea:
-  public SMESH_Hypothesis
+class SMESH_MaxElementArea:public SMESH_Hypothesis
 {
-public:
-  SMESH_MaxElementArea(int hypId, int studyId, SMESH_Gen* gen);
-  virtual ~SMESH_MaxElementArea();
+  public:
+       SMESH_MaxElementArea(int hypId, int studyId, SMESH_Gen * gen);
+         virtual ~ SMESH_MaxElementArea();
 
-  void SetMaxArea(double maxArea)
-    throw (SALOME_Exception);
+       void SetMaxArea(double maxArea) throw(SALOME_Exception);
 
-  double GetMaxArea();
+       double GetMaxArea() const;
 
-  virtual ostream & SaveTo(ostream & save);
-  virtual istream & LoadFrom(istream & load);
-  friend ostream & operator << (ostream & save, SMESH_MaxElementArea & hyp);
-  friend istream & operator >> (istream & load, SMESH_MaxElementArea & hyp);
+       virtual ostream & SaveTo(ostream & save);
+       virtual istream & LoadFrom(istream & load);
+       friend ostream & operator <<(ostream & save, SMESH_MaxElementArea & hyp);
+       friend istream & operator >>(istream & load, SMESH_MaxElementArea & hyp);
 
-protected:
-  double _maxArea;
+  protected:
+       double _maxArea;
 };
 
 #endif
index 400ee99..82f24dd 100644 (file)
 //  Module : SMESH
 //  $Header$
 
-using namespace std;
-using namespace std;
 #include "SMESH_Mesh.hxx"
 #include "SMESH_subMesh.hxx"
 #include "SMESH_Gen.hxx"
 #include "SMESH_Hypothesis.hxx"
 #include "SMESHDS_Script.hxx"
-//#include "SMESHDS_ListOfAsciiString.hxx"
-//#include "SMESHDS_ListIteratorOfListOfAsciiString.hxx"
-#include "SMESHDS_ListOfPtrHypothesis.hxx"
-#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
-#include "SMDS_MeshElement.hxx"
-#include "SMDS_MeshFacesIterator.hxx"
-#include "SMDS_MeshVolumesIterator.hxx"
-#include "TCollection_AsciiString.hxx"
+#include "SMDS_MeshVolume.hxx"
 
 #include "utilities.h"
 
@@ -49,6 +40,8 @@ using namespace std;
 #include "DriverDAT_W_SMESHDS_Mesh.h"
 #include "DriverUNV_W_SMESHDS_Mesh.h"
 
+#include <TCollection_AsciiString.hxx>
+
 //=============================================================================
 /*!
  * 
@@ -57,9 +50,9 @@ using namespace std;
 
 SMESH_Mesh::SMESH_Mesh()
 {
-  MESSAGE("SMESH_Mesh::SMESH_Mesh");
-  _id = -1;
-  ASSERT(0);
+       MESSAGE("SMESH_Mesh::SMESH_Mesh");
+       _id = -1;
+       ASSERT(0);
 }
 
 //=============================================================================
@@ -69,18 +62,16 @@ SMESH_Mesh::SMESH_Mesh()
 //=============================================================================
 
 SMESH_Mesh::SMESH_Mesh(int localId,
-                      int studyId,
-                      SMESH_Gen* gen,
-                      const Handle(SMESHDS_Document)& myDocument)
+       int studyId, SMESH_Gen * gen, SMESHDS_Document * myDocument)
 {
-  MESSAGE("SMESH_Mesh::SMESH_Mesh(int localId)");
-  _id = localId;
-  _studyId = studyId;
-  _gen = gen;
-  _myDocument = myDocument;
-  _idDoc = _myDocument->NewMesh();
-  _myMeshDS = _myDocument->GetMesh(_idDoc);
-  _isShapeToMesh = false;
+       MESSAGE("SMESH_Mesh::SMESH_Mesh(int localId)");
+       _id = localId;
+       _studyId = studyId;
+       _gen = gen;
+       _myDocument = myDocument;
+       _idDoc = _myDocument->NewMesh();
+       _myMeshDS = _myDocument->GetMesh(_idDoc);
+       _isShapeToMesh = false;
 }
 
 //=============================================================================
@@ -91,7 +82,7 @@ SMESH_Mesh::SMESH_Mesh(int localId,
 
 SMESH_Mesh::~SMESH_Mesh()
 {
-  MESSAGE("SMESH_Mesh::~SMESH_Mesh");
+       MESSAGE("SMESH_Mesh::~SMESH_Mesh");
 }
 
 //=============================================================================
@@ -100,17 +91,19 @@ SMESH_Mesh::~SMESH_Mesh()
  */
 //=============================================================================
 
-void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape& aShape)
-  throw (SALOME_Exception)
+void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape)
+throw(SALOME_Exception)
 {
-  MESSAGE("SMESH_Mesh::ShapeToMesh");
-  if (_isShapeToMesh)
-    throw SALOME_Exception(LOCALIZED("a shape to mesh as already been defined"));
-  _isShapeToMesh = true;
-  _myMeshDS->ShapeToMesh(aShape);
-
-  // NRI : 24/02/03
-  TopExp::MapShapes(aShape,_subShapes);
+       MESSAGE("SMESH_Mesh::ShapeToMesh");
+       if (_isShapeToMesh)
+               throw
+                       SALOME_Exception(LOCALIZED
+               ("a shape to mesh as already been defined"));
+       _isShapeToMesh = true;
+       _myMeshDS->ShapeToMesh(aShape);
+
+       // NRI : 24/02/03
+       TopExp::MapShapes(aShape, _subShapes);
 }
 
 //=============================================================================
@@ -119,47 +112,46 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape& aShape)
  */
 //=============================================================================
 
-bool SMESH_Mesh::AddHypothesis(const TopoDS_Shape& aSubShape,
-                              int anHypId)
-  throw (SALOME_Exception)
+bool SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape,
+       int anHypId) throw(SALOME_Exception)
 {
-  MESSAGE("SMESH_Mesh::AddHypothesis");
-
-  StudyContextStruct* sc = _gen->GetStudyContext(_studyId);
-  if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
-    {
-      MESSAGE("Hypothesis ID does not give an hypothesis");
-      SCRUTE(_studyId);
-      SCRUTE(anHypId);
-      throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
-    }
-
-  SMESH_subMesh* subMesh = GetSubMesh(aSubShape);
-  SMESH_Hypothesis* anHyp = sc->mapHypothesis[anHypId];
-  int event;
-
-  // shape 
-
-  if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
-    event = SMESH_subMesh::ADD_HYP;
-  else
-    event = SMESH_subMesh::ADD_ALGO;
-  int ret = subMesh->AlgoStateEngine(event, anHyp);
-
-  // subShapes (only when shape is mainShape)
-  TopoDS_Shape mainShape = _myMeshDS->ShapeToMesh();
-  if (aSubShape.IsSame(mainShape))
-    {
-      if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
-       event = SMESH_subMesh::ADD_FATHER_HYP;
-      else
-       event = SMESH_subMesh::ADD_FATHER_ALGO;
-      subMesh->SubMeshesAlgoStateEngine(event, anHyp);
-    }
-
-  subMesh->DumpAlgoState(true);
-  //SCRUTE(ret);
-  return ret;
+       MESSAGE("SMESH_Mesh::AddHypothesis");
+
+       StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
+       if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
+       {
+               MESSAGE("Hypothesis ID does not give an hypothesis");
+               SCRUTE(_studyId);
+               SCRUTE(anHypId);
+               throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
+       }
+
+       SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
+       SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
+       int event;
+
+       // shape 
+
+       if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
+               event = SMESH_subMesh::ADD_HYP;
+       else
+               event = SMESH_subMesh::ADD_ALGO;
+       int ret = subMesh->AlgoStateEngine(event, anHyp);
+
+       // subShapes (only when shape is mainShape)
+       TopoDS_Shape mainShape = _myMeshDS->ShapeToMesh();
+       if (aSubShape.IsSame(mainShape))
+       {
+               if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
+                       event = SMESH_subMesh::ADD_FATHER_HYP;
+               else
+                       event = SMESH_subMesh::ADD_FATHER_ALGO;
+               subMesh->SubMeshesAlgoStateEngine(event, anHyp);
+       }
+
+       subMesh->DumpAlgoState(true);
+       //SCRUTE(ret);
+       return ret;
 }
 
 //=============================================================================
@@ -168,45 +160,44 @@ bool SMESH_Mesh::AddHypothesis(const TopoDS_Shape& aSubShape,
  */
 //=============================================================================
 
-bool SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape& aSubShape,
-                                 int anHypId)
-  throw (SALOME_Exception)
+bool SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape & aSubShape,
+       int anHypId)throw(SALOME_Exception)
 {
-  MESSAGE("SMESH_Mesh::RemoveHypothesis");
-
-  StudyContextStruct* sc = _gen->GetStudyContext(_studyId);
-  if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
-    throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
-
-  SMESH_subMesh* subMesh = GetSubMesh(aSubShape);
-  SMESH_Hypothesis* anHyp = sc->mapHypothesis[anHypId];
-  int hypType = anHyp->GetType();
-  SCRUTE(hypType);
-  int event;
-
-  // shape 
-
-  if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
-    event = SMESH_subMesh::REMOVE_HYP;
-  else
-    event = SMESH_subMesh::REMOVE_ALGO;
-  int ret = subMesh->AlgoStateEngine(event, anHyp);
-
-  // subShapes (only when shape is mainShape)
-
-  TopoDS_Shape mainShape = _myMeshDS->ShapeToMesh();
-  if (aSubShape.IsSame(mainShape))
-    {
-      if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
-       event = SMESH_subMesh::REMOVE_FATHER_HYP;
-      else
-       event = SMESH_subMesh::REMOVE_FATHER_ALGO;
-      subMesh->SubMeshesAlgoStateEngine(event, anHyp);
-    }
-
-  subMesh->DumpAlgoState(true);
-  SCRUTE(ret);
-  return ret;
+       MESSAGE("SMESH_Mesh::RemoveHypothesis");
+
+       StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
+       if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
+               throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
+
+       SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
+       SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
+       int hypType = anHyp->GetType();
+       SCRUTE(hypType);
+       int event;
+
+       // shape 
+
+       if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
+               event = SMESH_subMesh::REMOVE_HYP;
+       else
+               event = SMESH_subMesh::REMOVE_ALGO;
+       int ret = subMesh->AlgoStateEngine(event, anHyp);
+
+       // subShapes (only when shape is mainShape)
+
+       TopoDS_Shape mainShape = _myMeshDS->ShapeToMesh();
+       if (aSubShape.IsSame(mainShape))
+       {
+               if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO)
+                       event = SMESH_subMesh::REMOVE_FATHER_HYP;
+               else
+                       event = SMESH_subMesh::REMOVE_FATHER_ALGO;
+               subMesh->SubMeshesAlgoStateEngine(event, anHyp);
+       }
+
+       subMesh->DumpAlgoState(true);
+       SCRUTE(ret);
+       return ret;
 }
 
 //=============================================================================
@@ -215,34 +206,34 @@ bool SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape& aSubShape,
  */
 //=============================================================================
 
-const Handle(SMESHDS_Mesh)& SMESH_Mesh::GetMeshDS()
+SMESHDS_Mesh * SMESH_Mesh::GetMeshDS()
 {
-  return _myMeshDS;
+       return _myMeshDS;
 }
 
-
 //=============================================================================
 /*!
  * 
  */
 //=============================================================================
 
-const list<SMESHDS_Hypothesis*>&
-SMESH_Mesh::GetHypothesisList(const TopoDS_Shape& aSubShape)
-  throw (SALOME_Exception)
+const list<const SMESHDS_Hypothesis*>&
+       SMESH_Mesh::GetHypothesisList(const TopoDS_Shape & aSubShape)
+       throw(SALOME_Exception)
 {
-  MESSAGE("SMESH_Mesh::GetHypothesisList");
-  _subShapeHypothesisList.clear();
-  const SMESHDS_ListOfPtrHypothesis& listHyp
-    = _myMeshDS->GetHypothesis(aSubShape);
-  SMESHDS_ListIteratorOfListOfPtrHypothesis it(listHyp);
-  while (it.More())
-    {
-      SMESHDS_Hypothesis* anHyp = it.Value();
-      _subShapeHypothesisList.push_back(anHyp);
-      it.Next();
-    }
-  return _subShapeHypothesisList;
+       MESSAGE("SMESH_Mesh::GetHypothesisList");
+       _subShapeHypothesisList.clear();
+       const list<const SMESHDS_Hypothesis*>& listHyp =
+               _myMeshDS->GetHypothesis(aSubShape);
+
+       list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
+       while (it!=listHyp.end())
+       {
+               const SMESHDS_Hypothesis *anHyp = *it;
+               _subShapeHypothesisList.push_back(anHyp);
+               it++;
+       }
+       return _subShapeHypothesisList;
 }
 
 //=============================================================================
@@ -251,20 +242,10 @@ SMESH_Mesh::GetHypothesisList(const TopoDS_Shape& aSubShape)
  */
 //=============================================================================
 
-const SMESHDS_ListOfCommand& SMESH_Mesh::GetLog()
-  throw (SALOME_Exception)
+const list<SMESHDS_Command*> & SMESH_Mesh::GetLog() throw(SALOME_Exception)
 {
-  MESSAGE("SMESH_Mesh::GetLog");
-  Handle (SMESHDS_Script) scriptDS = _myMeshDS->GetScript();
-  const SMESHDS_ListOfCommand& logDS = scriptDS->GetCommands();
-//   SMESHDS_ListIteratorOfListOfCommand its;
-//   const SMESHDS_ListOfAsciiString& logDS = scriptDS->GetCommands();
-//   SMESHDS_ListIteratorOfListOfAsciiString its;
-//   for (its.Initialize(logDS); its.More(); its.Next())
-//     {
-//       SCRUTE(its.Value().ToCString());
-//     }
-  return logDS;
+       MESSAGE("SMESH_Mesh::GetLog");
+       return _myMeshDS->GetScript()->GetCommands();
 }
 
 //=============================================================================
@@ -272,12 +253,10 @@ const SMESHDS_ListOfCommand& SMESH_Mesh::GetLog()
  * 
  */
 //=============================================================================
-void SMESH_Mesh::ClearLog()
-  throw (SALOME_Exception)
+void SMESH_Mesh::ClearLog() throw(SALOME_Exception)
 {
-  MESSAGE("SMESH_Mesh::ClearLog");
-  Handle (SMESHDS_Script) scriptDS = _myMeshDS->GetScript();
-  scriptDS->Clear();
+       MESSAGE("SMESH_Mesh::ClearLog");
+       _myMeshDS->GetScript()->Clear();
 }
 
 //=============================================================================
@@ -288,8 +267,8 @@ void SMESH_Mesh::ClearLog()
 
 int SMESH_Mesh::GetId()
 {
-  MESSAGE("SMESH_Mesh::GetId");
-  return _id;
+       MESSAGE("SMESH_Mesh::GetId");
+       return _id;
 }
 
 //=============================================================================
@@ -298,9 +277,9 @@ int SMESH_Mesh::GetId()
  */
 //=============================================================================
 
-SMESH_GenSMESH_Mesh::GetGen()
+SMESH_Gen *SMESH_Mesh::GetGen()
 {
-  return _gen;
+       return _gen;
 }
 
 //=============================================================================
@@ -309,37 +288,40 @@ SMESH_Gen* SMESH_Mesh::GetGen()
  */
 //=============================================================================
 
-SMESH_subMeshSMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
-  throw (SALOME_Exception)
+SMESH_subMesh *SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
+throw(SALOME_Exception)
 {
-  //MESSAGE("SMESH_Mesh::GetSubMesh");
-  SMESH_subMesh* aSubMesh;
-  int index = _subShapes.FindIndex(aSubShape);
-  if ( _mapSubMesh.find(index) != _mapSubMesh.end() ) {
-    aSubMesh = _mapSubMesh[index];
-  } else {
-    aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
-    _mapSubMesh[index] = aSubMesh;
-  }
-
-  /* NRI 24/02/2003
-  int index = -1;
-  if (_subShapes.Contains(aSubShape))
-    {
-      index = _subShapes.FindIndex(aSubShape);
-      ASSERT(_mapSubMesh.find(index) != _mapSubMesh.end());
-      aSubMesh = _mapSubMesh[index];
-      //MESSAGE("found submesh " << index);
-    }
-  else
-    {
-      index = _subShapes.Add(aSubShape);
-      aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
-      _mapSubMesh[index] = aSubMesh;
-      //MESSAGE("created submesh " << index);
-    }
-  */
-  return aSubMesh;
+       //MESSAGE("SMESH_Mesh::GetSubMesh");
+       SMESH_subMesh *aSubMesh;
+       int index = _subShapes.FindIndex(aSubShape);
+       if (_mapSubMesh.find(index) != _mapSubMesh.end())
+       {
+               aSubMesh = _mapSubMesh[index];
+       }
+       else
+       {
+               aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
+               _mapSubMesh[index] = aSubMesh;
+       }
+
+       /* NRI 24/02/2003
+        * int index = -1;
+        * if (_subShapes.Contains(aSubShape))
+        * {
+        * index = _subShapes.FindIndex(aSubShape);
+        * ASSERT(_mapSubMesh.find(index) != _mapSubMesh.end());
+        * aSubMesh = _mapSubMesh[index];
+        * //MESSAGE("found submesh " << index);
+        * }
+        * else
+        * {
+        * index = _subShapes.Add(aSubShape);
+        * aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
+        * _mapSubMesh[index] = aSubMesh;
+        * //MESSAGE("created submesh " << index);
+        * }
+        */
+       return aSubMesh;
 }
 
 //=============================================================================
@@ -358,30 +340,31 @@ SMESH_subMesh* SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
 //  * returns first created submesh of the two. 
 //  * subMesh is not created, return may be NULL.
 
-SMESH_subMeshSMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape)
-  throw (SALOME_Exception)
+SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape)
+throw(SALOME_Exception)
 {
-  //MESSAGE("SMESH_Mesh::GetSubMeshContaining");
-  bool isFound = false;
-  SMESH_subMesh* aSubMesh = NULL;
-
-  int index = _subShapes.FindIndex(aSubShape);
-  if ( _mapSubMesh.find(index) != _mapSubMesh.end() ) {
-    aSubMesh = _mapSubMesh[index];
-    isFound = true;
-  } 
-
-  /* NRI 24/02/2003
-  int index = -1;
-  if (_subShapes.Contains(aSubShape))
-    {
-      index = _subShapes.FindIndex(aSubShape);
-      ASSERT(_mapSubMesh.find(index) != _mapSubMesh.end());
-      aSubMesh = _mapSubMesh[index];
-      isFound = true;
-      //MESSAGE("found submesh " << index);
-    }
-  */
+       //MESSAGE("SMESH_Mesh::GetSubMeshContaining");
+       bool isFound = false;
+       SMESH_subMesh *aSubMesh = NULL;
+
+       int index = _subShapes.FindIndex(aSubShape);
+       if (_mapSubMesh.find(index) != _mapSubMesh.end())
+       {
+               aSubMesh = _mapSubMesh[index];
+               isFound = true;
+       }
+
+       /* NRI 24/02/2003
+        * int index = -1;
+        * if (_subShapes.Contains(aSubShape))
+        * {
+        * index = _subShapes.FindIndex(aSubShape);
+        * ASSERT(_mapSubMesh.find(index) != _mapSubMesh.end());
+        * aSubMesh = _mapSubMesh[index];
+        * isFound = true;
+        * //MESSAGE("found submesh " << index);
+        * }
+        */
 
 //   map<int, SMESH_subMesh*>::iterator itsm;
 //   for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
@@ -391,8 +374,9 @@ SMESH_subMesh* SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape)
 //       if (isFound) break;
 //     }
 
-  if (! isFound) aSubMesh = NULL;
-  return aSubMesh;
+       if (!isFound)
+               aSubMesh = NULL;
+       return aSubMesh;
 }
 
 //=============================================================================
@@ -401,33 +385,34 @@ SMESH_subMesh* SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape)
  */
 //=============================================================================
 
-const list <SMESH_subMesh*>&
-SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis* anHyp)
-  throw (SALOME_Exception)
+const list < SMESH_subMesh * >&
+       SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
+throw(SALOME_Exception)
 {
-  MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis");
-  map<int, SMESH_subMesh*>::iterator itsm;
-  _subMeshesUsingHypothesisList.clear();
-  for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
-    {
-      SMESH_subMesh* aSubMesh = (*itsm).second;
-      bool usesHyp = false;
-      SMESH_Algo* algo = _gen->GetAlgo(*this, aSubMesh->GetSubShape());
-      if (algo != NULL)
+       MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis");
+       map < int, SMESH_subMesh * >::iterator itsm;
+       _subMeshesUsingHypothesisList.clear();
+       for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
        {
-         const list<SMESHDS_Hypothesis*>& usedHyps
-           = algo->GetUsedHypothesis(*this, aSubMesh->GetSubShape());
-         list<SMESHDS_Hypothesis*>::const_iterator itl;
-         for(itl=usedHyps.begin(); itl != usedHyps.end(); itl++)
-           if (anHyp == (*itl))
-             {
-               usesHyp = true;
-               break;
-             }     
+               SMESH_subMesh *aSubMesh = (*itsm).second;
+               bool usesHyp = false;
+               SMESH_Algo *algo = _gen->GetAlgo(*this, aSubMesh->GetSubShape());
+               if (algo != NULL)
+               {
+                       const list <const SMESHDS_Hypothesis * >&usedHyps
+                               = algo->GetUsedHypothesis(*this, aSubMesh->GetSubShape());
+                       list <const SMESHDS_Hypothesis * >::const_iterator itl;
+                       for (itl = usedHyps.begin(); itl != usedHyps.end(); itl++)
+                               if (anHyp == (*itl))
+                               {
+                                       usesHyp = true;
+                                       break;
+                               }
+               }
+               if (usesHyp)
+                       _subMeshesUsingHypothesisList.push_back(aSubMesh);
        }
-      if (usesHyp) _subMeshesUsingHypothesisList.push_back(aSubMesh);
-    }
-  return _subMeshesUsingHypothesisList;
+       return _subMeshesUsingHypothesisList;
 }
 
 //=============================================================================
@@ -436,35 +421,31 @@ SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis* anHyp)
  */
 //=============================================================================
 
-void SMESH_Mesh::ExportMED( const char* file )
-  throw (SALOME_Exception)
+void SMESH_Mesh::ExportMED(const char *file) throw(SALOME_Exception)
 {
-  Mesh_Writer* myWriter = new DriverMED_W_SMESHDS_Mesh;
-  myWriter->SetFile( string(file) );
-  myWriter->SetMesh( _myMeshDS );
-  MESSAGE ( " _idDoc " << _idDoc )
-  myWriter->SetMeshId( _idDoc );
-  myWriter->Add();
+       Mesh_Writer *myWriter = new DriverMED_W_SMESHDS_Mesh;
+       myWriter->SetFile(string(file));
+       myWriter->SetMesh(_myMeshDS);
+       MESSAGE(" _idDoc " << _idDoc) myWriter->SetMeshId(_idDoc);
+       myWriter->Add();
 }
 
-void SMESH_Mesh::ExportDAT( const char* file )
-  throw (SALOME_Exception)
+void SMESH_Mesh::ExportDAT(const char *file) throw(SALOME_Exception)
 {
-  Mesh_Writer* myWriter = new DriverDAT_W_SMESHDS_Mesh;
-  myWriter->SetFile( string(file) );
-  myWriter->SetMesh( _myMeshDS );
-  myWriter->SetMeshId( _idDoc );
-  myWriter->Add();
+       Mesh_Writer *myWriter = new DriverDAT_W_SMESHDS_Mesh;
+       myWriter->SetFile(string(file));
+       myWriter->SetMesh(_myMeshDS);
+       myWriter->SetMeshId(_idDoc);
+       myWriter->Add();
 }
 
-void SMESH_Mesh::ExportUNV( const char* file )
-  throw (SALOME_Exception)
+void SMESH_Mesh::ExportUNV(const char *file) throw(SALOME_Exception)
 {
-  Mesh_Writer* myWriter = new DriverUNV_W_SMESHDS_Mesh;
-  myWriter->SetFile( string(file) );
-  myWriter->SetMesh( _myMeshDS );
-  myWriter->SetMeshId( _idDoc );
-  myWriter->Add();
+       Mesh_Writer *myWriter = new DriverUNV_W_SMESHDS_Mesh;
+       myWriter->SetFile(string(file));
+       myWriter->SetMesh(_myMeshDS);
+       myWriter->SetMeshId(_idDoc);
+       myWriter->Add();
 }
 
 //=============================================================================
@@ -472,10 +453,9 @@ void SMESH_Mesh::ExportUNV( const char* file )
  *  
  */
 //=============================================================================
-int SMESH_Mesh::NbNodes()
-  throw (SALOME_Exception)
+int SMESH_Mesh::NbNodes() throw(SALOME_Exception)
 {
-  return _myMeshDS->NbNodes();
+       return _myMeshDS->NbNodes();
 }
 
 //=============================================================================
@@ -483,10 +463,9 @@ int SMESH_Mesh::NbNodes()
  *  
  */
 //=============================================================================
-int SMESH_Mesh::NbEdges()
-  throw (SALOME_Exception)
+int SMESH_Mesh::NbEdges() throw(SALOME_Exception)
 {
-  return _myMeshDS->NbEdges();
+       return _myMeshDS->NbEdges();
 }
 
 //=============================================================================
@@ -494,44 +473,35 @@ int SMESH_Mesh::NbEdges()
  *  
  */
 //=============================================================================
-int SMESH_Mesh::NbFaces()
-  throw (SALOME_Exception)
+int SMESH_Mesh::NbFaces() throw(SALOME_Exception)
 {
-  return _myMeshDS->NbFaces();
+       return _myMeshDS->NbFaces();
 }
-int SMESH_Mesh::NbTriangles()
-  throw (SALOME_Exception)
+
+///////////////////////////////////////////////////////////////////////////////
+/// Return the number of 3 nodes faces in the mesh. This method run in O(n)
+///////////////////////////////////////////////////////////////////////////////
+int SMESH_Mesh::NbTriangles() throw(SALOME_Exception)
 {
-  SMDS_MeshFacesIterator itFaces(_myMeshDS);
-  int Nb = 0;
-  for (;itFaces.More();itFaces.Next()) {
-    const Handle(SMDS_MeshElement)& elem = itFaces.Value();
-
-    switch (elem->NbNodes()) {
-    case 3 : {
-      Nb++;
-      break;
-    }
-    }
-  }
-  return Nb;
+       int Nb = 0;
+
+       SMDS_Iterator<const SMDS_MeshFace*> * itFaces=_myMeshDS->facesIterator();
+       while(itFaces->more()) if(itFaces->next()->NbNodes()==3) Nb++;
+       delete itFaces;
+       return Nb;
 }
-int SMESH_Mesh::NbQuadrangles()
-  throw (SALOME_Exception)
+
+///////////////////////////////////////////////////////////////////////////////
+/// Return the number of 4 nodes faces in the mesh. This method run in O(n)
+///////////////////////////////////////////////////////////////////////////////
+int SMESH_Mesh::NbQuadrangles() throw(SALOME_Exception)
 {
-  SMDS_MeshFacesIterator itFaces(_myMeshDS);
-  int Nb = 0;
-  for (;itFaces.More();itFaces.Next()) {
-    const Handle(SMDS_MeshElement)& elem = itFaces.Value();
-    
-    switch (elem->NbNodes()) {
-    case 4 : {
-      Nb++;
-      break;
-    }
-    }
-  }
-  return Nb;
+       int Nb = 0;
+
+       SMDS_Iterator<const SMDS_MeshFace*> * itFaces=_myMeshDS->facesIterator();
+       while(itFaces->more()) if(itFaces->next()->NbNodes()==4) Nb++;
+       delete itFaces;
+       return Nb;
 }
 
 //=============================================================================
@@ -539,44 +509,27 @@ int SMESH_Mesh::NbQuadrangles()
  *  
  */
 //=============================================================================
-int SMESH_Mesh::NbVolumes()
-  throw (SALOME_Exception)
+int SMESH_Mesh::NbVolumes() throw(SALOME_Exception)
 {
-  return _myMeshDS->NbVolumes();
+       return _myMeshDS->NbVolumes();
 }
-int SMESH_Mesh::NbTetras()
-  throw (SALOME_Exception)
+
+int SMESH_Mesh::NbTetras() throw(SALOME_Exception)
 {
-  int Nb = 0;
-  SMDS_MeshVolumesIterator itVolumes(_myMeshDS);
-  for (;itVolumes.More();itVolumes.Next()) {
-    const Handle(SMDS_MeshElement)& elem = itVolumes.Value();
-
-    switch (elem->NbNodes()) {
-    case 4 : {
-      Nb++;
-      break;
-    }
-    }
-  }
-  return Nb;
+       int Nb = 0;
+       SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=_myMeshDS->volumesIterator();
+       while(itVolumes->more()) if(itVolumes->next()->NbNodes()==4) Nb++;
+       delete itVolumes;
+       return Nb;
 }
-int SMESH_Mesh::NbHexas()
-  throw (SALOME_Exception)
+
+int SMESH_Mesh::NbHexas() throw(SALOME_Exception)
 {
-  int Nb = 0;
-  SMDS_MeshVolumesIterator itVolumes(_myMeshDS);
-  for (;itVolumes.More();itVolumes.Next()) {
-    const Handle(SMDS_MeshElement)& elem = itVolumes.Value();
-
-    switch (elem->NbNodes()) {
-    case 8 : {
-      Nb++;
-      break;
-    }
-    }
-  }
-  return Nb;
+       int Nb = 0;
+       SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=_myMeshDS->volumesIterator();
+       while(itVolumes->more()) if(itVolumes->next()->NbNodes()==8) Nb++;
+       delete itVolumes;
+       return Nb;
 }
 
 //=============================================================================
@@ -584,8 +537,7 @@ int SMESH_Mesh::NbHexas()
  *  
  */
 //=============================================================================
-int SMESH_Mesh::NbSubMesh()
-  throw (SALOME_Exception)
+int SMESH_Mesh::NbSubMesh() throw(SALOME_Exception)
 {
-  return _myMeshDS->NbSubMesh();
+       return _myMeshDS->NbSubMesh();
 }
index ef0090d..f179f68 100644 (file)
 
 #include "SMESHDS_Document.hxx"
 #include "SMESHDS_Mesh.hxx"
+#include "SMESHDS_Command.hxx"
 #include "SMESH_Hypothesis.hxx"
 #include "SMESH_subMesh.hxx"
-#include "SMESHDS_ListOfCommand.hxx"
-//#include "SMESHDS_ListOfAsciiString.hxx"
-//#include "SMESHDS_ListIteratorOfListOfAsciiString.hxx"
-
-
 #include "Utils_SALOME_Exception.hxx"
 
 #include <TopExp.hxx>
@@ -63,103 +59,83 @@ class SMESH_Gen;
 
 class SMESH_Mesh
 {
-public:
-  SMESH_Mesh();
-  SMESH_Mesh(int localId,
-            int studyId,
-            SMESH_Gen* gen,
-            const Handle(SMESHDS_Document)& myDocument);
+  public:
+       SMESH_Mesh();
+       SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen,
+               SMESHDS_Document * myDocument);
 
-  virtual ~SMESH_Mesh();
+       virtual ~ SMESH_Mesh();
 
-  void ShapeToMesh(const TopoDS_Shape& aShape)
-    throw (SALOME_Exception);
+       void ShapeToMesh(const TopoDS_Shape & aShape) throw(SALOME_Exception);
 
-  bool AddHypothesis(const TopoDS_Shape& aSubShape,
-                    int anHypId)
-    throw (SALOME_Exception);
+       bool AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
+               throw(SALOME_Exception);
 
-  bool RemoveHypothesis(const TopoDS_Shape& aSubShape,
-                       int anHypId)
-    throw (SALOME_Exception);
+       bool RemoveHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
+               throw(SALOME_Exception);
 
-  const list<SMESHDS_Hypothesis*>&
-  GetHypothesisList(const TopoDS_Shape& aSubShape)
-    throw (SALOME_Exception);
+       const list <const SMESHDS_Hypothesis * >&
+               GetHypothesisList(const TopoDS_Shape & aSubShape)
+               throw(SALOME_Exception);
 
-  const SMESHDS_ListOfCommand& GetLog()
-    throw (SALOME_Exception);
+       const list<SMESHDS_Command*> & GetLog() throw(SALOME_Exception);
 
 //   const SMESHDS_ListOfAsciiString& GetLog()
 //     throw (SALOME_Exception);
 
-  void ClearLog()
-    throw (SALOME_Exception);
-
-  int GetId();
-  const Handle(SMESHDS_Mesh)& GetMeshDS();
-
-  SMESH_Gen* GetGen();
-
-  SMESH_subMesh* GetSubMesh(const TopoDS_Shape & aSubShape)
-    throw (SALOME_Exception);
-
-  SMESH_subMesh* GetSubMeshContaining(const TopoDS_Shape & aSubShape)
-    throw (SALOME_Exception);
-
-  const list <SMESH_subMesh*>&
-  GetSubMeshUsingHypothesis(SMESHDS_Hypothesis* anHyp)
-    throw (SALOME_Exception);
-
-  void ExportDAT( const char* file )
-    throw (SALOME_Exception);
-  void ExportMED( const char* file )
-    throw (SALOME_Exception);
-  void ExportUNV( const char* file )
-    throw (SALOME_Exception);
-    
-  int NbNodes()
-    throw (SALOME_Exception);
-  
-  int NbEdges()
-    throw (SALOME_Exception);
-  
-  int NbFaces()
-    throw (SALOME_Exception);
-
-  int NbTriangles()
-    throw (SALOME_Exception);
-
-  int NbQuadrangles()
-    throw (SALOME_Exception);
-  
-  int NbVolumes()
-    throw (SALOME_Exception);
-
-  int NbTetras()
-    throw (SALOME_Exception);
-
-  int NbHexas()
-    throw (SALOME_Exception);
-  
-  int NbSubMesh()
-    throw (SALOME_Exception);
-  
-
-private:
-
-  int _id;          // id given by creator (unique within the creator instance)
-  int _studyId;
-  int _idDoc;       // id given by SMESHDS_Document
-  bool _isShapeToMesh; // set to true when a shape is given (only once)
-  list<SMESHDS_Hypothesis*> _subShapeHypothesisList;
-  list<SMESH_subMesh*> _subMeshesUsingHypothesisList;
-  Handle (SMESHDS_Document) _myDocument;
-  Handle (SMESHDS_Mesh) _myMeshDS;
-  TopTools_IndexedMapOfShape _subShapes;
-  map<int, SMESH_subMesh*> _mapSubMesh;
-  SMESH_Gen* _gen;
+       void ClearLog() throw(SALOME_Exception);
+
+       int GetId();
+
+       SMESHDS_Mesh * GetMeshDS();
+
+       SMESH_Gen *GetGen();
+
+       SMESH_subMesh *GetSubMesh(const TopoDS_Shape & aSubShape)
+               throw(SALOME_Exception);
+
+       SMESH_subMesh *GetSubMeshContaining(const TopoDS_Shape & aSubShape)
+               throw(SALOME_Exception);
+
+       const list < SMESH_subMesh * >&
+               GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
+               throw(SALOME_Exception);
+
+       void ExportDAT(const char *file) throw(SALOME_Exception);
+       void ExportMED(const char *file) throw(SALOME_Exception);
+       void ExportUNV(const char *file) throw(SALOME_Exception);
+
+       int NbNodes() throw(SALOME_Exception);
+
+       int NbEdges() throw(SALOME_Exception);
+
+       int NbFaces() throw(SALOME_Exception);
+
+       int NbTriangles() throw(SALOME_Exception);
+
+       int NbQuadrangles() throw(SALOME_Exception);
+
+       int NbVolumes() throw(SALOME_Exception);
+
+       int NbTetras() throw(SALOME_Exception);
+
+       int NbHexas() throw(SALOME_Exception);
+
+       int NbSubMesh() throw(SALOME_Exception);
+
+  private:
+
+       int _id;                                        // id given by creator (unique within the creator instance)
+       int _studyId;
+       int _idDoc;                                     // id given by SMESHDS_Document
+       bool _isShapeToMesh;            // set to true when a shape is given (only once)
+       list<const SMESHDS_Hypothesis *> _subShapeHypothesisList;
+       list <SMESH_subMesh *> _subMeshesUsingHypothesisList;
+       SMESHDS_Document * _myDocument;
+       SMESHDS_Mesh * _myMeshDS;
+       TopTools_IndexedMapOfShape _subShapes;
+       map <int, SMESH_subMesh *>_mapSubMesh;
+       SMESH_Gen *_gen;
 };
 
 #endif
index 0cb8274..3b8a61b 100644 (file)
@@ -27,7 +27,6 @@
 //  $Header$
 
 using namespace std;
-using namespace std;
 #include "SMESH_Quadrangle_2D.hxx"
 #include "SMESH_Gen.hxx"
 #include "SMESH_Mesh.hxx"
@@ -56,15 +55,13 @@ using namespace std;
  */
 //=============================================================================
 
-SMESH_Quadrangle_2D::SMESH_Quadrangle_2D(int hypId, 
-                                        int studyId, 
-                                        SMESH_Gen* gen)
-  : SMESH_2D_Algo(hypId, studyId, gen)
+SMESH_Quadrangle_2D::SMESH_Quadrangle_2D(int hypId,
+       int studyId, SMESH_Gen * gen):SMESH_2D_Algo(hypId, studyId, gen)
 {
-  MESSAGE("SMESH_Quadrangle_2D::SMESH_Quadrangle_2D");
-  _name = "Quadrangle_2D";
-  //  _shapeType = TopAbs_FACE;
-  _shapeType = (1<<TopAbs_FACE);
+       MESSAGE("SMESH_Quadrangle_2D::SMESH_Quadrangle_2D");
+       _name = "Quadrangle_2D";
+       //  _shapeType = TopAbs_FACE;
+       _shapeType = (1 << TopAbs_FACE);
 }
 
 //=============================================================================
@@ -75,7 +72,7 @@ SMESH_Quadrangle_2D::SMESH_Quadrangle_2D(int hypId,
 
 SMESH_Quadrangle_2D::~SMESH_Quadrangle_2D()
 {
-  MESSAGE("SMESH_Quadrangle_2D::~SMESH_Quadrangle_2D");
+       MESSAGE("SMESH_Quadrangle_2D::~SMESH_Quadrangle_2D");
 }
 
 //=============================================================================
@@ -84,93 +81,89 @@ SMESH_Quadrangle_2D::~SMESH_Quadrangle_2D()
  */
 //=============================================================================
 
-bool SMESH_Quadrangle_2D::CheckHypothesis(SMESH_Mesh& aMesh,
-                                         const TopoDS_Shape& aShape)
+bool SMESH_Quadrangle_2D::CheckHypothesis(SMESH_Mesh & aMesh,
+       const TopoDS_Shape & aShape)
 {
-  //MESSAGE("SMESH_Quadrangle_2D::CheckHypothesis");
+       //MESSAGE("SMESH_Quadrangle_2D::CheckHypothesis");
 
-  bool isOk = true;
+       bool isOk = true;
 
-  // nothing to check
+       // nothing to check
 
-  return isOk;
+       return isOk;
 }
 
-
 //=============================================================================
 /*!
  *  
  */
 //=============================================================================
 
-bool SMESH_Quadrangle_2D::Compute(SMESH_Mesh& aMesh,
-                                 const TopoDS_Shape& aShape)
-  throw (SALOME_Exception)
+bool SMESH_Quadrangle_2D::Compute(SMESH_Mesh & aMesh,
+       const TopoDS_Shape & aShape)throw(SALOME_Exception)
 {
-  //MESSAGE("SMESH_Quadrangle_2D::Compute");
-  const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
-  SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape);
-
-  FaceQuadStruct* quad = CheckAnd2Dcompute(aMesh, aShape);
-  if (!quad) return false;
-
-  // --- compute 3D values on points, store points & quadrangles
-
-  int nbdown = quad->nbPts[0];
-  int nbright = quad->nbPts[1];
-  int nbVertices = nbdown*nbright;
-  int nbQuad = (nbdown-1)*(nbright-1);
-  //SCRUTE(nbVertices);
-  //SCRUTE(nbQuad);
-
-  //   const TopoDS_Face& FF = TopoDS::Face(aShape);
-  //   bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
-  //   TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
-  const TopoDS_Face& F = TopoDS::Face(aShape);
-  bool faceIsForward = (F.Orientation() == TopAbs_FORWARD);
-  Handle(Geom_Surface) S = BRep_Tool::Surface(F);
-
-  for (int i=1; i<nbdown-1; i++)
-    for (int j=1; j<nbright-1; j++)    // internal points
-      {
-       int ij = j*nbdown +i;
-       double u = quad->uv_grid[ij].u;
-       double v = quad->uv_grid[ij].v;
-       gp_Pnt P = S->Value(u,v);
-       int nodeId = meshDS->AddNode(P.X(), P.Y(), P.Z());
-       //MESSAGE("point "<< nodeId<<" "<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z());
-       Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
-       Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
-       meshDS->SetNodeOnFace(node, F);
-       quad->uv_grid[ij].nodeId = nodeId; 
-//     Handle (SMDS_FacePosition) fpos
-//       = new SMDS_FacePosition(theSubMesh->GetId(),i,j); // easier than u,v
-//     node->SetPosition(fpos);
-       Handle (SMDS_FacePosition) fpos
-         = Handle (SMDS_FacePosition)::DownCast(node->GetPosition());
-       fpos->SetUParameter(i);
-       fpos->SetVParameter(j);
-      }
-
-  //   bool isQuadForward = ( faceIsForward == quad->isEdgeForward[0]);
-  for (int i=0; i<nbdown-1; i++)
-    for (int j=0; j<nbright-1; j++)    // faces
-      {
-       int a = quad->uv_grid[   j *nbdown +i  ].nodeId;
-       int b = quad->uv_grid[   j *nbdown +i+1].nodeId;
-       int c = quad->uv_grid[(j+1)*nbdown +i+1].nodeId;
-       int d = quad->uv_grid[(j+1)*nbdown +i  ].nodeId;
-       int faceId;
-       //      if (isQuadForward) faceId = meshDS->AddFace(a,b,c,d);
-       //      else faceId = meshDS->AddFace(a,d,c,b);
-       faceId = meshDS->AddFace(a,b,c,d);
-       Handle (SMDS_MeshElement) elt = meshDS->FindElement(faceId);
-       meshDS->SetMeshElementOnShape(elt, F);
-      }
-
-  QuadDelete(quad);
-  bool isOk = true;
-  return isOk;
+       //MESSAGE("SMESH_Quadrangle_2D::Compute");
+       SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+       SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
+
+       FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape);
+       if (!quad)
+               return false;
+
+       // --- compute 3D values on points, store points & quadrangles
+
+       int nbdown = quad->nbPts[0];
+       int nbright = quad->nbPts[1];
+       int nbVertices = nbdown * nbright;
+       int nbQuad = (nbdown - 1) * (nbright - 1);
+       //SCRUTE(nbVertices);
+       //SCRUTE(nbQuad);
+
+       //   const TopoDS_Face& FF = TopoDS::Face(aShape);
+       //   bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
+       //   TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
+       const TopoDS_Face & F = TopoDS::Face(aShape);
+       bool faceIsForward = (F.Orientation() == TopAbs_FORWARD);
+       Handle(Geom_Surface) S = BRep_Tool::Surface(F);
+
+       for (int i = 1; i < nbdown - 1; i++)
+               for (int j = 1; j < nbright - 1; j++)   // internal points
+               {
+                       int ij = j * nbdown + i;
+                       double u = quad->uv_grid[ij].u;
+                       double v = quad->uv_grid[ij].v;
+                       gp_Pnt P = S->Value(u, v);
+                       SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
+                       int nodeId = node->GetID();
+                       meshDS->SetNodeOnFace(node, F);
+                       quad->uv_grid[ij].nodeId = nodeId;
+//  Handle (SMDS_FacePosition) fpos
+//    = new SMDS_FacePosition(theSubMesh->GetId(),i,j); // easier than u,v
+//  node->SetPosition(fpos);
+                       SMDS_FacePosition* fpos
+                               = dynamic_cast<SMDS_FacePosition*>(node->GetPosition());
+                       fpos->SetUParameter(i);
+                       fpos->SetVParameter(j);
+               }
+
+       //   bool isQuadForward = ( faceIsForward == quad->isEdgeForward[0]);
+       for (int i = 0; i < nbdown - 1; i++)
+               for (int j = 0; j < nbright - 1; j++)   // faces
+               {
+                       int a = quad->uv_grid[j * nbdown + i].nodeId;
+                       int b = quad->uv_grid[j * nbdown + i + 1].nodeId;
+                       int c = quad->uv_grid[(j + 1) * nbdown + i + 1].nodeId;
+                       int d = quad->uv_grid[(j + 1) * nbdown + i].nodeId;
+                       int faceId;
+                       //  if (isQuadForward) faceId = meshDS->AddFace(a,b,c,d);
+                       //  else faceId = meshDS->AddFace(a,d,c,b);
+                       SMDS_MeshFace * face = meshDS->AddFace(a, b, c, d);
+                       meshDS->SetMeshElementOnShape(face, F);
+               }
+
+       QuadDelete(quad);
+       bool isOk = true;
+       return isOk;
 }
 
 //=============================================================================
@@ -179,84 +172,82 @@ bool SMESH_Quadrangle_2D::Compute(SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-FaceQuadStruct*
-SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh& aMesh,
-                                      const TopoDS_Shape& aShape)
-  throw (SALOME_Exception)
+FaceQuadStruct *SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh & aMesh,
+       const TopoDS_Shape & aShape)throw(SALOME_Exception)
 {
-  //MESSAGE("SMESH_Quadrangle_2D::ComputeWithoutStore");
-
-  SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape);
-
-  //   const TopoDS_Face& FF = TopoDS::Face(aShape);
-  //   bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
-  //   TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
-  const TopoDS_Face& F = TopoDS::Face(aShape);
-  bool faceIsForward = (F.Orientation() == TopAbs_FORWARD);
-
-  // verify 1 wire only, with 4 edges, same number of points on opposite edges
-
-  if (NumberOfWires (F) != 1)
-    {
-      MESSAGE("only 1 wire by face (quadrangles)");
-      return 0;
-      //throw SALOME_Exception(LOCALIZED("only 1 wire by face (quadrangles)"));
-    }
-  //   const TopoDS_Wire WW = BRepTools::OuterWire(F);
-  //   TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD));
-  const TopoDS_Wire& W = BRepTools::OuterWire(F);
-  BRepTools_WireExplorer wexp(W,F);    
-
-  FaceQuadStruct* quad = new FaceQuadStruct;
-  for (int i=0; i<4; i++) quad->uv_edges[i] = 0;
-  quad->uv_grid = 0;
-
-  int nbEdges = 0;
-  for (wexp.Init(W,F);wexp.More(); wexp.Next())
-    {
-      //       const TopoDS_Edge& EE = wexp.Current();
-      //       TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
-      const TopoDS_Edge& E = wexp.Current();
-      int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
-      if (nbEdges < 4)
-       {         
-         quad->edge[nbEdges] = E;
-         quad->nbPts[nbEdges] = nb +2; // internal points + 2 extrema
+       //MESSAGE("SMESH_Quadrangle_2D::ComputeWithoutStore");
+
+       SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
+
+       //   const TopoDS_Face& FF = TopoDS::Face(aShape);
+       //   bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
+       //   TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
+       const TopoDS_Face & F = TopoDS::Face(aShape);
+       bool faceIsForward = (F.Orientation() == TopAbs_FORWARD);
+
+       // verify 1 wire only, with 4 edges, same number of points on opposite edges
+
+       if (NumberOfWires(F) != 1)
+       {
+               MESSAGE("only 1 wire by face (quadrangles)");
+               return 0;
+               //throw SALOME_Exception(LOCALIZED("only 1 wire by face (quadrangles)"));
        }
-      nbEdges++;
-    }
-
-  if (nbEdges != 4)
-    {
-      MESSAGE("face must have 4 edges /quadrangles");
-      QuadDelete(quad);
-      return 0;
-      //throw SALOME_Exception(LOCALIZED("face must have 4 edges /quadrangles"));
-    }
-
-  if (quad->nbPts[0] != quad->nbPts[2])
-    {
-      MESSAGE("different point number-opposed edge");
-      QuadDelete(quad);
-      return 0;
-      //throw SALOME_Exception(LOCALIZED("different point number-opposed edge"));
-    }
-
-  if (quad->nbPts[1] != quad->nbPts[3])
-    {
-      MESSAGE("different point number-opposed edge");
-      QuadDelete(quad);
-      return 0;
-      //throw SALOME_Exception(LOCALIZED("different point number-opposed edge"));
-    }
-
-  // set normalized grid on unit square in parametric domain
-
-  SetNormalizedGrid(aMesh, F, quad);
-  
-  return quad;
-}
+       //   const TopoDS_Wire WW = BRepTools::OuterWire(F);
+       //   TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD));
+       const TopoDS_Wire & W = BRepTools::OuterWire(F);
+       BRepTools_WireExplorer wexp(W, F);
+
+       FaceQuadStruct *quad = new FaceQuadStruct;
+       for (int i = 0; i < 4; i++)
+               quad->uv_edges[i] = 0;
+       quad->uv_grid = 0;
+
+       int nbEdges = 0;
+       for (wexp.Init(W, F); wexp.More(); wexp.Next())
+       {
+               //       const TopoDS_Edge& EE = wexp.Current();
+               //       TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
+               const TopoDS_Edge & E = wexp.Current();
+               int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
+               if (nbEdges < 4)
+               {
+                       quad->edge[nbEdges] = E;
+                       quad->nbPts[nbEdges] = nb + 2;  // internal points + 2 extrema
+               }
+               nbEdges++;
+       }
+
+       if (nbEdges != 4)
+       {
+               MESSAGE("face must have 4 edges /quadrangles");
+               QuadDelete(quad);
+               return 0;
+               //throw SALOME_Exception(LOCALIZED("face must have 4 edges /quadrangles"));
+       }
+
+       if (quad->nbPts[0] != quad->nbPts[2])
+       {
+               MESSAGE("different point number-opposed edge");
+               QuadDelete(quad);
+               return 0;
+               //throw SALOME_Exception(LOCALIZED("different point number-opposed edge"));
+       }
+
+       if (quad->nbPts[1] != quad->nbPts[3])
+       {
+               MESSAGE("different point number-opposed edge");
+               QuadDelete(quad);
+               return 0;
+               //throw SALOME_Exception(LOCALIZED("different point number-opposed edge"));
+       }
+
+       // set normalized grid on unit square in parametric domain
 
+       SetNormalizedGrid(aMesh, F, quad);
+
+       return quad;
+}
 
 //=============================================================================
 /*!
@@ -264,19 +255,21 @@ SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-  void SMESH_Quadrangle_2D::QuadDelete(FaceQuadStruct* quad)
+void SMESH_Quadrangle_2D::QuadDelete(FaceQuadStruct * quad)
 {
-  //MESSAGE("SMESH_Quadrangle_2D::QuadDelete");
-  if (quad)
-    {
-      for (int i=0; i<4; i++)
+       //MESSAGE("SMESH_Quadrangle_2D::QuadDelete");
+       if (quad)
        {
-         if (quad->uv_edges[i]) delete [] quad->uv_edges[i];
-         quad->edge[i].Nullify();
+               for (int i = 0; i < 4; i++)
+               {
+                       if (quad->uv_edges[i])
+                               delete[]quad->uv_edges[i];
+                       quad->edge[i].Nullify();
+               }
+               if (quad->uv_grid)
+                       delete[]quad->uv_grid;
+               delete quad;
        }
-      if (quad->uv_grid) delete [] quad->uv_grid;
-      delete quad;
-   }
 }
 
 //=============================================================================
@@ -285,77 +278,73 @@ SMESH_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
-                                           const TopoDS_Shape& aShape,
-                                           FaceQuadStruct* quad)
-  throw (SALOME_Exception)
+void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh & aMesh,
+       const TopoDS_Shape & aShape, FaceQuadStruct * quad) throw(SALOME_Exception)
 {
-  // Algorithme décrit dans "Génération automatique de maillages"
-  // P.L. GEORGE, MASSON, § 6.4.1 p. 84-85
-  // traitement dans le domaine paramétrique 2d u,v
-  // transport - projection sur le carré unité
-
-  const TopoDS_Face& F = TopoDS::Face(aShape);
-
-  // 1 --- find orientation of the 4 edges, by test on extrema
-
-  //      max             min                    0     x1     1
-  //     |<----north-2-------^                a3 -------------> a2
-  //     |                   |                   ^1          1^
-  //    west-3            east-1 =right          |            |
-  //     |                   |         ==>       |            |
-  //  y0 |                   | y1                |            |
-  //     |                   |                   |0          0|
-  //     v----south-0-------->                a0 -------------> a1
-  //      min             max                    0     x0     1
-  //             =down
-  //
-
-  Handle (Geom2d_Curve) c2d[4];
-  gp_Pnt2d pf[4];
-  gp_Pnt2d pl[4];
-  for (int i=0; i<4; i++)
-    {
-      c2d[i] = BRep_Tool::CurveOnSurface(quad->edge[i],
-                                        F,
-                                        quad->first[i],
-                                        quad->last[i]);
-      pf[i] = c2d[i]->Value(quad->first[i]);
-      pl[i] = c2d[i]->Value(quad->last[i]);
-      quad->isEdgeForward[i] = false;
-    }
-
-  double eps2d = 1.e-3; // *** utiliser plutot TopExp::CommonVertex, puis
-                        // distances si piece fausse
-  int i=0;
-  if ((pf[1].Distance(pl[0]) < eps2d) || (pl[1].Distance(pl[0]) < eps2d))
-    {
-      quad->isEdgeForward[0] = true;
-    }
-  else
-    {
-      double tmp =quad->first[0];
-      quad->first[0] = quad->last[0];
-      quad->last[0] = tmp;
-      pf[0] = c2d[0]->Value(quad->first[0]);
-      pl[0] = c2d[0]->Value(quad->last[0]);
-    }
-  for (int i=1; i<4; i++)
-    {
-      quad->isEdgeForward[i] = (pf[i].Distance(pl[i-1]) < eps2d);
-      if (! quad->isEdgeForward[i])
+       // Algorithme décrit dans "Génération automatique de maillages"
+       // P.L. GEORGE, MASSON, § 6.4.1 p. 84-85
+       // traitement dans le domaine paramétrique 2d u,v
+       // transport - projection sur le carré unité
+
+       const TopoDS_Face & F = TopoDS::Face(aShape);
+
+       // 1 --- find orientation of the 4 edges, by test on extrema
+
+       //      max             min                    0     x1     1
+       //     |<----north-2-------^                a3 -------------> a2
+       //     |                   |                   ^1          1^
+       //    west-3            east-1 =right          |            |
+       //     |                   |         ==>       |            |
+       //  y0 |                   | y1                |            |
+       //     |                   |                   |0          0|
+       //     v----south-0-------->                a0 -------------> a1
+       //      min             max                    0     x0     1
+       //             =down
+       //
+
+       Handle(Geom2d_Curve) c2d[4];
+       gp_Pnt2d pf[4];
+       gp_Pnt2d pl[4];
+       for (int i = 0; i < 4; i++)
        {
-         double tmp =quad->first[i];
-         quad->first[i] = quad->last[i];
-         quad->last[i] = tmp;
-         pf[i] = c2d[i]->Value(quad->first[i]);
-         pl[i] = c2d[i]->Value(quad->last[i]);
-         //SCRUTE(pf[i].Distance(pl[i-1]));
-         ASSERT(pf[i].Distance(pl[i-1]) < eps2d);
+               c2d[i] = BRep_Tool::CurveOnSurface(quad->edge[i],
+                       F, quad->first[i], quad->last[i]);
+               pf[i] = c2d[i]->Value(quad->first[i]);
+               pl[i] = c2d[i]->Value(quad->last[i]);
+               quad->isEdgeForward[i] = false;
        }
-    }
-  //SCRUTE(pf[0].Distance(pl[3]));
-  ASSERT(pf[0].Distance(pl[3]) < eps2d);
+
+       double eps2d = 1.e-3;           // *** utiliser plutot TopExp::CommonVertex, puis
+       // distances si piece fausse
+       int i = 0;
+       if ((pf[1].Distance(pl[0]) < eps2d) || (pl[1].Distance(pl[0]) < eps2d))
+       {
+               quad->isEdgeForward[0] = true;
+       }
+       else
+       {
+               double tmp = quad->first[0];
+               quad->first[0] = quad->last[0];
+               quad->last[0] = tmp;
+               pf[0] = c2d[0]->Value(quad->first[0]);
+               pl[0] = c2d[0]->Value(quad->last[0]);
+       }
+       for (int i = 1; i < 4; i++)
+       {
+               quad->isEdgeForward[i] = (pf[i].Distance(pl[i - 1]) < eps2d);
+               if (!quad->isEdgeForward[i])
+               {
+                       double tmp = quad->first[i];
+                       quad->first[i] = quad->last[i];
+                       quad->last[i] = tmp;
+                       pf[i] = c2d[i]->Value(quad->first[i]);
+                       pl[i] = c2d[i]->Value(quad->last[i]);
+                       //SCRUTE(pf[i].Distance(pl[i-1]));
+                       ASSERT(pf[i].Distance(pl[i - 1]) < eps2d);
+               }
+       }
+       //SCRUTE(pf[0].Distance(pl[3]));
+       ASSERT(pf[0].Distance(pl[3]) < eps2d);
 
 //   for (int i=0; i<4; i++)
 //     {
@@ -364,125 +353,121 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
 //       MESSAGE(" -last  "<<i<<" "<<pl[i].X()<<" "<<pl[i].Y());
 //     }
 
-  // 2 --- load 2d edge points (u,v) with orientation and value on unit square
-
-  for (int i=0; i<2; i++)
-    {
-      quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
-                                        quad->edge[i],
-                                        quad->first[i],
-                                        quad->last[i]);
-
-      //                                            quad->isEdgeForward[i]);
-    }
-  for (int i=2; i<4; i++)
-    {
-      quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
-                                        quad->edge[i],
-                                        quad->last[i],
-                                        quad->first[i]);
-
-      //                                            !quad->isEdgeForward[i]);
-    }
-
-  // 3 --- 2D normalized values on unit square [0..1][0..1]
-
-  int nbdown = quad->nbPts[0];
-  int nbright = quad->nbPts[1];
-  quad->uv_grid  = new UVPtStruct[nbright*nbdown];
-
-  UVPtStruct* uv_grid = quad->uv_grid;
-  UVPtStruct* uv_e0   = quad->uv_edges[0];
-  UVPtStruct* uv_e1   = quad->uv_edges[1];
-  UVPtStruct* uv_e2   = quad->uv_edges[2];
-  UVPtStruct* uv_e3   = quad->uv_edges[3];
-  gp_Pnt2d a0 = pf[0];
-  gp_Pnt2d a1 = pf[1];
-  gp_Pnt2d a2 = pf[2];
-  gp_Pnt2d a3 = pf[3];
-
-  // nodes Id on edges
-
-  int j = 0;
-  for (int i=0; i<nbdown; i++)
-    {
-      int ij = j*nbdown +i;
-      uv_grid[ij].nodeId = uv_e0[i].nodeId;
-    }
-  i = nbdown-1;
-  for (int j=0; j<nbright; j++)
-    {
-      int ij = j*nbdown +i;
-      uv_grid[ij].nodeId = uv_e1[j].nodeId;
-    }
-  j = nbright -1;
-  for (int i=0; i<nbdown; i++)
-    {
-      int ij = j*nbdown +i;
-      uv_grid[ij].nodeId = uv_e2[i].nodeId;
-    }
-  i = 0;
-  for (int j=0; j<nbright; j++)
-    {
-      int ij = j*nbdown +i;
-      uv_grid[ij].nodeId = uv_e3[j].nodeId;
-    }
-
-  // normalized 2d values on grid
-
-  for (int i=0; i<nbdown; i++)
-    for (int j=0; j<nbright; j++)
-      {
-       int ij = j*nbdown +i;
-       // --- droite i cste : x = x0 + y(x1-x0)
-       double x0 = uv_e0[i].normParam;              // bas - sud
-       double x1 = uv_e2[i].normParam;              // haut - nord
-       // --- droite j cste : y = y0 + x(y1-y0)
-       double y0 = uv_e3[j].normParam;              // gauche-ouest
-       double y1 = uv_e1[j].normParam;              // droite - est
-       // --- intersection : x=x0+(y0+x(y1-y0))(x1-x0)
-       double x=(x0+y0*(x1-x0))/(1-(y1-y0)*(x1-x0));
-       double y=y0+x*(y1-y0);
-       uv_grid[ij].x = x;
-       uv_grid[ij].y = y;
-       //MESSAGE("-xy-01 "<<x0<<" "<<x1<<" "<<y0<<" "<<y1);
-       //MESSAGE("-xy-norm "<<i<<" "<<j<<" "<<x<<" "<<y);
-      }
-
-  // 4 --- projection on 2d domain (u,v)
-
-  for (int i=0; i<nbdown; i++)
-    for (int j=0; j<nbright; j++)
-      {
-       int ij = j*nbdown +i;
-       double x = uv_grid[ij].x;
-       double y = uv_grid[ij].y;
-       double param_0 = uv_e0[0].param
-         + x*(uv_e0[nbdown-1].param -uv_e0[0].param);     // sud
-       double param_2 = uv_e2[0].param
-         + x*(uv_e2[nbdown-1].param -uv_e2[0].param);     // nord
-       double param_1 = uv_e1[0].param
-         + y*(uv_e1[nbright-1].param -uv_e1[0].param);    // est
-       double param_3 = uv_e3[0].param
-         + y*(uv_e3[nbright-1].param -uv_e3[0].param);    // ouest
-
-       //MESSAGE("params "<<param_0<<" "<<param_1<<" "<<param_2<<" "<<param_3);
-       gp_Pnt2d p0 = c2d[0]->Value(param_0);
-       gp_Pnt2d p1 = c2d[1]->Value(param_1);
-       gp_Pnt2d p2 = c2d[2]->Value(param_2);
-       gp_Pnt2d p3 = c2d[3]->Value(param_3);
-
-       double u = (1-y)*p0.X() + x*p1.X() + y*p2.X() + (1-x)*p3.X();
-       double v = (1-y)*p0.Y() + x*p1.Y() + y*p2.Y() + (1-x)*p3.Y();
-
-       u -= (1-x)*(1-y)*a0.X() + x*(1-y)*a1.X() + x*y*a2.X() + (1-x)*y*a3.X();
-       v -= (1-x)*(1-y)*a0.Y() + x*(1-y)*a1.Y() + x*y*a2.Y() + (1-x)*y*a3.Y();
-
-       uv_grid[ij].u = u;
-       uv_grid[ij].v = v;
-
-       //MESSAGE("-uv- "<<i<<" "<<j<<" "<<uv_grid[ij].u<<" "<<uv_grid[ij].v);
-      }
+       // 2 --- load 2d edge points (u,v) with orientation and value on unit square
+
+       for (int i = 0; i < 2; i++)
+       {
+               quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
+                       quad->edge[i], quad->first[i], quad->last[i]);
+
+               //                         quad->isEdgeForward[i]);
+       }
+       for (int i = 2; i < 4; i++)
+       {
+               quad->uv_edges[i] = LoadEdgePoints(aMesh, F,
+                       quad->edge[i], quad->last[i], quad->first[i]);
+
+               //                         !quad->isEdgeForward[i]);
+       }
+
+       // 3 --- 2D normalized values on unit square [0..1][0..1]
+
+       int nbdown = quad->nbPts[0];
+       int nbright = quad->nbPts[1];
+       quad->uv_grid = new UVPtStruct[nbright * nbdown];
+
+       UVPtStruct *uv_grid = quad->uv_grid;
+       UVPtStruct *uv_e0 = quad->uv_edges[0];
+       UVPtStruct *uv_e1 = quad->uv_edges[1];
+       UVPtStruct *uv_e2 = quad->uv_edges[2];
+       UVPtStruct *uv_e3 = quad->uv_edges[3];
+       gp_Pnt2d a0 = pf[0];
+       gp_Pnt2d a1 = pf[1];
+       gp_Pnt2d a2 = pf[2];
+       gp_Pnt2d a3 = pf[3];
+
+       // nodes Id on edges
+
+       int j = 0;
+       for (int i = 0; i < nbdown; i++)
+       {
+               int ij = j * nbdown + i;
+               uv_grid[ij].nodeId = uv_e0[i].nodeId;
+       }
+       i = nbdown - 1;
+       for (int j = 0; j < nbright; j++)
+       {
+               int ij = j * nbdown + i;
+               uv_grid[ij].nodeId = uv_e1[j].nodeId;
+       }
+       j = nbright - 1;
+       for (int i = 0; i < nbdown; i++)
+       {
+               int ij = j * nbdown + i;
+               uv_grid[ij].nodeId = uv_e2[i].nodeId;
+       }
+       i = 0;
+       for (int j = 0; j < nbright; j++)
+       {
+               int ij = j * nbdown + i;
+               uv_grid[ij].nodeId = uv_e3[j].nodeId;
+       }
+
+       // normalized 2d values on grid
+
+       for (int i = 0; i < nbdown; i++)
+               for (int j = 0; j < nbright; j++)
+               {
+                       int ij = j * nbdown + i;
+                       // --- droite i cste : x = x0 + y(x1-x0)
+                       double x0 = uv_e0[i].normParam; // bas - sud
+                       double x1 = uv_e2[i].normParam; // haut - nord
+                       // --- droite j cste : y = y0 + x(y1-y0)
+                       double y0 = uv_e3[j].normParam; // gauche-ouest
+                       double y1 = uv_e1[j].normParam; // droite - est
+                       // --- intersection : x=x0+(y0+x(y1-y0))(x1-x0)
+                       double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0));
+                       double y = y0 + x * (y1 - y0);
+                       uv_grid[ij].x = x;
+                       uv_grid[ij].y = y;
+                       //MESSAGE("-xy-01 "<<x0<<" "<<x1<<" "<<y0<<" "<<y1);
+                       //MESSAGE("-xy-norm "<<i<<" "<<j<<" "<<x<<" "<<y);
+               }
+
+       // 4 --- projection on 2d domain (u,v)
+
+       for (int i = 0; i < nbdown; i++)
+               for (int j = 0; j < nbright; j++)
+               {
+                       int ij = j * nbdown + i;
+                       double x = uv_grid[ij].x;
+                       double y = uv_grid[ij].y;
+                       double param_0 = uv_e0[0].param + x * (uv_e0[nbdown - 1].param - uv_e0[0].param);       // sud
+                       double param_2 = uv_e2[0].param + x * (uv_e2[nbdown - 1].param - uv_e2[0].param);       // nord
+                       double param_1 = uv_e1[0].param + y * (uv_e1[nbright - 1].param - uv_e1[0].param);      // est
+                       double param_3 = uv_e3[0].param + y * (uv_e3[nbright - 1].param - uv_e3[0].param);      // ouest
+
+                       //MESSAGE("params "<<param_0<<" "<<param_1<<" "<<param_2<<" "<<param_3);
+                       gp_Pnt2d p0 = c2d[0]->Value(param_0);
+                       gp_Pnt2d p1 = c2d[1]->Value(param_1);
+                       gp_Pnt2d p2 = c2d[2]->Value(param_2);
+                       gp_Pnt2d p3 = c2d[3]->Value(param_3);
+
+                       double u =
+                               (1 - y) * p0.X() + x * p1.X() + y * p2.X() + (1 - x) * p3.X();
+                       double v =
+                               (1 - y) * p0.Y() + x * p1.Y() + y * p2.Y() + (1 - x) * p3.Y();
+
+                       u -= (1 - x) * (1 - y) * a0.X() + x * (1 - y) * a1.X() +
+                               x * y * a2.X() + (1 - x) * y * a3.X();
+                       v -= (1 - x) * (1 - y) * a0.Y() + x * (1 - y) * a1.Y() +
+                               x * y * a2.Y() + (1 - x) * y * a3.Y();
+
+                       uv_grid[ij].u = u;
+                       uv_grid[ij].v = v;
+
+                       //MESSAGE("-uv- "<<i<<" "<<j<<" "<<uv_grid[ij].u<<" "<<uv_grid[ij].v);
+               }
 }
 
 //=============================================================================
@@ -491,137 +476,133 @@ void SMESH_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-UVPtStruct* SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh& aMesh,
-                                               const TopoDS_Face& F,
-                                               const TopoDS_Edge& E,
-                                               double first,
-                                               double last)
-  //                                           bool isForward)
+UVPtStruct *SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh & aMesh,
+       const TopoDS_Face & F, const TopoDS_Edge & E, double first, double last)
+  //                        bool isForward)
 {
-  //MESSAGE("SMESH_Quadrangle_2D::LoadEdgePoints");
-
-  Handle (SMDS_Mesh) meshDS = aMesh.GetMeshDS();
-
-  // --- IDNodes of first and last Vertex
-
-  TopoDS_Vertex VFirst, VLast;
-  TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
-  
-  ASSERT(!VFirst.IsNull());
-  SMESH_subMesh* firstSubMesh = aMesh.GetSubMesh(VFirst);
-  const TColStd_ListOfInteger& lidf
-    = firstSubMesh->GetSubMeshDS()->GetIDNodes();
-  int idFirst= lidf.First();
-  //SCRUTE(idFirst);
-  
-  ASSERT(!VLast.IsNull());
-  SMESH_subMesh* lastSubMesh = aMesh.GetSubMesh(VLast);
-  const TColStd_ListOfInteger& lidl
-    = lastSubMesh->GetSubMeshDS()->GetIDNodes();
-  int idLast= lidl.First();
-  //SCRUTE(idLast);
-
-  // --- edge internal IDNodes (relies on good order storage, not checked)
-
-  int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
-  //SCRUTE(nbPoints);
-  UVPtStruct * uvslf = new UVPtStruct[nbPoints+2];
-  
-  double f,l;
-  Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f,l);
-  
-  const TColStd_ListOfInteger& indElt
-    = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes();
-  TColStd_ListIteratorOfListOfInteger ite(indElt);
-  //SCRUTE(nbPoints);
-  //SCRUTE(indElt.Extent());
-  ASSERT(nbPoints == indElt.Extent());
-
-  map<double,int> params;
-  for (; ite.More(); ite.Next())
-    {
-      int nodeId = ite.Value();
-      Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
-      Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
-      Handle (SMDS_EdgePosition) epos
-       = Handle (SMDS_EdgePosition)::DownCast(node->GetPosition());
-      double param = epos->GetUParameter();
-      params[param] = nodeId;
-    }
-
-  bool isForward = (((l-f)*(last-first)) > 0);
-  double paramin = 0;
-  double paramax = 0;
-  if (isForward)
-    {
-      paramin = f;
-      paramax = l;
-      gp_Pnt2d p = C2d->Value(f);           // first point = Vertex Forward
-      uvslf [0].x = p.X();
-      uvslf [0].y = p.Y();
-      uvslf [0].param = f;
-      uvslf [0].nodeId = idFirst;
-      //MESSAGE("__ f "<<f<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
-      map<double,int>::iterator itp = params.begin();
-      for (int i = 1; i <= nbPoints; i++)   // nbPoints internal
+       //MESSAGE("SMESH_Quadrangle_2D::LoadEdgePoints");
+
+       SMDS_Mesh * meshDS = aMesh.GetMeshDS();
+
+       // --- IDNodes of first and last Vertex
+
+       TopoDS_Vertex VFirst, VLast;
+       TopExp::Vertices(E, VFirst, VLast);     // corresponds to f and l
+
+       ASSERT(!VFirst.IsNull());
+       SMESH_subMesh *firstSubMesh = aMesh.GetSubMesh(VFirst);
+       const vector<int>& lidf
+               = firstSubMesh->GetSubMeshDS()->GetIDNodes();
+       int idFirst = lidf[0];
+       //SCRUTE(idFirst);
+
+       ASSERT(!VLast.IsNull());
+       SMESH_subMesh *lastSubMesh = aMesh.GetSubMesh(VLast);
+       const vector<int> & lidl
+               = lastSubMesh->GetSubMeshDS()->GetIDNodes();
+       int idLast = lidl[0];
+       //SCRUTE(idLast);
+
+       // --- edge internal IDNodes (relies on good order storage, not checked)
+
+       int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
+       //SCRUTE(nbPoints);
+       UVPtStruct *uvslf = new UVPtStruct[nbPoints + 2];
+
+       double f, l;
+       Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
+
+       const vector<int> & indElt
+               = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetIDNodes();
+
+       //SCRUTE(nbPoints);
+       //SCRUTE(indElt.Extent());
+       ASSERT(nbPoints == indElt.size());
+
+       map<double, int> params;
+       for (int ite=0; ite<indElt.size(); ite++)
+       {
+               int nodeId = indElt[ite];
+               const SMDS_MeshNode * node = meshDS->FindNode(nodeId);
+               const SMDS_EdgePosition* epos
+                       = static_cast<const SMDS_EdgePosition*>(node->GetPosition());
+               double param = epos->GetUParameter();
+               params[param] = nodeId;
+       }
+
+       bool isForward = (((l - f) * (last - first)) > 0);
+       double paramin = 0;
+       double paramax = 0;
+       if (isForward)
        {
-         double param = (*itp).first;
-         int nodeId = (*itp).second;
-         gp_Pnt2d p = C2d->Value(param);
-         uvslf [i].x = p.X();
-         uvslf [i].y = p.Y();
-         uvslf[i].param = param;
-         uvslf[i].nodeId = nodeId;
-         //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
-         itp++;
+               paramin = f;
+               paramax = l;
+               gp_Pnt2d p = C2d->Value(f);     // first point = Vertex Forward
+               uvslf[0].x = p.X();
+               uvslf[0].y = p.Y();
+               uvslf[0].param = f;
+               uvslf[0].nodeId = idFirst;
+               //MESSAGE("__ f "<<f<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
+               map < double, int >::iterator itp = params.begin();
+               for (int i = 1; i <= nbPoints; i++)     // nbPoints internal
+               {
+                       double param = (*itp).first;
+                       int nodeId = (*itp).second;
+                       gp_Pnt2d p = C2d->Value(param);
+                       uvslf[i].x = p.X();
+                       uvslf[i].y = p.Y();
+                       uvslf[i].param = param;
+                       uvslf[i].nodeId = nodeId;
+                       //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
+                       itp++;
+               }
+               p = C2d->Value(l);              // last point = Vertex Reversed
+               uvslf[nbPoints + 1].x = p.X();
+               uvslf[nbPoints + 1].y = p.Y();
+               uvslf[nbPoints + 1].param = l;
+               uvslf[nbPoints + 1].nodeId = idLast;
+               //MESSAGE("__ l "<<l<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
        }
-      p = C2d->Value(l);                    // last point = Vertex Reversed
-      uvslf [nbPoints+1].x = p.X();
-      uvslf [nbPoints+1].y = p.Y();
-      uvslf [nbPoints+1].param = l;
-      uvslf [nbPoints+1].nodeId = idLast;
-      //MESSAGE("__ l "<<l<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
-    }
-  else 
-    {
-      paramin = l;
-      paramax = f;
-      gp_Pnt2d p = C2d->Value(l);           // first point = Vertex Reversed
-      uvslf [0].x = p.X();
-      uvslf [0].y = p.Y();
-      uvslf [0].param = l;
-      uvslf [0].nodeId = idLast;
-      //MESSAGE("__ l "<<l<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
-      map<double,int>::reverse_iterator itp = params.rbegin();
-      for (int j = nbPoints; j >= 1; j--)     // nbPoints internal
+       else
        {
-         double param = (*itp).first;
-         int nodeId = (*itp).second;
-         int i = nbPoints +1 -j;
-         gp_Pnt2d p = C2d->Value(param);
-         uvslf [i].x = p.X();
-         uvslf [i].y = p.Y();
-         uvslf[i].param = param;
-         uvslf[i].nodeId = nodeId;
-         //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
-         itp++;
+               paramin = l;
+               paramax = f;
+               gp_Pnt2d p = C2d->Value(l);     // first point = Vertex Reversed
+               uvslf[0].x = p.X();
+               uvslf[0].y = p.Y();
+               uvslf[0].param = l;
+               uvslf[0].nodeId = idLast;
+               //MESSAGE("__ l "<<l<<" "<<uvslf[0].x <<" "<<uvslf[0].y);
+               map < double, int >::reverse_iterator itp = params.rbegin();
+               for (int j = nbPoints; j >= 1; j--)     // nbPoints internal
+               {
+                       double param = (*itp).first;
+                       int nodeId = (*itp).second;
+                       int i = nbPoints + 1 - j;
+                       gp_Pnt2d p = C2d->Value(param);
+                       uvslf[i].x = p.X();
+                       uvslf[i].y = p.Y();
+                       uvslf[i].param = param;
+                       uvslf[i].nodeId = nodeId;
+                       //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[i].x <<" "<<uvslf[i].y);
+                       itp++;
+               }
+               p = C2d->Value(f);              // last point = Vertex Forward
+               uvslf[nbPoints + 1].x = p.X();
+               uvslf[nbPoints + 1].y = p.Y();
+               uvslf[nbPoints + 1].param = f;
+               uvslf[nbPoints + 1].nodeId = idFirst;
+               //MESSAGE("__ f "<<f<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
        }
-      p = C2d->Value(f);                    // last point = Vertex Forward
-      uvslf [nbPoints+1].x = p.X();
-      uvslf [nbPoints+1].y = p.Y();
-      uvslf [nbPoints+1].param = f;
-      uvslf [nbPoints+1].nodeId = idFirst;
-      //MESSAGE("__ f "<<f<<" "<<uvslf[nbPoints+1].x <<" "<<uvslf[nbPoints+1].y);
-    }
-
-  ASSERT(paramin != paramax);
-  for (int i = 0; i< nbPoints+2; i++)
-    {
-      uvslf[i].normParam = (uvslf[i].param -paramin)/(paramax -paramin);
-      //SCRUTE(uvslf[i].normParam);
-    }
-
-  return uvslf;
+
+       ASSERT(paramin != paramax);
+       for (int i = 0; i < nbPoints + 2; i++)
+       {
+               uvslf[i].normParam = (uvslf[i].param - paramin) / (paramax - paramin);
+               //SCRUTE(uvslf[i].normParam);
+       }
+
+       return uvslf;
 }
 
 //=============================================================================
@@ -632,7 +613,7 @@ UVPtStruct* SMESH_Quadrangle_2D::LoadEdgePoints(SMESH_Mesh& aMesh,
 
 ostream & SMESH_Quadrangle_2D::SaveTo(ostream & save)
 {
-  return save << this;
+       return save << this;
 }
 
 //=============================================================================
@@ -643,7 +624,7 @@ ostream & SMESH_Quadrangle_2D::SaveTo(ostream & save)
 
 istream & SMESH_Quadrangle_2D::LoadFrom(istream & load)
 {
-  return load >> (*this);
+       return load >> (*this);
 }
 
 //=============================================================================
@@ -652,9 +633,9 @@ istream & SMESH_Quadrangle_2D::LoadFrom(istream & load)
  */
 //=============================================================================
 
-ostream & operator << (ostream & save, SMESH_Quadrangle_2D & hyp)
+ostream & operator <<(ostream & save, SMESH_Quadrangle_2D & hyp)
 {
-  return save;
+       return save;
 }
 
 //=============================================================================
@@ -663,7 +644,7 @@ ostream & operator << (ostream & save, SMESH_Quadrangle_2D & hyp)
  */
 //=============================================================================
 
-istream & operator >> (istream & load, SMESH_Quadrangle_2D & hyp)
+istream & operator >>(istream & load, SMESH_Quadrangle_2D & hyp)
 {
-  return load;
+       return load;
 }
index 920cd77..3eddc11 100644 (file)
@@ -27,7 +27,7 @@
 //  $Header$
 
 using namespace std;
-using namespace std;
+
 #include "SMESH_Regular_1D.hxx"
 #include "SMESH_Gen.hxx"
 #include "SMESH_Mesh.hxx"
@@ -35,8 +35,6 @@ using namespace std;
 #include "SMESH_LocalLength.hxx"
 #include "SMESH_NumberOfSegments.hxx"
 
-#include "SMESHDS_ListOfPtrHypothesis.hxx"
-#include "SMESHDS_ListIteratorOfListOfPtrHypothesis.hxx"
 #include "SMDS_MeshElement.hxx"
 #include "SMDS_MeshNode.hxx"
 #include "SMDS_EdgePosition.hxx"
@@ -59,20 +57,20 @@ using namespace std;
  */
 //=============================================================================
 
-SMESH_Regular_1D::SMESH_Regular_1D(int hypId, int studyId, SMESH_Gen* gen)
-  SMESH_1D_Algo(hypId, studyId, gen)
+SMESH_Regular_1D::SMESH_Regular_1D(int hypId, int studyId,
+       SMESH_Gen * gen):SMESH_1D_Algo(hypId, studyId, gen)
 {
-  MESSAGE("SMESH_Regular_1D::SMESH_Regular_1D");
-  _name = "Regular_1D";
-  //  _shapeType = TopAbs_EDGE;
-  _shapeType = (1<<TopAbs_EDGE);
-  _compatibleHypothesis.push_back("LocalLength");
-  _compatibleHypothesis.push_back("NumberOfSegments");
-
-  _localLength = 0;
-  _numberOfSegments = 0;
-  _hypLocalLength = NULL;
-  _hypNumberOfSegments = NULL;
+       MESSAGE("SMESH_Regular_1D::SMESH_Regular_1D");
+       _name = "Regular_1D";
+       //  _shapeType = TopAbs_EDGE;
+       _shapeType = (1 << TopAbs_EDGE);
+       _compatibleHypothesis.push_back("LocalLength");
+       _compatibleHypothesis.push_back("NumberOfSegments");
+
+       _localLength = 0;
+       _numberOfSegments = 0;
+       _hypLocalLength = NULL;
+       _hypNumberOfSegments = NULL;
 }
 
 //=============================================================================
@@ -93,7 +91,7 @@ SMESH_Regular_1D::~SMESH_Regular_1D()
 
 ostream & SMESH_Regular_1D::SaveTo(ostream & save)
 {
-  return save << this;
+       return save << this;
 }
 
 //=============================================================================
@@ -104,7 +102,7 @@ ostream & SMESH_Regular_1D::SaveTo(ostream & save)
 
 istream & SMESH_Regular_1D::LoadFrom(istream & load)
 {
-  return load >> (*this);
+       return load >> (*this);
 }
 
 //=============================================================================
@@ -113,9 +111,9 @@ istream & SMESH_Regular_1D::LoadFrom(istream & load)
  */
 //=============================================================================
 
-ostream& operator << (ostream & save, SMESH_Regular_1D & hyp)
+ostream & operator <<(ostream & save, SMESH_Regular_1D & hyp)
 {
-  return save;
+       return save;
 }
 
 //=============================================================================
@@ -124,9 +122,9 @@ ostream& operator << (ostream & save, SMESH_Regular_1D & hyp)
  */
 //=============================================================================
 
-istream& operator >> (istream & load, SMESH_Regular_1D & hyp)
+istream & operator >>(istream & load, SMESH_Regular_1D & hyp)
 {
-  return load;
+       return load;
 }
 
 //=============================================================================
@@ -135,50 +133,51 @@ istream& operator >> (istream & load, SMESH_Regular_1D & hyp)
  */
 //=============================================================================
 
-bool SMESH_Regular_1D::CheckHypothesis(SMESH_Mesh& aMesh,
-                                      const TopoDS_Shape& aShape)
+bool SMESH_Regular_1D::CheckHypothesis(SMESH_Mesh & aMesh,
+       const TopoDS_Shape & aShape)
 {
-  //MESSAGE("SMESH_Regular_1D::CheckHypothesis");
-
-  list<SMESHDS_Hypothesis*>::const_iterator itl;
-  SMESHDS_Hypothesis* theHyp;
-
-  const list<SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape);
-  int nbHyp = hyps.size();
-  if (nbHyp != 1) return false;  // only one compatible hypothesis allowed
-
-  itl = hyps.begin();
-  theHyp = (*itl);
-
-  string hypName = theHyp->GetName();
-  int hypId = theHyp->GetID();
-  //SCRUTE(hypName);
-
-  bool isOk = false;
-
-  if (hypName == "LocalLength")
-    {
-      _hypLocalLength = dynamic_cast<SMESH_LocalLength*> (theHyp);
-      ASSERT(_hypLocalLength);
-      _localLength = _hypLocalLength->GetLength();
-      _numberOfSegments = 0;
-      isOk =true;
-    }
-
-  if (hypName == "NumberOfSegments")
-    {
-      _hypNumberOfSegments = dynamic_cast<SMESH_NumberOfSegments*> (theHyp);
-      ASSERT(_hypNumberOfSegments);
-      _numberOfSegments = _hypNumberOfSegments->GetNumberOfSegments();
-      _scaleFactor = _hypNumberOfSegments->GetScaleFactor();
-      _localLength = 0;
-      isOk = true;
-    }
-
-  //SCRUTE(_localLength);
-  //SCRUTE(_numberOfSegments);
-
-  return isOk;
+       //MESSAGE("SMESH_Regular_1D::CheckHypothesis");
+
+       list <const SMESHDS_Hypothesis * >::const_iterator itl;
+       const SMESHDS_Hypothesis *theHyp;
+
+       const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
+       int nbHyp = hyps.size();
+       if (nbHyp != 1) return false; // only one compatible hypothesis allowed
+
+       itl = hyps.begin();
+       theHyp = (*itl);
+
+       string hypName = theHyp->GetName();
+       int hypId = theHyp->GetID();
+       //SCRUTE(hypName);
+
+       bool isOk = false;
+
+       if (hypName == "LocalLength")
+       {
+               _hypLocalLength = dynamic_cast <const SMESH_LocalLength * >(theHyp);
+               ASSERT(_hypLocalLength);
+               _localLength = _hypLocalLength->GetLength();
+               _numberOfSegments = 0;
+               isOk = true;
+       }
+
+       if (hypName == "NumberOfSegments")
+       {
+               _hypNumberOfSegments =
+                       dynamic_cast <const SMESH_NumberOfSegments * >(theHyp);
+               ASSERT(_hypNumberOfSegments);
+               _numberOfSegments = _hypNumberOfSegments->GetNumberOfSegments();
+               _scaleFactor = _hypNumberOfSegments->GetScaleFactor();
+               _localLength = 0;
+               isOk = true;
+       }
+
+       //SCRUTE(_localLength);
+       //SCRUTE(_numberOfSegments);
+
+       return isOk;
 }
 
 //=============================================================================
@@ -187,151 +186,140 @@ bool SMESH_Regular_1D::CheckHypothesis(SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-bool SMESH_Regular_1D::Compute(SMESH_Mesh& aMesh,
-                              const TopoDS_Shape& aShape)
+bool SMESH_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
 {
-  //MESSAGE("SMESH_Regular_1D::Compute");
+       MESSAGE("SMESH_Regular_1D::Compute");
 
-  const Handle(SMESHDS_Mesh)& meshDS = aMesh.GetMeshDS();
-  SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape);
+       SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+       SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
 
-  const TopoDS_Edge& EE = TopoDS::Edge(aShape);
-  TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
+       const TopoDS_Edge & EE = TopoDS::Edge(aShape);
+       TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
 
-  double f,l;
-  Handle(Geom_Curve) Curve = BRep_Tool::Curve(E,f,l); 
+       double f, l;
+       Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l);
 
-  TopoDS_Vertex VFirst, VLast;
-  TopExp::Vertices(E, VFirst, VLast); // Vfirst corresponds to f and Vlast to l
+       TopoDS_Vertex VFirst, VLast;
+       TopExp::Vertices(E, VFirst, VLast);     // Vfirst corresponds to f and Vlast to l
 
-  double length = EdgeLength(E);
-  //SCRUTE(length);
+       double length = EdgeLength(E);
+       //SCRUTE(length);
 
-  double eltSize = 1;
+       double eltSize = 1;
 //   if (_localLength > 0) eltSize = _localLength;
-  if (_localLength > 0)
-    {
-      double nbseg = ceil(length/_localLength); // integer sup
-      if (nbseg <=0) nbseg = 1;                 // degenerated edge
-      eltSize = length/nbseg;
-    }
-  else
-    {
-      ASSERT(_numberOfSegments> 0);
-      eltSize = length/_numberOfSegments;
-    }
-  
-  ASSERT(!VFirst.IsNull());
-  SMESH_subMesh* firstSubMesh = aMesh.GetSubMesh(VFirst);
-  const TColStd_ListOfInteger& lidf
-    = firstSubMesh->GetSubMeshDS()->GetIDNodes();
-  int idFirst= lidf.First();
-  //SCRUTE(idFirst);
-  
-  ASSERT(!VLast.IsNull());
-  SMESH_subMesh* lastSubMesh = aMesh.GetSubMesh(VLast);
-  const TColStd_ListOfInteger& lidl
-    = lastSubMesh->GetSubMeshDS()->GetIDNodes();
-  int idLast= lidl.First();
-  //SCRUTE(idLast);
-
-  if (!Curve.IsNull())
-    {
-      GeomAdaptor_Curve C3d(Curve);
-      GCPnts_UniformAbscissa Discret(C3d,eltSize,f,l);
-      int NbPoints = Discret.NbPoints();
-      //MESSAGE("nb points on edge : "<<NbPoints);
-
-      // edge extrema (indexes : 1 & NbPoints) already in SMDS (TopoDS_Vertex)
-      // only internal nodes receive an edge position with param on curve
-
-      int idPrev = idFirst;
-      for (int i=2; i<NbPoints; i++)
+       if (_localLength > 0)
+       {
+               double nbseg = ceil(length / _localLength);     // integer sup
+               if (nbseg <= 0)
+                       nbseg = 1;                      // degenerated edge
+               eltSize = length / nbseg;
+       }
+       else
+       {
+               ASSERT(_numberOfSegments > 0);
+               eltSize = length / _numberOfSegments;
+       }
+
+       ASSERT(!VFirst.IsNull());
+       SMESH_subMesh *firstSubMesh = aMesh.GetSubMesh(VFirst);
+       const vector<int> & lidf
+               = firstSubMesh->GetSubMeshDS()->GetIDNodes();
+       int idFirst = lidf[0];
+       //SCRUTE(idFirst);
+
+       ASSERT(!VLast.IsNull());
+       SMESH_subMesh *lastSubMesh = aMesh.GetSubMesh(VLast);
+       const vector<int> & lidl
+               = lastSubMesh->GetSubMeshDS()->GetIDNodes();
+       int idLast = lidl[0];
+       //SCRUTE(idLast);
+
+       if (!Curve.IsNull())
        {
-         double param = Discret.Parameter(i);
+               GeomAdaptor_Curve C3d(Curve);
+               GCPnts_UniformAbscissa Discret(C3d, eltSize, f, l);
+               int NbPoints = Discret.NbPoints();
+               //MESSAGE("nb points on edge : "<<NbPoints);
+
+               // edge extrema (indexes : 1 & NbPoints) already in SMDS (TopoDS_Vertex)
+               // only internal nodes receive an edge position with param on curve
 
-         if(_numberOfSegments > 1)
-           {
-             double epsilon = 0.001;
-             if( fabs(_scaleFactor-1.0) > epsilon )
+               int idPrev = idFirst;
+               for (int i = 2; i < NbPoints; i++)
                {
-                 double alpha = pow(_scaleFactor, 1.0/(_numberOfSegments-1) );
-                 double d = length*(1-pow(alpha,i-1))/(1-pow(alpha,_numberOfSegments));
-                 param = d;
+                       double param = Discret.Parameter(i);
+
+                       if (_numberOfSegments > 1)
+                       {
+                               double epsilon = 0.001;
+                               if (fabs(_scaleFactor - 1.0) > epsilon)
+                               {
+                                       double alpha =
+                                               pow(_scaleFactor, 1.0 / (_numberOfSegments - 1));
+                                       double d =
+                                               length * (1 - pow(alpha, i - 1)) / (1 - pow(alpha,
+                                                       _numberOfSegments));
+                                       param = d;
+                               }
+                       }
+
+                       gp_Pnt P = Curve->Value(param);
+
+                       //Add the Node in the DataStructure
+                       //MESSAGE("point "<<nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<" - "<<i<<" "<<param);
+                       SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
+                       meshDS->SetNodeOnEdge(node, E);
+
+                       // **** edgePosition associe au point = param. 
+                       SMDS_EdgePosition* epos=dynamic_cast<SMDS_EdgePosition *>(node->GetPosition());
+                       epos->SetUParameter(param);
+
+                       SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node->GetID());
+                       meshDS->SetMeshElementOnShape(edge, E);
+                       idPrev = node->GetID();
                }
-           }
-
-         gp_Pnt P = Curve->Value(param);
-      
-         //Add the Node in the DataStructure
-         int nodeId = meshDS->AddNode(P.X(), P.Y(), P.Z());
-         //MESSAGE("point "<<nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<" - "<<i<<" "<<param);
-         Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
-         Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
-         meshDS->SetNodeOnEdge(node, E);
-
-         // **** edgePosition associe au point = param. 
-//       Handle (SMDS_EdgePosition) epos
-//         = new SMDS_EdgePosition(theSubMesh->GetId(),param); // non, deja cree
-//       node->SetPosition(epos);
-         Handle (SMDS_EdgePosition) epos
-           = Handle (SMDS_EdgePosition)::DownCast(node->GetPosition());
-         epos->SetUParameter(param);
-
-         int edgeId = meshDS->AddEdge(idPrev, nodeId);
-         elt = meshDS->FindElement(edgeId);
-         meshDS->SetMeshElementOnShape(elt, E);
-         idPrev = nodeId;
+               SMDS_MeshEdge* edge = meshDS->AddEdge(idPrev, idLast);
+               meshDS->SetMeshElementOnShape(edge, E);
        }
-      int edgeId = meshDS->AddEdge(idPrev, idLast);
-      Handle (SMDS_MeshElement) elt = meshDS->FindElement(edgeId);
-      meshDS->SetMeshElementOnShape(elt, E);
-    }
-  else
-    {
+       else
+       {
 //       MESSAGE ("Edge Degeneree non traitee --- arret");
 //       ASSERT(0);
-      if (BRep_Tool::Degenerated(E))
-       {
-         // Edge is a degenerated Edge : We put n = 5 points on the edge.
-         int NbPoints = 5;
-         BRep_Tool::Range(E,f,l);
-         double du = (l-f)/(NbPoints-1);
-         MESSAGE("************* Degenerated edge! *****************");
-      
-         TopoDS_Vertex V1,V2;
-         TopExp::Vertices (E,V1,V2);
-         gp_Pnt P = BRep_Tool::Pnt(V1);
-      
-         int idPrev = idFirst;
-         for (int i=2; i<NbPoints; i++)
-           {
-             double param = f + (i-1)*du;
-             //Add the Node in the DataStructure
-             int nodeId = meshDS->AddNode(P.X(), P.Y(), P.Z());
-             //MESSAGE("point "<<nodeId<<" "<<P.X()<<" "<<P.Y()<<" "<<P.Z()<<" - "<<i<<" "<<param);
-
-             Handle (SMDS_MeshElement) elt = meshDS->FindNode(nodeId);
-             Handle (SMDS_MeshNode) node = meshDS->GetNode(1, elt);
-             meshDS->SetNodeOnEdge(node, E);
-             
-//           Handle (SMDS_EdgePosition) epos
-//             = new SMDS_EdgePosition(theSubMesh->GetId(),param);
-//           node->SetPosition(epos);
-             Handle (SMDS_EdgePosition) epos
-               = Handle (SMDS_EdgePosition)::DownCast(node->GetPosition());
-             epos->SetUParameter(param);
-             
-             int edgeId = meshDS->AddEdge(idPrev, nodeId);
-             elt = meshDS->FindElement(edgeId);
-             meshDS->SetMeshElementOnShape(elt, E);
-             idPrev = nodeId;
-           }
-         int edgeId = meshDS->AddEdge(idPrev, idLast);
-         Handle (SMDS_MeshElement) elt = meshDS->FindElement(edgeId);
-         meshDS->SetMeshElementOnShape(elt, E);
+               if (BRep_Tool::Degenerated(E))
+               {
+                       // Edge is a degenerated Edge : We put n = 5 points on the edge.
+                       int NbPoints = 5;
+                       BRep_Tool::Range(E, f, l);
+                       double du = (l - f) / (NbPoints - 1);
+                       MESSAGE("************* Degenerated edge! *****************");
+
+                       TopoDS_Vertex V1, V2;
+                       TopExp::Vertices(E, V1, V2);
+                       gp_Pnt P = BRep_Tool::Pnt(V1);
+
+                       int idPrev = idFirst;
+                       for (int i = 2; i < NbPoints; i++)
+                       {
+                               double param = f + (i - 1) * du;
+                               SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
+                               meshDS->SetNodeOnEdge(node, E);
+
+//        Handle (SMDS_EdgePosition) epos
+//      = new SMDS_EdgePosition(theSubMesh->GetId(),param);
+//        node->SetPosition(epos);
+                               SMDS_EdgePosition* epos
+                                       = dynamic_cast<SMDS_EdgePosition*>(node->GetPosition());
+                               epos->SetUParameter(param);
+
+                               SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node->GetID());
+                               meshDS->SetMeshElementOnShape(edge, E);
+                               idPrev = node->GetID();
+                       }
+                       SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast);
+                       meshDS->SetMeshElementOnShape(edge, E);
+               }
+               else
+                       ASSERT(0);
        }
-      else ASSERT(0);
-    }
-  return true;
+       return true;
 }
index a4d5dea..711baf6 100644 (file)
@@ -47,31 +47,29 @@ using namespace std;
  */
 //=============================================================================
 
-SMESH_subMesh::SMESH_subMesh(int Id, 
-                            SMESH_Mesh* father,
-                            const Handle(SMESHDS_Mesh)& meshDS,
-                            const TopoDS_Shape & aSubShape)
+SMESH_subMesh::SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
+       const TopoDS_Shape & aSubShape)
 {
-  //MESSAGE("SMESH_subMesh::SMESH_subMesh");
-  _subShape = aSubShape;
-  _meshDS = meshDS;
-  _subMeshDS =  meshDS->MeshElements(_subShape); // may be null ...
-  _father = father;
-  _Id = Id;
-  _vertexSet = false;        // only for Vertex subMesh
-  _dependenceAnalysed = false;
-  _dependantsFound = false;
-
-  if (_subShape.ShapeType() == TopAbs_VERTEX)
-    {
-      _algoState = HYP_OK;
-      _computeState = READY_TO_COMPUTE;
-    }
-  else
-    {
-      _algoState = NO_ALGO;
-      _computeState = NOT_READY;
-    }
+       //MESSAGE("SMESH_subMesh::SMESH_subMesh");
+       _subShape = aSubShape;
+       _meshDS = meshDS;
+       _subMeshDS = meshDS->MeshElements(_subShape);   // may be null ...
+       _father = father;
+       _Id = Id;
+       _vertexSet = false;                     // only for Vertex subMesh
+       _dependenceAnalysed = false;
+       _dependantsFound = false;
+
+       if (_subShape.ShapeType() == TopAbs_VERTEX)
+       {
+               _algoState = HYP_OK;
+               _computeState = READY_TO_COMPUTE;
+       }
+       else
+       {
+               _algoState = NO_ALGO;
+               _computeState = NOT_READY;
+       }
 }
 
 //=============================================================================
@@ -82,8 +80,8 @@ SMESH_subMesh::SMESH_subMesh(int Id,
 
 SMESH_subMesh::~SMESH_subMesh()
 {
-  MESSAGE("SMESH_subMesh::~SMESH_subMesh");
-  // ****
+       MESSAGE("SMESH_subMesh::~SMESH_subMesh");
+       // ****
 }
 
 //=============================================================================
@@ -92,10 +90,10 @@ SMESH_subMesh::~SMESH_subMesh()
  */
 //=============================================================================
 
-int  SMESH_subMesh::GetId()
+int SMESH_subMesh::GetId()
 {
-  //MESSAGE("SMESH_subMesh::GetId");
-  return _Id;
+       //MESSAGE("SMESH_subMesh::GetId");
+       return _Id;
 }
 
 //=============================================================================
@@ -119,39 +117,39 @@ int  SMESH_subMesh::GetId()
 //     {
 // //     case TopAbs_COMPOUND:
 // //       {
-// //  //MESSAGE("---");
-// //  throw SALOME_Exception(LOCALIZED("Compound not yet treated"));
-// //  break;
+// //   //MESSAGE("---");
+// //   throw SALOME_Exception(LOCALIZED("Compound not yet treated"));
+// //   break;
 // //       }
 //     case TopAbs_COMPSOLID:
 //       {
-//     //MESSAGE("---");
-//     for (TopExp_Explorer exp(aSubShape,TopAbs_SOLID);exp.More();exp.Next())
-//       {
-//         contains = _subShape.IsSame(exp.Current());
-//         if (contains) break;
-//       }
-//     break;
+//  //MESSAGE("---");
+//  for (TopExp_Explorer exp(aSubShape,TopAbs_SOLID);exp.More();exp.Next())
+//    {
+//      contains = _subShape.IsSame(exp.Current());
+//      if (contains) break;
+//    }
+//  break;
 //       }
 //     case TopAbs_SHELL:
 //       {
-//     //MESSAGE("---");
-//     for (TopExp_Explorer exp(aSubShape,TopAbs_FACE);exp.More();exp.Next())
-//       {
-//         contains = _subShape.IsSame(exp.Current());
-//         if (contains) break;
-//       }
-//     break;
+//  //MESSAGE("---");
+//  for (TopExp_Explorer exp(aSubShape,TopAbs_FACE);exp.More();exp.Next())
+//    {
+//      contains = _subShape.IsSame(exp.Current());
+//      if (contains) break;
+//    }
+//  break;
 //       }
 //     case TopAbs_WIRE:
 //       {
-//     //MESSAGE("---");
-//     for (TopExp_Explorer exp(aSubShape,TopAbs_EDGE);exp.More();exp.Next())
-//       {
-//         contains = _subShape.IsSame(exp.Current());
-//         if (contains) break;
-//       }
-//     break;
+//  //MESSAGE("---");
+//  for (TopExp_Explorer exp(aSubShape,TopAbs_EDGE);exp.More();exp.Next())
+//    {
+//      contains = _subShape.IsSame(exp.Current());
+//      if (contains) break;
+//    }
+//  break;
 //       }
 //     case TopAbs_COMPOUND:
 //     case TopAbs_SOLID:
@@ -159,13 +157,13 @@ int  SMESH_subMesh::GetId()
 //     case TopAbs_EDGE:
 //     case TopAbs_VERTEX:
 //       {
-//     //MESSAGE("---");
-//     contains = _subShape.IsSame(aSubShape);
-//     break;
+//  //MESSAGE("---");
+//  contains = _subShape.IsSame(aSubShape);
+//  break;
 //       }
 //     default:
 //       {
-//     break;
+//  break;
 //       }
 //     }
 //   //SCRUTE(contains);
@@ -178,22 +176,21 @@ int  SMESH_subMesh::GetId()
  */
 //=============================================================================
 
-const Handle(SMESHDS_SubMesh)& SMESH_subMesh::GetSubMeshDS()
-  throw (SALOME_Exception)
+SMESHDS_SubMesh * SMESH_subMesh::GetSubMeshDS() throw(SALOME_Exception)
 {
-  //MESSAGE("SMESH_subMesh::GetSubMeshDS");
-  if (_subMeshDS.IsNull())
-    {
-      //MESSAGE("subMesh pointer still null, trying to get it...");
-      _subMeshDS =  _meshDS->MeshElements(_subShape); // may be null ...
-      if (_subMeshDS.IsNull())
+       //MESSAGE("SMESH_subMesh::GetSubMeshDS");
+       if (_subMeshDS==NULL)
        {
-         MESSAGE("problem... subMesh still empty");
-         //NRI   ASSERT(0);
-         //NRI   throw SALOME_Exception(LOCALIZED(subMesh still empty));
+               //MESSAGE("subMesh pointer still null, trying to get it...");
+               _subMeshDS = _meshDS->MeshElements(_subShape);  // may be null ...
+               if (_subMeshDS==NULL)
+               {
+                       MESSAGE("problem... subMesh still empty");
+                       //NRI   ASSERT(0);
+                       //NRI   throw SALOME_Exception(LOCALIZED(subMesh still empty));
+               }
        }
-    }
-  return _subMeshDS;
+       return _subMeshDS;
 }
 
 //=============================================================================
@@ -202,39 +199,38 @@ const Handle(SMESHDS_SubMesh)& SMESH_subMesh::GetSubMeshDS()
  */
 //=============================================================================
 
-SMESH_subMesh* SMESH_subMesh::GetFirstToCompute()
-  throw (SALOME_Exception)
+SMESH_subMesh *SMESH_subMesh::GetFirstToCompute() throw(SALOME_Exception)
 {
-  //MESSAGE("SMESH_subMesh::GetFirstToCompute");
-  const map<int, SMESH_subMesh*>& subMeshes = DependsOn();
-  SMESH_subMesh* firstToCompute = 0;
-
-  map<int, SMESH_subMesh*>::const_iterator itsub;
-  for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
-    {
-      SMESH_subMesh* sm = (*itsub).second;
+       //MESSAGE("SMESH_subMesh::GetFirstToCompute");
+       const map < int, SMESH_subMesh * >&subMeshes = DependsOn();
+       SMESH_subMesh *firstToCompute = 0;
+
+       map < int, SMESH_subMesh * >::const_iterator itsub;
+       for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
+       {
+               SMESH_subMesh *sm = (*itsub).second;
 //       SCRUTE(sm->GetId());
 //       SCRUTE(sm->GetComputeState());
-      bool readyToCompute = (sm->GetComputeState() == READY_TO_COMPUTE);
-      if (readyToCompute)
+               bool readyToCompute = (sm->GetComputeState() == READY_TO_COMPUTE);
+               if (readyToCompute)
+               {
+                       firstToCompute = sm;
+                       //SCRUTE(sm->GetId());
+                       break;
+               }
+       }
+       if (firstToCompute)
+       {
+               //MESSAGE("--- submesh to compute");
+               return firstToCompute;  // a subMesh of this
+       }
+       if (_computeState == READY_TO_COMPUTE)
        {
-         firstToCompute = sm; 
-         //SCRUTE(sm->GetId());
-         break;
+               //MESSAGE("--- this to compute");
+               return this;                    // this
        }
-    }
-  if (firstToCompute)
-    {
-      //MESSAGE("--- submesh to compute");
-      return firstToCompute;       // a subMesh of this
-    }
-  if (_computeState == READY_TO_COMPUTE)
-    {
-      //MESSAGE("--- this to compute");
-      return this;  // this
-    }
-  //MESSAGE("--- nothing to compute");
-  return 0;                                            // nothing to compute
+       //MESSAGE("--- nothing to compute");
+       return 0;                                       // nothing to compute
 }
 
 //=============================================================================
@@ -243,28 +239,27 @@ SMESH_subMesh* SMESH_subMesh::GetFirstToCompute()
  */
 //=============================================================================
 
-bool SMESH_subMesh::SubMeshesComputed()
-  throw (SALOME_Exception)
+bool SMESH_subMesh::SubMeshesComputed() throw(SALOME_Exception)
 {
-  //MESSAGE("SMESH_subMesh::SubMeshesComputed");
-  const map<int, SMESH_subMesh*>& subMeshes = DependsOn();
-
-  bool subMeshesComputed = true;
-  map<int, SMESH_subMesh*>::const_iterator itsub;
-  for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
-    {
-      SMESH_subMesh* sm = (*itsub).second;
+       //MESSAGE("SMESH_subMesh::SubMeshesComputed");
+       const map < int, SMESH_subMesh * >&subMeshes = DependsOn();
+
+       bool subMeshesComputed = true;
+       map < int, SMESH_subMesh * >::const_iterator itsub;
+       for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
+       {
+               SMESH_subMesh *sm = (*itsub).second;
 //       SCRUTE(sm->GetId());
 //       SCRUTE(sm->GetComputeState());
-      bool computeOk =  (sm->GetComputeState() == COMPUTE_OK);
-      if (! computeOk)
-       {
-         subMeshesComputed = false;
-         SCRUTE(sm->GetId());
-         break;
+               bool computeOk = (sm->GetComputeState() == COMPUTE_OK);
+               if (!computeOk)
+               {
+                       subMeshesComputed = false;
+                       SCRUTE(sm->GetId());
+                       break;
+               }
        }
-    }
-   return subMeshesComputed; 
+       return subMeshesComputed;
 }
 
 //=============================================================================
@@ -275,26 +270,26 @@ bool SMESH_subMesh::SubMeshesComputed()
 
 bool SMESH_subMesh::SubMeshesReady()
 {
-  MESSAGE("SMESH_subMesh::SubMeshesReady");
-  const map<int, SMESH_subMesh*>& subMeshes = DependsOn();
-
-  bool subMeshesReady = true;
-  map<int, SMESH_subMesh*>::const_iterator itsub;
-  for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
-    {
-      SMESH_subMesh* sm = (*itsub).second;
+       MESSAGE("SMESH_subMesh::SubMeshesReady");
+       const map < int, SMESH_subMesh * >&subMeshes = DependsOn();
+
+       bool subMeshesReady = true;
+       map < int, SMESH_subMesh * >::const_iterator itsub;
+       for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
+       {
+               SMESH_subMesh *sm = (*itsub).second;
 //       SCRUTE(sm->GetId());
 //       SCRUTE(sm->GetComputeState());
-      bool computeOk = (    (sm->GetComputeState() == COMPUTE_OK)
-                        || (sm->GetComputeState() == READY_TO_COMPUTE)) ;
-      if (! computeOk)
-       {
-         subMeshesReady = false;
-         SCRUTE(sm->GetId());
-         break;
+               bool computeOk = ((sm->GetComputeState() == COMPUTE_OK)
+                       || (sm->GetComputeState() == READY_TO_COMPUTE));
+               if (!computeOk)
+               {
+                       subMeshesReady = false;
+                       SCRUTE(sm->GetId());
+                       break;
+               }
        }
-    }
-  return subMeshesReady; 
+       return subMeshesReady;
 }
 
 //=============================================================================
@@ -309,158 +304,169 @@ bool SMESH_subMesh::SubMeshesReady()
  */
 //=============================================================================
 
-const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
+const map < int, SMESH_subMesh * >&SMESH_subMesh::DependsOn()
 {
- if (_dependenceAnalysed) return _mapDepend;
-
- //MESSAGE("SMESH_subMesh::DependsOn");
-
-  int type = _subShape.ShapeType();
-  //SCRUTE(type);
-  switch (type)
-    {
-    case TopAbs_COMPOUND:
-      {
-       //MESSAGE("compound");
-       list<TopoDS_Shape> shellInSolid;
-       for (TopExp_Explorer exp(_subShape,TopAbs_SOLID);exp.More();exp.Next())
-         {
-           InsertDependence(exp.Current());
-           for (TopExp_Explorer 
-                  exp2(exp.Current(),TopAbs_SHELL);exp2.More();exp2.Next())
-             {
-               shellInSolid.push_back(exp2.Current()); 
-             }
-         }
-       for (TopExp_Explorer exp(_subShape,TopAbs_SHELL);exp.More();exp.Next())
-         {
-           list<TopoDS_Shape>::iterator it1;
-           bool isInSolid = false;
-           for (it1 = shellInSolid.begin(); it1 != shellInSolid.end(); it1++)
-             {
-               TopoDS_Shape aShape = (*it1);
-               if (aShape.IsSame(exp.Current())) 
+       if (_dependenceAnalysed)
+               return _mapDepend;
+
+       //MESSAGE("SMESH_subMesh::DependsOn");
+
+       int type = _subShape.ShapeType();
+       //SCRUTE(type);
+       switch (type)
+       {
+       case TopAbs_COMPOUND:
+       {
+               //MESSAGE("compound");
+               list < TopoDS_Shape > shellInSolid;
+               for (TopExp_Explorer exp(_subShape, TopAbs_SOLID); exp.More();
+                       exp.Next())
+               {
+                       InsertDependence(exp.Current());
+                       for (TopExp_Explorer
+                               exp2(exp.Current(), TopAbs_SHELL); exp2.More(); exp2.Next())
+                       {
+                               shellInSolid.push_back(exp2.Current());
+                       }
+               }
+               for (TopExp_Explorer exp(_subShape, TopAbs_SHELL); exp.More();
+                       exp.Next())
+               {
+                       list < TopoDS_Shape >::iterator it1;
+                       bool isInSolid = false;
+                       for (it1 = shellInSolid.begin(); it1 != shellInSolid.end(); it1++)
+                       {
+                               TopoDS_Shape aShape = (*it1);
+                               if (aShape.IsSame(exp.Current()))
+                               {
+                                       isInSolid = true;
+                                       break;
+                               }
+                       }
+                       if (!isInSolid)
+                               InsertDependence(exp.Current());        //only shell not in solid
+               }
+               for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More();
+                       exp.Next())
+               {
+                       InsertDependence(exp.Current());
+               }
+               for (TopExp_Explorer exp(_subShape, TopAbs_EDGE); exp.More();
+                       exp.Next())
+               {
+                       InsertDependence(exp.Current());
+               }
+               break;
+       }
+       case TopAbs_COMPSOLID:
+       {
+               //MESSAGE("compsolid");
+               for (TopExp_Explorer exp(_subShape, TopAbs_SOLID); exp.More();
+                       exp.Next())
                {
-                 isInSolid = true;
-                 break;
+                       InsertDependence(exp.Current());
                }
-             }
-           if (!isInSolid)
-             InsertDependence(exp.Current()); //only shell not in solid
-         }
-       for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next())
-         {
-           InsertDependence(exp.Current());
-         }
-       for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next())
-         {
-           InsertDependence(exp.Current());
-         }
-       break;
-      }
-    case TopAbs_COMPSOLID:
-      {
-       //MESSAGE("compsolid");
-       for (TopExp_Explorer exp(_subShape,TopAbs_SOLID);exp.More();exp.Next())
-         {
-           InsertDependence(exp.Current());
-         }
-//     list<TopoDS_Shape> shapeList;
-//     for (TopExp_Explorer exp(_subShape,TopAbs_SOLID);exp.More();exp.Next())
-//       {
-//         for (TopExp_Explorer 
-//                exp2(exp.Current(),TopAbs_FACE);exp2.More();exp2.Next())
-//           {
-//             shapeList.push_back(exp2.Current()); 
-//           }
-//       }
-//     FinalizeDependence(shapeList);
-       break;
-      }
-    case TopAbs_SHELL:
-      {
-       //MESSAGE("shell");
-       for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next())
-         {
-           InsertDependence(exp.Current());
-         }
-//     list<TopoDS_Shape> shapeList;
-//     for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next())
-//       {
-//         for (TopExp_Explorer 
-//                exp2(exp.Current(),TopAbs_EDGE);exp2.More();exp2.Next())
-//           {
-//             shapeList.push_back(exp2.Current()); 
-//           }
-//       }
-//     FinalizeDependence(shapeList);
-       break;
-      }
-    case TopAbs_WIRE:
-      {
-       //MESSAGE("wire");
-       for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next())
-         {
-           InsertDependence(exp.Current());
-         }
-//     list<TopoDS_Shape> shapeList;
-//     for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next())
-//       {
-//         for (TopExp_Explorer 
-//                exp2(exp.Current(),TopAbs_VERTEX);exp2.More();exp2.Next())
-//           {
-//             shapeList.push_back(exp2.Current()); 
-//           }
-//       }
-//     FinalizeDependence(shapeList);
-       break;
-      }
-    case TopAbs_SOLID:
-      {
-       //MESSAGE("solid");
-//     for (TopExp_Explorer exp(_subShape,TopAbs_SHELL);exp.More();exp.Next())
-//       {
-//         InsertDependence(exp.Current());
-//       }
-       for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next())
-         {
-           InsertDependence(exp.Current());
-         }
-       break;
-      }
-    case TopAbs_FACE:
-      {
-       //MESSAGE("face");
-//     for (TopExp_Explorer exp(_subShape,TopAbs_WIRE);exp.More();exp.Next())
-//       {
-//         InsertDependence(exp.Current());
-//       }
-       for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next())
-         {
-           InsertDependence(exp.Current());
-         }
-       break;
-      }
-    case TopAbs_EDGE:
-      {
-       //MESSAGE("edge");
-       for (TopExp_Explorer exp(_subShape,TopAbs_VERTEX);exp.More();exp.Next())
-         {
-           InsertDependence(exp.Current());
-         }
-       break;
-      }
-    case TopAbs_VERTEX:
-      {
-       break;
-      }
-    default:
-      {
-       break;
-      }
-    }
-  _dependenceAnalysed = true;
-  return _mapDepend;
+//  list<TopoDS_Shape> shapeList;
+//  for (TopExp_Explorer exp(_subShape,TopAbs_SOLID);exp.More();exp.Next())
+//    {
+//      for (TopExp_Explorer 
+//         exp2(exp.Current(),TopAbs_FACE);exp2.More();exp2.Next())
+//        {
+//      shapeList.push_back(exp2.Current()); 
+//        }
+//    }
+//  FinalizeDependence(shapeList);
+               break;
+       }
+       case TopAbs_SHELL:
+       {
+               //MESSAGE("shell");
+               for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More();
+                       exp.Next())
+               {
+                       InsertDependence(exp.Current());
+               }
+//  list<TopoDS_Shape> shapeList;
+//  for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next())
+//    {
+//      for (TopExp_Explorer 
+//         exp2(exp.Current(),TopAbs_EDGE);exp2.More();exp2.Next())
+//        {
+//      shapeList.push_back(exp2.Current()); 
+//        }
+//    }
+//  FinalizeDependence(shapeList);
+               break;
+       }
+       case TopAbs_WIRE:
+       {
+               //MESSAGE("wire");
+               for (TopExp_Explorer exp(_subShape, TopAbs_EDGE); exp.More();
+                       exp.Next())
+               {
+                       InsertDependence(exp.Current());
+               }
+//  list<TopoDS_Shape> shapeList;
+//  for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next())
+//    {
+//      for (TopExp_Explorer 
+//         exp2(exp.Current(),TopAbs_VERTEX);exp2.More();exp2.Next())
+//        {
+//      shapeList.push_back(exp2.Current()); 
+//        }
+//    }
+//  FinalizeDependence(shapeList);
+               break;
+       }
+       case TopAbs_SOLID:
+       {
+               //MESSAGE("solid");
+//  for (TopExp_Explorer exp(_subShape,TopAbs_SHELL);exp.More();exp.Next())
+//    {
+//      InsertDependence(exp.Current());
+//    }
+               for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More();
+                       exp.Next())
+               {
+                       InsertDependence(exp.Current());
+               }
+               break;
+       }
+       case TopAbs_FACE:
+       {
+               //MESSAGE("face");
+//  for (TopExp_Explorer exp(_subShape,TopAbs_WIRE);exp.More();exp.Next())
+//    {
+//      InsertDependence(exp.Current());
+//    }
+               for (TopExp_Explorer exp(_subShape, TopAbs_EDGE); exp.More();
+                       exp.Next())
+               {
+                       InsertDependence(exp.Current());
+               }
+               break;
+       }
+       case TopAbs_EDGE:
+       {
+               //MESSAGE("edge");
+               for (TopExp_Explorer exp(_subShape, TopAbs_VERTEX); exp.More();
+                       exp.Next())
+               {
+                       InsertDependence(exp.Current());
+               }
+               break;
+       }
+       case TopAbs_VERTEX:
+       {
+               break;
+       }
+       default:
+       {
+               break;
+       }
+       }
+       _dependenceAnalysed = true;
+       return _mapDepend;
 }
 
 //=============================================================================
@@ -471,32 +477,32 @@ const map<int, SMESH_subMesh*>& SMESH_subMesh::DependsOn()
 
 void SMESH_subMesh::InsertDependence(const TopoDS_Shape aSubShape)
 {
-  //MESSAGE("SMESH_subMesh::InsertDependence");
-  //SMESH_subMesh* aSubMesh = _father->GetSubMeshContaining(aSubShape);
-  //SCRUTE(aSubMesh);
-  //if (! aSubMesh) aSubMesh = _father->GetSubMesh(aSubShape);
-
-  SMESH_subMesh* aSubMesh = _father->GetSubMesh(aSubShape);
-  int type = aSubShape.ShapeType();
-  int ordType = 9 - type; // 2 = Vertex, 8 = CompSolid
-  int cle = aSubMesh->GetId();
-  cle += 10000000 * ordType; // sort map by ordType then index
-  if (_mapDepend.find(cle) == _mapDepend.end())
-    {
-      _mapDepend[cle] = aSubMesh;
-      const map<int, SMESH_subMesh*>& subMap = aSubMesh->DependsOn();
-      map<int, SMESH_subMesh*>::const_iterator im;
-      for (im = subMap.begin(); im != subMap.end(); im++)
+       //MESSAGE("SMESH_subMesh::InsertDependence");
+       //SMESH_subMesh* aSubMesh = _father->GetSubMeshContaining(aSubShape);
+       //SCRUTE(aSubMesh);
+       //if (! aSubMesh) aSubMesh = _father->GetSubMesh(aSubShape);
+
+       SMESH_subMesh *aSubMesh = _father->GetSubMesh(aSubShape);
+       int type = aSubShape.ShapeType();
+       int ordType = 9 - type;         // 2 = Vertex, 8 = CompSolid
+       int cle = aSubMesh->GetId();
+       cle += 10000000 * ordType;      // sort map by ordType then index
+       if (_mapDepend.find(cle) == _mapDepend.end())
        {
-         int clesub = (*im).first;
-         SMESH_subMesh* sm = (*im).second;
-         if (_mapDepend.find(clesub) == _mapDepend.end())
-           _mapDepend[clesub] = sm;
+               _mapDepend[cle] = aSubMesh;
+               const map < int, SMESH_subMesh * >&subMap = aSubMesh->DependsOn();
+               map < int, SMESH_subMesh * >::const_iterator im;
+               for (im = subMap.begin(); im != subMap.end(); im++)
+               {
+                       int clesub = (*im).first;
+                       SMESH_subMesh *sm = (*im).second;
+                       if (_mapDepend.find(clesub) == _mapDepend.end())
+                               _mapDepend[clesub] = sm;
+               }
        }
-    }
 
 }
+
 //=============================================================================
 /*!
  * For collection shapes (compsolid, shell, wire).
@@ -513,10 +519,10 @@ void SMESH_subMesh::InsertDependence(const TopoDS_Shape aSubShape)
 //       TopoDS_Shape aSubShape = (*it1);
 //       int count = 0;
 //       for(it2 = shapeList.begin(); it2 != shapeList.end(); it2++)
-//     {
-//       TopoDS_Shape other = (*it2);
-//       if (other.IsSame(aSubShape)) count++;
-//     }
+//  {
+//    TopoDS_Shape other = (*it2);
+//    if (other.IsSame(aSubShape)) count++;
+//  }
 //       if (count == 1) InsertDependence(aSubShape);
 //       SCRUTE(count);
 //     }
@@ -528,10 +534,10 @@ void SMESH_subMesh::InsertDependence(const TopoDS_Shape aSubShape)
  */
 //=============================================================================
 
- const TopoDS_Shape& SMESH_subMesh::GetSubShape()
+const TopoDS_Shape & SMESH_subMesh::GetSubShape()
 {
-  //MESSAGE("SMESH_subMesh::GetSubShape");
-  return _subShape;
+       //MESSAGE("SMESH_subMesh::GetSubShape");
+       return _subShape;
 }
 
 //=============================================================================
@@ -540,382 +546,414 @@ void SMESH_subMesh::InsertDependence(const TopoDS_Shape aSubShape)
  */
 //=============================================================================
 
-bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis* anHyp)
-  throw (SALOME_Exception)
+bool SMESH_subMesh::AlgoStateEngine(int event, SMESH_Hypothesis * anHyp)
+throw(SALOME_Exception)
 {
-  //  MESSAGE("SMESH_subMesh::AlgoStateEngine");
-  //SCRUTE(_algoState);
-  //SCRUTE(event);
-
-  // **** les retour des evenement shape sont significatifs
-  // (add ou remove fait ou non)
-  // le retour des evenement father n'indiquent pas que add ou remove fait
-  int dim = SMESH_Gen::GetShapeDim(_subShape);
-
-  if (dim < 1)
-    {
-      _algoState = HYP_OK;
-      //SCRUTE(_algoState);
-      return true;
-    }
-
-  SMESH_Gen* gen =_father->GetGen();
-  bool ret;
-  _oldAlgoState = _algoState;
-  bool modifiedHyp = false;  // if set to true, force event MODIF_ALGO_STATE
-                             // in ComputeStateEngine
-
-  switch (_algoState)
-    {
-
-      // ----------------------------------------------------------------------
-
-    case NO_ALGO:
-      switch (event)
-       {
-       case ADD_HYP:
-         ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-         ret = _meshDS->AddHypothesis(_subShape, anHyp);
-         break;
-       case ADD_ALGO:
-         ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-         if (anHyp->GetDim() <= SMESH_Gen::GetShapeDim(_subShape))
-           {
-             ret = _meshDS->AddHypothesis(_subShape, anHyp);
-//           if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
-//           if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
-             if (ret &&(anHyp->GetShapeType() & (1<< _subShape.ShapeType())))
-               {
-                 SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-                 ASSERT(algo);
-                 ret = algo->CheckHypothesis((*_father),_subShape);
-                 if (ret) SetAlgoState(HYP_OK);
-                 else SetAlgoState(MISSING_HYP);
-               }
-           }
-         break;
-       case REMOVE_HYP:
-         ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-         ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-         break;
-       case REMOVE_ALGO:
-         ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-         ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-         break;
-       case ADD_FATHER_HYP:      // nothing to do
-         break;
-       case ADD_FATHER_ALGO:     // Algo just added in father
-         ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-//       if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
-//       if (anHyp->GetShapeType() == _subShape.ShapeType())
-         if (anHyp->GetShapeType() & (1<< _subShape.ShapeType()))
-           {
-             SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-             ASSERT(algo);
-             ret = algo->CheckHypothesis((*_father),_subShape);
-             if (ret) SetAlgoState(HYP_OK);
-             else SetAlgoState(MISSING_HYP);
-           }
-         break;
-       case REMOVE_FATHER_HYP:    // nothing to do
-         break;
-       case REMOVE_FATHER_ALGO:   // nothing to do
-         break;
-       default:
-         ASSERT(0);
-         break;
-       }
-      break;
+       //  MESSAGE("SMESH_subMesh::AlgoStateEngine");
+       //SCRUTE(_algoState);
+       //SCRUTE(event);
 
-      // ----------------------------------------------------------------------
+       // **** les retour des evenement shape sont significatifs
+       // (add ou remove fait ou non)
+       // le retour des evenement father n'indiquent pas que add ou remove fait
+       int dim = SMESH_Gen::GetShapeDim(_subShape);
 
-    case MISSING_HYP:
-      switch (event)
+       if (dim < 1)
        {
-       case ADD_HYP:
-         ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-         ret = _meshDS->AddHypothesis(_subShape, anHyp);
-         if (ret)
-           {
-             SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-             ASSERT(algo);
-             ret = algo->CheckHypothesis((*_father),_subShape);
-             if (ret) SetAlgoState(HYP_OK);
-             else SetAlgoState(MISSING_HYP);
-           }
-         break;
-       case ADD_ALGO:            //already existing algo : on father ?
-         ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-         if (anHyp->GetDim() <= SMESH_Gen::GetShapeDim(_subShape))
-           {
-             ret = _meshDS->AddHypothesis(_subShape, anHyp);
-//           if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
-//           if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
-             if (ret &&(anHyp->GetShapeType() & (1<< _subShape.ShapeType())))
-               {
-                 SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-                 if (algo == NULL) // two algo on the same subShape...
-                   {
-                     MESSAGE("two algo on the same subshape not allowed");
-                     ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-                     ret = false;
-                   }
-                 else
-                   {
-                     ret = algo->CheckHypothesis((*_father),_subShape);
-                     if (ret) SetAlgoState(HYP_OK);
-                     else SetAlgoState(MISSING_HYP);
-                   }
-               }
-           }
-         break;
-       case REMOVE_HYP:
-         ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);  
-         ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-         break;
-       case REMOVE_ALGO:         // perhaps a father algo applies ?
-         ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-         ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-//       if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
-//       if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
-         if (ret &&(anHyp->GetShapeType() & (1<<_subShape.ShapeType())))
-           {
-             SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-             if (algo == NULL)  // no more algo applying on subShape...
-               {
-                 SetAlgoState(NO_ALGO);
-               }
-             else
-               {
-                 ret = algo->CheckHypothesis((*_father),_subShape);
-                 if (ret) SetAlgoState(HYP_OK);
-                 else SetAlgoState(MISSING_HYP);
-               }
-           }
-         break;
-       case ADD_FATHER_HYP:
-         ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-         {
-           SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-           ASSERT(algo);
-           ret = algo->CheckHypothesis((*_father),_subShape);
-           if (ret) SetAlgoState(HYP_OK);
-           else SetAlgoState(MISSING_HYP);
-         }
-         break;
-       case ADD_FATHER_ALGO:     // detect if two algo of same dim on father
-         ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-//       if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
-//       if (anHyp->GetShapeType() == _subShape.ShapeType())
-         if (anHyp->GetShapeType() & (1<< _subShape.ShapeType()))
-           {
-             SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-             if (algo == NULL)  // two applying algo on father
-               {
-                 MESSAGE("two applying algo on fatherShape...");
-                 SetAlgoState(NO_ALGO);
-               }
-             else
-               {
-                 ret = algo->CheckHypothesis((*_father),_subShape);
-                 if (ret) SetAlgoState(HYP_OK);
-                 else SetAlgoState(MISSING_HYP);
-               }
-           }
-         break;
-       case REMOVE_FATHER_HYP:    // nothing to do
-         break;
-       case REMOVE_FATHER_ALGO:
-         ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-//       if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
-//       if (anHyp->GetShapeType() == _subShape.ShapeType())
-         if (anHyp->GetShapeType() & (1<< _subShape.ShapeType()))
-           {
-             SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-             if (algo == NULL)  // no more applying algo on father
-               {
-                 SetAlgoState(NO_ALGO);
-               }
-             else
-               {
-                 ret = algo->CheckHypothesis((*_father),_subShape);
-                 if (ret) SetAlgoState(HYP_OK);
-                 else SetAlgoState(MISSING_HYP);
-               }
-           }
-         break;
-       default:
-         ASSERT(0);
-         break;
+               _algoState = HYP_OK;
+               //SCRUTE(_algoState);
+               return true;
        }
-      break;
 
-      // ----------------------------------------------------------------------
+       SMESH_Gen *gen = _father->GetGen();
+       bool ret;
+       _oldAlgoState = _algoState;
+       bool modifiedHyp = false;       // if set to true, force event MODIF_ALGO_STATE
+       // in ComputeStateEngine
 
-    case HYP_OK:
-      switch (event)
+       switch (_algoState)
        {
-       case ADD_HYP:
-         {
-           ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-           SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-           ASSERT(algo);
-           list<SMESHDS_Hypothesis*> originalUsedHyps
-             = algo->GetUsedHypothesis((*_father), _subShape); // copy
-           
-           ret = _meshDS->AddHypothesis(_subShape, anHyp);
-           if (ret)
-             {
-               ret = algo->CheckHypothesis((*_father),_subShape);
-               if (! ret) 
-                 {
-                   INFOS("two applying algo on the same shape not allowed");
-                   ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-                   ret = false;
-                 }
-               else  // compare SMESHDS_Hypothesis* lists (order important)
-                 {
-                   MESSAGE("---");
-                   const list<SMESHDS_Hypothesis*>& newUsedHyps
-                     = algo->GetUsedHypothesis((*_father), _subShape);
-                   modifiedHyp = (originalUsedHyps != newUsedHyps); 
-                 }
-             }
-         }
-         break;
-       case ADD_ALGO:            //already existing algo : on father ?
-         ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-         if (anHyp->GetDim() <= SMESH_Gen::GetShapeDim(_subShape))
-           {
-             ret = _meshDS->AddHypothesis(_subShape, anHyp);
-//           if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
-//           if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
-             if (ret &&(anHyp->GetShapeType() & (1<< _subShape.ShapeType())))
-               {
-                 SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-                 if (algo == NULL) // two algo on the same subShape...
-                   {
-                     INFOS("two algo on the same subshape not allowed");
-                     ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-                     ret = false;
-                   }
-                 else
-                   {
-                     ret = algo->CheckHypothesis((*_father),_subShape);
-                     if (ret) SetAlgoState(HYP_OK);
-                     else SetAlgoState(MISSING_HYP);
-                   }
-               }
-           }
-         break;
-       case REMOVE_HYP:
-         ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-         ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-         if (ret)
-           {
-             SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-             ASSERT(algo);
-             ret = algo->CheckHypothesis((*_father),_subShape);
-             if (ret) SetAlgoState(HYP_OK);
-             else SetAlgoState(MISSING_HYP);
-             modifiedHyp = true;
-           }
-         break;
-       case REMOVE_ALGO:         // perhaps a father algo applies ?
-         ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-         ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
-//       if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
-//       if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
-         if (ret &&(anHyp->GetShapeType() & (1<< _subShape.ShapeType())))
-           {
-             SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-             if (algo == NULL)   // no more algo applying on subShape...
-               {
-                 SetAlgoState(NO_ALGO);
-               }
-             else
+
+               // ----------------------------------------------------------------------
+
+       case NO_ALGO:
+               switch (event)
                {
-                 ret = algo->CheckHypothesis((*_father),_subShape);
-                 if (ret) SetAlgoState(HYP_OK);
-                 else SetAlgoState(MISSING_HYP);
+               case ADD_HYP:
+                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+                       ret = _meshDS->AddHypothesis(_subShape, anHyp);
+                       break;
+               case ADD_ALGO:
+                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+                       if (anHyp->GetDim() <= SMESH_Gen::GetShapeDim(_subShape))
+                       {
+                               ret = _meshDS->AddHypothesis(_subShape, anHyp);
+//        if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
+//        if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
+                               if (ret &&
+                                       (anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
+                               {
+                                       SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
+                                       ASSERT(algo);
+                                       ret = algo->CheckHypothesis((*_father), _subShape);
+                                       if (ret)
+                                               SetAlgoState(HYP_OK);
+                                       else
+                                               SetAlgoState(MISSING_HYP);
+                               }
+                       }
+                       break;
+               case REMOVE_HYP:
+                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+                       ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+                       break;
+               case REMOVE_ALGO:
+                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+                       ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+                       break;
+               case ADD_FATHER_HYP:    // nothing to do
+                       break;
+               case ADD_FATHER_ALGO:   // Algo just added in father
+                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+//    if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
+//    if (anHyp->GetShapeType() == _subShape.ShapeType())
+                       if (anHyp->GetShapeType() & (1 << _subShape.ShapeType()))
+                       {
+                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
+                               ASSERT(algo);
+                               ret = algo->CheckHypothesis((*_father), _subShape);
+                               if (ret)
+                                       SetAlgoState(HYP_OK);
+                               else
+                                       SetAlgoState(MISSING_HYP);
+                       }
+                       break;
+               case REMOVE_FATHER_HYP: // nothing to do
+                       break;
+               case REMOVE_FATHER_ALGO:        // nothing to do
+                       break;
+               default:
+                       ASSERT(0);
+                       break;
                }
-           }
-         break;
-       case ADD_FATHER_HYP:
-         ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-         {
-           SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-           ASSERT(algo);
-           ret = algo->CheckHypothesis((*_father),_subShape);
-           if (ret) SetAlgoState(HYP_OK);
-           else SetAlgoState(MISSING_HYP);
-         }
-         break;
-       case ADD_FATHER_ALGO:     // detect if two algo of same dim on father
-         ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-//       if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
-//       if (anHyp->GetShapeType() == _subShape.ShapeType())
-         if (anHyp->GetShapeType() & (1<< _subShape.ShapeType()))
-           {
-             SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-             if (algo == NULL)  // two applying algo on father
+               break;
+
+               // ----------------------------------------------------------------------
+
+       case MISSING_HYP:
+               switch (event)
                {
-                 MESSAGE("two applying algo on fatherShape...");
-                 SetAlgoState(NO_ALGO);
+               case ADD_HYP:
+                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+                       ret = _meshDS->AddHypothesis(_subShape, anHyp);
+                       if (ret)
+                       {
+                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
+                               ASSERT(algo);
+                               ret = algo->CheckHypothesis((*_father), _subShape);
+                               if (ret)
+                                       SetAlgoState(HYP_OK);
+                               else
+                                       SetAlgoState(MISSING_HYP);
+                       }
+                       break;
+               case ADD_ALGO:                  //already existing algo : on father ?
+                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+                       if (anHyp->GetDim() <= SMESH_Gen::GetShapeDim(_subShape))
+                       {
+                               ret = _meshDS->AddHypothesis(_subShape, anHyp);
+//        if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
+//        if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
+                               if (ret &&
+                                       (anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
+                               {
+                                       SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
+                                       if (algo == NULL)       // two algo on the same subShape...
+                                       {
+                                               MESSAGE("two algo on the same subshape not allowed");
+                                               ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+                                               ret = false;
+                                       }
+                                       else
+                                       {
+                                               ret = algo->CheckHypothesis((*_father), _subShape);
+                                               if (ret)
+                                                       SetAlgoState(HYP_OK);
+                                               else
+                                                       SetAlgoState(MISSING_HYP);
+                                       }
+                               }
+                       }
+                       break;
+               case REMOVE_HYP:
+                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+                       ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+                       break;
+               case REMOVE_ALGO:               // perhaps a father algo applies ?
+                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+                       ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+//    if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
+//    if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
+                       if (ret && (anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
+                       {
+                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
+                               if (algo == NULL)       // no more algo applying on subShape...
+                               {
+                                       SetAlgoState(NO_ALGO);
+                               }
+                               else
+                               {
+                                       ret = algo->CheckHypothesis((*_father), _subShape);
+                                       if (ret)
+                                               SetAlgoState(HYP_OK);
+                                       else
+                                               SetAlgoState(MISSING_HYP);
+                               }
+                       }
+                       break;
+               case ADD_FATHER_HYP:
+                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+                       {
+                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
+                               ASSERT(algo);
+                               ret = algo->CheckHypothesis((*_father), _subShape);
+                               if (ret)
+                                       SetAlgoState(HYP_OK);
+                               else
+                                       SetAlgoState(MISSING_HYP);
+                       }
+                       break;
+               case ADD_FATHER_ALGO:   // detect if two algo of same dim on father
+                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+//    if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
+//    if (anHyp->GetShapeType() == _subShape.ShapeType())
+                       if (anHyp->GetShapeType() & (1 << _subShape.ShapeType()))
+                       {
+                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
+                               if (algo == NULL)       // two applying algo on father
+                               {
+                                       MESSAGE("two applying algo on fatherShape...");
+                                       SetAlgoState(NO_ALGO);
+                               }
+                               else
+                               {
+                                       ret = algo->CheckHypothesis((*_father), _subShape);
+                                       if (ret)
+                                               SetAlgoState(HYP_OK);
+                                       else
+                                               SetAlgoState(MISSING_HYP);
+                               }
+                       }
+                       break;
+               case REMOVE_FATHER_HYP: // nothing to do
+                       break;
+               case REMOVE_FATHER_ALGO:
+                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+//    if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
+//    if (anHyp->GetShapeType() == _subShape.ShapeType())
+                       if (anHyp->GetShapeType() & (1 << _subShape.ShapeType()))
+                       {
+                               SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
+                               if (algo == NULL)       // no more applying algo on father
+                               {
+                                       SetAlgoState(NO_ALGO);
+                               }
+                               else
+                               {
+                                       ret = algo->CheckHypothesis((*_father), _subShape);
+                                       if (ret)
+                                               SetAlgoState(HYP_OK);
+                                       else
+                                               SetAlgoState(MISSING_HYP);
+                               }
+                       }
+                       break;
+               default:
+                       ASSERT(0);
+                       break;
                }
-             else
+               break;
+
+               // ----------------------------------------------------------------------
+
+       case HYP_OK:
+               switch (event)
                {
-                 ret = algo->CheckHypothesis((*_father),_subShape);
-                 if (ret) SetAlgoState(HYP_OK);
-                 else SetAlgoState(MISSING_HYP);
-               }
-           }
-         break;
-       case REMOVE_FATHER_HYP:
-         ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
-         {
-           SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-           ASSERT(algo);
-           ret = algo->CheckHypothesis((*_father),_subShape);
-           if (ret) SetAlgoState(HYP_OK);
-           else SetAlgoState(MISSING_HYP);
-         }
-         break;
-       case REMOVE_FATHER_ALGO:
-         ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
-//       if (anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape))
-//       if (anHyp->GetShapeType() == _subShape.ShapeType())
-         if (anHyp->GetShapeType() & (1<< _subShape.ShapeType()))
-           {
-             SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
-             if (algo == NULL)  // no more applying algo on father
+               case ADD_HYP:
                {
-                 SetAlgoState(NO_ALGO);
+                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+                       SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
+                       ASSERT(algo);
+                       list<const SMESHDS_Hypothesis *> originalUsedHyps = algo->GetUsedHypothesis((*_father), _subShape);     // copy
+
+                       ret = _meshDS->AddHypothesis(_subShape, anHyp);
+                       if (ret)
+                       {
+                               ret = algo->CheckHypothesis((*_father), _subShape);
+                               if (!ret)
+                               {
+                                       INFOS("two applying algo on the same shape not allowed");
+                                       ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+                                       ret = false;
+                               }
+                               else                    // compare SMESHDS_Hypothesis* lists (order important)
+                               {
+                                       MESSAGE("---");
+                                       const list <const SMESHDS_Hypothesis *> & newUsedHyps
+                                               = algo->GetUsedHypothesis((*_father), _subShape);
+                                       modifiedHyp = (originalUsedHyps != newUsedHyps);
+                               }
+                       }
                }
-             else
-               {
-                 ret = algo->CheckHypothesis((*_father),_subShape);
-                 if (ret) SetAlgoState(HYP_OK);
-                 else SetAlgoState(MISSING_HYP);
+                       break;
+               case ADD_ALGO:                  //already existing algo : on father ?
+                       ASSERT(anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO);
+                       if (anHyp->GetDim() <= SMESH_Gen::GetShapeDim(_subShape))
+                       {
+                               ret = _meshDS->AddHypothesis(_subShape, anHyp);
+//        if (ret &&(anHyp->GetDim() == SMESH_Gen::GetShapeDim(_subShape)))
+//        if (ret &&(anHyp->GetShapeType() == _subShape.ShapeType()))
+                               if (ret &&
+                                       (anHyp->GetShapeType() & (1 << _subShape.ShapeType())))
+                               {
+                                       SMESH_Algo *algo = gen->GetAlgo((*_father), _subShape);
+                                       if (algo == NULL)       // two algo on the same subShape...
+                                       {
+                                               INFOS("two algo on the same subshape not allowed");
+                                               ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+                                               ret = false;
+                                       }
+                                       else
+                                       {
+                                               ret = algo->CheckHypothesis((*_father), _subShape);
+                                               if (ret)
+                                                       SetAlgoState(HYP_OK);
+                                               else
+                                                       SetAlgoState(MISSING_HYP);
+                                       }
+                               }
+                       }
+                       break;
+               case REMOVE_HYP:
+                       ASSERT(anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO);
+                       ret = _meshDS->RemoveHypothesis(_subShape, anHyp);
+                       if (ret)
+