Salome HOME
Fix the option remove_tiny_uv_edges to use the new advanced options mechanism
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Hypothesis.cxx
index cda6029ac392572730d39eb8507cc77affb1457f..4048437af099027795a3c30e5f8b1c06efe32a24 100644 (file)
@@ -81,7 +81,6 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_G
   _verb(GetDefaultVerbosity()),
   _topology(GetDefaultTopology()),
   _preCADMergeEdges(GetDefaultPreCADMergeEdges()),
-  _preCADRemoveTinyUVEdges(GetDefaultPreCADRemoveTinyUVEdges()),
   _preCADRemoveDuplicateCADFaces(GetDefaultPreCADRemoveDuplicateCADFaces()),
   _preCADProcess3DTopology(GetDefaultPreCADProcess3DTopology()),
   _preCADDiscardInput(GetDefaultPreCADDiscardInput()),
@@ -141,7 +140,11 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_G
                                             "remove_duplicate_cad_faces",               // default = 1
                                             // "create_tag_on_collision",                  // default = 1
                                             "debug",                                    // default = 0 
+                                            "process_3d_topology",                      // default = 1
                                             // "remove_tiny_edges",                        // default = 0
+                                            // remove_tiny_uv_edges option is not documented
+                                            // but it is useful that the user can change it to disable all preprocessing options
+                                            "remove_tiny_uv_edges",                        // default = 1
                                             "" // mark of end
       };
   const char* preCADintOptionNames[] = {    // "manifold_geometry",                        // default = 0
@@ -206,6 +209,8 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_G
   _defaultOptionValues["rectify_jacobian"                       ] = "yes";
   _defaultOptionValues["respect_geometry"                       ] = "yes";
   _defaultOptionValues["tiny_edge_avoid_surface_intersections"  ] = "yes";
+  _defaultOptionValues["process_3d_topology"                    ] = "no";
+  _defaultOptionValues["remove_tiny_uv_edges"                   ] = "no";
   _defaultOptionValues["closed_geometry"                        ] = "no";
   _defaultOptionValues["debug"                                  ] = "no";
   _defaultOptionValues["discard_input_topology"                 ] = "no";
@@ -242,7 +247,6 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_G
 
 TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry)
 {
-  MESSAGE("BLSURFPlugin_Hypothesis::entryToShape "<<entry );
   GEOM::GEOM_Object_var aGeomObj;
   SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
   SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy();
@@ -288,7 +292,6 @@ void BLSURFPlugin_Hypothesis::SetPhySize(double theVal, bool isRelative) {
     _phySizeRel = isRelative;
     if (theVal == 0) {
       _phySize = GetMaxSize();
-      MESSAGE("Warning: nul physical size is not allowed");
     }
     else
       _phySize = theVal;
@@ -324,6 +327,7 @@ void BLSURFPlugin_Hypothesis::SetUseGradation(bool theVal) {
 
 //=============================================================================
 void BLSURFPlugin_Hypothesis::SetGradation(double theVal) {
+  _useGradation = ( theVal > 0 );
   if (theVal != _gradation) {
     _gradation = theVal;
     NotifySubMeshesHypothesisModification();
@@ -340,6 +344,7 @@ void BLSURFPlugin_Hypothesis::SetUseVolumeGradation(bool theVal) {
 
 //=============================================================================
 void BLSURFPlugin_Hypothesis::SetVolumeGradation(double theVal) {
+  _useVolumeGradation = ( theVal > 0 );
   if (theVal != _volumeGradation) {
     _volumeGradation = theVal;
     NotifySubMeshesHypothesisModification();
@@ -528,7 +533,7 @@ bool BLSURFPlugin_Hypothesis::GetJacobianRectification()
 }
 //=============================================================================
 
-void BLSURFPlugin_Hypothesis::SetMaxNumberOfPointsPerPatch( CORBA::Long nb )
+void BLSURFPlugin_Hypothesis::SetMaxNumberOfPointsPerPatch( int nb )
   throw (std::invalid_argument)
 {
   if ( nb < 0 )
@@ -682,22 +687,83 @@ std::string BLSURFPlugin_Hypothesis::GetTags()
   return GetPreCADOptionValue("tags", GET_DEFAULT());
 }
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetPreCADMergeEdges(bool theVal)
+void BLSURFPlugin_Hypothesis::SetHyperPatches(const THyperPatchList& hpl)
 {
-  if (theVal != _preCADMergeEdges) {
-//     SetTopology(PreCAD);
-    _preCADMergeEdges = theVal;
-    SetPreCADOptionValue("merge_edges", theVal ? "yes" : "no" );
+  if ( hpl != _hyperPatchList )
+  {
+    // join patches sharing tags
+    _hyperPatchList.clear();
+    for ( size_t i = 0; i < hpl.size(); ++i )
+    {
+      const THyperPatchTags& tags = hpl[i];
+      if ( tags.size() < 2 ) continue;
+
+      std::set<int> iPatches;
+      if ( !_hyperPatchList.empty() )
+      {
+        THyperPatchTags::iterator t = tags.begin();
+        for ( ; t != tags.end(); ++t )
+        {
+          int iPatch = -1;
+          GetHyperPatchTag( *t, this, &iPatch );
+          if ( iPatch >= 0 )
+            iPatches.insert( iPatch );
+        }
+      }
+
+      if ( iPatches.empty() )
+      {
+        _hyperPatchList.push_back( tags );
+      }
+      else
+      {
+        std::set<int>::iterator iPatch = iPatches.begin();
+        THyperPatchTags&     mainPatch = _hyperPatchList[ *iPatch ];
+        mainPatch.insert( tags.begin(), tags.end() );
+
+        for ( ++iPatch; iPatch != iPatches.end(); ++iPatch )
+        {
+          mainPatch.insert( _hyperPatchList[ *iPatch ].begin(), _hyperPatchList[ *iPatch ].end() );
+          _hyperPatchList[ *iPatch ].clear();
+        }
+        if ( iPatches.size() > 1 )
+          for ( int j = _hyperPatchList.size()-1; j > 0; --j )
+            if ( _hyperPatchList[j].empty() )
+              _hyperPatchList.erase( _hyperPatchList.begin() + j );
+      }
+    }
     NotifySubMeshesHypothesisModification();
   }
 }
+//=============================================================================
+/*!
+ * \brief Return a tag of a face taking into account the hyper-patches. Optionally
+ *        return an index of a patch including the face
+ */
+//================================================================================
 
+int BLSURFPlugin_Hypothesis::GetHyperPatchTag( const int                      faceTag,
+                                               const BLSURFPlugin_Hypothesis* hyp,
+                                               int*                           iPatch)
+{
+  if ( hyp )
+  {
+    const THyperPatchList& hpl = hyp->_hyperPatchList;
+    for ( size_t i = 0; i < hpl.size(); ++i )
+      if ( hpl[i].count( faceTag ))
+      {
+        if ( iPatch ) *iPatch = i;
+        return *( hpl[i].begin() );
+      }
+  }
+  return faceTag;
+}
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetPreCADRemoveTinyUVEdges(bool theVal)
+void BLSURFPlugin_Hypothesis::SetPreCADMergeEdges(bool theVal)
 {
-  if (theVal != _preCADRemoveTinyUVEdges) {
-//     SetTopology(PreCAD);
-    _preCADRemoveTinyUVEdges = theVal;
+  if (theVal != ToBool( GetPreCADOptionValue("merge_edges", GET_DEFAULT()))) {
+    _preCADMergeEdges = theVal;
+    SetPreCADOptionValue("merge_edges", theVal ? "yes" : "no" );
     NotifySubMeshesHypothesisModification();
   }
 }
@@ -705,8 +771,7 @@ void BLSURFPlugin_Hypothesis::SetPreCADRemoveTinyUVEdges(bool theVal)
 //=============================================================================
 void BLSURFPlugin_Hypothesis::SetPreCADRemoveDuplicateCADFaces(bool theVal)
 {
-  if (theVal != _preCADRemoveDuplicateCADFaces) {
-    //     SetTopology(PreCAD);
+  if (theVal != ToBool( GetPreCADOptionValue("remove_duplicate_cad_faces", GET_DEFAULT()))) {
     _preCADRemoveDuplicateCADFaces = theVal;
     SetPreCADOptionValue("remove_duplicate_cad_faces", theVal ? "yes" : "no" );
     NotifySubMeshesHypothesisModification();
@@ -716,9 +781,9 @@ void BLSURFPlugin_Hypothesis::SetPreCADRemoveDuplicateCADFaces(bool theVal)
 //=============================================================================
 void BLSURFPlugin_Hypothesis::SetPreCADProcess3DTopology(bool theVal)
 {
-  if (theVal != _preCADProcess3DTopology) {
-    //     SetTopology(PreCAD);
+  if (theVal != ToBool( GetPreCADOptionValue("process_3d_topology", GET_DEFAULT()))) {
     _preCADProcess3DTopology = theVal;
+    SetPreCADOptionValue("process_3d_topology", theVal ? "yes" : "no" );
     NotifySubMeshesHypothesisModification();
   }
 }
@@ -726,14 +791,38 @@ void BLSURFPlugin_Hypothesis::SetPreCADProcess3DTopology(bool theVal)
 //=============================================================================
 void BLSURFPlugin_Hypothesis::SetPreCADDiscardInput(bool theVal)
 {
-  if (theVal != _preCADDiscardInput) {
-    //     SetTopology(PreCAD);
+  if (theVal != ToBool( GetPreCADOptionValue("discard_input_topology", GET_DEFAULT()))) {
     _preCADDiscardInput = theVal;
     SetPreCADOptionValue("discard_input_topology", theVal ? "yes" : "no" );
     NotifySubMeshesHypothesisModification();
   }
 }
 
+//=============================================================================
+// Return true if any PreCAD option is activated
+bool BLSURFPlugin_Hypothesis::HasPreCADOptions(const BLSURFPlugin_Hypothesis* hyp)
+{
+  if ( !hyp )
+  {
+    return false;
+  }
+  bool orDefault, isOk;
+  return ( ToBool( hyp->GetPreCADOptionValue("closed_geometry"           , &orDefault )) ||
+           ToBool( hyp->GetPreCADOptionValue("discard_input_topology"    , &orDefault )) ||
+           ToBool( hyp->GetPreCADOptionValue("merge_edges"               , &orDefault )) ||
+           ToBool( hyp->GetPreCADOptionValue("remove_duplicate_cad_faces", &orDefault )) ||
+           ToBool( hyp->GetPreCADOptionValue("process_3d_topology"       , &orDefault )) ||
+           ToBool( hyp->GetPreCADOption     ("manifold_geometry")        , &isOk       ) ||
+           hyp->GetPreCADOptionValue("sewing_tolerance", &orDefault ) != "5e-4*D"        ||
+           !hyp->_preCadFacesPeriodicityVector.empty()                                   ||
+           !hyp->_preCadEdgesPeriodicityVector.empty()                                   ||
+           !hyp->_facesPeriodicityVector.empty()                                         ||
+           !hyp->_edgesPeriodicityVector.empty()                                         ||
+           !hyp->_verticesPeriodicityVector.empty()                                      ||
+           !hyp->GetHyperPatches().empty()                                               ||
+           hyp->GetTopology() != FromCAD );
+}
+
 //=============================================================================
 // void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName, bool isBinary)
 void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName)
@@ -995,9 +1084,9 @@ void BLSURFPlugin_Hypothesis::AddPreCADOption(const std::string& optionName, con
 }
 
 //=============================================================================
-std::string BLSURFPlugin_Hypothesis::GetOption(const std::string& optionName)
+std::string BLSURFPlugin_Hypothesis::GetOption(const std::string& optionName) const
 {
-  TOptionValues::iterator op_val = _customOption2value.find(optionName);
+  TOptionValues::const_iterator op_val = _customOption2value.find(optionName);
   if (op_val != _customOption2value.end())
     return op_val->second;
   else
@@ -1005,9 +1094,9 @@ std::string BLSURFPlugin_Hypothesis::GetOption(const std::string& optionName)
 }
 
 //=============================================================================
-std::string BLSURFPlugin_Hypothesis::GetPreCADOption(const std::string& optionName)
+std::string BLSURFPlugin_Hypothesis::GetPreCADOption(const std::string& optionName) const
 {
-  TOptionValues::iterator op_val = _customOption2value.find(optionName);
+  TOptionValues::const_iterator op_val = _customOption2value.find(optionName);
   if (op_val != _customOption2value.end())
     return op_val->second;
   else
@@ -1204,7 +1293,6 @@ void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry,
            ++it_clAt;
        }
        while ( it_clAt != _classAttractors.end() );
-       MESSAGE("_classAttractors.size() = "<<_classAttractors.size())
        NotifySubMeshesHypothesisModification();
      }
      else
@@ -1231,7 +1319,6 @@ void BLSURFPlugin_Hypothesis::ClearSizeMaps() {
 //                                                        bool toEnforceInternalVertices,
 //                                                        TEnfGroupName theGroupName) {
 
-//  MESSAGE("BLSURFPlugin_Hypothesis::SetInternalEnforcedVertex("<< theFaceEntry << ", "
 //      << toEnforceInternalVertices << ", " << theGroupName << ")");
   
 //  TFaceEntryInternalVerticesList::iterator it = _faceEntryInternalVerticesList.find(theFaceEntry);
@@ -1254,15 +1341,14 @@ void BLSURFPlugin_Hypothesis::ClearSizeMaps() {
 //=======================================================================
 //function : SetEnforcedVertex
 //=======================================================================
-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 << ")");
-
+bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry        theFaceEntry,
+                                                TEnfName      theVertexName,
+                                                TEntry        theVertexEntry,
+                                                TEnfGroupName theGroupName,
+                                                double x, double y, double z)
+{
   SetPhysicalMesh(PhysicalLocalSize);
 
-  //  TEnfVertexList::iterator it;
   bool toNotify = false;
   bool toCreate = true;
 
@@ -1279,27 +1365,23 @@ bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, TEnfName th
   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 (oldEnVertex->grpName != theGroupName) {
-      MESSAGE("Update group name from \"" << oldEnVertex->grpName << "\" to \"" << theGroupName << "\"");
       oldEnVertex->grpName = theGroupName;
       toNotify = true;
     }
     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;
@@ -1322,7 +1404,6 @@ bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, TEnfName th
 //   //////// CREATE ////////////
   if (toCreate) {
     toNotify = true;
-    MESSAGE("Creating new enforced vertex");
     _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex);
     _enfVertexList.insert(newEnfVertex);
     if (theVertexEntry == "") {
@@ -1338,7 +1419,6 @@ bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, TEnfName th
   if (toNotify)
     NotifySubMeshesHypothesisModification();
 
-  MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END");
   return toNotify;
 }
 
@@ -1452,7 +1532,6 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, do
   TEnfVertexEntryEnfVertexMap::iterator it_enfVertexEntry = _enfVertexEntryEnfVertexMap.find(theVertexEntry);
   if (it_enfVertexEntry != _enfVertexEntryEnfVertexMap.end()) {
     // Success
-    MESSAGE("Found enforced vertex with geom entry " << theVertexEntry);
     oldEnfVertex = it_enfVertexEntry->second;
 
     _enfVertexEntryEnfVertexMap.erase(it_enfVertexEntry);
@@ -1474,7 +1553,6 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, do
     TCoordsEnfVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords);
     if (it_coords_enf != _coordsEnfVertexMap.end()) {
       // Success
-      MESSAGE("Found enforced vertex with coords " << x << ", " << y << ", " << z);
       oldEnfVertex = it_coords_enf->second;
 
       _coordsEnfVertexMap.erase(it_coords_enf);
@@ -1497,8 +1575,6 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, do
     }
   }
 
-  MESSAGE("Remove enf vertex from _enfVertexList");
-
   // update _enfVertexList
   TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
   if (it != _enfVertexList.end()) {
@@ -1507,7 +1583,6 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, do
       _enfVertexList.erase(it);
       toNotify = true;
     }
-    MESSAGE("Done");
   }
 
   // update _faceEntryEnfVertexListMap
@@ -1515,9 +1590,7 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, do
   currentEnfVertexList.erase(oldEnfVertex);
 
   if (currentEnfVertexList.size() == 0) {
-    MESSAGE("Remove _faceEntryEnfVertexListMap[" << theFaceEntry <<"]");
     _faceEntryEnfVertexListMap.erase(theFaceEntry);
-    MESSAGE("Done");
   }
 
   if (toNotify)
@@ -1552,7 +1625,6 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry)
           _enfVertexList.erase(it);
           toNotify = true;
         }
-        MESSAGE("Done");
       }
     }
     _faceEntryCoordsListMap.erase(it_entry_coords);
@@ -1576,7 +1648,6 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry)
           _enfVertexList.erase(it);
           toNotify = true;
         }
-        MESSAGE("Done");
       }
     }
     _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
@@ -1755,7 +1826,7 @@ void BLSURFPlugin_Hypothesis::ClearPreCadPeriodicityVectors() {
 //function : AddPreCadFacesPeriodicity
 //=======================================================================
 void BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity(TEntry theFace1Entry, TEntry theFace2Entry,
-    std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries) {
+                                                        std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries) {
 
   TPreCadPeriodicity preCadFacesPeriodicity;
   preCadFacesPeriodicity.shape1Entry = theFace1Entry;
@@ -1786,44 +1857,45 @@ void BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TE
 }
 
 //=============================================================================
-std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
-   // We must keep at least the same number of arguments when increasing the SALOME version
-   // When MG-CADSurf becomes CADMESH, some parameters were fused into a single one. Thus the same
-   // parameter can be written several times to keep the old global number of parameters.
+std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save)
+{
+  // We must keep at least the same number of arguments when increasing the SALOME version
+  // When MG-CADSurf becomes CADMESH, some parameters were fused into a single one. Thus the same
+  // parameter can be written several times to keep the old global number of parameters.
+
+  // Treat old options which are now in the advanced options
+  TOptionValues::iterator op_val;
+  int _decimesh = -1;
+  int _preCADRemoveNanoEdges = -1;
+  double _preCADEpsNano = -1.0;
+  op_val = _option2value.find("respect_geometry");
+  if (op_val != _option2value.end()) {
+    std::string value = op_val->second;
+    if (!value.empty())
+      _decimesh = value.compare("1") == 0 ? 1 : 0;
+  }
+  op_val = _preCADoption2value.find("remove_tiny_edges");
+  if (op_val != _preCADoption2value.end()) {
+    std::string value = op_val->second;
+    if (!value.empty())
+      _preCADRemoveNanoEdges = value.compare("1") == 0 ? 1 : 0;
+  }
+  op_val = _preCADoption2value.find("tiny_edge_length");
+  if (op_val != _preCADoption2value.end()) {
+    std::string value = op_val->second;
+    if (!value.empty())
+      _preCADEpsNano = strtod(value.c_str(), NULL);
+  }
 
-   // Treat old options which are now in the advanced options
-   TOptionValues::iterator op_val;
-   int _decimesh = -1;
-   int _preCADRemoveNanoEdges = -1;
-   double _preCADEpsNano = -1.0;
-   op_val = _option2value.find("respect_geometry");
-   if (op_val != _option2value.end()) {
-     std::string value = op_val->second;
-     if (!value.empty())
-       _decimesh = value.compare("1") == 0 ? 1 : 0;
-   }
-   op_val = _preCADoption2value.find("remove_tiny_edges");
-   if (op_val != _preCADoption2value.end()) {
-     std::string value = op_val->second;
-     if (!value.empty())
-       _preCADRemoveNanoEdges = value.compare("1") == 0 ? 1 : 0;
-   }
-   op_val = _preCADoption2value.find("tiny_edge_length");
-   if (op_val != _preCADoption2value.end()) {
-     std::string value = op_val->second;
-     if (!value.empty())
-       _preCADEpsNano = strtod(value.c_str(), NULL);
-   }
-   
   save << " " << (int) _topology << " " << (int) _physicalMesh << " " << (int) _geometricMesh << " " << _phySize << " "
-      << _angleMesh << " " << _gradation << " " << (int) _quadAllowed << " " << _decimesh;
+       << _angleMesh << " " << _gradation << " " << (int) _quadAllowed << " " << _decimesh;
   save << " " << _minSize << " " << _maxSize << " " << _angleMesh << " " << _minSize << " " << _maxSize << " " << _verb;
   save << " " << (int) _preCADMergeEdges << " " << _preCADRemoveNanoEdges << " " << (int) _preCADDiscardInput << " " << _preCADEpsNano ;
   save << " " << (int) _enforcedInternalVerticesAllFaces;
   save << " " << (int) _phySizeRel << " " << (int) _minSizeRel << " " << (int) _maxSizeRel << " " << _chordalError ;
   save << " " << (int) _anisotropic << " " << _anisotropicRatio << " " << (int) _removeTinyEdges << " " << _tinyEdgeLength ;
   save << " " << (int) _badElementRemoval << " " << _badElementAspectRatio << " " << (int) _optimizeMesh << " " << (int) _quadraticMesh ;
-  save << " " << (int) _preCADProcess3DTopology << " " << (int) _preCADRemoveDuplicateCADFaces << " " << (int) _preCADRemoveTinyUVEdges;
+  save << " " << (int) _preCADProcess3DTopology << " " << (int) _preCADRemoveDuplicateCADFaces;
   save << " " << (int)_optimiseTinyEdges << " " << _tinyEdgeOptimisationLength;
   save << " " << (int)_correctSurfaceIntersec << " " << _corrSurfaceIntersCost;
   save << " " << (int)_useGradation << " " << (int)_useVolumeGradation << " " << _volumeGradation;
@@ -1896,7 +1968,6 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
     }
     save << " " << "__NEW_ATTRACTORS_END__";
     test << " " << "__NEW_ATTRACTORS_END__";
-    MESSAGE(" Attractor hypothesis saved as "<<test.str())
   }
 
   TEnfVertexList::const_iterator it_enf = _enfVertexList.begin();
@@ -1933,7 +2004,10 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
         save << " " << "__BEGIN_FACELIST__";
       }
       for (; faceEntriesIt != enfVertex->faceEntries.end(); ++faceEntriesIt)
-        save << " " << (*faceEntriesIt);
+        if ( faceEntriesIt->empty() )
+          save << " _no_face_";
+        else
+          save << " " << (*faceEntriesIt);
       if (hasFaces)
         save << " " << "__END_FACELIST__";
       save << " " << "__END_VERTEX__";
@@ -1950,6 +2024,17 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
   SaveEdgesPeriodicity(save);
   SaveVerticesPeriodicity(save);
 
+  // HYPER-PATCHES
+  save << " " << _hyperPatchList.size() << " ";
+  for ( size_t i = 0; i < _hyperPatchList.size(); ++i )
+  {
+    THyperPatchTags& patch = _hyperPatchList[i];
+    save << patch.size() << " ";
+    THyperPatchTags::iterator tag = patch.begin();
+    for ( ; tag != patch.end(); ++tag )
+      save << *tag << " ";
+  }
+
   return save;
 }
 
