]> SALOME platform Git repositories - plugins/blsurfplugin.git/commitdiff
Salome HOME
New Enforced Vertex structure done
authorgdd <gdd>
Wed, 16 Feb 2011 18:43:15 +0000 (18:43 +0000)
committergdd <gdd>
Wed, 16 Feb 2011 18:43:15 +0000 (18:43 +0000)
It is possible to add enforced vertices with following combinaisons:
Face / Coordinates
Face / Geom vertex
Face / Geom group (or compound) of vertices
Group (or compound) of faces / Coordinates
Group (or compound) of faces / Geom vertex
Group (or compound) of faces / Geom group (or compound) of vertices

With each combinaison it is possible to define a group of nodes in which the nodes created by the enforced vertices will be defined.

TODO: update the GUI

idl/BLSURFPlugin_Algorithm.idl
src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx
src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx
src/GUI/BLSURFPluginGUI_HypothesisCreator.h

index f1faa49bc2d2c41e5e32b73dc7476a9b9626c42d..44de7311eaba4b085646cd074e806f647eff6d86 100644 (file)
@@ -56,7 +56,7 @@ module BLSURFPlugin
     TEntry geomEntry;
     TEnfVertexCoords coords;
     TEnfGroupName grpName;
-    //TEntryList faceEntries;
+    TEntryList faceEntries;
   };
   // List of enforced vertices
   typedef sequence<TEnfVertex> TEnfVertexList;
@@ -295,10 +295,10 @@ module BLSURFPlugin
     boolean SetEnforcedVertex(in GEOM::GEOM_Object theFace, in double x, in double y, in double z) raises (SALOME::SALOME_Exception);
     boolean SetEnforcedVertexNamed(in GEOM::GEOM_Object theFace, in double x, in double y, in double z, in TEnfName theVertexName) raises (SALOME::SALOME_Exception);
     boolean SetEnforcedVertexGeom(in GEOM::GEOM_Object theFace, in GEOM::GEOM_Object theVertex) raises (SALOME::SALOME_Exception);
-    /* TODO GROUPS
-    void SetEnforcedVertexWithGroup(in GEOM::GEOM_Object theFace, in double x, in double y, in double z, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception);
-    void SetEnforcedVertexGeomWithGroup(in GEOM::GEOM_Object theFace, in GEOM::GEOM_Object theVertex, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception);
-    */
+    boolean SetEnforcedVertexWithGroup(in GEOM::GEOM_Object theFace, in double x, in double y, in double z, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception);
+    boolean SetEnforcedVertexNamedWithGroup(in GEOM::GEOM_Object theFace, in double x, in double y, in double z, in TEnfName theVertexName, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception);
+    boolean SetEnforcedVertexGeomWithGroup(in GEOM::GEOM_Object theFace, in GEOM::GEOM_Object theVertex, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception);
+
     
     TEnfVertexList GetEnforcedVertices(in GEOM::GEOM_Object theFace) raises (SALOME::SALOME_Exception);
     
index fbd248875cd64f0c2a7a7cfcfec31166603e4d0c..c407b30254cce14fc50dae11b7c4d65b04fbd80c 100644 (file)
@@ -213,7 +213,8 @@ std::map<int,BLSURFPlugin_Hypothesis::TEnfVertexCoords > FaceId2AttractorCoords;
 
 TopTools_IndexedMapOfShape FacesWithEnforcedVertices;
 std::map< int, BLSURFPlugin_Hypothesis::TEnfVertexCoordsList > FaceId2EnforcedVertexCoords;
-std::map< BLSURFPlugin_Hypothesis::TEnfVertexCoords, BLSURFPlugin_Hypothesis::TEnfVertexCoords > EnfVertex2ProjVertex;
+std::map< BLSURFPlugin_Hypothesis::TEnfVertexCoords, BLSURFPlugin_Hypothesis::TEnfVertexCoords > EnfVertexCoords2ProjVertex;
+std::map< BLSURFPlugin_Hypothesis::TEnfVertexCoords, BLSURFPlugin_Hypothesis::TEnfVertexList > EnfVertexCoords2EnfVertexList;
 
 bool HasSizeMapOnFace=false;
 bool HasSizeMapOnEdge=false;
@@ -275,7 +276,8 @@ BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF(int hypId, int studyId,
   FaceId2AttractorCoords.clear();
   FacesWithEnforcedVertices.Clear();
   FaceId2EnforcedVertexCoords.clear();
-  EnfVertex2ProjVertex.clear();
+  EnfVertexCoords2ProjVertex.clear();
+  EnfVertexCoords2EnfVertexList.clear();
 }
 
 //=============================================================================
@@ -417,7 +419,7 @@ TopoDS_Shape BLSURFPlugin_BLSURF::entryToShape(std::string entry)
   return S;
 }
 
