Salome HOME
Merge changes from 'master' branch.
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_Hypothesis.cxx
index c362938d01fc1c710e25d3f66712531f3a5624b8..abb5b6aacef9645611fac42ee8c775083dc665b0 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -40,21 +40,24 @@ using namespace std;
  *  
  */
 //=============================================================================
-NETGENPlugin_Hypothesis::NETGENPlugin_Hypothesis (int hypId, int studyId,
+NETGENPlugin_Hypothesis::NETGENPlugin_Hypothesis (int hypId,
                                                   SMESH_Gen * gen)
-  : SMESH_Hypothesis(hypId, studyId, gen),
-    _maxSize         (GetDefaultMaxSize()),
-    _minSize         (0),
-    _growthRate      (GetDefaultGrowthRate()),
-    _nbSegPerEdge    (GetDefaultNbSegPerEdge()),
-    _nbSegPerRadius  (GetDefaultNbSegPerRadius()),
-    _fineness        (GetDefaultFineness()),
-    _secondOrder     (GetDefaultSecondOrder()),
-    _optimize        (GetDefaultOptimize()),
-    _localSize       (GetDefaultLocalSize()),
-    _quadAllowed     (GetDefaultQuadAllowed()),
-    _surfaceCurvature(GetDefaultSurfaceCurvature()),
-    _fuseEdges       (GetDefaultFuseEdges())
+
+  : SMESH_Hypothesis(hypId, gen),
+    _maxSize            (GetDefaultMaxSize()),
+    _minSize            (0),
+    _growthRate         (GetDefaultGrowthRate()),
+    _nbSegPerEdge       (GetDefaultNbSegPerEdge()),
+    _nbSegPerRadius     (GetDefaultNbSegPerRadius()),
+    _fineness           (GetDefaultFineness()),
+    _chordalErrorEnabled(GetDefaultChordalError() > 0),
+    _chordalError       (GetDefaultChordalError() ),
+    _secondOrder        (GetDefaultSecondOrder()),
+    _optimize           (GetDefaultOptimize()),
+    _localSize          (GetDefaultLocalSize()),
+    _quadAllowed        (GetDefaultQuadAllowed()),
+    _surfaceCurvature   (GetDefaultSurfaceCurvature()),
+    _fuseEdges          (GetDefaultFuseEdges())
 {
   _name = "NETGEN_Parameters";
   _param_algo_dim = 3;
@@ -208,6 +211,34 @@ void NETGENPlugin_Hypothesis::SetNbSegPerRadius(double theVal)
   }
 }
 
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+void NETGENPlugin_Hypothesis::SetChordalErrorEnabled(bool theVal)
+{
+  if (theVal != _chordalErrorEnabled)
+  {
+    _chordalErrorEnabled = theVal;
+    NotifySubMeshesHypothesisModification();
+  }
+}
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+void NETGENPlugin_Hypothesis::SetChordalError(double theVal)
+{
+  if (theVal != _chordalError)
+  {
+    _chordalError = theVal;
+    NotifySubMeshesHypothesisModification();
+  }
+}
+
 //=============================================================================
 /*!
  *  
@@ -247,6 +278,20 @@ void NETGENPlugin_Hypothesis::UnsetLocalSizeOnEntry(const std::string& entry)
   NotifySubMeshesHypothesisModification();
 }
 
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+void NETGENPlugin_Hypothesis::SetMeshSizeFile(const std::string& fileName)
+{
+  if ( fileName != _meshSizeFile )
+  {
+    _meshSizeFile = fileName;
+    NotifySubMeshesHypothesisModification();
+  }
+}
+
 //=============================================================================
 /*!
  *  
@@ -337,8 +382,8 @@ ostream & NETGENPlugin_Hypothesis::SaveTo(ostream & save)
   if (it_sm != _localSize.end()) {
     save << " " << "__LOCALSIZE_BEGIN__";
     for ( ; it_sm != _localSize.end(); ++it_sm ) {
-        save << " " << it_sm->first
-             << " " << it_sm->second << "%#"; // "%#" is a mark of value end
+      save << " " << it_sm->first
+           << " " << it_sm->second << "%#"; // "%#" is a mark of value end
     }
     save << " " << "__LOCALSIZE_END__";
   }
@@ -347,6 +392,10 @@ ostream & NETGENPlugin_Hypothesis::SaveTo(ostream & save)
   save << " " << _surfaceCurvature;
   save << " " << _fuseEdges;
 
+  save << " " << _meshSizeFile.size() << " " << _meshSizeFile;
+
+  save << " " << ( _chordalErrorEnabled ? _chordalError : 0. );
+
   return save;
 }
 
@@ -432,25 +481,47 @@ istream & NETGENPlugin_Hypothesis::LoadFrom(istream & load)
 
   if ( !hasLocalSize && !option_or_sm.empty() )
     _minSize = atof( option_or_sm.c_str() );
+  else
+    load >> _minSize;
 
-  isOK = static_cast<bool>( load >> _quadAllowed );
-  if ( !isOK )
+  isOK = static_cast<bool>( load >> is );
+  if ( isOK )
+    _quadAllowed = (bool) is;
+  else
     _quadAllowed = GetDefaultQuadAllowed();
 
-  isOK = static_cast<bool>( load >> _surfaceCurvature );
-  if ( !isOK )
+  isOK = static_cast<bool>( load >> is );
+  if ( isOK )
+    _surfaceCurvature = (bool) is;
+  else
     _surfaceCurvature = GetDefaultSurfaceCurvature();
 
-  isOK = static_cast<bool>( load >> _fuseEdges );
-  if ( !isOK )
+  isOK = static_cast<bool>( load >> is );
+  if ( isOK )
+    _fuseEdges = (bool) is;
+  else
     _fuseEdges = GetDefaultFuseEdges();
 
+  isOK = static_cast<bool>( load >> is >> std::ws ); // size of meshSizeFile
+  if ( isOK && is > 0 )
+  {
+    _meshSizeFile.resize( is );
+    load.get( &_meshSizeFile[0], is+1 );
+  }
+
+  isOK = static_cast<bool>(load >> val);
+  if (isOK)
+    _chordalError = val;
+  else
+    load.clear(ios::badbit | load.rdstate());
+  _chordalErrorEnabled = ( _chordalError > 0 );
+
   return load;
 }
 
 //=============================================================================
 /*!
- *  
+ *
  */
 //=============================================================================
 ostream & operator <<(ostream & save, NETGENPlugin_Hypothesis & hyp)
@@ -460,7 +531,7 @@ ostream & operator <<(ostream & save, NETGENPlugin_Hypothesis & hyp)
 
 //=============================================================================
 /*!
- *  
+ *
  */
 //=============================================================================
 istream & operator >>(istream & load, NETGENPlugin_Hypothesis & hyp)
@@ -553,6 +624,15 @@ double NETGENPlugin_Hypothesis::GetDefaultNbSegPerRadius()
 {
   return 2;
 }
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+double NETGENPlugin_Hypothesis::GetDefaultChordalError()
+{
+  return -1; // disabled by default
+}
 
 //=============================================================================
 /*!