@@ -1957,7 +2042,6 @@ void BLSURFPlugin_Hypothesis::SaveFacesPeriodicity(std::ostream & save){
 
   TFacesPeriodicityVector::const_iterator it_faces_periodicity = _facesPeriodicityVector.begin();
   if (it_faces_periodicity != _facesPeriodicityVector.end()) {
-    MESSAGE("__FACES_PERIODICITY_BEGIN__");
     save << " " << "__FACES_PERIODICITY_BEGIN__";
     for (; it_faces_periodicity != _facesPeriodicityVector.end(); ++it_faces_periodicity) {
       TFacesPeriodicity periodicity_i = (*it_faces_periodicity);
@@ -1971,7 +2055,6 @@ void BLSURFPlugin_Hypothesis::SaveFacesPeriodicity(std::ostream & save){
       save << " " << "__END_PERIODICITY_DESCRIPTION__";
     }
     save << " " << "__FACES_PERIODICITY_END__";
-    MESSAGE("__FACES_PERIODICITY_END__");
   }
 }
 
@@ -1980,7 +2063,6 @@ void BLSURFPlugin_Hypothesis::SaveEdgesPeriodicity(std::ostream & save){
   TEdgesPeriodicityVector::const_iterator it_edges_periodicity = _edgesPeriodicityVector.begin();
   if (it_edges_periodicity != _edgesPeriodicityVector.end()) {
     save << " " << "__EDGES_PERIODICITY_BEGIN__";
-    MESSAGE("__EDGES_PERIODICITY_BEGIN__");
     for (; it_edges_periodicity != _edgesPeriodicityVector.end(); ++it_edges_periodicity) {
       TEdgePeriodicity periodicity_i = (*it_edges_periodicity);
       save << " " << "__BEGIN_PERIODICITY_DESCRIPTION__";
@@ -2006,7 +2088,6 @@ void BLSURFPlugin_Hypothesis::SaveEdgesPeriodicity(std::ostream & save){
       save << " " << "__END_PERIODICITY_DESCRIPTION__";
     }
     save << " " << "__EDGES_PERIODICITY_END__";
-    MESSAGE("__EDGES_PERIODICITY_END__");
   }
 }
 
@@ -2014,7 +2095,6 @@ void BLSURFPlugin_Hypothesis::SaveVerticesPeriodicity(std::ostream & save){
 
   TVerticesPeriodicityVector::const_iterator it_vertices_periodicity = _verticesPeriodicityVector.begin();
   if (it_vertices_periodicity != _verticesPeriodicityVector.end()) {
-    MESSAGE("__VERTICES_PERIODICITY_BEGIN__");
     save << " " << "__VERTICES_PERIODICITY_BEGIN__";
     for (; it_vertices_periodicity != _verticesPeriodicityVector.end(); ++it_vertices_periodicity) {
       TVertexPeriodicity periodicity_i = (*it_vertices_periodicity);
@@ -2034,7 +2114,6 @@ void BLSURFPlugin_Hypothesis::SaveVerticesPeriodicity(std::ostream & save){
       save << " " << "__END_PERIODICITY_DESCRIPTION__";
     }
     save << " " << "__VERTICES_PERIODICITY_END__";
-    MESSAGE("__VERTICES_PERIODICITY_END__");
   }
 }
 
@@ -2091,7 +2170,8 @@ void BLSURFPlugin_Hypothesis::SavePreCADPeriodicity(std::ostream & save, const c
 }
 
 //=============================================================================
-std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
+std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
+{
   bool isOK = true;
   int i;
   double val;
@@ -2359,12 +2439,6 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
       else
         load.clear(std::ios::badbit | load.rdstate());
 
-      isOK = static_cast<bool>(load >> i);
-      if (isOK)
-        _preCADRemoveTinyUVEdges = (bool) i;
-      else
-        load.clear(std::ios::badbit | load.rdstate());
-
       isOK = static_cast<bool>(load >> i);
       if (isOK)
         _optimiseTinyEdges = (bool) i;
@@ -2463,7 +2537,8 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
           break;
         }
       }
-      value.resize(len - 2); //cut off "%#"
+      if ( value[ len - 1] == '#' )
+        value.resize(len - 2); //cut off "%#"
     }
   }
 
