Salome HOME
Adding multithread computation (available since MeshGems-2.4-2)
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Hypothesis.cxx
index 6790461b07dc37b911f0b4f2766d45d463ec8d57..818b5893b67858503253069c83c613bc95e7225c 100644 (file)
@@ -121,6 +121,7 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_G
       };
 
   const char* intOptionNames[] = {          "max_number_of_points_per_patch",           // default = 100000
+                                            "max_number_of_threads",                    // default = 4
                                             "" // mark of end
       };
   const char* doubleOptionNames[] = {       // "surface_intersections_processing_max_cost",// default = 15
@@ -206,6 +207,7 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_G
   _defaultOptionValues["enforce_cad_edge_sizes"                 ] = "no";
   _defaultOptionValues["jacobian_rectification_respect_geometry"] = "yes";
   _defaultOptionValues["max_number_of_points_per_patch"         ] = "0";
+  _defaultOptionValues["max_number_of_threads"                  ] = "4";
   _defaultOptionValues["rectify_jacobian"                       ] = "yes";
   _defaultOptionValues["respect_geometry"                       ] = "yes";
   _defaultOptionValues["tiny_edge_avoid_surface_intersections"  ] = "yes";
@@ -555,6 +557,25 @@ int BLSURFPlugin_Hypothesis::GetMaxNumberOfPointsPerPatch()
 }
 //=============================================================================
 
+void BLSURFPlugin_Hypothesis::SetMaxNumberOfThreads( int nb )
+  throw (std::invalid_argument)
+{
+  if ( nb < 0 )
+    throw std::invalid_argument( SMESH_Comment("Invalid number of threads: ") << nb );
+
+  if ( GetMaxNumberOfThreads() != nb )
+  {
+    SetOptionValue("max_number_of_threads", SMESH_Comment( nb ));
+    NotifySubMeshesHypothesisModification();
+  }
+}
+//=============================================================================
+int BLSURFPlugin_Hypothesis::GetMaxNumberOfThreads()
+{
+  return ToInt( GetOptionValue("max_number_of_threads", GET_DEFAULT()));
+}
+//=============================================================================
+
 void BLSURFPlugin_Hypothesis::SetRespectGeometry( bool toRespect )
 {
   if ( GetRespectGeometry() != toRespect )