-void _createEnforcedVertexOnFace(TopoDS_Face FaceShape, gp_Pnt aPnt)
+void _createEnforcedVertexOnFace(TopoDS_Face faceShape, gp_Pnt aPnt, BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex)
 {
   BLSURFPlugin_Hypothesis::TEnfVertexCoords enf_coords, coords, s_coords;
   enf_coords.clear();
@@ -425,7 +427,7 @@ void _createEnforcedVertexOnFace(TopoDS_Face FaceShape, gp_Pnt aPnt)
   s_coords.clear();
 
   // Get the (u,v) values of the enforced vertex on the face
-  projectionPoint myPoint = getProjectionPoint(FaceShape,aPnt);
+  projectionPoint myPoint = getProjectionPoint(faceShape,aPnt);
 
   MESSAGE("Enforced Vertex: " << aPnt.X() << ", " << aPnt.Y() << ", " << aPnt.Z());
   MESSAGE("Projected Vertex: " << myPoint.xyz.X() << ", " << myPoint.xyz.Y() << ", " << myPoint.xyz.Z());
@@ -448,18 +450,20 @@ void _createEnforcedVertexOnFace(TopoDS_Face FaceShape, gp_Pnt aPnt)
   // Save pair projected vertex / enf vertex
   MESSAGE("Storing pair projected vertex / enf vertex:");
   MESSAGE("("<< myPoint.xyz.X() << ", " << myPoint.xyz.Y() << ", " << myPoint.xyz.Z() <<") / (" << aPnt.X() << ", " << aPnt.Y() << ", " << aPnt.Z()<<")");
-  EnfVertex2ProjVertex[s_coords] = enf_coords;
+  EnfVertexCoords2ProjVertex[s_coords] = enf_coords;
+  MESSAGE("Group name is: \"" << enfVertex->grpName << "\"");
+  EnfVertexCoords2EnfVertexList[s_coords].insert(enfVertex);
 
   int key = 0;
-  if (! FacesWithEnforcedVertices.Contains(FaceShape)) {
-    key = FacesWithEnforcedVertices.Add(FaceShape);
+  if (! FacesWithEnforcedVertices.Contains(faceShape)) {
+    key = FacesWithEnforcedVertices.Add(faceShape);
   }
   else {
-    key = FacesWithEnforcedVertices.FindIndex(FaceShape);
+    key = FacesWithEnforcedVertices.FindIndex(faceShape);
   }
 
   // If a node is already created by an attractor, do not create enforced vertex
-  int attractorKey = FacesWithSizeMap.FindIndex(FaceShape);
+  int attractorKey = FacesWithSizeMap.FindIndex(faceShape);
   bool sameAttractor = false;
   if (attractorKey >= 0)
     if (FaceId2AttractorCoords.count(attractorKey) > 0)
@@ -488,9 +492,9 @@ void _createEnforcedVertexOnFace(TopoDS_Face FaceShape, gp_Pnt aPnt)
 }
 
 /////////////////////////////////////////////////////////
-void BLSURFPlugin_BLSURF::createEnforcedVertexOnFace(TopoDS_Shape FaceShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList)
+void BLSURFPlugin_BLSURF::createEnforcedVertexOnFace(TopoDS_Shape faceShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList)
 {
-  BLSURFPlugin_Hypothesis::TEnfVertex enfVertex;
+  BLSURFPlugin_Hypothesis::TEnfVertex* enfVertex;
   gp_Pnt aPnt;
 
   BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator enfVertexListIt = enfVertexList.begin();
@@ -498,25 +502,25 @@ void BLSURFPlugin_BLSURF::createEnforcedVertexOnFace(TopoDS_Shape FaceShape, BLS
   for( ; enfVertexListIt != enfVertexList.end() ; ++enfVertexListIt ) {
     enfVertex = *enfVertexListIt;
     // Case of manual coords
-    if (enfVertex.coords.size() != 0) {
-      aPnt.SetCoord(enfVertex.coords[0],enfVertex.coords[1],enfVertex.coords[2]);
-      _createEnforcedVertexOnFace( TopoDS::Face(FaceShape),  aPnt);
+    if (enfVertex->coords.size() != 0) {
+      aPnt.SetCoord(enfVertex->coords[0],enfVertex->coords[1],enfVertex->coords[2]);
+      _createEnforcedVertexOnFace( TopoDS::Face(faceShape),  aPnt, enfVertex);
     }
 
     // Case of geom vertex coords
-    if (enfVertex.geomEntry != "") {
-      TopoDS_Shape GeomShape = entryToShape(enfVertex.geomEntry);
+    if (enfVertex->geomEntry != "") {
+      TopoDS_Shape GeomShape = entryToShape(enfVertex->geomEntry);
       TopAbs_ShapeEnum GeomType  = GeomShape.ShapeType();
        if (GeomType == TopAbs_VERTEX){
          aPnt = BRep_Tool::Pnt(TopoDS::Vertex(GeomShape));
-         _createEnforcedVertexOnFace( TopoDS::Face(FaceShape),  aPnt);
+         _createEnforcedVertexOnFace( TopoDS::Face(faceShape),  aPnt, enfVertex);
        }
        // Group Management
        if (GeomType == TopAbs_COMPOUND){
          for (TopoDS_Iterator it (GeomShape); it.More(); it.Next()){
            if (it.Value().ShapeType() == TopAbs_VERTEX){
              aPnt = BRep_Tool::Pnt(TopoDS::Vertex(it.Value()));
-             _createEnforcedVertexOnFace( TopoDS::Face(FaceShape),  aPnt);
+             _createEnforcedVertexOnFace( TopoDS::Face(faceShape),  aPnt, enfVertex);
            }
          }
        }
@@ -1078,19 +1082,25 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
           TopAbs_State result = scl.State();
           MESSAGE("Position of point on face: "<<result);
           if ( result == TopAbs_OUT ) {
-              MESSAGE("Point is out of face: node is not created");
-              if (EnfVertex2ProjVertex.find(xyzCoords) != EnfVertex2ProjVertex.end())
-                EnfVertex2ProjVertex.erase(xyzCoords);
+            MESSAGE("Point is out of face: node is not created");
+            if (EnfVertexCoords2ProjVertex.find(xyzCoords) != EnfVertexCoords2ProjVertex.end()) {
+              EnfVertexCoords2ProjVertex.erase(xyzCoords);
+              EnfVertexCoords2EnfVertexList.erase(xyzCoords);
+            }
           }
           if ( result == TopAbs_UNKNOWN ) {
             MESSAGE("Point position on face is unknown: node is not created");
-            if (EnfVertex2ProjVertex.find(xyzCoords) != EnfVertex2ProjVertex.end())
-              EnfVertex2ProjVertex.erase(xyzCoords);
+            if (EnfVertexCoords2ProjVertex.find(xyzCoords) != EnfVertexCoords2ProjVertex.end()) {
+              EnfVertexCoords2ProjVertex.erase(xyzCoords);
+              EnfVertexCoords2EnfVertexList.erase(xyzCoords);
+            }
           }
           if ( result == TopAbs_ON ) {
             MESSAGE("Point is on border of face: node is not created");
-            if (EnfVertex2ProjVertex.find(xyzCoords) != EnfVertex2ProjVertex.end())
-              EnfVertex2ProjVertex.erase(xyzCoords);
+            if (EnfVertexCoords2ProjVertex.find(xyzCoords) != EnfVertexCoords2ProjVertex.end()) {
+              EnfVertexCoords2ProjVertex.erase(xyzCoords);
+              EnfVertexCoords2EnfVertexList.erase(xyzCoords);
+            }
           }
           if ( result == TopAbs_IN )
           {
@@ -1307,73 +1317,74 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
     }
     nodes[iv] = meshDS->AddNode(xyz[0], xyz[1], xyz[2]);
 
-    /* TODO GROUPS
     // Create group of enforced vertices if requested
     if(_hypothesis) {
       BLSURFPlugin_Hypothesis::TEnfVertexCoords projVertex;
       projVertex.push_back((double)xyz[0]);
       projVertex.push_back((double)xyz[1]);
       projVertex.push_back((double)xyz[2]);
-      std::map< BLSURFPlugin_Hypothesis::TEnfVertexCoords, BLSURFPlugin_Hypothesis::TEnfVertexCoords >::const_iterator projIt = EnfVertex2ProjVertex.find(projVertex);
-      if (projIt != EnfVertex2ProjVertex.end()) {
-//        double x = (projIt->second)[0];
-//        double y = (projIt->second)[1];
-//        double z = (projIt->second)[2];
-        BLSURFPlugin_Hypothesis::TEnfVertexCoords enfVertex = projIt->second;
-//        enfVertex.push_back(x);
-//        enfVertex.push_back(y);
-//        enfVertex.push_back(z);
+//       std::map< BLSURFPlugin_Hypothesis::TEnfVertexCoords, BLSURFPlugin_Hypothesis::TEnfVertexCoords >::const_iterator projIt = EnfVertexCoords2ProjVertex.find(projVertex);
+//       if (projIt != EnfVertexCoords2ProjVertex.end()) {
+//         BLSURFPlugin_Hypothesis::TEnfVertexCoords enfVertexCoords = projIt->second;
           
-        BLSURFPlugin_Hypothesis::TEnfVertexGroupNameMap groupNameMap =  _hypothesis->_GetEnforcedVertexGroupNameMap();
-        BLSURFPlugin_Hypothesis::TEnfVertexGroupNameMap::const_iterator groupNameMapIt = groupNameMap.find(enfVertex);
-        if (groupNameMapIt != groupNameMap.end()) {
+//         BLSURFPlugin_Hypothesis::TEnfVertexGroupNameMap groupNameMap =  _hypothesis->_GetEnforcedVertexGroupNameMap();
+//         BLSURFPlugin_Hypothesis::TEnfVertexGroupNameMap::const_iterator groupNameMapIt = groupNameMap.find(enfVertexCoords);
+        std::map< BLSURFPlugin_Hypothesis::TEnfVertexCoords, BLSURFPlugin_Hypothesis::TEnfVertexList >::const_iterator enfCoordsIt = EnfVertexCoords2EnfVertexList.find(projVertex);
+        if (enfCoordsIt != EnfVertexCoords2EnfVertexList.end()) {
           MESSAGE("Found enforced vertex @ " << xyz[0] << ", " << xyz[1] << ", " << xyz[2])
-          BLSURFPlugin_Hypothesis::TEnfGroupName groupName = groupNameMapIt->second;
-          if (groupName != "") {
-            bool groupDone = false;
-            const set<SMESHDS_GroupBase*>& allGroups = meshDS->GetGroups();
-            set<SMESHDS_GroupBase*>::const_iterator grIt;
-            MESSAGE("Parsing the groups of the mesh");
-            for ( grIt = allGroups.begin(); grIt != allGroups.end(); ++grIt ) {
-              SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *grIt );
-              MESSAGE("Group: " << group->GetStoreName());
-              if ( group && group->SMDSGroup().GetType()==SMDSAbs_Node
-                          && groupName.compare(group->GetStoreName())==0) {
-                group->SMDSGroup().Add(nodes[iv]);
-//                 int id = // recuperer l'id SMESH du noeud
-//                 _hypothesis->AddEnfVertexIDs(groupName,id)
-                groupDone = true;
-                MESSAGE("Successfully added enforced vertex to existing group " << groupName);
-                break;
-              }
-            }
-            if (!groupDone)
-            {
-              int groupId;
-              SMESH_Group* aGroup = aMesh.AddGroup(SMDSAbs_Node, groupName.c_str(), groupId);
-              if ( aGroup ) {
-                SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
-                if ( aGroupDS ) {
-                  aGroupDS->SetStoreName( groupName.c_str() );
-                  aGroupDS->SMDSGroup().Add(nodes[iv]);
-                  MESSAGE("Successfully created enforced vertex group " << groupName);
+//           BLSURFPlugin_Hypothesis::TEnfGroupName groupName = groupNameMapIt->second;
+//           if (groupName != "") {
+          BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator enfListIt = enfCoordsIt->second.begin();
+          BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
+          for (; enfListIt != enfCoordsIt->second.end(); ++enfListIt) {
+            currentEnfVertex = (*enfListIt);
+            if (currentEnfVertex->grpName != "") {
+              bool groupDone = false;
+              const set<SMESHDS_GroupBase*>& allGroups = meshDS->GetGroups();
+              set<SMESHDS_GroupBase*>::const_iterator grIt;
+              MESSAGE("Parsing the groups of the mesh");
+              for ( grIt = allGroups.begin(); grIt != allGroups.end(); ++grIt ) {
+                SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *grIt );
+                if (group)
+                  MESSAGE("Group: " << group->GetStoreName());
+                if ( group && group->SMDSGroup().GetType()==SMDSAbs_Node
+                            && currentEnfVertex->grpName.compare(group->GetStoreName())==0) {
+                  group->SMDSGroup().Add(nodes[iv]);
+  //                 int id = // recuperer l'id SMESH du noeud
+  //                 _hypothesis->AddEnfVertexIDs(groupName,id)
                   groupDone = true;
+                  MESSAGE("Successfully added enforced vertex to existing group " << currentEnfVertex->grpName);
+                  break;
+                }
+              }
+              if (!groupDone)
+              {
+                int groupId;
+                SMESH_Group* aGroup = aMesh.AddGroup(SMDSAbs_Node, currentEnfVertex->grpName.c_str(), groupId);
+                if ( aGroup ) {
+                  SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
+                  if ( aGroupDS ) {
+                    aGroupDS->SetStoreName( currentEnfVertex->grpName.c_str() );
+                    aGroupDS->SMDSGroup().Add(nodes[iv]);
+                    MESSAGE("Successfully created enforced vertex group " << currentEnfVertex->grpName);
+                    groupDone = true;
+                  }
                 }
               }
+              if (!groupDone)
+                throw SALOME_Exception(LOCALIZED("A enforced vertex node was not added to a group"));
             }
-            if (!groupDone)
-              throw SALOME_Exception(LOCALIZED("A enforced vertex node was not added to a group"));
+            else
+              MESSAGE("Group name is empty: '"<<currentEnfVertex->grpName<<"' => group is not created");
           }
-          else
-            MESSAGE("Group name is empty: '"<<groupName<<"' => group is not created");
         }
-        else
-          MESSAGE("No group name for projected vertex ("<<x<<","<<y<<","<<z<<")")
-      }
+//         else
+//           MESSAGE("No group name for projected vertex ("<<projVertex[0]<<","<<projVertex[1]<<","<<projVertex[2]<<")")
+//       }
 //       else
 //         MESSAGE("No group name for vertex ("<<xyz[0]<<","<<xyz[1]<<","<<xyz[2]<<")")
     }
-    */
+
 
     // internal point are tagged to zero
     if(tag > 0 && tag <= pmap.Extent() ){
index 21d51dd9b9ab90fa5129eac7b44ba2031e8eb937..b014d82127e940fcded9367c484e20ed2800f95f 100644 (file)
 
 //=============================================================================
 BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen) :
-  SMESH_Hypothesis(hypId, studyId, gen), _topology(GetDefaultTopology()), _physicalMesh(GetDefaultPhysicalMesh()),
-      _phySize(GetDefaultPhySize()), _phyMax(GetDefaultMaxSize()), _phyMin(GetDefaultMinSize()), _hgeoMax(
-          GetDefaultMaxSize()), _hgeoMin(GetDefaultMinSize()), _geometricMesh(GetDefaultGeometricMesh()), _angleMeshS(
-          GetDefaultAngleMeshS()), _angleMeshC(GetDefaultAngleMeshC()), _gradation(GetDefaultGradation()),
-      _quadAllowed(GetDefaultQuadAllowed()), _decimesh(GetDefaultDecimesh()), _verb(GetDefaultVerbosity()), _sizeMap(
-          GetDefaultSizeMap()), _attractors(GetDefaultSizeMap()), _faceEntryEnfVertexListMap(
-          GetDefaultFaceEntryEnfVertexListMap()), _enfVertexList(GetDefaultEnfVertexList()), _faceEntryCoordsListMap(
-          GetDefaultFaceEntryCoordsListMap()), _coordsEnfVertexMap(GetDefaultCoordsEnfVertexMap()),
-      _faceEntryEnfVertexEntryListMap(GetDefaultFaceEntryEnfVertexEntryListMap()), _enfVertexEntryEnfVertexMap(
-          GetDefaultEnfVertexEntryEnfVertexMap())
+  SMESH_Hypothesis(hypId, studyId, gen), _topology(GetDefaultTopology()),
+  _physicalMesh(GetDefaultPhysicalMesh()),
+  _phySize(GetDefaultPhySize()),
+  _phyMax(GetDefaultMaxSize()),
+  _phyMin(GetDefaultMinSize()),
+  _hgeoMax(GetDefaultMaxSize()),
+  _hgeoMin(GetDefaultMinSize()), 
+  _geometricMesh(GetDefaultGeometricMesh()),
+  _angleMeshS(GetDefaultAngleMeshS()),
+  _angleMeshC(GetDefaultAngleMeshC()),
+  _gradation(GetDefaultGradation()),
+  _quadAllowed(GetDefaultQuadAllowed()),
+  _decimesh(GetDefaultDecimesh()),
+  _verb(GetDefaultVerbosity()),
+  _sizeMap(GetDefaultSizeMap()),
+  _attractors(GetDefaultSizeMap()),
+  _faceEntryEnfVertexListMap(GetDefaultFaceEntryEnfVertexListMap()),
+  _enfVertexList(GetDefaultEnfVertexList()),
+  _faceEntryCoordsListMap(GetDefaultFaceEntryCoordsListMap()),
+  _coordsEnfVertexMap(GetDefaultCoordsEnfVertexMap()),
+  _faceEntryEnfVertexEntryListMap(GetDefaultFaceEntryEnfVertexEntryListMap()),
+  _enfVertexEntryEnfVertexMap(GetDefaultEnfVertexEntryEnfVertexMap())
 
 /* TODO GROUPS
  _groupNameEnfVertexListMap(GetDefaultGroupNameEnfVertexListMap()),
@@ -367,34 +379,11 @@ void BLSURFPlugin_Hypothesis::ClearSizeMaps() {
   _attractors.clear();
 }
 
-//struct CompareEnfVertices
-//{
-//  bool operator () (const TEnfVertex& e1, const TEnfVertex& e2) const
-//  {
-//    if (e1 && e2) {
-//      if (e1.geomEntry == "")
-//        if (e2.geomEntry == "")
-//          if ((e1.coords.size()) && (e2.coords.size()))
-//            return e1.coords < e2.coords;
-//          else
-//            return e1 < e2;
-//        else {
-//
-//          if (e1.coords.size())
-//            return true;
-//        }
-//
-//    }
-//    const bool cmpCoords = ( e1 && e2 && e1.coords.size() && e2.coords.size() );
-//    return cmpCoords ? ( e1.coords < e2.coords) : ( &e1 < &e2 );
-//  }
-//};
-
 //=======================================================================
 //function : SetEnforcedVertex
 //=======================================================================
-bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEntry& theFaceEntry, double x, double y, double z,
-    const TEnfName& theVertexName, const TEntry& theVertexEntry, const TEnfGroupName& theGroupName) {
+bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry,
+                                                TEnfGroupName theGroupName, double x, double y, double z) {
 
   MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex("<< theFaceEntry << ", "
       << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theVertexEntry << ", " << theGroupName << ")");
@@ -403,128 +392,146 @@ bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEntry& theFaceEntry, doub
   bool toNotify = false;
   bool toCreate = true;
 
-  TEnfVertex oldEnfVertex;
-  TEnfVertex newEnfVertex;
-  newEnfVertex.name = theVertexName;
-  newEnfVertex.coords.clear();
+  TEnfVertex *oldEnVertex;
+  TEnfVertex *newEnfVertex = new TEnfVertex();
+  newEnfVertex->name = theVertexName;
+  newEnfVertex->geomEntry = theVertexEntry;
+  newEnfVertex->coords.clear();
   if (theVertexEntry == "") {
-    newEnfVertex.coords.push_back(x);
-    newEnfVertex.coords.push_back(y);
-    newEnfVertex.coords.push_back(z);
+    newEnfVertex->coords.push_back(x);
+    newEnfVertex->coords.push_back(y);
+    newEnfVertex->coords.push_back(z);
   }
-  newEnfVertex.geomEntry = theVertexEntry;
-  newEnfVertex.grpName = theGroupName;
-
-  //////// UPDATE ////////////
-  // If "manual" enf vertex (theVertexEntry="") maybe an existing enf vertex needs to be update with new name or new group name
-  TCoordsEnfVertexMap::iterator it_CoordsEnfVertex = _coordsEnfVertexMap.find(newEnfVertex.coords);
-  if (it_CoordsEnfVertex != _coordsEnfVertexMap.end()) {
-    if (it_CoordsEnfVertex->second.name != theVertexName) {
-      MESSAGE("Update enf vertex name from " << it_CoordsEnfVertex->second.name << " to " << theVertexName);
-
-      // update _faceEntryEnfVertexListMap
-      TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
-      for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) {
-        if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
-          currentEnfVertexList.erase(it);
-          currentEnfVertexList.insert(newEnfVertex);
-          break;
-        }
-      }
-
-      // update _enfVertexList
-      for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) {
-        if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
-          _enfVertexList.erase(it);
-          _enfVertexList.insert(newEnfVertex);
-          break;
-        }
-      }
-
-      // update _coordsEnfVertexMap
-      _coordsEnfVertexMap[newEnfVertex.coords] = newEnfVertex;
-
-      toCreate = false;
+  newEnfVertex->grpName = theGroupName;
+  newEnfVertex->faceEntries.clear();
+  newEnfVertex->faceEntries.insert(theFaceEntry);
+  
+  
+  // update _enfVertexList
+  TEnfVertexList::iterator it = _enfVertexList.find(newEnfVertex);
+  if (it != _enfVertexList.end()) {
+    toCreate = false;
+    oldEnVertex = (*it);
+    MESSAGE("Enforced Vertex was found => Update");
+    if (oldEnVertex->name != theVertexName) {
+      MESSAGE("Update name from \"" << oldEnVertex->name << "\" to \"" << theVertexName << "\"");
+      oldEnVertex->name = theVertexName;
       toNotify = true;
     }
-    if (it_CoordsEnfVertex->second.grpName != theGroupName) {
-      MESSAGE("Update enf vertex group name from " << it_CoordsEnfVertex->second.grpName << " to " << theGroupName);
-      oldEnfVertex = it_CoordsEnfVertex->second;
-
-      // update _faceEntryEnfVertexListMap
-      TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
-      for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) {
-        if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
-          currentEnfVertexList.erase(it);
-          currentEnfVertexList.insert(newEnfVertex);
-          break;
-        }
-      }
-
-      // update _enfVertexList
-      for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) {
-        if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
-          _enfVertexList.erase(it);
-          _enfVertexList.insert(newEnfVertex);
-          break;
-        }
-      }
-
-      // update _coordsEnfVertexMap
-      _coordsEnfVertexMap[newEnfVertex.coords] = newEnfVertex;
-      toCreate = false;
+    if (oldEnVertex->grpName != theGroupName) {
+      MESSAGE("Update group name from \"" << oldEnVertex->grpName << "\" to \"" << theGroupName << "\"");
+      oldEnVertex->grpName = theGroupName;
       toNotify = true;
     }
-  }
-
-  // If "selected" enf vertex (theVertexEntry!="") maybe an existing enf vertex needs to be update with new group name
-  TEnfVertexEntryEnfVertexMap::iterator it_EnfEntryEnfVertex = _enfVertexEntryEnfVertexMap.find(theVertexEntry);
-  if (it_EnfEntryEnfVertex != _enfVertexEntryEnfVertexMap.end()) {
-    if (it_EnfEntryEnfVertex->second.grpName != theGroupName) {
-      MESSAGE("Update enf vertex group name from " << it_EnfEntryEnfVertex->second.grpName << " to " << theGroupName);
-      oldEnfVertex = it_EnfEntryEnfVertex->second;
-
-      // update _faceEntryEnfVertexListMap
-      TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
-      for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) {
-        if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
-          currentEnfVertexList.erase(it);
-          currentEnfVertexList.insert(newEnfVertex);
-          break;
-        }
+    TEntryList::iterator it_faceEntries = oldEnVertex->faceEntries.find(theFaceEntry);
+    if (it_faceEntries == oldEnVertex->faceEntries.end()) {
+      MESSAGE("Update face list by adding \"" << theFaceEntry << "\"");
+      oldEnVertex->faceEntries.insert(theFaceEntry);
+      _faceEntryEnfVertexListMap[theFaceEntry].insert(oldEnVertex);
+      toNotify = true;
+    }
+    if (toNotify) {
+      // update map coords / enf vertex if needed
+      if (oldEnVertex->coords.size()) {
+        _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex;
+        _faceEntryCoordsListMap[theFaceEntry].insert(oldEnVertex->coords);
       }
 
-      // update _enfVertexList
-      for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) {
-        if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
-          _enfVertexList.erase(it);
-          _enfVertexList.insert(newEnfVertex);
-          break;
-        }
+      // update map geom entry / enf vertex if needed
+      if (oldEnVertex->geomEntry != "") {
+        _enfVertexEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex;
+        _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(oldEnVertex->geomEntry);
       }
-
-      _enfVertexEntryEnfVertexMap[theVertexEntry] = newEnfVertex;
-
-      toCreate = false;
-      toNotify = true;
     }
   }
-
-  //////// CREATE ////////////
+  
+  
+//   TEnfVertexList::iterator it = _enfVertexList.begin();
+//   for ( ; it != _enfVertexList.end() ; ++it) {
+//     if (TEnfVertexCmp(&(*it),&newEnfVertex)) {
+//       // Found enf vertex
+//       TEntryList::const_iterator it_entry = it->faceEntries.begin();
+//       for (;it_entry<it->faceEntries.end();++it_entry) {
+//         std::string currentFaceEntry = (*it_entry);
+//         
+//         if (_faceEntryCoordsListMap.count(currentFaceEntry))
+//           _faceEntryCoordsListMap[currentFaceEntry].erase(it->coords);
+//         
+//         if (_faceEntryEnfVertexEntryListMap.count(currentFaceEntry))
+//         _faceEntryEnfVertexEntryListMap[currentFaceEntry].erase(it->geomEntry);
+//         
+//         if (_faceEntryEnfVertexListMap.count(currentFaceEntry)) {
+//           TEnfVertexList newEnfVertexList;
+//           TEnfVertexList::const_iterator it_enfVertexList = _faceEntryEnfVertexListMap[currentFaceEntry].begin();
+//           for (;it_enfVertexList != _faceEntryEnfVertexListMap[currentFaceEntry].end(); ++it_enfVertexList) {
+//             if (!TEnfVertexCmp(&(*it),&(*it_enfVertexList)))
+//               newEnfVertexList.insert(*it_enfVertexList);
+//           }
+//           _faceEntryEnfVertexListMap.erase(currentFaceEntry);
+//           _faceEntryEnfVertexListMap[currentFaceEntry] = newEnfVertexList;
+//         }
+//       }
+//       _coordsEnfVertexMap.erase(it->coords);
+//       _enfVertexEntryEnfVertexMap.erase(it->geomEntry);
+//       _enfVertexList.erase(it);
+// //       toCreate = false;
+// //       oldEnVertex = (*it);
+// //       break;
+//     }
+//   }
+  
+//   //////// UPDATE ////////////
+//   if (!toCreate) {
+//     // Update list of face entries
+//     
+//     TEntryList::const_iterator it_faceEntries = oldEnVertex.faceEntries.begin();
+//     for (;it_faceEntries!=oldEnVertex.faceEntries.end();++it_faceEntries)
+//         newEnfVertex.faceEntries.insert(*it_faceEntries);
+// //         _faceEntries.insert(theFaceEntry);
+// //         (*it).faceEntries.insert(theFaceEntry);
+//     if (oldEnVertex.faceEntries.find(theFaceEntry) == oldEnVertex.faceEntries.end()) {
+//       MESSAGE("Update enf vertex faceEntries by adding " << theFaceEntry);
+//       _faceEntryEnfVertexListMap[theFaceEntry].insert((*it));
+//       toNotify = true;
+//     }
+// 
+//     
+//     if ((*it).name != newEnfVertex.name) {
+//       MESSAGE("Update enf vertex name from \"" << (*it).name << "\" to \"" << newEnfVertex.name << "\"");
+//       (*it).name = newEnfVertex.name;
+//       toNotify = true;
+//     }
+//     
+//     if ((*it).grpName != newEnfVertex.grpName) {
+//       MESSAGE("Update enf vertex group name from \"" << (*it).grpName << "\" to \"" << newEnfVertex.grpName << "\"");
+//       (*it).grpName = newEnfVertex.grpName;
+//       toNotify = true;
+//     }
+//     
+//     if (toNotify) {
+//       // update map coords / enf vertex if needed
+//       if ((*it).coords.size())
+//         _coordsEnfVertexMap[(*it).coords] = (*it);
+// 
+//       // update map geom entry / enf vertex if needed
+//       if ((*it).geomEntry != "")
+//         _enfVertexEntryEnfVertexMap[(*it).geomEntry] = (*it);
+//     }
+//   }
+//   
+//   //////// CREATE ////////////
   if (toCreate) {
+    toNotify = true;
     MESSAGE("Creating new enforced vertex");
-    std::pair<TEnfVertexList::iterator, bool> res = _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex);
-    toNotify = res.second;
-
-    if (toNotify) {
-      _enfVertexList.insert(newEnfVertex);
-      if (theVertexEntry == "") {
-        _faceEntryCoordsListMap[theFaceEntry].insert(newEnfVertex.coords);
-        _coordsEnfVertexMap[newEnfVertex.coords] = newEnfVertex;
-      } else {
-        _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(newEnfVertex.geomEntry);
-        _enfVertexEntryEnfVertexMap[newEnfVertex.geomEntry] = newEnfVertex;
-      }
+    _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex);
+    _enfVertexList.insert(newEnfVertex);
+    if (theVertexEntry == "") {
+      _faceEntryCoordsListMap[theFaceEntry].insert(newEnfVertex->coords);
+      _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex;
+    }
+    else {
+      _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(newEnfVertex->geomEntry);
+      _enfVertexEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex;
     }
   }
 
@@ -534,6 +541,129 @@ bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEntry& theFaceEntry, doub
   MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END");
   return toNotify;
 }
+  
+//     TEnfVertex oldEnfVertex;
+//   // If "manual" enf vertex (theVertexEntry="") maybe an existing enf vertex needs to be update with new name or new group name
+//   TCoordsEnfVertexMap::iterator it_CoordsEnfVertex = _coordsEnfVertexMap.find(newEnfVertex.coords);
+//   if (it_CoordsEnfVertex != _coordsEnfVertexMap.end()) {
+//     toCreate = false;
+//     if ((it_CoordsEnfVertex->second.name != theVertexName) || (it_CoordsEnfVertex->second.grpName != theGroupName)) {
+//       oldEnfVertex = it_CoordsEnfVertex->second;
+//       MESSAGE("Update enf vertex name from " << oldEnfVertex.name << " to " << newEnfVertex.name);
+//       MESSAGE("Update enf vertex group name from " << oldEnfVertex.grpName << " to " << newEnfVertex.grpName);
+// 
+//       // update _faceEntryEnfVertexListMap
+//       TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
+//       for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) {
+//         if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
+//           currentEnfVertexList.erase(it);
+//           currentEnfVertexList.insert(newEnfVertex);
+//           break;
+//         }
+//       }
+// 
+//       // update _enfVertexList
+//       for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) {
+//         
+//         if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
+//           
+//           _enfVertexList.erase(it);
+//           _enfVertexList.insert(newEnfVertex);
+//           break;
+//         }
+//       }
+// 
+//       // update _coordsEnfVertexMap
+//       _coordsEnfVertexMap[newEnfVertex.coords] = newEnfVertex;
+// 
+//       toNotify = true;
+//     }
+//     if (it_CoordsEnfVertex->second.grpName != theGroupName) {
+//       MESSAGE("Update enf vertex group name from " << it_CoordsEnfVertex->second.grpName << " to " << theGroupName);
+//       oldEnfVertex = it_CoordsEnfVertex->second;
+// 
+//       // update _faceEntryEnfVertexListMap
+//       TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
+//       for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) {
+//         if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
+//           currentEnfVertexList.erase(it);
+//           currentEnfVertexList.insert(newEnfVertex);
+//           break;
+//         }
+//       }
+// 
+//       // update _enfVertexList
+//       for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) {
+//         if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
+//           _enfVertexList.erase(it);
+//           _enfVertexList.insert(newEnfVertex);
+//           break;
+//         }
+//       }
+// 
+//       // update _coordsEnfVertexMap
+//       _coordsEnfVertexMap[newEnfVertex.coords] = newEnfVertex;
+//       toNotify = true;
+//     }
+//   }
+// 
+//   // If "selected" enf vertex (theVertexEntry!="") maybe an existing enf vertex needs to be update with new group name
+//   TEnfVertexEntryEnfVertexMap::iterator it_EnfEntryEnfVertex = _enfVertexEntryEnfVertexMap.find(theVertexEntry);
+//   if (it_EnfEntryEnfVertex != _enfVertexEntryEnfVertexMap.end()) {
+//     toCreate = false;
+//     if (it_EnfEntryEnfVertex->second.grpName != theGroupName) {
+//       oldEnfVertex = it_EnfEntryEnfVertex->second;
+//       MESSAGE("Update enf vertex group name from " << oldEnfVertex.grpName << " to " << newEnfVertex.grpName);
+// 
+//       // update _faceEntryEnfVertexListMap
+//       TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
+//       for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) {
+//         if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
+//           currentEnfVertexList.erase(it);
+//           currentEnfVertexList.insert(newEnfVertex);
+//           break;
+//         }
+//       }
+// 
+//       // update _enfVertexList
+//       for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) {
+//         if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
+//           _enfVertexList.erase(it);
+//           _enfVertexList.insert(newEnfVertex);
+//           break;
+//         }
+//       }
+// 
+//       _enfVertexEntryEnfVertexMap[theVertexEntry] = newEnfVertex;
+// 
+//       toNotify = true;
+//     }
+//   }
+
+//   //////// CREATE ////////////
+//   if (toCreate) {
+//     MESSAGE("Creating new enforced vertex");
+//     std::pair<TEnfVertexList::iterator, bool> res = _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex);
+//     toNotify = res.second;
+// 
+//     if (toNotify) {
+//       _enfVertexList.insert(newEnfVertex);
+//       if (theVertexEntry == "") {
+//         _faceEntryCoordsListMap[theFaceEntry].insert(newEnfVertex.coords);
+//         _coordsEnfVertexMap[newEnfVertex.coords] = newEnfVertex;
+//       } else {
+//         _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(newEnfVertex.geomEntry);
+//         _enfVertexEntryEnfVertexMap[newEnfVertex.geomEntry] = newEnfVertex;
+//       }
+//     }
+//   }
+// 
+//   if (toNotify)
+//     NotifySubMeshesHypothesisModification();
+// 
+//   MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END");
+//   return toNotify;
+// }
 
 //=======================================================================
 //function : GetEnforcedVertices
@@ -584,7 +714,7 @@ BLSURFPlugin_Hypothesis::TEntryList BLSURFPlugin_Hypothesis::GetEnfVertexEntryLi
 //function : GetEnfVertex(TEnfVertexCoords coords)
 //=======================================================================
 
-BLSURFPlugin_Hypothesis::TEnfVertex BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVertexCoords coords)
+BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVertexCoords coords)
     throw (std::invalid_argument) {
 
   if (_coordsEnfVertexMap.count(coords) > 0)
@@ -599,7 +729,7 @@ BLSURFPlugin_Hypothesis::TEnfVertex BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVe
 //function : GetEnfVertex(const TEntry& theEnfVertexEntry)
 //=======================================================================
 
-BLSURFPlugin_Hypothesis::TEnfVertex BLSURFPlugin_Hypothesis::GetEnfVertex(const TEntry& theEnfVertexEntry)
+BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(const TEntry& theEnfVertexEntry)
     throw (std::invalid_argument) {
 
   if (_enfVertexEntryEnfVertexMap.count(theEnfVertexEntry) > 0)
@@ -619,7 +749,7 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, do
 
   bool toNotify = false;
   std::ostringstream msg;
-  TEnfVertex oldEnfVertex;
+  TEnfVertex *oldEnfVertex;
   TEnfVertexCoords coords;
   coords.clear();
   coords.push_back(x);
@@ -632,10 +762,6 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, do
     // Success
     MESSAGE("Found enforced vertex with geom entry " << theVertexEntry);
     oldEnfVertex = it_enfVertexEntry->second;
-//    oldEnfVertex.name = it_enfVertexEntry->second.name;
-//    oldEnfVertex.geomEntry = it_enfVertexEntry->second.geomEntry;
-//    oldEnfVertex.grpName = it_enfVertexEntry->second.grpName;
-//    oldEnfVertex.coords = it_enfVertexEntry->second.coords;
 
     _enfVertexEntryEnfVertexMap.erase(it_enfVertexEntry);
 
@@ -648,7 +774,6 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, do
     //    it_entry_entry->second.erase(it_entryList);
     //    if (it_entry_entry->second.size() == 0)
     //      _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
-
   } else {
     // Fail
     MESSAGE("Enforced vertex with geom entry " << theVertexEntry << " not found");
@@ -671,7 +796,6 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, do
       //      it_entry_coords->second.erase(it_coordsList);
       //      if (it_entry_coords->second.size() == 0)
       //        _faceEntryCoordsListMap.erase(it_entry_coords);
-
     } else {
       // Fail
       MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found");
@@ -684,24 +808,38 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, do
   MESSAGE("Remove enf vertex from _enfVertexList");
 
   // update _enfVertexList
-  for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) {
-    if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
+  TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
+  if (it != _enfVertexList.end()) {
+    (*it)->faceEntries.erase(theFaceEntry);
+    if ((*it)->faceEntries.size() == 0){
       _enfVertexList.erase(it);
       toNotify = true;
-      MESSAGE("Done");
-      break;
     }
+    MESSAGE("Done");
   }
+  
+//   for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) {
+//     if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
+//       (*it).faceEntries.erase(theFaceEntry);
+//       if ((*it).faceEntries.size() == 0){
+//         _enfVertexList.erase(it);
+//         toNotify = true;
+//       }
+//       MESSAGE("Done");
+//       break;
+//     }
+//   }
 
   // update _faceEntryEnfVertexListMap
   TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
-  for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) {
-    if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
-      currentEnfVertexList.erase(it);
-      toNotify = true;
-      break;
-    }
-  }
+  currentEnfVertexList.erase(oldEnfVertex);
+//   for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) {
+//     if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
+//       currentEnfVertexList.erase(it);
+//       toNotify = true;
+//       break;
+//     }
+//   }
   if (currentEnfVertexList.size() == 0) {
     MESSAGE("Remove _faceEntryEnfVertexListMap[" << theFaceEntry <<"]");
     _faceEntryEnfVertexListMap.erase(theFaceEntry);
@@ -721,7 +859,7 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, do
 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument) {
 
   bool toNotify = false;
-  TEnfVertex enfVertex;
+  TEnfVertex *oldEnfVertex;
 
   TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
   if (it_entry_coords != _faceEntryCoordsListMap.end()) {
@@ -730,9 +868,26 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry)
     TEnfVertexCoordsList::iterator it_coordsList = coordsList.begin();
     for (; it_coordsList != coordsList.end(); ++it_coordsList) {
       TEnfVertexCoords coords = (*it_coordsList);
-      enfVertex = _coordsEnfVertexMap[coords];
-      _enfVertexList.erase(enfVertex);
+      oldEnfVertex = _coordsEnfVertexMap[coords];
       _coordsEnfVertexMap.erase(coords);
+      // update _enfVertexList
+      TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
+      if (it != _enfVertexList.end()) {
+        (*it)->faceEntries.erase(theFaceEntry);
+        if ((*it)->faceEntries.size() == 0){
+          _enfVertexList.erase(it);
+          toNotify = true;
+        }
+        MESSAGE("Done");
+      }
+//       for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) {
+//         if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
+//           (*it).faceEntries.erase(theFaceEntry);
+//           if ((*it).faceEntries.size() == 0)
+//             _enfVertexList.erase(it);
+//           break;
+//         }
+//       }
     }
     _faceEntryCoordsListMap.erase(it_entry_coords);
     _faceEntryEnfVertexListMap.erase(theFaceEntry);
@@ -745,9 +900,26 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry)
     TEntryList::iterator it_enfVertexEntryList = enfVertexEntryList.begin();
     for (; it_enfVertexEntryList != enfVertexEntryList.end(); ++it_enfVertexEntryList) {
       TEntry enfVertexEntry = (*it_enfVertexEntryList);
-      enfVertex = _enfVertexEntryEnfVertexMap[enfVertexEntry];
-      _enfVertexList.erase(enfVertex);
+      oldEnfVertex = _enfVertexEntryEnfVertexMap[enfVertexEntry];
       _enfVertexEntryEnfVertexMap.erase(enfVertexEntry);
+      // update _enfVertexList
+      TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
+      if (it != _enfVertexList.end()) {
+        (*it)->faceEntries.erase(theFaceEntry);
+        if ((*it)->faceEntries.size() == 0){
+          _enfVertexList.erase(it);
+          toNotify = true;
+        }
+        MESSAGE("Done");
+      }
+//       for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) {
+//         if (TEnfVertexCmp(&(*it),&oldEnfVertex)) {
+//           (*it).faceEntries.erase(theFaceEntry);
+//           if ((*it).faceEntries.size() == 0)
+//             _enfVertexList.erase(it);
+//           break;
+//         }
+//       }
     }
     _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
     _faceEntryEnfVertexListMap.erase(theFaceEntry);
@@ -854,18 +1026,18 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
       TEnfVertexList enfVertexList = it_enf->second;
       TEnfVertexList::const_iterator it_enfVertexList = enfVertexList.begin();
       for (; it_enfVertexList != enfVertexList.end(); ++it_enfVertexList) {
-        TEnfVertex enfVertex = (*it_enfVertexList);
-        save << " " << enfVertex.name << ";";
-        save << " " << enfVertex.geomEntry << ";";
-        if (enfVertex.coords.size()) {
-          save << " " << enfVertex.coords[0] << ";";
-          save << " " << enfVertex.coords[1] << ";";
-          save << " " << enfVertex.coords[2] << ";";
+        TEnfVertex *enfVertex = (*it_enfVertexList);
+        save << " " << enfVertex->name << ";";
+        save << " " << enfVertex->geomEntry << ";";
+        if (enfVertex->coords.size()) {
+          save << " " << enfVertex->coords[0] << ";";
+          save << " " << enfVertex->coords[1] << ";";
+          save << " " << enfVertex->coords[2] << ";";
         }
         else {
           save <<" ; ; ;";
         }
-        save << " " << enfVertex.grpName;
+        save << " " << enfVertex->grpName;
         save << " " << "$"; // "$" is a mark of enforced vertex end
       }
       save << "#"; // "#" is a mark of enforced shape end
@@ -1119,13 +1291,13 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
       TEnfVertexCoordsList & coordsList = _faceEntryCoordsListMap[enfVertexEntry];
       coordsList.clear();
       TEnfVertexCoords coords;
-      TEnfVertex enfVertex;
+      TEnfVertex *enfVertex;
 
       // continue reading until "#" encountered
       while (enfValue[len4 - 1] != '#') {
         // New vector begin
         coords.clear();
-        enfVertex.coords.clear();
+        enfVertex->coords.clear();
 
         while (enfValue[len4 - 1] != '$') {
           isOK = (load >> enfValue);
@@ -1161,25 +1333,25 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
             if (enfValue[len4 - 1] != '$') {
               // Add to vertex
               // name
-              enfVertex.name = enfValue;
+              enfVertex->name = enfValue;
               isOK = (load >> enfValue);
               len4 = enfValue.size();
             }
             if (enfValue[len4 - 1] != '$') {
               // X coord
-              enfVertex.coords.push_back(atof(enfValue.c_str()));
+              enfVertex->coords.push_back(atof(enfValue.c_str()));
               isOK = (load >> enfValue);
               len4 = enfValue.size();
             }
             if (enfValue[len4 - 1] != '$') {
               // Y coord
-              enfVertex.coords.push_back(atof(enfValue.c_str()));
+              enfVertex->coords.push_back(atof(enfValue.c_str()));
               isOK = (load >> enfValue);
               len4 = enfValue.size();
             }
             if (enfValue[len4 - 1] != '$') {
               // Z coord
-              enfVertex.coords.push_back(atof(enfValue.c_str()));
+              enfVertex->coords.push_back(atof(enfValue.c_str()));
               isOK = (load >> enfValue);
               len4 = enfValue.size();
             }
@@ -1198,11 +1370,11 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
            }
            */
           enfValue[len4 - 1] = '\0'; //cut off "$#"
-          enfVertex.coords.push_back(atof(enfValue.c_str()));
+          enfVertex->coords.push_back(atof(enfValue.c_str()));
           MESSAGE("Add vertex to list");
           // Add vertex to list of vertex
-          coordsList.insert(enfVertex.coords);
-          _coordsEnfVertexMap[enfVertex.coords] = enfVertex;
+          coordsList.insert(enfVertex->coords);
+          _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
           //           _enfVertexList.insert(enfVertex);
         }
       }
@@ -1216,10 +1388,10 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
          */
         // Remove '$#' and add to vertex
         enfValue[len4 - 2] = '\0'; //cut off "$#"
-        enfVertex.coords.push_back(atof(enfValue.c_str()));
+        enfVertex->coords.push_back(atof(enfValue.c_str()));
         // Add vertex to list of vertex
-        coordsList.insert(enfVertex.coords);
-        _coordsEnfVertexMap[enfVertex.coords] = enfVertex;
+        coordsList.insert(enfVertex->coords);
+        _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
         //         _enfVertexList.insert(enfVertex);
       }
     } else
index 7019f0086b5ec1cb57f373be7ddc1a2c5968c9df..15d717602af8482a4aa4c66ee6cdd40da5755e9e 100644 (file)
@@ -148,34 +148,42 @@ public:
   typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList;
 
   // Enforced vertex
-  typedef struct TEnfVertex{
+  struct TEnfVertex {
     TEnfName name;
     TEntry geomEntry;
     TEnfVertexCoords coords;
     TEnfGroupName grpName;
-    //    TEntryList faceEntries; // any use ?
-  } TEnfVertex;
-  
+    TEntryList faceEntries;
+  };
+    
   struct CompareEnfVertices
   {
-    bool operator () (const TEnfVertex &e1, const TEnfVertex &e2) const
-      return true;
+    bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
+      if (e1 && e2) {
+        if (e1->coords.size() && e2->coords.size())
+          return (e1->coords < e2->coords);
+        else
+          return (e1->geomEntry < e2->geomEntry);
+      }
+      return false;
+    }
   };
 
+  // if coords or geom entry are identical => same enforced vertex
   int TEnfVertexCmp(const TEnfVertex *e1, const TEnfVertex *e2) {
     if (e1 && e2) {
       bool sameCoords = true;
       if (e1->coords.size() && e2->coords.size())
         sameCoords = (e1->coords[0] == e2->coords[0]) && (e1->coords[1] == e2->coords[1]) && (e1->coords[2]
             == e2->coords[2]);
-      return ( sameCoords && (e1->geomEntry == e2->geomEntry) && (e1->grpName == e2->grpName)
-          && (e1->name == e2->name));
-    } else
-      return (e1 < e2);
+      return ( sameCoords && (e1->geomEntry == e2->geomEntry));// && (e1->grpName == e2->grpName)
+//           && (e1->name == e2->name));
+    }
+    return false;
   }
 
   // List of enforced vertices
-  typedef std::set< TEnfVertex, CompareEnfVertices > TEnfVertexList;
+  typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
 
   // Map Face Entry / List of enforced vertices
   typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap;
@@ -187,10 +195,10 @@ public:
   typedef std::map< TEntry, TEntryList > TFaceEntryEnfVertexEntryListMap;
   
   // Map Coords / Enforced vertex
-  typedef std::map< TEnfVertexCoords, TEnfVertex > TCoordsEnfVertexMap;
+  typedef std::map< TEnfVertexCoords, TEnfVertex* > TCoordsEnfVertexMap;
 
   // Map Vertex entry / Enforced vertex
-  typedef std::map< TEntry, TEnfVertex > TEnfVertexEntryEnfVertexMap;
+  typedef std::map< TEntry, TEnfVertex* > TEnfVertexEntryEnfVertexMap;
 
   /* TODO GROUPS
   // Map Group Name / List of enforced vertices
@@ -200,14 +208,13 @@ public:
   
 //   TODO GROUPS
 //   void SetEnforcedVertex(const TEntry& entry, double x, double y, double z, const TEnfGroupName& groupName="");
-  bool                  SetEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0,
-                                          const TEnfName& theVertexName="", const TEntry& theVertexEntry="",
-                                          const TEnfGroupName& theGroupName="");
+  bool                  SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry, TEnfGroupName theGroupName,
+                                          double x = 0.0, double y = 0.0, double z = 0.0);
   TEnfVertexList        GetEnfVertexList(const TEntry& theFaceEntry) throw (std::invalid_argument);
   TEnfVertexCoordsList  GetEnfVertexCoordsList(const TEntry& theFaceEntry) throw (std::invalid_argument);
   TEntryList            GetEnfVertexEntryList (const TEntry& theFaceEntry) throw (std::invalid_argument);
-  TEnfVertex            GetEnfVertex(TEnfVertexCoords coords) throw (std::invalid_argument);
-  TEnfVertex            GetEnfVertex(const TEntry& theEnfVertexEntry) throw (std::invalid_argument);
+  TEnfVertex*           GetEnfVertex(TEnfVertexCoords coords) throw (std::invalid_argument);
+  TEnfVertex*           GetEnfVertex(const TEntry& theEnfVertexEntry) throw (std::invalid_argument);
   
   bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0, const TEntry& theVertexEntry="") throw (std::invalid_argument);
 //  bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0) throw (std::invalid_argument);
index e17b02bb660db1b0e863ee5cd0c67ad93351d034..1718e03a675960f1c9ad11108dfa7ce7eb65fc7a 100644 (file)
@@ -736,25 +736,35 @@ BLSURFPlugin::TFaceEntryEnfVertexListMap* BLSURFPlugin_Hypothesis_i::GetAllEnfor
     MESSAGE("Number of enf vertex: " << enfVertexList->length());
 
     ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator it_enfVertex = _enfVertexList.begin();
+    ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
     for (int j = 0; it_enfVertex != _enfVertexList.end(); ++it_enfVertex, ++j) {
+      currentEnfVertex = (*it_enfVertex);
 
       BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
 
       // Name
-      enfVertex->name = CORBA::string_dup(it_enfVertex->name.c_str());
+      enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
 
       // Geom entry
-      enfVertex->geomEntry = CORBA::string_dup(it_enfVertex->geomEntry.c_str());
+      enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
 
       // Coords
       BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
-      coords->length(it_enfVertex->coords.size());
+      coords->length(currentEnfVertex->coords.size());
       for (int i=0;i<coords->length();i++)
-        coords[i] = it_enfVertex->coords[i];
+        coords[i] = currentEnfVertex->coords[i];
       enfVertex->coords = coords;
 
       // Group name
-      enfVertex->grpName = CORBA::string_dup(it_enfVertex->grpName.c_str());
+      enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());
+      
+      // Face entry list
+      BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
+      faceEntryList->length(currentEnfVertex->faceEntries.size());
+      ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
+      for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
+        faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
+      enfVertex->faceEntries = faceEntryList;
 
       ostringstream msg;
       msg << "Enforced vertex: \n"
@@ -789,21 +799,30 @@ BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices(
   MESSAGE("Enforced Vertex map size is " << resultMap->length());
 
   ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin();
+  ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
   for (int i = 0; evlIt != enfVertexList.end(); ++evlIt, ++i) {
     MESSAGE("Enforced Vertex #" << i);
+    currentEnfVertex = (*evlIt);
     BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
     // Name
-    enfVertex->name = CORBA::string_dup(evlIt->name.c_str());
+    enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
     // Geom entry
-    enfVertex->geomEntry = CORBA::string_dup(evlIt->geomEntry.c_str());
+    enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
     // Coords
     BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
-    coords->length(evlIt->coords.size());
+    coords->length(currentEnfVertex->coords.size());
     for (int ind = 0; ind < coords->length(); ind++)
-      coords[ind] = evlIt->coords[ind];
+      coords[ind] = currentEnfVertex->coords[ind];
     enfVertex->coords = coords;
     // Group name
-    enfVertex->grpName = CORBA::string_dup(evlIt->grpName.c_str());
+    enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());  
+    // Face entry list
+    BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
+    faceEntryList->length(currentEnfVertex->faceEntries.size());
+    ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
+    for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
+      faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
+    enfVertex->faceEntries = faceEntryList;
 
     ostringstream msg;
     msg << "Enforced vertex: \n"
@@ -880,8 +899,10 @@ BLSURFPlugin::TCoordsEnfVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVert
   MESSAGE("Enforced Vertex map size is " << resultMap->length());
 
   ::BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap::const_iterator it_coords = coordsEnfVertexMap.begin();
+  ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
   for (int i = 0; it_coords != coordsEnfVertexMap.end(); ++it_coords, ++i) {
     MESSAGE("Enforced Vertex #" << i);
+    currentEnfVertex = (it_coords->second);
     BLSURFPlugin::TCoordsEnfVertexElement_var mapElement = new BLSURFPlugin::TCoordsEnfVertexElement();
     BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
     coords->length(it_coords->first.size());
@@ -892,17 +913,25 @@ BLSURFPlugin::TCoordsEnfVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVert
 
     BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
     // Name
-    enfVertex->name = CORBA::string_dup(it_coords->second.name.c_str());
+    enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
     // Geom entry
-    enfVertex->geomEntry = CORBA::string_dup(it_coords->second.geomEntry.c_str());
+    enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
     // Coords
     BLSURFPlugin::TEnfVertexCoords_var coords2 = new BLSURFPlugin::TEnfVertexCoords();
-    coords2->length(it_coords->second.coords.size());
+    coords2->length(currentEnfVertex->coords.size());
     for (int ind=0;ind<coords2->length();ind++)
-      coords2[ind] = it_coords->second.coords[ind];
+      coords2[ind] = currentEnfVertex->coords[ind];
     enfVertex->coords = coords2;
     // Group name
-    enfVertex->grpName = CORBA::string_dup(it_coords->second.grpName.c_str());
+    enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());  
+    // Face entry list
+    BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
+    faceEntryList->length(currentEnfVertex->faceEntries.size());
+    ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
+    for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
+      faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
+    enfVertex->faceEntries = faceEntryList;
+      
     mapElement->enfVertex = enfVertex;
     ostringstream msg;
     msg << "Enforced vertex: \n"
@@ -976,27 +1005,35 @@ BLSURFPlugin::TEnfVertexEntryEnfVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnfo
   resultMap->length(enfVertexEntryEnfVertexMap.size());
   MESSAGE("Enforced Vertex map size is " << resultMap->length());
 
-  ::BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap::const_iterator it_enfVertexEntry =
-      enfVertexEntryEnfVertexMap.begin();
+  ::BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap::const_iterator it_enfVertexEntry = enfVertexEntryEnfVertexMap.begin();
+  ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
   for (int i = 0; it_enfVertexEntry != enfVertexEntryEnfVertexMap.end(); ++it_enfVertexEntry, ++i) {
     MESSAGE("Enforced Vertex #" << i);
+    currentEnfVertex = it_enfVertexEntry->second;
     BLSURFPlugin::TEnfVertexEntryEnfVertexElement_var mapElement = new BLSURFPlugin::TEnfVertexEntryEnfVertexElement();
     mapElement->enfVertexEntry = CORBA::string_dup(it_enfVertexEntry->first.c_str());;
     MESSAGE("Enf Vertex Entry #" << i << ": " << mapElement->enfVertexEntry);
 
     BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
     // Name
-    enfVertex->name = CORBA::string_dup(it_enfVertexEntry->second.name.c_str());
+    enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
     // Geom entry
-    enfVertex->geomEntry = CORBA::string_dup(it_enfVertexEntry->second.geomEntry.c_str());
+    enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
     // Coords
     BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
-    coords->length(it_enfVertexEntry->second.coords.size());
+    coords->length(currentEnfVertex->coords.size());
     for (int ind=0;ind<coords->length();ind++)
-      coords[ind] = it_enfVertexEntry->second.coords[ind];
+      coords[ind] = currentEnfVertex->coords[ind];
     enfVertex->coords = coords;
     // Group name
-    enfVertex->grpName = CORBA::string_dup(it_enfVertexEntry->second.grpName.c_str());
+    enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());  
+    // Face entry list
+    BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
+    faceEntryList->length(currentEnfVertex->faceEntries.size());
+    ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
+    for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
+      faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
+    enfVertex->faceEntries = faceEntryList;
 
     ostringstream msg;
     msg << "Enforced vertex: \n"
@@ -1052,7 +1089,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr theFace,
   if (theFaceEntry == "")
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
   MESSAGE("IDL : GetName : " << theFace->GetName());
-  MESSAGE("IDL : SetEnforcedVertex ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ")");
+  MESSAGE("IDL : SetEnforcedVertex( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ")");
   try {
     return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z);
   } catch (SALOME_Exception& ex) {
@@ -1091,7 +1128,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamed(GEOM::GEOM_Object_ptr the
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
   
   MESSAGE("IDL : GetName : " << theFace->GetName());
-  MESSAGE("IDL : SetEnforcedVertex ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theVertexName << ")");
+  MESSAGE("IDL : SetEnforcedVertexNamed( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theVertexName << ")");
   try {
     return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, theVertexName);
   } catch (SALOME_Exception& ex) {
@@ -1161,7 +1198,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theF
   string theVertexName = theVertex->GetName();
   MESSAGE("IDL : theFace->GetName : " << theFace->GetName());
   MESSAGE("IDL : theVertex->GetName : " << theVertexName);
-  MESSAGE("IDL : SetEnforcedVertexGeom ( "<< theFaceEntry << ", " << theVertexEntry<< ")");
+  MESSAGE("IDL : SetEnforcedVertexGeom( "<< theFaceEntry << ", " << theVertexEntry<< ")");
   try {
     return SetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str());
   } catch (SALOME_Exception& ex) {
@@ -1170,37 +1207,149 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theF
 }
 
 /*!
- * Set/get/unset an enforced vertex with group name on face
+ * Set an enforced vertex with group name on face
  */
-/* TODO GROUPS
- void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGroup(GEOM::GEOM_Object_ptr theFace,
- CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName)
+bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName)
  throw (SALOME::SALOME_Exception)
- {
- ASSERT(myBaseImpl);
+{
 ASSERT(myBaseImpl);
 
- if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
- MESSAGE("theFace shape type is not FACE or COMPOUND");
- THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
- }
+  if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
+    MESSAGE("theFace shape type is not FACE or COMPOUND");
+    THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
+  }
+
+  string theFaceEntry = theFace->GetStudyEntry();
+  
+  if (theFaceEntry == "") {
+    GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
+    SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
+    string aName;
+    if (theFace->GetShapeType() == GEOM::FACE)
+      aName = "Face_";
+    if (theFace->GetShapeType() == GEOM::COMPOUND)
+      aName = "Compound_";
+    aName += theFace->GetEntry();
+    SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
+    if (!theSFace->_is_nil())
+      theFaceEntry = theSFace->GetID();
+  }
+  if (theFaceEntry == "")
+    THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
+  MESSAGE("IDL : GetName : " << theFace->GetName());
+  MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theGroupName << ")");
+  try {
+    return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, "", "", theGroupName);
+  } catch (SALOME_Exception& ex) {
+    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+  }
+}
 
- // TODO publish geom objects it not published
- string theFaceEntry = theFace->GetStudyEntry();
+/*!
+ * Set an enforced vertex with name and group name on face
+ */
+bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, 
+                                                                const char* theVertexName, const char* theGroupName)
+ throw (SALOME::SALOME_Exception)
+{
+  ASSERT(myBaseImpl);
 
- if (theFaceEntry == "")
- THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
+  if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
+    MESSAGE("theFace shape type is not FACE or COMPOUND");
+    THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
+  }
 