@@ -2516,7 +2591,8 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
           break;
         }
       }
-      value.resize(len - 2); //cut off "%#"
+      if ( value[ len - 1] == '#' )
+        value.resize(len - 2); //cut off "%#"
       _customOption2value[optName] = value;
     }
   }
@@ -2569,7 +2645,8 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
           break;
         }
       }
-      value.resize(len - 2); //cut off "%#"
+      if ( value[ len - 1] == '#' )
+        value.resize(len - 2); //cut off "%#"
     }
   }
 
@@ -2708,7 +2785,6 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
       isOK = static_cast<bool>(load >> attParams[0]>>attParams[1]>>attParams[2]>>attParams[3]); //>>step);
     }
     if (isOK) {
-      MESSAGE(" LOADING ATTRACTOR HYPOTHESIS ")
       const TopoDS_Shape attractorShape = BLSURFPlugin_Hypothesis::entryToShape(newAtShapeEntry);
       const TopoDS_Face faceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(newAtFaceEntry));
       BLSURFPlugin_Attractor* attractor = new BLSURFPlugin_Attractor(faceShape, attractorShape, newAtShapeEntry);//, step);
@@ -2743,17 +2819,17 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
 // __ENFORCED_VERTICES_BEGIN__ 
 // __BEGIN_VERTEX__  => no name, no entry
 // __BEGIN_GROUP__ mon groupe __END_GROUP__
