From: vsr Date: Wed, 11 Mar 2020 09:02:54 +0000 (+0300) Subject: Porting to MeshGems 2.10: better implementation, keeping sources backward compatibili... X-Git-Tag: V9_5_0a2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2ece90273b78d161112f75bac003b585dc74a5e6;p=plugins%2Fblsurfplugin.git Porting to MeshGems 2.10: better implementation, keeping sources backward compatibility in compile time --- diff --git a/src/BLSURFPlugin/BLSURFPluginBuilder.py b/src/BLSURFPlugin/BLSURFPluginBuilder.py index 1571de3..ce756a8 100644 --- a/src/BLSURFPlugin/BLSURFPluginBuilder.py +++ b/src/BLSURFPlugin/BLSURFPluginBuilder.py @@ -294,7 +294,8 @@ class BLSURF_Algorithm(Mesh_Algorithm): # can set this parameter to 0 # def SetMaxNumberOfPointsPerPatch( self, nb ): - print("Warning: method SetMaxNumberOfPointsPerPatch() is deprecated") + if not version_less(self.Parameters().GetMeshGemsVersion(), '2.10'): + print("Warning: method SetMaxNumberOfPointsPerPatch() is deprecated") self.Parameters().SetMaxNumberOfPointsPerPatch( nb ) ## Set max_number_of_threads parameter @@ -812,3 +813,7 @@ class BLSURF_Algorithm(Mesh_Algorithm): return pass # end of BLSURF_Algorithm class + +def version_less(version: str, ref_version: str): + from re import split + return [int(i) for i in split('[.-]', version)] < [int(i) for i in re.split('[.-]', ref_version)] diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index e20cc14..8c1740a 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -114,7 +114,9 @@ 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 // Deprecated since MeshGems 2.10 +#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 @@ -125,7 +127,9 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, SMESH_Gen * gen, boo }; const char* intOptionNames[] = { - //"max_number_of_points_per_patch", // default = 100000 // Deprecated since MeshGems 2.10 +#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 }; @@ -210,9 +214,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"; // Deprecated since MeshGems 2.10 +#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"; // Deprecated since MeshGems 2.10 +#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"; @@ -562,21 +570,24 @@ void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal) { //============================================================================= void BLSURFPlugin_Hypothesis::SetEnforceCadEdgesSize( bool toEnforce ) { - /* Deprecated since MeshGems 2.10 +#if MESHGEMS_VERSION_HEX < 0x020A00 + // Deprecated since MeshGems 2.10 if ( GetEnforceCadEdgesSize() != toEnforce ) { SetOptionValue( "enforce_cad_edge_sizes", toEnforce ? "yes" : "no" ); NotifySubMeshesHypothesisModification(); } - */ +#endif } //============================================================================= bool BLSURFPlugin_Hypothesis::GetEnforceCadEdgesSize() { - /* Deprecated since MeshGems 2.10 +#if MESHGEMS_VERSION_HEX < 0x020A00 + // Deprecated since MeshGems 2.10 return ToBool( GetOptionValue( "enforce_cad_edge_sizes" ), GET_DEFAULT() ); - */ +#else return false; +#endif } //============================================================================= @@ -628,7 +639,8 @@ bool BLSURFPlugin_Hypothesis::GetUseDeprecatedPatchMesher() void BLSURFPlugin_Hypothesis::SetMaxNumberOfPointsPerPatch( int nb ) throw (std::invalid_argument) { - /* Deprecated since MeshGems 2.10 +#if MESHGEMS_VERSION_HEX < 0x020A00 + // Deprecated since MeshGems 2.10 if ( nb < 0 ) throw std::invalid_argument( SMESH_Comment("Invalid number of points: ") << nb ); @@ -637,15 +649,17 @@ void BLSURFPlugin_Hypothesis::SetMaxNumberOfPointsPerPatch( int nb ) SetOptionValue("max_number_of_points_per_patch", SMESH_Comment( nb )); NotifySubMeshesHypothesisModification(); } - */ +#endif } //============================================================================= int BLSURFPlugin_Hypothesis::GetMaxNumberOfPointsPerPatch() { - /* Deprecated since MeshGems 2.10 +#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 } //============================================================================= @@ -2670,7 +2684,11 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) } // read the value of the advanced option // unless this option is no more used - if (isOK && optName != "enforce_cad_edge_sizes" && optName != "max_number_of_points_per_patch") { + 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();