- MESSAGE("IDL : GetName : " << theFace->GetName());
- MESSAGE("IDL : SetEnforcedVertexGroup ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theGroupName <<")");
- try {
- SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, "", "", theGroupName.c_str());
- }
- catch (SALOME_Exception& ex) {
- THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
- }
- }
+  string theFaceEntry = theFace->GetStudyEntry();
+  
+  if (theFaceEntry == "") {
+    GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
+    SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
+    string aName;
+    if (theFace->GetShapeType() == GEOM::FACE)
+      aName = "Face_";
+    if (theFace->GetShapeType() == GEOM::COMPOUND)
+      aName = "Compound_";
+    aName += theFace->GetEntry();
+    SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
+    if (!theSFace->_is_nil())
+      theFaceEntry = theSFace->GetID();
+  }
+  if (theFaceEntry == "")
+    THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
+  MESSAGE("IDL : GetName : " << theFace->GetName());
+  MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theGroupName << ")");
+  try {
+    return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, theVertexName, "", theGroupName);
+  } catch (SALOME_Exception& ex) {
+    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+  }
+}
+
+/*!
+ * Set an enforced vertex with geom entry and group name on face
  */
+bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex, const char* theGroupName)
+ throw (SALOME::SALOME_Exception)
+{
+  ASSERT(myBaseImpl);
 
+  if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
+    MESSAGE("theFace shape type is not FACE or COMPOUND");
+    THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
+  }
+
+  if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
+    MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
+    THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
+  }
+
+  string theFaceEntry = theFace->GetStudyEntry();
+  string theVertexEntry = theVertex->GetStudyEntry();
+  
+  GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
+  SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
+  string aName;
+  
+  if (theFaceEntry == "") {
+    if (theFace->GetShapeType() == GEOM::FACE)
+      aName = "Face_";
+    if (theFace->GetShapeType() == GEOM::COMPOUND)
+      aName = "Compound_";
+    aName += theFace->GetEntry();
+    SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str());
+    if (!theSFace->_is_nil())
+      theFaceEntry = theSFace->GetID();
+  }
+  if (theFaceEntry == "")
+    THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
+  
+  if (theVertexEntry == "") {
+    if (theVertex->GetShapeType() == GEOM::VERTEX)
+      aName = "Vertex_";
+    if (theVertex->GetShapeType() == GEOM::COMPOUND)
+      aName = "Compound_";
+    aName += theVertex->GetEntry();
+    SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
+    if (!theSVertex->_is_nil())
+      theVertexEntry = theSVertex->GetID();
+  }
+  if (theVertexEntry == "")
+    THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
+
+  string theVertexName = theVertex->GetName();
+  MESSAGE("IDL : theFace->GetName : " << theFace->GetName());
+  MESSAGE("IDL : theVertex->GetName : " << theVertexName);
+  MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theFaceEntry << ", " << theVertexEntry<< ", " << theGroupName<< ")");
+  try {
+    return SetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName);
+  } catch (SALOME_Exception& ex) {
+    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+  }
+}
+
+/*!
+ * Get the list of all enforced vertices
+ */
 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr theFace)
     throw (SALOME::SALOME_Exception) {
   ASSERT(myBaseImpl);
@@ -1396,8 +1545,8 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* theFaceEntry,
         newValue = true;
       } else {
         MESSAGE("Coords already found, compare names");
-        ::BLSURFPlugin_Hypothesis::TEnfVertex enfVertex = this->GetImpl()->GetEnfVertex(coords);
-        if ((enfVertex.name != theVertexName) || (enfVertex.grpName != theGroupName)) {
+        ::BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex = this->GetImpl()->GetEnfVertex(coords);
+        if ((enfVertex->name != theVertexName) || (enfVertex->grpName != theGroupName)) {
           MESSAGE("The names are different: update");
 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
           newValue = true;
@@ -1412,11 +1561,16 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* theFaceEntry,
     }
     if (newValue)
       if (theVertexName == "")
-        SMESH::TPythonDump() << _this() << ".SetEnforcedVertex(" << theFaceEntry << ", " << x << ", " << y << ", " << z
-            << ")";
+        if (theGroupName == "")
+          SMESH::TPythonDump() << _this() << ".SetEnforcedVertex(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ")";
+        else
+          SMESH::TPythonDump() << _this() << ".SetEnforcedVertexWithGroup(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theGroupName << "\")";
       else
-        SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamed(" << theFaceEntry << ", " << x << ", " << y << ", "
-            << z << ", \"" << theVertexName << "\")";
+        if (theGroupName == "")
+          SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamed(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\")";
+        else
+          SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamedWithGroup(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" 
+                                          << theVertexName << ", \"" << theGroupName << "\")";
   } else {
     try {
       ::BLSURFPlugin_Hypothesis::TEntryList enfVertexEntryList = this->GetImpl()->GetEnfVertexEntryList(theFaceEntry);
@@ -1431,11 +1585,14 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* theFaceEntry,
       newValue = true;
     }
     if (newValue)
-      SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeom(" << theFaceEntry << ", " << theVertexEntry << ")";
+        if (theGroupName == "")
+          SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeom(" << theFaceEntry << ", " << theVertexEntry << ")";
+        else
+          SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeomWithGroup(" << theFaceEntry << ", " << theVertexEntry << ", \"" << theGroupName << "\")";
   }
 
   if (newValue)
-    this->GetImpl()->SetEnforcedVertex(theFaceEntry, x, y, z, theVertexName, theVertexEntry, theGroupName);
+    this->GetImpl()->SetEnforcedVertex(theFaceEntry, theVertexName, theVertexEntry, theGroupName, x, y, z);
 
   MESSAGE("IDL : SetEnforcedVertexEntry END");
   return newValue;
@@ -1453,22 +1610,29 @@ BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntr
     MESSAGE("Number of enforced vertices: " << vertexList->length());
     ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = _vList.begin();
     for (int i = 0; evlIt != _vList.end(); ++evlIt, ++i) {
-      ::BLSURFPlugin_Hypothesis::TEnfVertex _enfVertex = (*evlIt);
+      ::BLSURFPlugin_Hypothesis::TEnfVertex *_enfVertex = (*evlIt);
 
       BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
 
       // Name
-      enfVertex->name = CORBA::string_dup(_enfVertex.name.c_str());
+      enfVertex->name = CORBA::string_dup(_enfVertex->name.c_str());
       // Geom Vertex Entry
-      enfVertex->geomEntry = CORBA::string_dup(_enfVertex.geomEntry.c_str());
+      enfVertex->geomEntry = CORBA::string_dup(_enfVertex->geomEntry.c_str());
       // Coords
       BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
-      coords->length(_enfVertex.coords.size());
+      coords->length(_enfVertex->coords.size());
       for (int ind=0;ind<coords->length();ind++)
-        coords[ind] = _enfVertex.coords[ind];
+        coords[ind] = _enfVertex->coords[ind];
       enfVertex->coords = coords;
       // Group Name
-      enfVertex->grpName = CORBA::string_dup(_enfVertex.grpName.c_str());
+      enfVertex->grpName = CORBA::string_dup(_enfVertex->grpName.c_str());
+      // Face entry list
+      BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
+      faceEntryList->length(_enfVertex->faceEntries.size());
+      ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = _enfVertex->faceEntries.begin();
+      for (int ind = 0; it_entry != _enfVertex->faceEntries.end();++it_entry, ++ind)
+        faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
+      enfVertex->faceEntries = faceEntryList;
 
       vertexList[i] = enfVertex;
     }
index 6553cd40b0c2344ce8521631042bfc2f9a8e0947..6de292d3bfb901779f1c3b2ce47531785413cd27 100644 (file)
@@ -154,14 +154,16 @@ public:
    */
   bool SetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z)
       throw (SALOME::SALOME_Exception);
-  bool SetEnforcedVertexNamed(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z,
-      const char* theVertexName = "") throw (SALOME::SALOME_Exception);
+  bool SetEnforcedVertexNamed(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theVertexName)
+      throw (SALOME::SALOME_Exception);
   bool SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex)
       throw (SALOME::SALOME_Exception);
-  //   TODO GROUPS
-  //   void SetEnforcedVertexGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName) throw (SALOME::SALOME_Exception);
-  //   void SetEnforcedVertexNamedGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName, const char* theVertexName = "") throw (SALOME::SALOME_Exception);
-  //   void SetEnforcedVertexGeomGroup(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex, const char* theGroupName) throw (SALOME::SALOME_Exception);
+  bool SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName)
+      throw (SALOME::SALOME_Exception);
+  bool SetEnforcedVertexNamedWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theVertexName, const char* theGroupName)
+      throw (SALOME::SALOME_Exception);
+  bool SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex, const char* theGroupName)
+      throw (SALOME::SALOME_Exception);
 
   BLSURFPlugin::TEnfVertexList* GetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) throw (SALOME::SALOME_Exception);
 