-// __BEGIN_COORDS__ 10 10 10 __END_COORDS__ 
-// __BEGIN_FACELIST__ 0:1:1:1:1 __END_FACELIST__ 
-// __END_VERTEX__ 
+// __BEGIN_COORDS__ 10 10 10 __END_COORDS__
+// __BEGIN_FACELIST__ 0:1:1:1:1 __END_FACELIST__
+// __END_VERTEX__
 // __BEGIN_VERTEX__ => no coords
-// __BEGIN_NAME__ mes points __END_NAME__ 
+// __BEGIN_NAME__ mes points __END_NAME__
 // __BEGIN_ENTRY__ 0:1:1:4 __END_ENTRY__
 // __BEGIN_GROUP__ mon groupe __END_GROUP__
 // __BEGIN_FACELIST__ 0:1:1:1:3 __END_FACELIST__
-// __END_VERTEX__ 
+// __END_VERTEX__
 // __ENFORCED_VERTICES_END__
-// 
+//
 
   std::string enfSeparator;
   std::string enfName;
@@ -2762,29 +2838,28 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
   TEntryList enfFaceEntryList;
   double enfCoords[3];
   bool hasCoords = false;
-  
+
   _faceEntryEnfVertexListMap.clear();
   _enfVertexList.clear();
   _faceEntryCoordsListMap.clear();
   _coordsEnfVertexMap.clear();
   _faceEntryEnfVertexEntryListMap.clear();
   _enfVertexEntryEnfVertexMap.clear();
