Salome HOME
Adding element generation with cartesian core and global physical size
[plugins/hybridplugin.git] / src / HYBRIDPlugin / HYBRIDPlugin_Hypothesis.cxx
index 4d2f0222ed6e0c5795bc338d27147059c8ff22db..de92a756b2e2f23eb4de5a81c7eb5d1db8783c7d 100644 (file)
@@ -62,6 +62,7 @@ HYBRIDPlugin_Hypothesis::HYBRIDPlugin_Hypothesis(int hypId, int studyId, SMESH_G
   mySmoothNormals(DefaultSmoothNormals()),
   myHeightFirstLayer(DefaultHeightFirstLayer()),
   myBoundaryLayersProgression(DefaultBoundaryLayersProgression()),
+  myCoreSize(DefaultCoreSize()),
   myMultinormalsAngle(DefaultMultinormalsAngle()),
   myNbOfBoundaryLayers(DefaultNbOfBoundaryLayers()),
   _enfVertexList(DefaultHYBRIDEnforcedVertexList()),
@@ -391,6 +392,27 @@ double HYBRIDPlugin_Hypothesis::GetBoundaryLayersProgression() const
   return myBoundaryLayersProgression;
 }
 
+//=======================================================================
+//function : SetCoreSize
+//=======================================================================
+
+void HYBRIDPlugin_Hypothesis::SetCoreSize(double toCoreSize)
+{
+  if ( myCoreSize != toCoreSize ) {
+    myCoreSize = toCoreSize;
+    NotifySubMeshesHypothesisModification();
+  }
+}
+
+//=======================================================================
+//function : GetCoreSize
+//=======================================================================
+
+double HYBRIDPlugin_Hypothesis::GetCoreSize() const
+{
+  return myCoreSize;
+}
+
 //=======================================================================
 //function : SetMultinormalsAngle
 //=======================================================================
@@ -425,7 +447,7 @@ void HYBRIDPlugin_Hypothesis::SetNbOfBoundaryLayers(short toNbOfBoundaryLayers)
 }
 
 //=======================================================================
-//function : GetMultinormalsAngle
+//function : GetCoreSize
 //=======================================================================
 
 short HYBRIDPlugin_Hypothesis::GetNbOfBoundaryLayers() const
@@ -1293,6 +1315,14 @@ double HYBRIDPlugin_Hypothesis::DefaultBoundaryLayersProgression()
   return 1.0;
 }
 
+//=======================================================================
+//function : DefaultCoreSize
+//=======================================================================
+double HYBRIDPlugin_Hypothesis::DefaultCoreSize()
+{
+  return 0.0;
+}
+
 //=======================================================================
 //function : DefaultMultinormalsAngle
 //=======================================================================
@@ -1329,6 +1359,8 @@ std::ostream & HYBRIDPlugin_Hypothesis::SaveTo(std::ostream & save)
   save << (int) myKeepFiles << " ";
   save << myWorkingDirectory << " ";
   save << myVerboseLevel << " ";
+  save << myCoreSize << " ";
+
   if (!myTextOption.empty()) {
     save << "__OPTIONS_BEGIN__ ";
     save << myTextOption << " ";
@@ -1501,6 +1533,11 @@ std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load)
   else
     load.clear(ios::badbit | load.rdstate());
 
+  isOK = static_cast<bool>(load >> d);
+  if (isOK)
+    myCoreSize = d;
+  else
+    load.clear(ios::badbit | load.rdstate());
 
   std::string separator;
   bool hasOptions = false;
@@ -1784,13 +1821,11 @@ std::string HYBRIDPlugin_Hypothesis::CommandToRun(const HYBRIDPlugin_Hypothesis*
   bool p_eg    = ( hyp && hyp->myTextOption.find("--element_generation ") != std::string::npos );
   bool p_cm    = ( hyp && hyp->myTextOption.find("--collision_mode ") != std::string::npos );
   bool p_am    = ( hyp && hyp->myTextOption.find("--add_multinormals ") != std::string::npos );
+  bool p_cs    = ( hyp && hyp->myTextOption.find("--global_physical_size ") != std::string::npos );
   bool p_mat   = ( hyp && hyp->myTextOption.find("--multinormal_angle_threshold ") != std::string::npos );
   bool p_sn    = ( hyp && hyp->myTextOption.find("--smooth_normals ") != std::string::npos );
 
   //missing options :
-  //- global_physical_size
-  //- boundary_layer_size_mode
-  //- boundary_layer_initial_height_on_surface_tags
   //- boundary_layer_max_element_angle
 
   bool nolayers = false;
@@ -1862,12 +1897,18 @@ std::string HYBRIDPlugin_Hypothesis::CommandToRun(const HYBRIDPlugin_Hypothesis*
   }
 
   if ( !p_eg && hyp ) {
-    if ( hyp->myElementGeneration >= 0 && hyp->myElementGeneration <= 1 ) {
-      const char* value[] = { "tetra-dominant" , "hexa-dominant" };
+    if ( hyp->myElementGeneration >= 0 && hyp->myElementGeneration <= 2 ) {
+      const char* value[] = { "tetra-dominant" , "hexa-dominant", "cartesian_core" };
       cmd << " --element_generation " << value[ hyp->myElementGeneration ];
     }
   }
-  
+
+  if ( !p_cs && hyp ) {
+    if ( hyp->myCoreSize >= 0 ) {
+      cmd << " --global_physical_size " << hyp->myCoreSize;
+    }
+  }
+
   if ( !p_cm && hyp ) {
     if ( hyp->myCollisionMode >= 0 && hyp->myCollisionMode <= 1 ) {
       const char* value[] = { "decrease" , "stop" };