@@ -177,21 +179,13 @@ public:
   bool SetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x = 0, CORBA::Double y = 0, CORBA::Double z = 0,
       const char* theVertexName = "", const char* theVertexEntry = "", const char* theGroupName = "")
       throw (SALOME::SALOME_Exception);
-  //  bool SetEnforcedVertexEntryNamed(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theVertexName="") throw (SALOME::SALOME_Exception);
-  //  bool SetEnforcedVertexEntryGeom(const char* theFaceEntry, const char* theVertexEntry, const char* theVertexName) throw (SALOME::SALOME_Exception);
 
   BLSURFPlugin::TEnfVertexList* GetEnforcedVerticesEntry(const char* theFaceEntry) throw (SALOME::SALOME_Exception);
 
   bool UnsetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z,
       const char* theVertexEntry = "") throw (SALOME::SALOME_Exception);
-  //  bool UnsetEnforcedVertexEntryGeom(const char* theFaceEntry, const char* theVertexEntry)
-  //      throw (SALOME::SALOME_Exception);
   bool UnsetEnforcedVerticesEntry(const char* theFaceEntry) throw (SALOME::SALOME_Exception);
 
-  bool _setEnfVertex(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z,
-      const char* theVertexEntry = "", const char* enfName = "", const char* theGroupName = "");
-  bool _unsetEnfVertex(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z);
-
   /*!
    * Set/get node group to an enforced vertex
    */