-  
-  
-  while (isOK && hasEnforcedVertex) {
+
+
+  while (isOK && hasEnforcedVertex)
+  {
     isOK = static_cast<bool>(load >> enfSeparator); // __BEGIN_VERTEX__
     TEnfVertex *enfVertex = new TEnfVertex();
-//     MESSAGE("enfSeparator: " <<enfSeparator);
     if (enfSeparator == "__ENFORCED_VERTICES_END__")
       break; // __ENFORCED_VERTICES_END__
     if (enfSeparator != "__BEGIN_VERTEX__")
       throw std::exception();
-    
+
     while (isOK) {
       isOK = static_cast<bool>(load >> enfSeparator);
-      MESSAGE("enfSeparator: " <<enfSeparator);
       if (enfSeparator == "__END_VERTEX__") {
-        
+
         enfVertex->name = enfName;
         enfVertex->geomEntry = enfGeomEntry;
         enfVertex->grpName = enfGroup;
@@ -2792,9 +2867,9 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
         if (hasCoords)
           enfVertex->coords.assign(enfCoords,enfCoords+3);
         enfVertex->faceEntries = enfFaceEntryList;
-        
+
         _enfVertexList.insert(enfVertex);
-        
+
         if (enfVertex->coords.size()) {
           _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
           for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
@@ -2809,7 +2884,7 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
             _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
           }
         }
-        
+
         enfName.clear();
         enfGeomEntry.clear();
         enfGroup.clear();
@@ -2817,7 +2892,7 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
         hasCoords = false;
         break; // __END_VERTEX__
       }
-        
+
       if (enfSeparator == "__BEGIN_NAME__") {  // __BEGIN_NAME__
         while (isOK && (enfSeparator != "__END_NAME__")) {
           isOK = static_cast<bool>(load >> enfSeparator);
@@ -2827,17 +2902,15 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
             enfName += enfSeparator;
           }
         }
-        MESSAGE("enfName: " <<enfName);
       }
-        
+
       if (enfSeparator == "__BEGIN_ENTRY__") {  // __BEGIN_ENTRY__
         isOK = static_cast<bool>(load >> enfGeomEntry);
         isOK = static_cast<bool>(load >> enfSeparator); // __END_ENTRY__
         if (enfSeparator != "__END_ENTRY__")
           throw std::exception();
-        MESSAGE("enfGeomEntry: " <<enfGeomEntry);
       }
-        
+
       if (enfSeparator == "__BEGIN_GROUP__") {  // __BEGIN_GROUP__
         while (isOK && (enfSeparator != "__END_GROUP__")) {
           isOK = static_cast<bool>(load >> enfSeparator);
@@ -2847,33 +2920,31 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
             enfGroup += enfSeparator;
           }
         }
-        MESSAGE("enfGroup: " <<enfGroup);
       }
