Salome HOME
bos #20256: [CEA 18523] Porting SMESH to int 64 bits
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Hypothesis.cxx
index 3ebd4bb6c7c6e1cdb2cf3ec479cdc05d35c8381a..e69a2696fd643025180c745b0c5d1000eb5a2ac2 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -32,6 +32,8 @@
 #include <iostream>
 #include <sstream>
 
+#include <Basics_Utils.hxx>
+
 // cascade include
 #include "ShapeAnalysis.hxx"
 
 #include CORBA_CLIENT_HEADER(GEOM_Gen)
 
 #include <meshgems/meshgems.h>
+#define MESHGEMS_VERSION_HEX (MESHGEMS_VERSION_MAJOR << 16 | MESHGEMS_VERSION_MINOR << 8 | MESHGEMS_VERSION_PATCH)
+
+#include <boost/archive/text_oarchive.hpp>
+#include <boost/archive/text_iarchive.hpp>
+#include <boost/serialization/set.hpp>
+#include <boost/serialization/vector.hpp>
+#include <boost/serialization/string.hpp>
 
 namespace
 {
@@ -112,19 +121,25 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, SMESH_Gen * gen, boo
 
   // Advanced options with their defaults according to MG User Manual
 
-  const char* boolOptionNames[] = { "enforce_cad_edge_sizes",                   // default = 0
-                                    "jacobian_rectification_respect_geometry",  // default = 1
-                                    "rectify_jacobian",                         // default = 1
-                                    "respect_geometry",                         // default = 1
-                                    "tiny_edge_avoid_surface_intersections",    // default = 1
-                                    "debug",                                    // default = 0
-                                    "allow_patch_independent",                   // false
-                                    "" // mark of end
+  const char* boolOptionNames[] = {
+#if MESHGEMS_VERSION_HEX < 0x020A00
+    "enforce_cad_edge_sizes",                   // default = 0 // Deprecated since MeshGems 2.10
+#endif
+    "jacobian_rectification_respect_geometry",  // default = 1
+    "rectify_jacobian",                         // default = 1
+    "respect_geometry",                         // default = 1
+    "tiny_edge_avoid_surface_intersections",    // default = 1
+    "debug",                                    // default = 0
+    "allow_patch_independent",                   // false
+    "" // mark of end
   };
 
-  const char* intOptionNames[] = {          "max_number_of_points_per_patch",           // default = 100000
-                                            "max_number_of_threads",                    // default = 4
-                                            "" // mark of end
+  const char* intOptionNames[] = {
+#if MESHGEMS_VERSION_HEX < 0x020A00
+    "max_number_of_points_per_patch",           // default = 100000 // Deprecated since MeshGems 2.10
+#endif
+    "max_number_of_threads",                    // default = 4
+    "" // mark of end
   };
   const char* doubleOptionNames[] = {       // "surface_intersections_processing_max_cost",// default = 15
                                             // "periodic_tolerance",                       // default = diag/100
@@ -207,9 +222,13 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, SMESH_Gen * gen, boo
 
   // default values to be used while MG meshing
 
-  _defaultOptionValues["enforce_cad_edge_sizes"                 ] = "no";
+#if MESHGEMS_VERSION_HEX < 0x020A00
+  _defaultOptionValues["enforce_cad_edge_sizes"                 ] = "no";  // Deprecated since MeshGems 2.10
+#endif
   _defaultOptionValues["jacobian_rectification_respect_geometry"] = "yes";
-  _defaultOptionValues["max_number_of_points_per_patch"         ] = "0";
+#if MESHGEMS_VERSION_HEX < 0x020A00
+  _defaultOptionValues["max_number_of_points_per_patch"         ] = "0";   // Deprecated since MeshGems 2.10
+#endif
   _defaultOptionValues["max_number_of_threads"                  ] = "4";
   _defaultOptionValues["rectify_jacobian"                       ] = "yes";
   _defaultOptionValues["respect_geometry"                       ] = "yes";
@@ -232,7 +251,7 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, SMESH_Gen * gen, boo
     _defaultOptionValues["compute_ridges"                         ] = "yes";
   }
 
-  if ( strcmp( MESHGEMS_VERSION_LONG, "2.9-6" ) < 0 )
+  if ( MESHGEMS_VERSION_HEX < 0x020906 )
   {
     std::string missingOption = "allow_patch_independent";
     _defaultOptionValues.erase( missingOption );
@@ -255,7 +274,7 @@ TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry)
   GEOM::GEOM_Object_var aGeomObj;
   
   TopoDS_Shape S = TopoDS_Shape();
-  SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.c_str() );
+  SALOMEDS::SObject_var aSObj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( entry.c_str() );
   if (!aSObj->_is_nil() ) {
     CORBA::Object_var obj = aSObj->GetObject();
     aGeomObj = GEOM::GEOM_Object::_narrow(obj);
@@ -267,7 +286,14 @@ TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry)
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh) {
+std::string BLSURFPlugin_Hypothesis::GetMeshGemsVersion()
+{
+  return MESHGEMS_VERSION_LONG;
+}
+
+//=============================================================================
+void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh)
+{
   if (thePhysicalMesh != _physicalMesh) {
     _physicalMesh = thePhysicalMesh;
     NotifySubMeshesHypothesisModification();
@@ -275,7 +301,8 @@ void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh) {
+void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh)
+{
   if (theGeometricMesh != _geometricMesh) {
     _geometricMesh = theGeometricMesh;
 //     switch (_geometricMesh) {
@@ -290,7 +317,8 @@ void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetPhySize(double theVal, bool isRelative) {
+void BLSURFPlugin_Hypothesis::SetPhySize(double theVal, bool isRelative)
+{
   if ((theVal != _phySize) || (isRelative != _phySizeRel)) {
     _phySizeRel = isRelative;
     if (theVal == 0) {
@@ -303,7 +331,8 @@ void BLSURFPlugin_Hypothesis::SetPhySize(double theVal, bool isRelative) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetMinSize(double theMinSize, bool isRelative) {
+void BLSURFPlugin_Hypothesis::SetMinSize(double theMinSize, bool isRelative)
+{
   if ((theMinSize != _minSize) || (isRelative != _minSizeRel)) {
     _minSizeRel = isRelative;
     _minSize = theMinSize;
@@ -312,7 +341,8 @@ void BLSURFPlugin_Hypothesis::SetMinSize(double theMinSize, bool isRelative) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetMaxSize(double theMaxSize, bool isRelative) {
+void BLSURFPlugin_Hypothesis::SetMaxSize(double theMaxSize, bool isRelative)
+{
   if ((theMaxSize != _maxSize) || (isRelative != _maxSizeRel)) {
     _maxSizeRel = isRelative;
     _maxSize = theMaxSize;
@@ -321,7 +351,8 @@ void BLSURFPlugin_Hypothesis::SetMaxSize(double theMaxSize, bool isRelative) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetUseGradation(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetUseGradation(bool theVal)
+{
   if (theVal != _useGradation) {
     _useGradation = theVal;
     NotifySubMeshesHypothesisModification();
@@ -329,7 +360,8 @@ void BLSURFPlugin_Hypothesis::SetUseGradation(bool theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetGradation(double theVal) {
+void BLSURFPlugin_Hypothesis::SetGradation(double theVal)
+{
   _useGradation = ( theVal > 0 );
   if (theVal != _gradation) {
     _gradation = theVal;
@@ -338,7 +370,8 @@ void BLSURFPlugin_Hypothesis::SetGradation(double theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetUseVolumeGradation(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetUseVolumeGradation(bool theVal)
+{
   if (theVal != _useVolumeGradation) {
     _useVolumeGradation = theVal;
     NotifySubMeshesHypothesisModification();
@@ -346,7 +379,8 @@ void BLSURFPlugin_Hypothesis::SetUseVolumeGradation(bool theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetVolumeGradation(double theVal) {
+void BLSURFPlugin_Hypothesis::SetVolumeGradation(double theVal)
+{
   _useVolumeGradation = ( theVal > 0 );
   if (theVal != _volumeGradation) {
     _volumeGradation = theVal;
@@ -355,7 +389,8 @@ void BLSURFPlugin_Hypothesis::SetVolumeGradation(double theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetElementType(ElementType theElementType) {
+void BLSURFPlugin_Hypothesis::SetElementType(ElementType theElementType)
+{
   if (theElementType != _elementType) {
     _elementType = theElementType;
     NotifySubMeshesHypothesisModification();
@@ -363,7 +398,8 @@ void BLSURFPlugin_Hypothesis::SetElementType(ElementType theElementType) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetAngleMesh(double theVal) {
+void BLSURFPlugin_Hypothesis::SetAngleMesh(double theVal)
+{
   if (theVal != _angleMesh) {
     _angleMesh = theVal;
     NotifySubMeshesHypothesisModification();
@@ -371,7 +407,8 @@ void BLSURFPlugin_Hypothesis::SetAngleMesh(double theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetChordalError(double theDistance) {
+void BLSURFPlugin_Hypothesis::SetChordalError(double theDistance)
+{
   if (theDistance != _chordalError) {
     _chordalError = theDistance;
     NotifySubMeshesHypothesisModification();
@@ -379,7 +416,8 @@ void BLSURFPlugin_Hypothesis::SetChordalError(double theDistance) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetAnisotropic(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetAnisotropic(bool theVal)
+{
   if (theVal != _anisotropic) {
     _anisotropic = theVal;
     NotifySubMeshesHypothesisModification();
@@ -387,7 +425,8 @@ void BLSURFPlugin_Hypothesis::SetAnisotropic(bool theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetAnisotropicRatio(double theVal) {
+void BLSURFPlugin_Hypothesis::SetAnisotropicRatio(double theVal)
+{
   if (theVal != _anisotropicRatio) {
     _anisotropicRatio = theVal;
     NotifySubMeshesHypothesisModification();
@@ -395,7 +434,8 @@ void BLSURFPlugin_Hypothesis::SetAnisotropicRatio(double theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetRemoveTinyEdges(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetRemoveTinyEdges(bool theVal)
+{
   if (theVal != _removeTinyEdges) {
     _removeTinyEdges = theVal;
     NotifySubMeshesHypothesisModification();
@@ -403,7 +443,8 @@ void BLSURFPlugin_Hypothesis::SetRemoveTinyEdges(bool theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetTinyEdgeLength(double theVal) {
+void BLSURFPlugin_Hypothesis::SetTinyEdgeLength(double theVal)
+{
   if (theVal != _tinyEdgeLength) {
     _tinyEdgeLength = theVal;
     NotifySubMeshesHypothesisModification();
@@ -411,7 +452,8 @@ void BLSURFPlugin_Hypothesis::SetTinyEdgeLength(double theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetOptimiseTinyEdges(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetOptimiseTinyEdges(bool theVal)
+{
   if (theVal != _optimiseTinyEdges) {
     _optimiseTinyEdges = theVal;
     NotifySubMeshesHypothesisModification();
@@ -419,7 +461,8 @@ void BLSURFPlugin_Hypothesis::SetOptimiseTinyEdges(bool theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetTinyEdgeOptimisationLength(double theVal) {
+void BLSURFPlugin_Hypothesis::SetTinyEdgeOptimisationLength(double theVal)
+{
   if (theVal != _tinyEdgeOptimisationLength) {
     _tinyEdgeOptimisationLength = theVal;
     NotifySubMeshesHypothesisModification();
@@ -427,7 +470,8 @@ void BLSURFPlugin_Hypothesis::SetTinyEdgeOptimisationLength(double theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetCorrectSurfaceIntersection(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetCorrectSurfaceIntersection(bool theVal)
+{
   if (theVal != _correctSurfaceIntersec) {
     _correctSurfaceIntersec = theVal;
     NotifySubMeshesHypothesisModification();
@@ -435,7 +479,8 @@ void BLSURFPlugin_Hypothesis::SetCorrectSurfaceIntersection(bool theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetCorrectSurfaceIntersectionMaxCost(double theVal) {
+void BLSURFPlugin_Hypothesis::SetCorrectSurfaceIntersectionMaxCost(double theVal)
+{
   if (theVal != _corrSurfaceIntersCost) {
     _corrSurfaceIntersCost = theVal;
     NotifySubMeshesHypothesisModification();
@@ -443,7 +488,8 @@ void BLSURFPlugin_Hypothesis::SetCorrectSurfaceIntersectionMaxCost(double theVal
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetBadElementRemoval(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetBadElementRemoval(bool theVal)
+{
   if (theVal != _badElementRemoval) {
     _badElementRemoval = theVal;
     NotifySubMeshesHypothesisModification();
@@ -451,7 +497,8 @@ void BLSURFPlugin_Hypothesis::SetBadElementRemoval(bool theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetBadElementAspectRatio(double theVal) {
+void BLSURFPlugin_Hypothesis::SetBadElementAspectRatio(double theVal)
+{
   if (theVal != _badElementAspectRatio) {
     _badElementAspectRatio = theVal;
     NotifySubMeshesHypothesisModification();
@@ -459,7 +506,8 @@ void BLSURFPlugin_Hypothesis::SetBadElementAspectRatio(double theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetOptimizeMesh(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetOptimizeMesh(bool theVal)
+{
   if (theVal != _optimizeMesh) {
     _optimizeMesh = theVal;
     NotifySubMeshesHypothesisModification();
@@ -467,7 +515,8 @@ void BLSURFPlugin_Hypothesis::SetOptimizeMesh(bool theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetQuadraticMesh(bool theVal) {
+void BLSURFPlugin_Hypothesis::SetQuadraticMesh(bool theVal)
+{
   if (theVal != _quadraticMesh) {
     _quadraticMesh = theVal;
     NotifySubMeshesHypothesisModification();
@@ -475,7 +524,8 @@ void BLSURFPlugin_Hypothesis::SetQuadraticMesh(bool theVal) {
 }
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) {
+void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology)
+{
   if (theTopology != _topology) {
     _topology = theTopology;
     NotifySubMeshesHypothesisModification();
@@ -553,16 +603,26 @@ void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal) {
 //=============================================================================
 void BLSURFPlugin_Hypothesis::SetEnforceCadEdgesSize( bool toEnforce )
 {
+#if MESHGEMS_VERSION_HEX < 0x020A00
+  // Deprecated since MeshGems 2.10
   if ( GetEnforceCadEdgesSize() != toEnforce )
   {
     SetOptionValue( "enforce_cad_edge_sizes", toEnforce ? "yes" : "no" );
     NotifySubMeshesHypothesisModification();
   }
+#else
+  (void)toEnforce; // maybe unused
+#endif
 }
 //=============================================================================
 bool BLSURFPlugin_Hypothesis::GetEnforceCadEdgesSize()
 {
+#if MESHGEMS_VERSION_HEX < 0x020A00
+  // Deprecated since MeshGems 2.10
   return ToBool( GetOptionValue( "enforce_cad_edge_sizes" ), GET_DEFAULT() );
+#else
+  return false;
+#endif
 }
 //=============================================================================
 
@@ -596,7 +656,7 @@ bool BLSURFPlugin_Hypothesis::GetJacobianRectification()
 }
 //=============================================================================
 
-void BLSURFPlugin_Hypothesis::SetUseDeprecatedPatchMesher( bool useDeprecatedPatchMesher )
+void BLSURFPlugin_Hypothesis::SetUseDeprecatedPatchMesher( bool /*useDeprecatedPatchMesher*/ )
 {
   // if ( GetUseDeprecatedPatchMesher() != useDeprecatedPatchMesher )
   // {
@@ -612,8 +672,9 @@ bool BLSURFPlugin_Hypothesis::GetUseDeprecatedPatchMesher()
 //=============================================================================
 
 void BLSURFPlugin_Hypothesis::SetMaxNumberOfPointsPerPatch( int nb )
-  throw (std::invalid_argument)
 {
+#if MESHGEMS_VERSION_HEX < 0x020A00
+  // Deprecated since MeshGems 2.10
   if ( nb < 0 )
     throw std::invalid_argument( SMESH_Comment("Invalid number of points: ") << nb );
 
@@ -622,16 +683,23 @@ void BLSURFPlugin_Hypothesis::SetMaxNumberOfPointsPerPatch( int nb )
     SetOptionValue("max_number_of_points_per_patch", SMESH_Comment( nb ));
     NotifySubMeshesHypothesisModification();
   }
+#else
+  (void)nb; // maybe unused
+#endif
 }
 //=============================================================================
 int BLSURFPlugin_Hypothesis::GetMaxNumberOfPointsPerPatch()
 {
+#if MESHGEMS_VERSION_HEX < 0x020A00
+  // Deprecated since MeshGems 2.10
   return ToInt( GetOptionValue("max_number_of_points_per_patch", GET_DEFAULT()));
+#else
+  return 0;
+#endif
 }
 //=============================================================================
 
 void BLSURFPlugin_Hypothesis::SetMaxNumberOfThreads( int nb )
-  throw (std::invalid_argument)
 {
   if ( nb < 0 )
     throw std::invalid_argument( SMESH_Comment("Invalid number of threads: ") << nb );
@@ -710,7 +778,6 @@ bool BLSURFPlugin_Hypothesis::GetDebug()
 //=============================================================================
 
 void BLSURFPlugin_Hypothesis::SetPeriodicTolerance( CORBA::Double tol )
-  throw (std::invalid_argument)
 {
   if ( tol <= 0 )
     throw std::invalid_argument( SMESH_Comment("Invalid tolerance: ") << tol );
@@ -728,7 +795,6 @@ double BLSURFPlugin_Hypothesis::GetPeriodicTolerance()
 //=============================================================================
 
 void BLSURFPlugin_Hypothesis::SetRequiredEntities( const std::string& howToTreat )
-  throw (std::invalid_argument)
 {
   if ( howToTreat != "respect" && howToTreat != "ignore" && howToTreat != "clear"  )
     throw std::invalid_argument
@@ -748,7 +814,6 @@ std::string BLSURFPlugin_Hypothesis::GetRequiredEntities()
 //=============================================================================
 
 void BLSURFPlugin_Hypothesis::SetSewingTolerance( CORBA::Double tol )
-  throw (std::invalid_argument)
 {
   if ( tol <= 0 )
     throw std::invalid_argument( SMESH_Comment("Invalid tolerance: ") << tol );
@@ -766,7 +831,6 @@ CORBA::Double BLSURFPlugin_Hypothesis::GetSewingTolerance()
 //=============================================================================
 
 void BLSURFPlugin_Hypothesis::SetTags( const std::string& howToTreat )
-  throw (std::invalid_argument)
 {
   if ( howToTreat != "respect" && howToTreat != "ignore" && howToTreat != "clear"  )
     throw std::invalid_argument
@@ -783,8 +847,9 @@ std::string BLSURFPlugin_Hypothesis::GetTags()
 {
   return GetPreCADOptionValue("tags", GET_DEFAULT());
 }
+
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetHyperPatches(const THyperPatchList& hpl)
+void BLSURFPlugin_Hypothesis::SetHyperPatches(const THyperPatchList& hpl, bool notifyMesh)
 {
   if ( hpl != _hyperPatchList )
   {
@@ -824,14 +889,68 @@ void BLSURFPlugin_Hypothesis::SetHyperPatches(const THyperPatchList& hpl)
           _hyperPatchList[ *iPatch ].clear();
         }
         if ( iPatches.size() > 1 )
-          for ( int j = _hyperPatchList.size()-1; j > 0; --j )
+          for ( int j = (int) _hyperPatchList.size()-1; j > 0; --j )
             if ( _hyperPatchList[j].empty() )
               _hyperPatchList.erase( _hyperPatchList.begin() + j );
       }
     }
+    if ( notifyMesh )
+      NotifySubMeshesHypothesisModification();
+  }
+}
+//=============================================================================
+void BLSURFPlugin_Hypothesis::SetHyperPatches(const THyperPatchEntriesList& hpel)
+{
+  if ( hpel != _hyperPatchEntriesList )
+  {
+    _hyperPatchEntriesList = hpel;
+    _hyperPatchList.clear();
+
     NotifySubMeshesHypothesisModification();
   }
 }
+//================================================================================
+/*!
+ * \brief Set _hyperPatchList by _hyperPatchEntriesList
+ */
+//================================================================================
+
+void BLSURFPlugin_Hypothesis::
+SetHyperPatchIDsByEntry( const TopoDS_Shape&                          mainShape,
+                         const std::map< std::string, TopoDS_Shape >& entryToShape)
+{
+  _hyperPatchList.clear();
+  if ( _hyperPatchEntriesList.empty() || mainShape.IsNull() )
+    return;
+
+  _hyperPatchList.resize( _hyperPatchEntriesList.size() );
+
+  TopTools_IndexedMapOfShape shapeMap;
+  TopExp::MapShapes( mainShape, shapeMap );
+
+  for ( size_t i = 0; i < _hyperPatchEntriesList.size(); ++i )
+  {
+    THyperPatchTags &            idsList = _hyperPatchList       [ i ];
+    const THyperPatchEntries & entryList = _hyperPatchEntriesList[ i ];
+    for ( const std::string & entry : entryList )
+    {
+      auto e2sIt = entryToShape.find( entry );
+      if ( e2sIt != entryToShape.end() )
+      {
+        for ( TopExp_Explorer fExp( e2sIt->second, TopAbs_FACE ); fExp.More(); fExp.Next() )
+        {
+          int id = shapeMap.FindIndex( fExp.Current() );
+          if ( id > 0 )
+            idsList.insert( id );
+        }
+      }
+    }
+  }
+  THyperPatchList hpl;
+  hpl.swap( _hyperPatchList );
+  SetHyperPatches( hpl, /*notifyMesh=*/false );
+}
+
 //=============================================================================
 /*!
  * \brief Return a tag of a face taking into account the hyper-patches. Optionally
@@ -849,7 +968,7 @@ int BLSURFPlugin_Hypothesis::GetHyperPatchTag( const int                      fa
     for ( size_t i = 0; i < hpl.size(); ++i )
       if ( hpl[i].count( faceTag ))
       {
-        if ( iPatch ) *iPatch = i;
+        if ( iPatch ) *iPatch = (int) i;
         return *( hpl[i].begin() );
       }
   }
@@ -931,8 +1050,7 @@ void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName)
 
 //=============================================================================
 void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, const std::string& optionValue)
-  throw (std::invalid_argument) {
-
+{
   TOptionValues::iterator op_val = _option2value.find(optionName);
   if (op_val == _option2value.end())
   {
@@ -949,7 +1067,7 @@ void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, cons
     // strip white spaces
     while (ptr[0] == ' ')
       ptr++;
-    int i = strlen(ptr);
+    size_t i = strlen(ptr);
     while (i != 0 && ptr[i - 1] == ' ')
       i--;
     // check value type
@@ -988,8 +1106,7 @@ void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, cons
 
 //=============================================================================
 void BLSURFPlugin_Hypothesis::SetPreCADOptionValue(const std::string& optionName, const std::string& optionValue)
-  throw (std::invalid_argument) {
-
+{
   TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
   if (op_val == _preCADoption2value.end()) {
     op_val = _option2value.find(optionName);
@@ -1004,7 +1121,7 @@ void BLSURFPlugin_Hypothesis::SetPreCADOptionValue(const std::string& optionName
     // strip white spaces
     while (ptr[0] == ' ')
       ptr++;
-    int i = strlen(ptr);
+    size_t i = strlen(ptr);
     while (i != 0 && ptr[i - 1] == ' ')
       i--;
     // check value type
@@ -1048,7 +1165,6 @@ void BLSURFPlugin_Hypothesis::SetPreCADOptionValue(const std::string& optionName
 //=============================================================================
 std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName,
                                                     bool*              isDefault) const
-  throw (std::invalid_argument)
 {
   TOptionValues::const_iterator op_val = _option2value.find(optionName);
   if (op_val == _option2value.end())
@@ -1079,7 +1195,6 @@ std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionNam
 //=============================================================================
 std::string BLSURFPlugin_Hypothesis::GetPreCADOptionValue(const std::string& optionName,
                                                           bool*              isDefault) const
-  throw (std::invalid_argument)
 {
   TOptionValues::const_iterator op_val = _preCADoption2value.find(optionName);
   if (op_val == _preCADoption2value.end())
@@ -1540,8 +1655,7 @@ void BLSURFPlugin_Hypothesis::AddEnforcedVertex( const TEntry& faceEntry,
 //=======================================================================
 
 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexList(const TEntry& theFaceEntry)
-    throw (std::invalid_argument) {
-
+{
   if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0)
     return _faceEntryEnfVertexListMap[theFaceEntry];
   else
@@ -1556,9 +1670,8 @@ BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexLis
 //function : GetEnfVertexCoordsList
 //=======================================================================
 
-BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList(
-    const TEntry& theFaceEntry) throw (std::invalid_argument) {
-
+BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList(const TEntry& theFaceEntry)
+{
   if (_faceEntryCoordsListMap.count(theFaceEntry) > 0)
     return _faceEntryCoordsListMap[theFaceEntry];
 
@@ -1572,8 +1685,7 @@ BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVer
 //=======================================================================
 
 BLSURFPlugin_Hypothesis::TEntryList BLSURFPlugin_Hypothesis::GetEnfVertexEntryList(const TEntry& theFaceEntry)
-    throw (std::invalid_argument) {
-
+{
   if (_faceEntryEnfVertexEntryListMap.count(theFaceEntry) > 0)
     return _faceEntryEnfVertexEntryListMap[theFaceEntry];
 
@@ -1587,8 +1699,7 @@ BLSURFPlugin_Hypothesis::TEntryList BLSURFPlugin_Hypothesis::GetEnfVertexEntryLi
 //=======================================================================
 
 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVertexCoords coords)
-    throw (std::invalid_argument) {
-
+{
   if (_coordsEnfVertexMap.count(coords) > 0)
     return _coordsEnfVertexMap[coords];
 
@@ -1602,8 +1713,7 @@ BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfV
 //=======================================================================
 
 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(const TEntry& theEnfVertexEntry)
-    throw (std::invalid_argument) {
-
+{
   if (_enfVertexEntryEnfVertexMap.count(theEnfVertexEntry) > 0)
     return _enfVertexEntryEnfVertexMap[theEnfVertexEntry];
 
@@ -1628,9 +1738,10 @@ BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(const
 //function : ClearEnforcedVertex
 //=======================================================================
 
-bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, double x, double y, double z,
-    const TEntry& theVertexEntry) throw (std::invalid_argument) {
-
+bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry,
+                                                  double x, double y, double z,
+                                                  const TEntry& theVertexEntry)
+{
   bool toNotify = false;
   std::ostringstream msg;
   TEnfVertex *oldEnfVertex;
@@ -1715,8 +1826,8 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, do
 //function : ClearEnforcedVertices
 //=======================================================================
 
-bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument) {
-
+bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry)
+{
   bool toNotify = false;
   TEnfVertex *oldEnfVertex;
 
@@ -1805,7 +1916,8 @@ void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices()
 
 
 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByFace(
-    const BLSURFPlugin_Hypothesis* hyp) {
+    const BLSURFPlugin_Hypothesis* hyp)
+{
   return hyp ? hyp->_GetAllEnforcedVerticesByFace() : GetDefaultFaceEntryEnfVertexListMap();
 }
 
@@ -1826,31 +1938,36 @@ BLSURFPlugin_Hypothesis::TEnfGroupName BLSURFPlugin_Hypothesis::GetInternalEnfor
 }
 
 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(
-    const BLSURFPlugin_Hypothesis* hyp) {
+    const BLSURFPlugin_Hypothesis* hyp)
+{
   return hyp ? hyp->_GetAllEnforcedVertices() : GetDefaultEnfVertexList();
 }
 
 BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace(
-    const BLSURFPlugin_Hypothesis* hyp) {
+    const BLSURFPlugin_Hypothesis* hyp)
+{
   return hyp ? hyp->_GetAllCoordsByFace() : GetDefaultFaceEntryCoordsListMap();
 }
 
 BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords(
-    const BLSURFPlugin_Hypothesis* hyp) {
+    const BLSURFPlugin_Hypothesis* hyp)
+{
   return hyp ? hyp->_GetAllEnforcedVerticesByCoords() : GetDefaultCoordsEnfVertexMap();
 }
 
 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap BLSURFPlugin_Hypothesis::GetAllEnfVertexEntriesByFace(
-    const BLSURFPlugin_Hypothesis* hyp) {
+    const BLSURFPlugin_Hypothesis* hyp)
+{
   return hyp ? hyp->_GetAllEnfVertexEntriesByFace() : GetDefaultFaceEntryEnfVertexEntryListMap();
 }
 
 BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByEnfVertexEntry(
-    const BLSURFPlugin_Hypothesis* hyp) {
+    const BLSURFPlugin_Hypothesis* hyp)
+{
   return hyp ? hyp->_GetAllEnforcedVerticesByEnfVertexEntry() : GetDefaultEnfVertexEntryEnfVertexMap();
 }
 
-std::set<int> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument)
+std::set<smIdType> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName)
 {
   TGroupNameNodeIDMap::const_iterator it = _groupNameNodeIDMap.find(theGroupName);
   if (it != _groupNameNodeIDMap.end()) {
@@ -1861,16 +1978,16 @@ std::set<int> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGrou
   throw std::invalid_argument(msg.str());
 }
 
-void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID)
+void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,smIdType theNodeID)
 {
   _groupNameNodeIDMap[theGroupName].insert(theNodeID);
 }
 
-void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument)
+void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,smIdType theNodeID)
 {
   TGroupNameNodeIDMap::iterator it = _groupNameNodeIDMap.find(theGroupName);
   if (it != _groupNameNodeIDMap.end()) {
-    std::set<int>::iterator IDit = it->second.find(theNodeID);
+    std::set<smIdType>::iterator IDit = it->second.find(theNodeID);
     if (IDit != it->second.end())
       it->second.erase(IDit);
     std::ostringstream msg;
@@ -1884,7 +2001,8 @@ void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,i
 
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices) {
+void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices)
+{
   if (toEnforceInternalVertices != _enforcedInternalVerticesAllFaces) {
     _enforcedInternalVerticesAllFaces = toEnforceInternalVertices;
     if (toEnforceInternalVertices)
@@ -1895,7 +2013,8 @@ void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFaces(bool toEnforceIn
 
 
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFacesGroup(BLSURFPlugin_Hypothesis::TEnfGroupName theGroupName) {
+void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFacesGroup(BLSURFPlugin_Hypothesis::TEnfGroupName theGroupName)
+{
   if (std::string(theGroupName) != std::string(_enforcedInternalVerticesAllFacesGroup)) {
     _enforcedInternalVerticesAllFacesGroup = theGroupName;
     NotifySubMeshesHypothesisModification();
@@ -1904,38 +2023,44 @@ void BLSURFPlugin_Hypothesis::SetInternalEnforcedVertexAllFacesGroup(BLSURFPlugi
 
 //=============================================================================
 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadFacesPeriodicityVector(
-    const BLSURFPlugin_Hypothesis* hyp) {
+    const BLSURFPlugin_Hypothesis* hyp)
+{
   return hyp ? hyp->_GetPreCadFacesPeriodicityVector() : GetDefaultPreCadFacesPeriodicityVector();
 }
 
 //=============================================================================
 BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector BLSURFPlugin_Hypothesis::GetPreCadEdgesPeriodicityVector(
-    const BLSURFPlugin_Hypothesis* hyp) {
+    const BLSURFPlugin_Hypothesis* hyp)
+{
   return hyp ? hyp->_GetPreCadEdgesPeriodicityVector() : GetDefaultPreCadEdgesPeriodicityVector();
 }
 
 //=============================================================================
 BLSURFPlugin_Hypothesis::TFacesPeriodicityVector BLSURFPlugin_Hypothesis::GetFacesPeriodicityVector(
-    const BLSURFPlugin_Hypothesis* hyp) {
+    const BLSURFPlugin_Hypothesis* hyp)
+{
   return hyp ? hyp->_GetFacesPeriodicityVector() : GetDefaultFacesPeriodicityVector();
 }
 
 //=============================================================================
 BLSURFPlugin_Hypothesis::TEdgesPeriodicityVector BLSURFPlugin_Hypothesis::GetEdgesPeriodicityVector(
-    const BLSURFPlugin_Hypothesis* hyp){
+    const BLSURFPlugin_Hypothesis* hyp)
+{
   return hyp ? hyp->_GetEdgesPeriodicityVector() : GetDefaultEdgesPeriodicityVector();
 }
 
 //=============================================================================
 BLSURFPlugin_Hypothesis::TVerticesPeriodicityVector BLSURFPlugin_Hypothesis::GetVerticesPeriodicityVector(
-    const BLSURFPlugin_Hypothesis* hyp){
+    const BLSURFPlugin_Hypothesis* hyp)
+{
   return hyp ? hyp->_GetVerticesPeriodicityVector() : GetDefaultVerticesPeriodicityVector();
 }
 
 //=======================================================================
 //function : ClearAllEnforcedVertices
 //=======================================================================
-void BLSURFPlugin_Hypothesis::ClearPreCadPeriodicityVectors() {
+void BLSURFPlugin_Hypothesis::ClearPreCadPeriodicityVectors()
+{
   _preCadFacesPeriodicityVector.clear();
   _preCadEdgesPeriodicityVector.clear();
   NotifySubMeshesHypothesisModification();
@@ -1945,7 +2070,8 @@ 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;
@@ -1962,8 +2088,8 @@ void BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity(TEntry theFace1Entry, TE
 //function : AddPreCadEdgesPeriodicity
 //=======================================================================
 void BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry,
-    std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries) {
-
+    std::vector<std::string> &theSourceVerticesEntries, std::vector<std::string> &theTargetVerticesEntries)
+{
   TPreCadPeriodicity preCadEdgesPeriodicity;
   preCadEdgesPeriodicity.shape1Entry = theEdge1Entry;
   preCadEdgesPeriodicity.shape2Entry = theEdge2Entry;
@@ -2162,11 +2288,18 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save)
   save << " " << _nbVolumeProximityLayers;
   save << " " << _volumeProximityRatio;
 
+  // hyper-patches as entries
+  std::ostringstream hpStream;
+  boost::archive::text_oarchive( hpStream ) << _hyperPatchEntriesList;
+  std::string hpString = hpStream.str();
+  save << " " << hpString.size() <<  " " << hpString;
+
+
   return save;
 }
 
-void BLSURFPlugin_Hypothesis::SaveFacesPeriodicity(std::ostream & save){
-
+void BLSURFPlugin_Hypothesis::SaveFacesPeriodicity(std::ostream & save)
+{
   TFacesPeriodicityVector::const_iterator it_faces_periodicity = _facesPeriodicityVector.begin();
   if (it_faces_periodicity != _facesPeriodicityVector.end()) {
     save << " " << "__FACES_PERIODICITY_BEGIN__";
@@ -2185,8 +2318,8 @@ void BLSURFPlugin_Hypothesis::SaveFacesPeriodicity(std::ostream & save){
   }
 }
 
-void BLSURFPlugin_Hypothesis::SaveEdgesPeriodicity(std::ostream & save){
-
+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__";
@@ -2218,8 +2351,8 @@ void BLSURFPlugin_Hypothesis::SaveEdgesPeriodicity(std::ostream & save){
   }
 }
 
-void BLSURFPlugin_Hypothesis::SaveVerticesPeriodicity(std::ostream & save){
-
+void BLSURFPlugin_Hypothesis::SaveVerticesPeriodicity(std::ostream & save)
+{
   TVerticesPeriodicityVector::const_iterator it_vertices_periodicity = _verticesPeriodicityVector.begin();
   if (it_vertices_periodicity != _verticesPeriodicityVector.end()) {
     save << " " << "__VERTICES_PERIODICITY_BEGIN__";
@@ -2244,7 +2377,8 @@ void BLSURFPlugin_Hypothesis::SaveVerticesPeriodicity(std::ostream & save){
   }
 }
 
-void BLSURFPlugin_Hypothesis::SavePreCADPeriodicity(std::ostream & save, const char* shapeType) {
+void BLSURFPlugin_Hypothesis::SavePreCADPeriodicity(std::ostream & save, const char* shapeType)
+{
   TPreCadPeriodicityVector precad_periodicity;
   if ( shapeType  &&  strcmp( shapeType, "FACES" ) == 0 )
     precad_periodicity = _preCadFacesPeriodicityVector;
@@ -2454,13 +2588,13 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
   bool hasVerticesPeriodicity = false;
 
   isOK = static_cast<bool>(load >> option_or_sm);
-  if (isOK)
-    if ( (option_or_sm == "1")||(option_or_sm == "0") ) {
+  if (isOK) {
+    if (( option_or_sm == "1" ) || ( option_or_sm == "0" )) {
       i = atoi(option_or_sm.c_str());
       hasCADSurfOptions = true;
       _phySizeRel = (bool) i;
     }
-    if (option_or_sm == "__OPTIONS_BEGIN__")
+    else if (option_or_sm == "__OPTIONS_BEGIN__")
       hasOptions = true;
     else if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
       hasCustomOptions = true;
@@ -2484,6 +2618,7 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
       hasEdgesPeriodicity = true;
     else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
       hasVerticesPeriodicity = true;
+  }
 
   if (isOK && hasCADSurfOptions) {
     isOK = static_cast<bool>(load >> i);
@@ -2649,17 +2784,23 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
         break;
       isOK = static_cast<bool>(load >> optValue);
     }
-    if (isOK) {
+    // read the value of the advanced option
+    // unless this option is no more used
+    if (isOK
+#if MESHGEMS_VERSION_HEX >= 0x020A00
+        && optName != "enforce_cad_edge_sizes" && optName != "max_number_of_points_per_patch"
+#endif
+        ) {
       std::string & value = _option2value[optName];
       value = optValue;
-      int len = value.size();
+      int len = (int) value.size();
       // continue reading until "%#" encountered
       while (value[len - 1] != '#' || value[len - 2] != '%') {
         isOK = static_cast<bool>(load >> optValue);
         if (isOK) {
           value += " ";
           value += optValue;
-          len = value.size();
+          len = (int) value.size();
         } else {
           break;
         }
@@ -2706,14 +2847,14 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
     }
     if (isOK) {
       std::string& value = optValue;
-      int len = value.size();
+      int len = (int) value.size();
       // continue reading until "%#" encountered
       while (value[len - 1] != '#' || value[len - 2] != '%') {
         isOK = static_cast<bool>(load >> optValue);
         if (isOK) {
           value += " ";
           value += optValue;
-          len = value.size();
+          len = (int) value.size();
         } else {
           break;
         }
@@ -2760,14 +2901,14 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
     if (isOK) {
       std::string & value = _preCADoption2value[optName];
       value = optValue;
-      int len = value.size();
+      int len = (int) value.size();
       // continue reading until "%#" encountered
       while (value[len - 1] != '#' || value[len - 2] != '%') {
         isOK = static_cast<bool>(load >> optValue);
         if (isOK) {
           value += " ";
           value += optValue;
-          len = value.size();
+          len = (int) value.size();
         } else {
           break;
         }
@@ -2812,14 +2953,14 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
     if (isOK) {
       std::string & value2 = _sizeMap[smEntry];
       value2 = smValue;
-      int len2 = value2.size();
+      int len2 = (int) value2.size();
       // continue reading until "%#" encountered
       while (value2[len2 - 1] != '#' || value2[len2 - 2] != '%') {
         isOK = static_cast<bool>(load >> smValue);
         if (isOK) {
           value2 += " ";
           value2 += smValue;
-          len2 = value2.size();
+          len2 = (int) value2.size();
         } else {
           break;
         }
@@ -2830,10 +2971,10 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
 
   if (hasSizeMap) {
     isOK = static_cast<bool>(load >> option_or_sm);
-    if (isOK)
+    if (isOK) {
       if (option_or_sm == "__ATTRACTORS_BEGIN__")
         hasAttractor = true;
-      if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
+      else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
         hasNewAttractor = true;
       else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
         hasEnforcedVertex = true;
@@ -2847,6 +2988,7 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
         hasEdgesPeriodicity = true;
       else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
         hasVerticesPeriodicity = true;
+    }
   }
 
   std::string atEntry, atValue;
@@ -2860,14 +3002,14 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
     if (isOK) {
       std::string & value3 = _attractors[atEntry];
       value3 = atValue;
-      int len3 = value3.size();
+      int len3 = (int) value3.size();
       // continue reading until "%#" encountered
       while (value3[len3 - 1] != '#' || value3[len3 - 2] != '%') {
         isOK = static_cast<bool>(load >> atValue);
         if (isOK) {
           value3 += " ";
           value3 += atValue;
-          len3 = value3.size();
+          len3 = (int) value3.size();
         } else {
           break;
         }
@@ -3176,7 +3318,7 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
   }
 
   // New options in 2.9.6 (issue #17784)
-  if ( static_cast<bool>( load >> _useSurfaceProximity ));
+  if ( static_cast<bool>( load >> _useSurfaceProximity ))
   {
     load >> _nbSurfaceProximityLayers;
     load >> _surfaceProximityRatio;
@@ -3185,11 +3327,26 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
     isOK = static_cast<bool>( load >> _volumeProximityRatio );
   }
 
+  // hyper-patches as entries (issue bos #20543)
+  if ( static_cast<bool>( load >> i ) && i > 0 )
+  {
+    std::string buffer( i, '\0' );
+    load.get( buffer[0] ); // remove a white-space
+    load.get( & buffer[0], i + 1 );
+
+    std::istringstream istream( buffer.data() );
+    boost::archive::text_iarchive archive( istream );
+    try {
+      archive >> _hyperPatchEntriesList;
+    }
+    catch (...) {}
+  }
+
   return load;
 }
 
-void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load){
-
+void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load)
+{
   bool isOK = true;
 
   std::string periodicitySeparator;
@@ -3237,8 +3394,8 @@ void BLSURFPlugin_Hypothesis::LoadFacesPeriodicity(std::istream & load){
 }
 
 
-void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load){
-
+void BLSURFPlugin_Hypothesis::LoadEdgesPeriodicity(std::istream & load)
+{
   bool isOK = true;
 
   std::string periodicitySeparator;
@@ -3379,8 +3536,8 @@ void BLSURFPlugin_Hypothesis::LoadVerticesPeriodicity(std::istream & load)
   }
 }
 
-void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const char* shapeType) {
-
+void BLSURFPlugin_Hypothesis::LoadPreCADPeriodicity(std::istream & load, const char* shapeType)
+{
   bool isOK = true;
 
   std::string periodicitySeparator;
@@ -3485,7 +3642,8 @@ std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp) {
  */
 //================================================================================
 
-bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape) {
+bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/, const TopoDS_Shape& /*theShape*/)
+{
   return false;
 }
 
@@ -3495,7 +3653,8 @@ bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, con
  */
 //================================================================================
 
-double BLSURFPlugin_Hypothesis::GetDefaultPhySize(double diagonal, double bbSegmentation) {
+double BLSURFPlugin_Hypothesis::GetDefaultPhySize(double diagonal, double bbSegmentation)
+{
   if (bbSegmentation != 0 && diagonal != 0)
     return diagonal / bbSegmentation ;
   return 10;
@@ -3507,7 +3666,8 @@ double BLSURFPlugin_Hypothesis::GetDefaultPhySize(double diagonal, double bbSegm
  */
 //================================================================================
 
-double BLSURFPlugin_Hypothesis::GetDefaultMinSize(double diagonal) {
+double BLSURFPlugin_Hypothesis::GetDefaultMinSize(double diagonal)
+{
   if (diagonal != 0)
     return diagonal / 1000.0 ;
   return undefinedDouble();
@@ -3519,7 +3679,8 @@ double BLSURFPlugin_Hypothesis::GetDefaultMinSize(double diagonal) {
  */
 //================================================================================
 
-double BLSURFPlugin_Hypothesis::GetDefaultMaxSize(double diagonal) {
+double BLSURFPlugin_Hypothesis::GetDefaultMaxSize(double diagonal)
+{
   if (diagonal != 0)
     return diagonal / 5.0 ;
   return undefinedDouble();
@@ -3531,7 +3692,8 @@ double BLSURFPlugin_Hypothesis::GetDefaultMaxSize(double diagonal) {
  */
 //================================================================================
 
-double BLSURFPlugin_Hypothesis::GetDefaultChordalError(double diagonal) {
+double BLSURFPlugin_Hypothesis::GetDefaultChordalError(double diagonal)
+{
   if (diagonal != 0)
     return diagonal;
   return undefinedDouble();
@@ -3543,7 +3705,8 @@ double BLSURFPlugin_Hypothesis::GetDefaultChordalError(double diagonal) {
  */
 //================================================================================
 
-double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeLength(double diagonal) {
+double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeLength(double diagonal)
+{
   if (diagonal != 0)
     return diagonal * 1e-6 ;
   return undefinedDouble();
@@ -3555,7 +3718,8 @@ double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeLength(double diagonal) {
  */
 //================================================================================
 
-double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeOptimisationLength(double diagonal) {
+double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeOptimisationLength(double diagonal)
+{
   if (diagonal != 0)
     return diagonal * 1e-6 ;
   return undefinedDouble();
@@ -3569,7 +3733,7 @@ double BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeOptimisationLength(double diag
 //=============================================================================
 
 bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults&  dflts,
-                                                      const SMESH_Mesh* theMesh)
+                                                      const SMESH_Mesh* /*theMesh*/)
 {
   _phySize = GetDefaultPhySize(dflts._diagonal, _gen->GetBoundaryBoxSegmentation());
   _minSize = GetDefaultMinSize(dflts._diagonal);
@@ -3583,6 +3747,8 @@ bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults&  dflts,
     _maxSize      = dflts._elemLength * 2.;
     _chordalError = dflts._elemLength / 2.;
     _elementType  = dflts._quadDominated ? QuadrangleDominant : Triangles;
+    _physicalMesh = PhysicalLocalSize; // to activate _enforcedInternalVerticesAllFaces
+    _enforcedInternalVerticesAllFaces = true;
   }
   else
   {
@@ -3600,13 +3766,12 @@ bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults&  dflts,
 //================================================================================
 
 bool BLSURFPlugin_Hypothesis::ToBool(const std::string& str, bool* isOk )
-  throw (std::invalid_argument)
 {
   std::string s = str;
   if ( isOk ) *isOk = true;
 
   for ( size_t i = 0; i <= s.size(); ++i )
-    s[i] = tolower( s[i] );
+    s[i] = (char) tolower( s[i] );
 
   if ( s == "1" || s == "true" || s == "active" || s == "yes" )
     return true;
@@ -3630,10 +3795,12 @@ bool BLSURFPlugin_Hypothesis::ToBool(const std::string& str, bool* isOk )
 //================================================================================
 
 double BLSURFPlugin_Hypothesis::ToDbl(const std::string& str, bool* isOk )
-  throw (std::invalid_argument)
 {
   if ( str.empty() ) throw std::invalid_argument("Empty value provided");
 
+  // Forces "C" locale to be set as LC_NUMERIC
+  Kernel_Utils::Localizer loc;
+
   char * endPtr;
   double val = strtod(&str[0], &endPtr);
   bool ok = (&str[0] != endPtr);
@@ -3655,7 +3822,6 @@ double BLSURFPlugin_Hypothesis::ToDbl(const std::string& str, bool* isOk )
 //================================================================================
 
 int BLSURFPlugin_Hypothesis::ToInt(const std::string& str, bool* isOk )
-  throw (std::invalid_argument)
 {
   if ( str.empty() ) throw std::invalid_argument("Empty value provided");