index bb7d0e230cb9301f76eaeea86933d90da7c8b22c..797c88ebc1e616e0bc2c77ac046a6e2acd117a68 100644 (file)
@@ -118,7 +118,7 @@ enum {
   ENF_VER_Y_COLUMN,
   ENF_VER_Z_COLUMN,
   ENF_VER_ENTRY_COLUMN,
-//   ENF_VER_GROUP_COLUMN,
+  ENF_VER_GROUP_COLUMN,
   ENF_VER_NB_COLUMNS
 };
 
@@ -141,11 +141,11 @@ enum {
   ENF_VER_X_COORD,
   ENF_VER_Y_COORD,
   ENF_VER_Z_COORD,
-//   ENF_VER_GROUP,
+  ENF_VER_GROUP,
   ENF_VER_VERTEX_BTN,
   ENF_VER_REMOVE_BTN,
 //   ENF_VER_SEPARATOR,
-//   ENF_VER_GROUP_CHECK,
+  ENF_VER_GROUP_CHECK,
   ENF_VER_NB_LINES
 };
 
@@ -181,9 +181,9 @@ PyStdOut_write(PyStdOut *self, PyObject *args)
   return Py_None;
 }
 
-static PyMethodDef PyStdOut_methods[] = {
+static PyMethodDef PyStdOut_methods[] = { 
   {"write",  (PyCFunction)PyStdOut_write,  METH_VARARGS,
-    PyDoc_STR("write(string) -> None")},
+  PyDoc_STR("write(string) -> None")},
   {NULL,    NULL}   /* sentinel */
 };
 
@@ -270,17 +270,23 @@ QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
                                               const QStyleOptionViewItem & option ,
                                               const QModelIndex & index ) const
 {
+//   QModelIndex father = index.parent();
+//   QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
+  
   if (index.column() == ENF_VER_X_COLUMN || \
-    index.column() == ENF_VER_Y_COLUMN || \
-    index.column() == ENF_VER_Z_COLUMN)
+      index.column() == ENF_VER_Y_COLUMN || \
+      index.column() == ENF_VER_Z_COLUMN)
   {
     SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
     editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
+//     editor->setEnabled(entry.isEmpty());
     return editor;
   }
   else
   {
     QLineEdit *editor = new QLineEdit(parent);
+//     if (index.column() != ENF_VER_GROUP_COLUMN)
+//       editor->setEnabled(entry.isEmpty());
     return editor;
   }
 