-        
+
       if (enfSeparator == "__BEGIN_COORDS__") {  // __BEGIN_COORDS__
         hasCoords = true;
         isOK = static_cast<bool>(load >> enfCoords[0] >> enfCoords[1] >> enfCoords[2]);
         isOK = static_cast<bool>(load >> enfSeparator); // __END_COORDS__
         if (enfSeparator != "__END_COORDS__")
           throw std::exception();
-        MESSAGE("enfCoords: " << enfCoords[0] <<","<< enfCoords[1] <<","<< enfCoords[2]);
-      } 
-        
+      }
+
       if (enfSeparator == "__BEGIN_FACELIST__") {  // __BEGIN_FACELIST__
         while (isOK && (enfSeparator != "__END_FACELIST__")) {
           isOK = static_cast<bool>(load >> enfSeparator);
           if (enfSeparator != "__END_FACELIST__") {
             enfFaceEntryList.insert(enfSeparator);
-            MESSAGE(enfSeparator << " was inserted into enfFaceEntryList");
           }
         }
-      } 
+      }
     }
   }
 
   // PERIODICITY
 
-  if (hasPreCADFacesPeriodicity){
+  if (hasPreCADFacesPeriodicity)
+  {
     LoadPreCADPeriodicity(load, "FACES");
 
     isOK = static_cast<bool>(load >> option_or_sm);
@@ -2889,7 +2960,8 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
     }
   }
 
-  if (hasPreCADEdgesPeriodicity){
+  if (hasPreCADEdgesPeriodicity)
+  {
     LoadPreCADPeriodicity(load, "EDGES");
 
     isOK = static_cast<bool>(load >> option_or_sm);
@@ -2903,8 +2975,9 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
     }
   }
 
-  if (hasFacesPeriodicity){
-      LoadFacesPeriodicity(load);
+  if (hasFacesPeriodicity)
+  {
+    LoadFacesPeriodicity(load);
 
     isOK = static_cast<bool>(load >> option_or_sm);
     if (isOK) {
@@ -2915,8 +2988,9 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
     }
   }
 
-  if (hasEdgesPeriodicity){
-      LoadEdgesPeriodicity(load);
+  if (hasEdgesPeriodicity)
+  {
+    LoadEdgesPeriodicity(load);
 
     isOK = static_cast<bool>(load >> option_or_sm);
     if (isOK)
@@ -2925,7 +2999,38 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
   }
 
   if (hasVerticesPeriodicity)
-      LoadVerticesPeriodicity(load);
+    LoadVerticesPeriodicity(load);
+
+  // HYPER-PATCHES
+  if ( !option_or_sm.empty() && option_or_sm[0] == '_' )
+    isOK = static_cast<bool>(load >> option_or_sm);
+  if ( isOK && !option_or_sm.empty() )
+  {
+    int nbPatches = atoi( option_or_sm.c_str() );
+    if ( nbPatches >= 0 )
+    {
+      _hyperPatchList.resize( nbPatches );
+      for ( int iP = 0; iP < nbPatches && isOK; ++iP )
+      {
+        isOK = static_cast<bool>(load >> i) && i >= 2;
+        if ( !isOK ) break;
+        int nbTags = i;
+        for ( int iT = 0; iT < nbTags; ++iT )
+        {
+          if (( isOK = static_cast<bool>(load >> i)))
+            _hyperPatchList[ iP ].insert( i );
+          else
+            break;
+        }
+      }
+      if ( !isOK ) // remove invalid patches
+      {
+        for ( i = nbPatches - 1; i >= 0; i-- )
+          if ( _hyperPatchList[i].size() < 2 )
+            _hyperPatchList.resize( i );
+      }
+    }
+  }
 
   return load;
 }
@@ -2942,18 +3047,15 @@ void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load){
 
   while (isOK) {
     isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
-    MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
     TFacesPeriodicity *periodicity_i = new TFacesPeriodicity();
     if (periodicitySeparator == "__FACES_PERIODICITY_END__")
       break; // __FACES_PERIODICITY_END__
     if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
-      MESSAGE("//" << periodicitySeparator << "//");
       throw std::exception();
     }
 
     while (isOK) {
       isOK = static_cast<bool>(load >> periodicitySeparator);
-      MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
       if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
 
         periodicity_i->first = shape1Entry;
@@ -2969,7 +3071,6 @@ void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load){
         isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY1__
         if (periodicitySeparator != "__END_ENTRY1__")
           throw std::exception();
-        MESSAGE("shape1Entry: " <<shape1Entry);
       }
 
       if (periodicitySeparator == "__BEGIN_ENTRY2__") {  // __BEGIN_ENTRY2__
@@ -2977,7 +3078,6 @@ void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load){
         isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY2__
         if (periodicitySeparator != "__END_ENTRY2__")
           throw std::exception();
-        MESSAGE("shape2Entry: " <<shape2Entry);
       }
     }
   }
@@ -2999,18 +3099,15 @@ void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
 
   while (isOK) {
     isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
-    MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
     TEdgePeriodicity *periodicity_i = new TEdgePeriodicity();
     if (periodicitySeparator == "__EDGES_PERIODICITY_END__")
       break; // __EDGES_PERIODICITY_END__
     if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
-      MESSAGE("//" << periodicitySeparator << "//");
       throw std::exception();
     }
 
     while (isOK) {
       isOK = static_cast<bool>(load >> periodicitySeparator);
-      MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
       if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
 
         periodicity_i->theFace1Entry = theFace1Entry;
@@ -3026,13 +3123,10 @@ void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
 
       if (periodicitySeparator == "__BEGIN_FACE1__") {  // __BEGIN_FACE1__
         isOK = static_cast<bool>(load >> theFace1Entry);
-        MESSAGE("//" << theFace1Entry << "//");
         isOK = static_cast<bool>(load >> periodicitySeparator); // __END_FACE1__
         if (periodicitySeparator != "__END_FACE1__"){
-          MESSAGE("//" << periodicitySeparator << "//");
           throw std::exception();
         }
-        MESSAGE("theFace1Entry: " <<theFace1Entry);
       }
 
       if (periodicitySeparator == "__BEGIN_EDGE1__") {  // __BEGIN_EDGE1__
@@ -3040,7 +3134,6 @@ void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
         isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE1__
         if (periodicitySeparator != "__END_EDGE1__")
           throw std::exception();
-        MESSAGE("theEdge1Entry: " <<theEdge1Entry);
       }
 
       if (periodicitySeparator == "__BEGIN_FACE2__") {  // __BEGIN_FACE2__
@@ -3048,7 +3141,6 @@ void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
         isOK = static_cast<bool>(load >> periodicitySeparator); // __END_FACE2__
         if (periodicitySeparator != "__END_FACE2__")
           throw std::exception();
-        MESSAGE("theFace2Entry: " <<theFace2Entry);
       }
 
       if (periodicitySeparator == "__BEGIN_EDGE2__") {  // __BEGIN_EDGE2__
@@ -3056,7 +3148,6 @@ void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
         isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE2__
         if (periodicitySeparator != "__END_EDGE2__")
           throw std::exception();
-        MESSAGE("theEdge2Entry: " <<theEdge2Entry);
       }
 
       if (periodicitySeparator == "__BEGIN_EDGE_ORIENTATION__") {  // __BEGIN_EDGE_ORIENTATION__
@@ -3064,14 +3155,13 @@ void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
         isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE_ORIENTATION__
         if (periodicitySeparator != "__END_EDGE_ORIENTATION__")
           throw std::exception();
-        MESSAGE("edge_orientation: " <<edge_orientation);
       }
     }
   }
 }
 