@@ -289,31 +295,14 @@ QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
 void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor,
                                            const QModelIndex &index) const
 {
-  QModelIndex parent = index.parent();
-  QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
   QString value = index.model()->data(index, Qt::EditRole).toString();
+
   if (index.column() == ENF_VER_X_COLUMN ||
       index.column() == ENF_VER_Y_COLUMN ||
       index.column() == ENF_VER_Z_COLUMN)
   {
-    // If no entry for current index => manual enforced vertex
-    // Editor is a SMESHGUI_SpinBox
-    if (entry.isEmpty()) {
-      SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
-      lineEdit->setText(value);
-    } else {
-      // If there is an entry => selected enforced vertexEntry
-      // Editor is a read-only QLineEdit
-      QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
-      lineEdit->setText("");
-      lineEdit->setReadOnly(true);
-    }
-  } else if ((entry.isEmpty()) && (index.column() == ENF_VER_NAME_COLUMN)) {
-    // If there is an entry => selected enforced vertexEntry
-    // Editor is a read-only QLineEdit
-    QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
+    SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
     lineEdit->setText(value);
-    lineEdit->setReadOnly(true);
   }
   else {
     QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
@@ -324,28 +313,26 @@ void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor,
 void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
                                           const QModelIndex &index) const
 {
-  if (index.column() == ENF_VER_X_COLUMN || \
-    index.column() == ENF_VER_Y_COLUMN || \
-    index.column() == ENF_VER_Z_COLUMN)
-  {
+  QModelIndex parent = index.parent();
+  QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
+  if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || index.column() == ENF_VER_Z_COLUMN) {
     SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
-    if (! vertexExists(model, index, lineEdit->GetString())) {
+    if (entry.isEmpty() && !vertexExists(model, index, lineEdit->GetString()))
       model->setData(index, lineEdit->GetValue(), Qt::EditRole);
-    }
   } else if (index.column() == ENF_VER_NAME_COLUMN) {
     QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
     QString value = lineEdit->text();
-    if (! vertexExists(model, index, value)) {
+    if (entry.isEmpty() && !vertexExists(model, index, value))
       model->setData(index, value, Qt::EditRole);
-    }
-  }
-  /* TODO GROUPS
-  else if (index.column() == ENF_VER_GROUP_COLUMN) {
+  } else if (index.column() == ENF_VER_ENTRY_COLUMN) {
+    QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
+    QString value = lineEdit->text();
+    if (! vertexExists(model, index, value))
+      model->setData(index, value, Qt::EditRole);
+  } else if (index.column() == ENF_VER_GROUP_COLUMN) {
     QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
     model->setData(index, lineEdit->text(), Qt::EditRole);
-//     MESSAGE("Value " << value.toString().toStdString() << " was set at index(" << index.row() << "," << index.column() << ")");
   }
-  */
 }
 
 void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor,
@@ -430,6 +417,75 @@ bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model,
 // END EnforcedTreeWidgetDelegate
 //
 
+//
+// BEGIN BLSURFPluginGUI_ObjectReferenceParamWdg
+//
+//================================================================================
+
+// BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg
+// ( SUIT_SelectionFilter* f, QWidget* parent, bool multiSelection)
+//   : StdMeshersGUI_ObjectReferenceParamWdg(f, parent, multiSelection)
+// {
+//   init();
+// }
+// 
+// 
+// BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg
+// ( MeshObjectType objType, QWidget* parent, bool multiSelection )
+//   : StdMeshersGUI_ObjectReferenceParamWdg( objType, parent, multiSelection )
+// {
+//   init();
+// }
+// 
+// BLSURFPluginGUI_ObjectReferenceParamWdg::~BLSURFPluginGUI_ObjectReferenceParamWdg()
+// {
+//   if ( myFilter )
+//   {
+//     mySelectionMgr->removeFilter( myFilter );
+//     delete myFilter;
+//   }
+// }
+// 
+// void BLSURFPluginGUI_ObjectReferenceParamWdg::init()
+// {
+//   StdMeshersGUI_ObjectReferenceParamWdg::init();
+//   disconnect( mySelButton, SIGNAL(clicked()), SLOT(activateSelection()));
+//   connect( mySelButton, SIGNAL(toggled(bool)), SLOT(setActivationStatus(bool)));
+// }
+// 
+// void BLSURFPluginGUI_ObjectReferenceParamWdg::setActivationStatus(bool status)
+// {
+//   if (status)
+//     activateSelection();
+//   else
+//     deactivateSelection();
+// }
+// 
+// void BLSURFPluginGUI_ObjectReferenceParamWdg::activateSelectionOnly()
+// {
+//   if ( !mySelectionActivated && mySelectionMgr )
+//   {
+//     mySelectionActivated = true;
+//     mySelectionMgr->clearFilters();
+//     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+//       aViewWindow->SetSelectionMode(ActorSelection);
+//     if ( myFilter )
+//       mySelectionMgr->installFilter( myFilter );
+//     connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
+//   }
+//   emit selectionActivated();
+// }
+// 
+// void BLSURFPluginGUI_ObjectReferenceParamWdg::deactivateSelectionOnly()
+// {
+//   mySelectionActivated = false;
+//   disconnect(mySelectionMgr, 0, this, 0 );
+//   mySelectionMgr->removeFilter( myFilter );
+// }
+// 
+//
+// END BLSURFPluginGUI_ObjectReferenceParamWdg
+//
 
 /**
  * \brief {BLSURFPluginGUI_HypothesisCreator constructor}
@@ -763,10 +819,8 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   QStringList enforcedHeaders;
   enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN")
                   << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN")
-                  << tr("BLSURF_ENF_VER_ENTRY_COLUMN");
-  /* TODO GROUPS
-  << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
-  */
+                  << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
+
   myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
   myEnforcedTreeWidget->setAlternatingRowColors(true);
   myEnforcedTreeWidget->setUniformRowHeights(true);
@@ -780,7 +834,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
   myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
   myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
-
+  
 // FACE AND VERTEX SELECTION
   TColStd_MapOfInteger shapeTypes1, shapeTypes2;
   shapeTypes1.Add( TopAbs_FACE );
@@ -810,10 +864,8 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
   myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
 
-  /* TODO GROUPS
   QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
   myGroupName = new QLineEdit(myEnfGroup);
-  */
 
   addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
 //   QFrame *line = new QFrame(myEnfGroup);
@@ -821,7 +873,6 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
 //   line->setFrameShadow(QFrame::Sunken);
   removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
 
-  /* TODO GROUPS
   // CheckBox for groups generation
   makeGroupsCheck = new QGroupBox(tr("BLSURF_ENF_VER_GROUPS"), myEnfGroup);
   makeGroupsCheck->setCheckable(true);
@@ -829,30 +880,26 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   QGridLayout* aGroupLayout = new QGridLayout(makeGroupsCheck);
   myGlobalGroupName = new QLineEdit(makeGroupsCheck);
   aGroupLayout->addWidget(myGlobalGroupName);
-  */
-
 
   anEnfLayout->addWidget(myEnforcedTreeWidget,     0, 0, ENF_VER_NB_LINES+1, 1);
+  QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
 //  FACE AND VERTEX SELECTION
-  anEnfLayout->addWidget(myEnfFaceWdg,             ENF_VER_FACE, 1, 1, 2);
-  anEnfLayout->addWidget(myEnfVertexWdg,           ENF_VER_VERTEX, 1, 1, 2);
-
-  anEnfLayout->addWidget(myXCoordLabel,            ENF_VER_X_COORD, 1, 1, 1);
-  anEnfLayout->addWidget(myXCoord,                 ENF_VER_X_COORD, 2, 1, 1);
-  anEnfLayout->addWidget(myYCoordLabel,            ENF_VER_Y_COORD, 1, 1, 1);
-  anEnfLayout->addWidget(myYCoord,                 ENF_VER_Y_COORD, 2, 1, 1);
-  anEnfLayout->addWidget(myZCoordLabel,            ENF_VER_Z_COORD, 1, 1, 1);
-  anEnfLayout->addWidget(myZCoord,                 ENF_VER_Z_COORD, 2, 1, 1);
-  /* TODO GROUPS
-  anEnfLayout->addWidget(myGroupNameLabel,         ENF_VER_GROUP, 1, 1, 1);
-  anEnfLayout->addWidget(myGroupName,              ENF_VER_GROUP, 2, 1, 1);
-  */
-  anEnfLayout->addWidget(addVertexButton,          ENF_VER_VERTEX_BTN, 1, 1, 2);
-  anEnfLayout->addWidget(removeVertexButton,       ENF_VER_REMOVE_BTN, 1, 1, 2);
-//   anEnfLayout->addWidget(line,                     ENF_VER_SEPARATOR, 1, 1, 2);
-  /* TODO GROUPS
-  anEnfLayout->addWidget(makeGroupsCheck,          ENF_VER_GROUP_CHECK, 1, 1, 2);
-  */
+  anEnfLayout2->addWidget(myEnfFaceWdg,             ENF_VER_FACE, 0, 1, 2);
+  anEnfLayout2->addWidget(myEnfVertexWdg,           ENF_VER_VERTEX, 0, 1, 2);
+
+  anEnfLayout2->addWidget(myXCoordLabel,            ENF_VER_X_COORD, 0, 1, 1);
+  anEnfLayout2->addWidget(myXCoord,                 ENF_VER_X_COORD, 1, 1, 1);
+  anEnfLayout2->addWidget(myYCoordLabel,            ENF_VER_Y_COORD, 0, 1, 1);
+  anEnfLayout2->addWidget(myYCoord,                 ENF_VER_Y_COORD, 1, 1, 1);
+  anEnfLayout2->addWidget(myZCoordLabel,            ENF_VER_Z_COORD, 0, 1, 1);
+  anEnfLayout2->addWidget(myZCoord,                 ENF_VER_Z_COORD, 1, 1, 1);
+  anEnfLayout2->addWidget(myGroupNameLabel,         ENF_VER_GROUP, 0, 1, 1);
+  anEnfLayout2->addWidget(myGroupName,              ENF_VER_GROUP, 1, 1, 1);
+  anEnfLayout2->addWidget(addVertexButton,          ENF_VER_VERTEX_BTN, 0, 1, 2);
+  anEnfLayout2->addWidget(removeVertexButton,       ENF_VER_REMOVE_BTN, 0, 1, 2);
+//   anEnfLayout->addWidget(line,                     ENF_VER_SEPARATOR, 0, 1, 2);
+  anEnfLayout2->addWidget(makeGroupsCheck,          ENF_VER_GROUP_CHECK, 0, 1, 2);
+  anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
 
   // ---
   tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
@@ -876,14 +923,14 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   connect( mySizeMapTable,     SIGNAL( cellChanged ( int, int  )),    this,         SLOT( onSetSizeMap(int,int ) ) );
 
   connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
-  connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) );
+  connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
   connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ),     this,         SLOT( synchronizeCoords() ) );
   connect( addVertexButton,    SIGNAL( clicked()),                    this,         SLOT( onAddEnforcedVertices() ) );
   connect( removeVertexButton, SIGNAL( clicked()),                    this,         SLOT( onRemoveEnforcedVertex() ) );
   connect( myEnfVertexWdg,     SIGNAL( contentModified()),            this,         SLOT( onSelectEnforcedVertex() ) );
 //   connect( myEnfVertexWdg,     SIGNAL( selectionActivated()),         this,         SLOT( onVertexSelectionActivated() ) );
 //   connect( myEnfFaceWdg,       SIGNAL( selectionActivated()),         this,         SLOT( onFaceSelectionActivated() ) );
-  connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(deactivateSelection(QWidget*, QWidget*)));
+//   connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(deactivateSelection(QWidget*, QWidget*)));
 
   return fr;
 }
@@ -893,7 +940,8 @@ This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParam
 */
 void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now)
 {
-  if ((now != myEnfVertexWdg) and (now != myEnfFaceWdg)) {
+  if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord)
+      || (now = myGroupName) || (now = makeGroupsCheck) || (now = myEnforcedTreeWidget)) {
     BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
     that->getGeomSelectionTool()->selectionMgr()->clearFilters();
     myEnfFaceWdg->deactivateSelection();
@@ -901,66 +949,85 @@ void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidge
   }
 }
 
+/** 
+ * This method resets the content of the X, Y, Z and GroupNAme widgets;
+**/
+void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
+{
+  myXCoord->setCleared(true);
+  myYCoord->setCleared(true);
+  myZCoord->setCleared(true);
+  myXCoord->setText("");
+  myYCoord->setText("");
+  myZCoord->setText("");
+  myGroupName->setText("");
+}
 
-/** BLSURFPluginGUI_HypothesisCreator::update(item, column)
+/** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column)
 This method updates the tooltip of a modified item. The QLineEdit widgets content
 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
 */
-void BLSURFPluginGUI_HypothesisCreator::update(QTreeWidgetItem* item, int column) {
-//   MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateVertexList");
+void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) {
+//   MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues");
+  QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
   QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
+  QVariant y = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
+  QVariant z = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
   QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
-  if (!x.isNull() && !entry.isNull()) {
-    QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
-    QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
-    QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
-    /* TODO GROUPS
-    QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
-    */
-
-    QTreeWidgetItem* parent = item->parent();
-    if (parent) {
+  QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
+  QTreeWidgetItem* parent = item->parent();
+  
+  clearEnforcedVertexWidgets();
+  
+  if (parent && (!x.isNull() || !entry.isNull())) {
       QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
       QString toolTip = shapeName + QString(": ") + vertexName.toString();
-      QString entryName = parent->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole).toString();
-      if (entryName.isEmpty()) {
+      if (entry.isNull()) {
         toolTip += QString("(") + x.toString();
         toolTip += QString(", ") + y.toString();
         toolTip += QString(", ") + z.toString();
         toolTip += QString(")");
       }
+      
+      if (!groupName.isEmpty())
+        toolTip += QString(" [") + groupName + QString("]");
+
       item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
+
+    if (!x.isNull()) {
+      myXCoord->SetValue(x.toDouble());
+      myYCoord->SetValue(y.toDouble());
+      myZCoord->SetValue(z.toDouble());
     }
-    myXCoord->SetValue(x.toDouble());
-    myYCoord->SetValue(y.toDouble());
-    myZCoord->SetValue(z.toDouble());
-    /* TODO GROUPS
-    myGroupName->setText(groupName);
-    */
+    
+    if (!groupName.isEmpty())
+      myGroupName->setText(groupName);
   }
 }
 
 void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
   int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
-  if (nbSelEnfVertex != 0)
+  clearEnforcedVertexWidgets();
+  if (nbSelEnfVertex == 1)
   {
     if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
     return ;
 
-    BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
-    GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
-    if (CORBA::is_nil(measureOp))
-      return;
-
     myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
-    CORBA::Double x,y,z;
-    x = y = z = 0.;
-    measureOp->PointCoordinates (myEnfVertex, x, y, z);
-    if ( measureOp->IsDone() )
-    {
-      myXCoord->SetValue(x);
-      myYCoord->SetValue(y);
-      myZCoord->SetValue(z);
+    if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
+      BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
+      GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
+      if (CORBA::is_nil(measureOp))
+        return;
+      
+      CORBA::Double x,y,z;
+      measureOp->PointCoordinates (myEnfVertex, x, y, z);
+      if ( measureOp->IsDone() )
+      {
+        myXCoord->SetValue(x);
+        myYCoord->SetValue(y);
+        myZCoord->SetValue(z);
+      }
     }
   }
 }
@@ -970,37 +1037,34 @@ This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the
 of the enforced vertex clicked in the tree widget.
 */
 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
-//   MESSAGE("BLSURFPluginGUI_HypothesisCreator::synchronizeCoords");
+  clearEnforcedVertexWidgets();
   QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
-  if (! items.isEmpty()) {
-    QTreeWidgetItem *item;
-    for (int i=0 ; i < items.size() ; i++) {
-      item = items[i];
+  if (! items.isEmpty() && items.size() == 1) {
+    QTreeWidgetItem *item = items[0];
+//     for (int i=0 ; i < items.size() ; i++) {
+//       item = items[i];
       QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
-      if (! x.isNull()) {
-        QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
-        QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
+      QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
+      QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
+      QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
+      QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole);
+      if (!x.isNull()/* && entry.isNull()*/) {
         myXCoord->SetValue(x.toDouble());
         myYCoord->SetValue(y.toDouble());
         myZCoord->SetValue(z.toDouble());
-        /* TODO GROUPS
-        myGroupName->setText(item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString());
-        */
-        break;
+//         break;
       }
-    }
+      if (!group.isNull() && (!x.isNull() || !entry.isNull()))
+        myGroupName->setText(group.toString());
+//     }
   }
 }
 
 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
 */
-/* TODO GROUPS
-void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEntry, std::string theFaceName,
-    double x, double y, double z, std::string vertexName, std::string groupName) {
-*/
 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEntry, std::string theFaceName,
-    double x, double y, double z, std::string vertexName, std::string geomEntry) {
+    double x, double y, double z, std::string vertexName, std::string geomEntry, std::string groupName) {
   // Find theFaceEntry item
   QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
   QTreeWidgetItem* theItem;
@@ -1022,70 +1086,91 @@ void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEnt
 //   MESSAGE("Number of child rows: " << nbVert);
   if (nbVert >0) {
     double childValueX,childValueY,childValueZ;
-//     QString childGrouName;
+    QString childEntry, childGroupName;
     QTreeWidgetItem* child;
     for (int row = 0;row<nbVert;row++) {
       child = theItem->child(row);
+      childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString();
+      childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString();
       childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
       childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
       childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
-      if ((childValueX == x) && (childValueY == y) && (childValueZ == z)) {
-        /* TODO GROUPS
+      if (((childValueX == x) && (childValueY == y) && (childValueZ == z)) || (childEntry.toStdString() == geomEntry)) {
         // update group name
-        child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
-        */
+        if (childGroupName.toStdString() != groupName) {
+          MESSAGE("Group is updated from \"" << childGroupName.toStdString() << "\" to \"" << groupName << "\"");
+          child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
+        }
         okToCreate = false;
         break;
-      }
+      } // if
+    } // for
+  } // if
+  if (!okToCreate) {
+    if (geomEntry == "") {
+      MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
     }
+    else {
+      MESSAGE("In " << theFaceName << " vertex with entry " << geomEntry << " already exist: dont create again");
+    }
+    return;
   }
-  if (okToCreate) {
+    
+  if (geomEntry == "") {
     MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z<< " is created");
+  }
+  else {
+    MESSAGE("In " << theFaceName << " vertex with geom entry " << geomEntry << " is created");
+  }
 
-    QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem);
-    vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
-    int vertexIndex=1;
-    QString myVertexName;
-    int indexRef = 0;
-    while(indexRef != vertexIndex) {
-      indexRef = vertexIndex;
-      if (vertexName == "")
-        myVertexName = QString("Vertex #%1").arg(vertexIndex);
-      else
-        myVertexName = QString(vertexName.c_str());
-
+  QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem);
+  vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
+  QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
+  QSize iconSize = iconSelect.size()*0.7;
+  
+  int vertexIndex=1;
+  QString myVertexName;
+  int indexRef = 0;
+  while(indexRef != vertexIndex) {
+    indexRef = vertexIndex;
+    if (vertexName == "")
+      myVertexName = QString("Vertex #%1").arg(vertexIndex);
+    else
+      myVertexName = QString(vertexName.c_str());
 
-      for (int row = 0;row<nbVert;row++) {
-        QString name = theItem->child(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
-        if (myVertexName == name) {
-          vertexIndex++;
-          break;
-        }
+    for (int row = 0;row<nbVert;row++) {
+      QString name = theItem->child(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
+      if (myVertexName == name) {
+        vertexIndex++;
+        break;
       }
     }
-    vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
+  }
+  vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
+  if (geomEntry == "") {
     vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
     vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
     vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
+  }
+  else {
+    vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
     vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) );
-
-    /* TODO GROUPS
+  }
+  if (groupName != "")
     vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
-    */
-    QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName;
+
+  QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName;
+  if (geomEntry == "") {
     toolTip += QString(" (%1, ").arg(x);
     toolTip += QString("%1, ").arg(y);
     toolTip += QString("%1)").arg(z);
-    vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
-    theItem->setExpanded(true);
-    myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
   }
-  else
-    /* TODO GROUPS
-    MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z <<
-        " already exist: dont create again, only group name is updated with " << groupName);
-    */
-    MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
+  if (groupName != "")
+    toolTip += QString(" [%1]").arg(groupName.c_str());
+  
+  vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
+  theItem->setExpanded(true);
+  myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
 }
 
 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
@@ -1121,13 +1206,12 @@ void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
     entry = myEnfFace->GetStudyEntry();
     shapeName = myEnfFace->GetName();
 
-// //     TODO GROUPS
-//     std::string groupName = myGroupName->text().toStdString();
-//     if (makeGroupsCheck->isChecked())
-//       groupName = myGlobalGroupName->text().toStdString();
-//
-//     if (boost::trim_copy(groupName) == "")
-//       groupName = "";
+    std::string groupName = myGroupName->text().toStdString();
+    if (makeGroupsCheck->isChecked())
+      groupName = myGlobalGroupName->text().toStdString();
+
+    if (boost::trim_copy(groupName) == "")
+      groupName = "";
 
     if (selEnfVertex <= 1)
     {
@@ -1135,16 +1219,12 @@ void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
       x = myXCoord->GetValue();
       y = myYCoord->GetValue();
       z = myZCoord->GetValue();
-// //       TODO GROUPS
-//       addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertexWdg->GetObject< GEOM::GEOM_Object >()->GetName(), groupName);
       if (selEnfVertex == 1) {
         myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
-        addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry());
+        addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
       }
       else
-// //       TODO GROUPS
-//       addEnforcedVertex(entry, shapeName, x, y, z, groupName);
-        addEnforcedVertex(entry, shapeName, x, y, z);
+        addEnforcedVertex(entry, shapeName, x, y, z, "", "", groupName);
     }
     else
     {
@@ -1160,38 +1240,20 @@ void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
       for (int j = 0 ; j < selEnfVertex ; j++)
       {
         myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
-        measureOp->PointCoordinates (myEnfVertex, x, y, z);
-        if ( measureOp->IsDone() )
-        {
-// //           TODO GROUPS
-//           addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(), groupName);
-          addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry());
+        if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
+          measureOp->PointCoordinates (myEnfVertex, x, y, z);
+          if ( measureOp->IsDone() )
+            addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
+        } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
+            addEnforcedVertex(entry, shapeName, 0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
         }
       }
     }
   }
 
-//   TopAbs_ShapeEnum shapeType;
-//   GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
-//   LightApp_SelectionMgr* mySel = myGeomToolSelected->selectionMgr();
-//   SALOME_ListIO ListSelectedObjects;
-//   mySel->selectedObjects(ListSelectedObjects, NULL, false );
-//   if (!ListSelectedObjects.IsEmpty()) {
-//     SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects);
-//     for (; Object_It.More(); Object_It.Next()) {
-//       Handle(SALOME_InteractiveObject) anObject = Object_It.Value();
-//       entry     = myGeomToolSelected->getEntryOfObject(anObject);
-//       shapeName = anObject->getName();
-//       shapeType = myGeomToolSelected->entryToShapeType(entry);
-// //       MESSAGE("Object Name = " << shapeName << "& Type is " << anObject->getComponentDataType() << " & ShapeType is " << shapeType);
-//       if (shapeType == TopAbs_FACE) {
-//         /* TODO GROUPS
-//         addEnforcedVertex(entry, shapeName, x, y, z, groupName);
-//         */
-//         addEnforcedVertex(entry, shapeName, x, y, z);
-//       }
-//     }
-//   }
+  myEnfFaceWdg->SetObject(GEOM::GEOM_Object::_nil());
+  myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
+  
   for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
     myEnforcedTreeWidget->resizeColumnToContents(column);
 
@@ -1215,8 +1277,13 @@ void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
     QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
     if (! value.isNull())
       selectedVertices.append(item);