-void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load){
-
+void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load)
+{
   bool isOK = true;
 
   std::string periodicitySeparator;
@@ -3084,18 +3174,15 @@ void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load){
 
   while (isOK) {
     isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
-    MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
     TVertexPeriodicity *periodicity_i = new TVertexPeriodicity();
     if (periodicitySeparator == "__VERTICES_PERIODICITY_END__")
       break; // __VERTICES_PERIODICITY_END__
     if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
-      MESSAGE("//" << periodicitySeparator << "//");
       throw std::exception();
     }
 
     while (isOK) {
       isOK = static_cast<bool>(load >> periodicitySeparator);
-      MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
       if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
 
         periodicity_i->theEdge1Entry = theEdge1Entry;
@@ -3113,7 +3200,6 @@ void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load){
         isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE1__
         if (periodicitySeparator != "__END_EDGE1__")
           throw std::exception();
-        MESSAGE("theEdge1Entry: " <<theEdge1Entry);
       }
 
       if (periodicitySeparator == "__BEGIN_VERTEX1__") {  // __BEGIN_VERTEX1__
@@ -3121,7 +3207,6 @@ void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load){
         isOK = static_cast<bool>(load >> periodicitySeparator); // __END_VERTEX1__
         if (periodicitySeparator != "__END_VERTEX1__")
           throw std::exception();
-        MESSAGE("theVertex1Entry: " <<theVertex1Entry);
       }
 
       if (periodicitySeparator == "__BEGIN_EDGE2__") {  // __BEGIN_EDGE2__
@@ -3129,7 +3214,6 @@ void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load){
         isOK = static_cast<bool>(load >> periodicitySeparator); // __END_EDGE2__
         if (periodicitySeparator != "__END_EDGE2__")
           throw std::exception();
-        MESSAGE("theEdge2Entry: " <<theEdge2Entry);
       }
 
       if (periodicitySeparator == "__BEGIN_VERTEX2__") {  // __BEGIN_VERTEX2__
@@ -3137,7 +3221,6 @@ void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load){
         isOK = static_cast<bool>(load >> periodicitySeparator); // __END_VERTEX2__
         if (periodicitySeparator != "__END_VERTEX2__")
           throw std::exception();
-        MESSAGE("theVertex2Entry: " <<theVertex2Entry);
       }
     }
   }
@@ -3164,29 +3247,21 @@ void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const c
 
   while (isOK) {
     isOK = static_cast<bool>(load >> periodicitySeparator); // __BEGIN_PERIODICITY_DESCRIPTION__
-    MESSAGE("periodicitySeparator 1: " <<periodicitySeparator);
     TPreCadPeriodicity *periodicity_i = new TPreCadPeriodicity();
-//     MESSAGE("periodicitySeparator: " <<periodicitySeparator);
     std::string endSeparator = "__PRECAD_" + std::string(shapeType) + "_PERIODICITY_END__";
     if (periodicitySeparator == endSeparator)
       break; // __PRECAD_FACES_PERIODICITY_END__
     if (periodicitySeparator != "__BEGIN_PERIODICITY_DESCRIPTION__"){
-      MESSAGE("//" << endSeparator << "//");
-      MESSAGE("//" << periodicitySeparator << "//");
       throw std::exception();
     }
 
     while (isOK) {
       isOK = static_cast<bool>(load >> periodicitySeparator);
-      MESSAGE("periodicitySeparator 2: " <<periodicitySeparator);
       if (periodicitySeparator == "__END_PERIODICITY_DESCRIPTION__") {
 
         periodicity_i->shape1Entry = shape1Entry;
         periodicity_i->shape2Entry = shape2Entry;
 
-        MESSAGE("theSourceVerticesEntries.size(): " << theSourceVerticesEntries.size());
-        MESSAGE("theTargetVerticesEntries.size(): " << theTargetVerticesEntries.size());
-
         if (hasSourceVertices)
           periodicity_i->theSourceVerticesEntries = theSourceVerticesEntries;
         if (hasTargetVertices)
@@ -3209,7 +3284,6 @@ void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const c
         isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY1__
         if (periodicitySeparator != "__END_ENTRY1__")
           throw std::exception();
-        MESSAGE("shape1Entry: " <<shape1Entry);
       }
 
       if (periodicitySeparator == "__BEGIN_ENTRY2__") {  // __BEGIN_ENTRY2__
@@ -3217,7 +3291,6 @@ void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const c
         isOK = static_cast<bool>(load >> periodicitySeparator); // __END_ENTRY2__
         if (periodicitySeparator != "__END_ENTRY2__")
           throw std::exception();
-        MESSAGE("shape2Entry: " <<shape2Entry);
       }
 
       if (periodicitySeparator == "__BEGIN_SOURCE_VERTICES_LIST__") {  // __BEGIN_SOURCE_VERTICES_LIST__
@@ -3226,7 +3299,6 @@ void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const c
           isOK = static_cast<bool>(load >> periodicitySeparator);
           if (periodicitySeparator != "__END_SOURCE_VERTICES_LIST__") {
             theSourceVerticesEntries.push_back(periodicitySeparator);
-            MESSAGE("theSourceVerticesEntries: " <<periodicitySeparator);
           }
         }
       }
@@ -3237,7 +3309,6 @@ void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const c
           isOK = static_cast<bool>(load >> periodicitySeparator);
           if (periodicitySeparator != "__END_TARGET_VERTICES_LIST__") {
             theTargetVerticesEntries.push_back(periodicitySeparator);
-            MESSAGE("theTargetVerticesEntries: " <<periodicitySeparator);
           }
         }
       }