-    else
-      selectedEntries.insert(item);
+    else {
+      value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
+      if (! value.isNull())
+        selectedVertices.append(item);
+      else
+        selectedEntries.insert(item);
+    }
   }
 
   foreach(item,selectedVertices) {
@@ -1338,42 +1405,38 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
   mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
 
   // Enforced vertices
-  MESSAGE("retrieveParams(): data.entryCoordsListMap.size() = " << data.entryCoordsListMap.size());
-  TEntryCoordsListMap::const_iterator evmIt = data.entryCoordsListMap.begin();
-  for ( ; evmIt != data.entryCoordsListMap.end() ; ++evmIt) {
+  MESSAGE("retrieveParams(): data.entryCoordsListMap.size() = " << data.faceEntryEnfVertexListMap.size());
+  TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin();
+  for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
     TEntry entry = (*evmIt).first;
     std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
     MESSAGE("Face entry: " << entry);
     MESSAGE("Face name: " << shapeName);
 
-    TEnfVertexCoordsList evs;
-    try  {
-      evs = (*evmIt).second;
-    }
-    catch(...) {
-      MESSAGE("evs = (*evmIt).second: FAIL");
-      break;
-    }
+    TEnfVertexList evs = (*evmIt).second;
+//     try  {
+//       evs = (*evmIt).second;
+//     }
+//     catch(...) {
+//       MESSAGE("evs = (*evmIt).second: FAIL");
+//       break;
+//     }
 
-    TEnfVertexCoordsList::const_iterator evsIt = evs.begin();
+    TEnfVertexList::const_iterator evsIt = evs.begin();
     TEnfVertex enfVertex;
     for ( ; evsIt != evs.end() ; ++evsIt) {
-      TEnfVertexCoords coords = (*evsIt);
-      MESSAGE("Found coords: "<< coords[0] << ", " << coords[1] << ", " << coords[2]);
-      TCoordsEnfVertexMap::const_iterator it = data.coordsEnfVertexMap.find(coords);
-      if (it != data.coordsEnfVertexMap.end()) {
-        MESSAGE("Found enforced vertex");
-        enfVertex = it->second;
-        MESSAGE("Name: " << enfVertex.name);
-        MESSAGE("Geom entry: " << enfVertex.geomEntry);
-        that->addEnforcedVertex(entry, shapeName, coords[0], coords[1], coords[2], enfVertex.name, enfVertex.geomEntry);
-      }
-      else {
-        MESSAGE("Enforced vertex NOT found")
-        that->addEnforcedVertex(entry, shapeName, coords[0], coords[1], coords[2]);
+      enfVertex = (*evsIt);
+      MESSAGE("Name: " << enfVertex.name);
+      double x, y, z = 0;
+      if (enfVertex.coords.size()) {
+        x = enfVertex.coords[0];
+        y = enfVertex.coords[1];
+        z = enfVertex.coords[2];
       }
+      that->addEnforcedVertex(entry, shapeName, x, y, z, enfVertex.name, enfVertex.geomEntry, enfVertex.grpName);
     }
   }
+  
   for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
     myEnforcedTreeWidget->resizeColumnToContents(column);
 
@@ -1500,66 +1563,63 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData
   }
 
   // Enforced vertices
-  h_data.coordsList.clear();
-  h_data.entryCoordsListMap.clear();
-  h_data.coordsEnfVertexMap.clear();
+  h_data.enfVertexList.clear();
+  h_data.faceEntryEnfVertexListMap.clear();
   /* TODO GROUPS
   h_data.groupNameEnfVertexListMap.clear();
-//   h_data.enfVertexGroupNameMap.clear();
   */
 
-  BLSURFPlugin::TEntryCoordsListMap_var entryCoordsListMap = h->GetAllCoordsByFace();
-  MESSAGE("entryCoordsListMap->length() = " << entryCoordsListMap->length());
-
-  for ( int i = 0;i<entryCoordsListMap->length(); ++i ) {
-    std::string entry =  entryCoordsListMap[i].entry.in();
-    BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str());
-
-    TEnfVertexCoordsList& coordsList = h_data.entryCoordsListMap[entry];
-    /* TODO GROUPS
-    std::string groupName = "";
-    */
-    for (int j=0 ; j<vertexList->length(); ++j) {
-      BLSURFPlugin::TEnfVertexCoords _coords = vertexList[j].coords;
+  BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace();
+  MESSAGE("faceEntryEnfVertexListMap->length() = " << faceEntryEnfVertexListMap->length());
 
-      TEnfVertexCoords coords;
-      coords.push_back(_coords[0]);
-      coords.push_back(_coords[1]);
-      coords.push_back(_coords[2]);
-      coordsList.insert(coords);
-      h_data.coordsList.insert(coords);
+  for ( int i = 0;i<faceEntryEnfVertexListMap->length(); ++i ) {
+    std::string entry =  faceEntryEnfVertexListMap[i].faceEntry.in();
+//     BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList.in();
+    BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList;
+//     BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str());
 
-      TEnfVertex& enfVertex = h_data.coordsEnfVertexMap[coords];
+    TEnfVertexList& enfVertexList = h_data.faceEntryEnfVertexListMap[entry];
 
+    for (int j=0 ; j<vertexList.length(); ++j) {
+      TEnfVertex enfVertex;
+      
       enfVertex.name = vertexList[j].name.in();
-      enfVertex.coords = coords;
-      enfVertex.faceEntries.insert(entry);
       enfVertex.geomEntry = vertexList[j].geomEntry.in();
+      enfVertex.grpName = vertexList[j].grpName.in();
+      for (int k=0 ; k< vertexList[j].coords.length();k++)
+        enfVertex.coords.push_back(vertexList[j].coords[k]);
+
+      enfVertexList.insert(enfVertex);
 
       /* TODO GROUPS
-      enfVertex.grpName = vertexList[j].grpName.in();
-      groupName.assign(h->GetEnforcedVertexGroupName(x, y, z));
-      MESSAGE("readParamsFromHypo, groupName = "<<groupName)
-      h_data.enfVertexGroupNameMap[ev] = groupName;
       if (groupName != "") {
         h_data.groupNameEnfVertexListMap[groupName].insert(ev);
       }
       */
-//       MESSAGE("New enf vertex for entry " << entry << ": " << x << ", " << y << ", " << z);
-//       h_data.coordsEnfVertexMap[coords] = enfVertex;
     }
 //     h_data.enfVertMap[entry] = evs;
 //     h_data.entryCoordsListMap[entry] = coordsList;
-    if (coordsList.size() == 0) {
-//       MESSAGE("No enf vertex for entry " << entry << ": key is erased");
-//       h_data.enfVertMap.erase(entry);
-      h_data.entryCoordsListMap.erase(entry);
+
+    if (enfVertexList.size() == 0) {
+      h_data.faceEntryEnfVertexListMap.erase(entry);
     }
   }
 
   return true;
 }
 
+bool TEnfVertexGUICmp(const TEnfVertex *e1, const TEnfVertex *e2) {
+  if (e1 && e2) {
+    bool sameCoords = true;
+    if (e1->coords.size() && e2->coords.size())
+      sameCoords = (e1->coords[0] == e2->coords[0]) && (e1->coords[1] == e2->coords[1]) && (e1->coords[2]
+          == e2->coords[2]);
+    return ( sameCoords && (e1->geomEntry == e2->geomEntry) && (e1->grpName == e2->grpName)
+        && (e1->name == e2->name));
+  } else
+    return (e1 < e2);
+}
+
 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
 Saves the hypothesis data to hypothesis values.
 */
@@ -1651,128 +1711,102 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi
     // Enforced vertices
     bool ret;
     int hypNbVertex;
-    double x, y, z;
+    double x, y, z = 0;
     std::string enfName;
     /* TODO GROUPS
     std::string groupName = "";
     */
 
-    TEntryCoordsListMap::const_iterator evmIt = h_data.entryCoordsListMap.begin();
+    TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin();
 
-    BLSURFPlugin::TEntryCoordsListMap_var allCoordsByFace = h->GetAllCoordsByFace();
-    hypNbVertex =  allCoordsByFace->length();
+    BLSURFPlugin::TFaceEntryEnfVertexListMap_var allEnforcedVerticesByFace = h->GetAllEnforcedVerticesByFace();
+    hypNbVertex =  allEnforcedVerticesByFace->length();
+    
 
     // All enforced vertices were deleted
-    if (evmIt == h_data.entryCoordsListMap.end() && hypNbVertex!=0)
+    if (evmIt == h_data.faceEntryEnfVertexListMap.end() && hypNbVertex!=0) {
       h->ClearAllEnforcedVertices();
-
-    // All enforced vertices for a specific entry were deleted
-    for (int i=0 ; i<hypNbVertex; i++) {
-      BLSURFPlugin::TEntryCoordsListMapElement el = allCoordsByFace[i];
-      TEnfName entry = el.entry.in();
-      if (h_data.entryCoordsListMap.find(entry) == h_data.entryCoordsListMap.end()) {
-        MESSAGE("Remove all enforced vertices for entry " << entry);
-        h->UnsetEnforcedVerticesEntry(entry.c_str());
-      }
+      ok = true;
     }
-
-    // One or several enforced vertices are added or removed for a specific entry
-    TEnfVertexCoordsList coordsFromHyp;
-    BLSURFPlugin::TEnfVertexList_var hypCoordsList;
-    TEnfName entry;
-    TEnfVertexCoordsList evs;
-    TEnfVertexCoordsList::const_iterator evsIt, coordsToRemove;
-    for ( ; evmIt != h_data.entryCoordsListMap.end() ; ++evmIt) {
-      MESSAGE("Enforced vertices for face entry " << evmIt->first);
-      entry = evmIt->first;
-      evs = evmIt->second;
-      evsIt = evs.begin();
-
-      hypCoordsList = h->GetEnforcedVerticesEntry(entry.c_str());
-      hypNbVertex = hypCoordsList->length();
-      MESSAGE("Number of enforced vertices from hypothesis: " << hypNbVertex);
-      coordsFromHyp.clear();
-      for (int i =0 ; i<hypNbVertex ; i++) {
-        TEnfVertexCoords _coords;
-        _coords.push_back(hypCoordsList[i].coords[0]);
-        _coords.push_back(hypCoordsList[i].coords[1]);
-        _coords.push_back(hypCoordsList[i].coords[2]);
-        coordsFromHyp.insert(_coords);
-        MESSAGE("From hyp: enf. vertex at " << _coords[0]<<", "<<_coords[1]<<", "<<_coords[2]);
+    else {
+      // All enforced vertices for a specific entry were deleted
+      for (int i=0 ; i<hypNbVertex; i++) {
+        BLSURFPlugin::TFaceEntryEnfVertexListMapElement el = allEnforcedVerticesByFace[i];
+        TEnfName entry = el.faceEntry.in();
+        if (h_data.faceEntryEnfVertexListMap.find(entry) == h_data.faceEntryEnfVertexListMap.end()) {
+          MESSAGE("Remove all enforced vertices for entry " << entry);
+          h->UnsetEnforcedVerticesEntry(entry.c_str());
+        }
       }
 
-      TEnfVertex enfVertex;
-      TEnfVertexCoords coords;
-      TCoordsEnfVertexMap::const_iterator it;
-      for ( int i=0 ; evsIt != evs.end() ; ++evsIt,++i) {
-        MESSAGE("Enf vertex #"<<i);
-        coords = (*evsIt);
-        it = h_data.coordsEnfVertexMap.find(coords);
-        if (it == h_data.coordsEnfVertexMap.end()) {
-          MESSAGE("Error vertex not found");
-          throw std::runtime_error("Error vertex not found");
+      // One or several enforced vertices are added or removed for a specific entry
+      TEnfVertexList enfVertexFromHyp;
+      BLSURFPlugin::TEnfVertexList_var hypEnfVertexList;
+      TEnfName faceEntry;
+      TEnfVertexList evs;
+      TEnfVertexList::const_iterator evsIt, enfVertexToRemove;
+      for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
+        faceEntry = evmIt->first;
+        MESSAGE("Enforced vertices for face entry " << faceEntry);
+        evs = evmIt->second;
+        evsIt = evs.begin();
+
+        hypEnfVertexList = h->GetEnforcedVerticesEntry(faceEntry.c_str());
+        hypNbVertex = hypEnfVertexList->length();
+        MESSAGE("Number of enforced vertices from hypothesis: " << hypNbVertex);
+        enfVertexFromHyp.clear();
+        for (int i =0 ; i<hypNbVertex ; i++) {
+          TEnfVertex _enfVertex;
+          _enfVertex.name = hypEnfVertexList[i].name.in();
+          _enfVertex.geomEntry = hypEnfVertexList[i].geomEntry.in();
+          for (int j=0 ; j< hypEnfVertexList[i].coords.length() ; j++)
+            _enfVertex.coords.push_back(hypEnfVertexList[i].coords[j]);
+          _enfVertex.grpName = hypEnfVertexList[i].grpName.in();
+          enfVertexFromHyp.insert(_enfVertex);
+          MESSAGE("From hyp: enf vertex " << _enfVertex.name);
+//           MESSAGE("From hyp: enf. vertex at " << _coords[0]<<", "<<_coords[1]<<", "<<_coords[2]);
         }
 
-        enfVertex = it->second;
-        x = enfVertex.coords[0];
-        y = enfVertex.coords[1];
-        z = enfVertex.coords[2];
-        if (enfVertex.geomEntry == "")
-          ret = h->SetEnforcedVertexEntry( entry.c_str(), x, y, z, enfVertex.name.c_str() );
-        else
-          ret = h->SetEnforcedVertexEntryWithPoint( entry.c_str(), enfVertex.geomEntry.c_str(), enfVertex.name.c_str(), x, y, z );
-
-        /* TODO GROUPS
-        groupName = enfVertex.grpName;
-        h->SetEnforcedVertexEntryWithGroup( entry.c_str(), x, y, z, groupName.c_str() );
-        */
-
-        if (coordsFromHyp.find(coords) != coordsFromHyp.end()) {
-          MESSAGE("Coords "<<x<<", "<<y<<", "<<z<<" must not be deleted")
-          coordsFromHyp.erase(coords);
+        TEnfVertex enfVertex;
+        for ( ; evsIt != evs.end() ; ++evsIt) {
+          enfVertex = (*evsIt);
+          if (enfVertex.coords.size()) {
+            x = enfVertex.coords[0];
+            y = enfVertex.coords[1];
+            z = enfVertex.coords[2];
+          }
+          ret = h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, enfVertex.name.c_str(), enfVertex.geomEntry.c_str(), enfVertex.grpName.c_str());
+          
+          for (enfVertexToRemove = enfVertexFromHyp.begin() ; enfVertexToRemove != enfVertexFromHyp.end() ; ++enfVertexToRemove) {
+            if (!TEnfVertexGUICmp(&enfVertex, &(*enfVertexToRemove))) {
+              MESSAGE("Enf vertex  " << enfVertex.name << " must not be deleted")
+              enfVertexFromHyp.erase(enfVertexToRemove);
+            }
+          }
         }
-      }
 
-      // Remove old vertices
-      coordsToRemove = coordsFromHyp.begin();
-      for ( ; coordsToRemove!=coordsFromHyp.end() ; ++coordsToRemove) {
-        coords = (*coordsToRemove);
-        x = coords[0];
-        y = coords[1];
-        z = coords[2];
-
-        it = h_data.coordsEnfVertexMap.find(coords);
-        if (it == h_data.coordsEnfVertexMap.end()) {
-          MESSAGE("Error vertex not found");
-          throw std::runtime_error("Error vertex not found");
-        }
-        enfVertex = it->second;
-        if (enfVertex.geomEntry == "") {
-          ret = h->UnsetEnforcedVertexEntry( entry.c_str(), x, y, z );
-        }
-        else {
-          ret = h->UnsetEnforcedVertexEntryWithPoint( entry.c_str(), enfVertex.geomEntry.c_str(), x, y, z );
-        }
-        if (ret)
-          MESSAGE("SUCCESS");
-      }
-//       if (hypNbVertex >0) {
-//         for (int i =0 ; i<hypNbVertex ; i++) {
-//           x = hypCoordsList[i].coords[0];
-//           y = hypCoordsList[i].coords[1];
-//           z = hypCoordsList[i].coords[2];
-//           TEnfVertexCoords coords;
-//           coords.push_back(x);
-//           coords.push_back(y);
-//           coords.push_back(z);
-//           if (evs.find(coords) == evs.end()) {
-//             MESSAGE("UnsetEnforcedVertexEntry("<<entry<<", "<<x<<", "<<y<<", "<<z<<")");
-//             h->UnsetEnforcedVertexEntry( entry.c_str(), x, y, z );
-//           }
-//         }
-//       }
-    }
-  }
+        // Remove old vertices
+        enfVertexToRemove = enfVertexFromHyp.begin();
+        for ( ; enfVertexToRemove!=enfVertexFromHyp.end() ; ++enfVertexToRemove) {
+          enfVertex = (*enfVertexToRemove);
+          
+          for ( evsIt=h_data.enfVertexList.begin();evsIt!=h_data.enfVertexList.end();evsIt++) {
+            if (TEnfVertexGUICmp(&(*evsIt),&enfVertex)) {
+              MESSAGE("Remove enf vertex " << enfVertex.name);
+              if (enfVertex.coords.size()) {
+                x = enfVertex.coords[0];
+                y = enfVertex.coords[1];
+                z = enfVertex.coords[2];
+              }
+              ret = h->UnsetEnforcedVertexEntry(faceEntry.c_str(), x, y, z, enfVertex.geomEntry.c_str());
+              if (ret)
+                MESSAGE("SUCCESS");
+            } // if
+          } // for
+        } // for
+      } // for
+    } // else
+  } // try
   catch(const std::exception& ex) {
     std::cout << "Exception: " << ex.what() << std::endl;
     throw ex;
@@ -1853,9 +1887,8 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes
   }
 
   // Enforced vertices
-  h_data.coordsList.clear();
-  h_data.entryCoordsListMap.clear();
-  h_data.coordsEnfVertexMap.clear();
+  h_data.enfVertexList.clear();
+  h_data.faceEntryEnfVertexListMap.clear();
 
   int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
   int nbEnforcedVertices = 0;
@@ -1864,13 +1897,13 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes
   for (int i=0 ; i<nbEnforcedShapes ; i++) {
     QTreeWidgetItem* shapeItem = myEnforcedTreeWidget->topLevelItem(i);
     if (shapeItem) {
-      std::string entry = shapeItem->data(ENF_VER_FACE_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
+      std::string faceEntry = shapeItem->data(ENF_VER_FACE_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
       nbEnforcedVertices = shapeItem->childCount();
       if (nbEnforcedVertices >0) {
         double childValueX,childValueY,childValueZ;
         std::string childName, vertexEntry;
         QTreeWidgetItem* child;
-        TEnfVertexCoordsList evs;
+        TEnfVertexList evs;
         for (row = 0;row<nbEnforcedVertices;row++) {
           child = shapeItem->child(row);
           childName   = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
@@ -1878,33 +1911,28 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes
           childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
           childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
           vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
-          TEnfVertexCoords coords;
-          coords.push_back(childValueX);
-          coords.push_back(childValueY);
-          coords.push_back(childValueZ);
-          evs.insert(coords);
-          h_data.coordsList.insert(coords);
+          if (makeGroupsCheck->isChecked())
+            groupName = myGlobalGroupName->text().toStdString();
+          else
+            groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
 
           TEnfVertex enfVertex;
           enfVertex.name = childName;
-          enfVertex.coords = coords;
-          enfVertex.faceEntries.insert(entry);
           enfVertex.geomEntry = vertexEntry;
-
-          /* TODO GROUPS
-          groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
+          if (vertexEntry == "") {
+            enfVertex.coords.push_back(childValueX);
+            enfVertex.coords.push_back(childValueY);
+            enfVertex.coords.push_back(childValueZ);
+          }
           enfVertex.grpName = groupName;
 
-          // Group
-          if (makeGroupsCheck->isChecked())
-            groupName = myGlobalGroupName->text().toStdString();
-          h_data.enfVertexGroupNameMap[vertex] = groupName;
+          h_data.enfVertexList.insert(enfVertex);
+          /* TODO GROUPS
           if (groupName != "")
             h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
           */
-          h_data.coordsEnfVertexMap[coords] = enfVertex;
         }
-        h_data.entryCoordsListMap[entry] = evs;
+        h_data.faceEntryEnfVertexListMap[faceEntry] = evs;
       }
     }
   }
index 0ba44b2820ee6158e90e293d2e7e552c4ca145b0..40c63e403c2b7370f51fc92b55b602d27c982b27 100644 (file)
@@ -95,22 +95,24 @@ typedef struct {
   TEnfName grpName;
 } TEnfVertex;
 
-int TEnfVertexCmp(const TEnfVertex *e1, const TEnfVertex *e2) {
-  if (e1 && e2) {
-    bool sameCoords = true;
-    if (e1->coords.size() && e2->coords.size())
-      sameCoords = (e1->coords[0] == e2->coords[0]) && (e1->coords[1] == e2->coords[1]) && (e1->coords[2]
-          == e2->coords[2]);
-    return ( sameCoords && (e1->geomEntry == e2->geomEntry) && (e1->grpName == e2->grpName)
-        && (e1->name == e2->name));
-  } else
-    return (e1 < e2);
-}
+bool TEnfVertexGUICmp(const TEnfVertex *e1, const TEnfVertex *e2);
+// {
+//   if (e1 && e2) {
+//     bool sameCoords = true;
+//     if (e1->coords.size() && e2->coords.size())
+//       sameCoords = (e1->coords[0] == e2->coords[0]) && (e1->coords[1] == e2->coords[1]) && (e1->coords[2]
+//           == e2->coords[2]);
+//     return ( sameCoords && (e1->geomEntry == e2->geomEntry) && (e1->grpName == e2->grpName)
+//         && (e1->name == e2->name));
+//   } else
+//     return (e1 < e2);
+// }
 
 struct CompareEnfVertices
 {
-  bool operator () (const TEnfVertex &e1, const TEnfVertex &e2) const
+  bool operator () (const TEnfVertex &e1, const TEnfVertex &e2) const {
     return true;
+  }
 };
 
 // List of enforced vertices
@@ -143,6 +145,28 @@ typedef struct
 } BlsurfHypothesisData;
 
 
+
+// class BLSURFPluginGUI_ObjectReferenceParamWdg: public StdMeshersGUI_ObjectReferenceParamWdg
+// {
+//   Q_OBJECT
+// public:
+//   BLSURFPluginGUI_ObjectReferenceParamWdg( SUIT_SelectionFilter* filter, 
+//                                          QWidget*              parent,
+//                                          bool                  multiSelection=false);
+//   BLSURFPluginGUI_ObjectReferenceParamWdg( MeshObjectType objType,
+//                                          QWidget*       parent,
+//                                          bool           multiSelection=false);
+//   ~BLSURFPluginGUI_ObjectReferenceParamWdg();
+// 
+// private:
+//   void init();
+//   
+// public slots:
+//   void activateSelectionOnly();
+//   void deactivateSelectionOnly();
+//   void setActivationStatus(bool status);
+// };
+
 /*!
  * \brief Class for creation of BLSURF hypotheses
 */
@@ -181,16 +205,15 @@ protected slots:
   void                onRemoveMap();
   void                onSetSizeMap(int,int);
 
-  /* TODO GROUPS
-  void                addEnforcedVertex(std::string, std::string, double, double, double, std::string, std::string);
-  */
-  void                addEnforcedVertex(std::string theFaceEntry, std::string theFaceName, double x, double y, double z, std::string vertexName = "", std::string geomEntry = "");
+  void                addEnforcedVertex(std::string theFaceEntry, std::string theFaceName, double x=0, double y=0, double z=0, 
+                                        std::string vertexName = "", std::string geomEntry = "", std::string groupName = "");
   void                onAddEnforcedVertices();
   void                onRemoveEnforcedVertex();
   void                synchronizeCoords();
-  void                update(QTreeWidgetItem* , int );
+  void                updateEnforcedVertexValues(QTreeWidgetItem* , int );
   void                onSelectEnforcedVertex();
   void                deactivateSelection(QWidget*, QWidget*);
+  void                clearEnforcedVertexWidgets();
 
 private:
   bool                readParamsFromHypo( BlsurfHypothesisData& ) const;
@@ -243,11 +266,11 @@ private:
   SMESHGUI_SpinBox*   myXCoord;
   SMESHGUI_SpinBox*   myYCoord;
   SMESHGUI_SpinBox*   myZCoord;
-  /* TODO GROUPS
+
   QLineEdit*          myGroupName;
   QGroupBox*          makeGroupsCheck;
   QLineEdit*          myGlobalGroupName;
-  */
+
   QPushButton*        addVertexButton;
   QPushButton*        removeVertexButton;