Salome HOME
0023299: [CEA] Finalize multi-study removal
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_Hypothesis.cxx
index 5bef9fdc9b951c64da5f0db95ccd5e0e8d739a3c..5ec88e3e4b944e08709d5823b7d318d634f66a85 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  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,9 +40,9 @@ 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),
+  : SMESH_Hypothesis(hypId, gen),
     _maxSize         (GetDefaultMaxSize()),
     _minSize         (0),
     _growthRate      (GetDefaultGrowthRate()),
@@ -216,15 +216,15 @@ void NETGENPlugin_Hypothesis::SetNbSegPerRadius(double theVal)
 void NETGENPlugin_Hypothesis::SetLocalSizeOnEntry(const std::string& entry, double localSize)
 {
   if(_localSize[entry] != localSize)
-    {
-      _localSize[entry] = localSize;
-      NotifySubMeshesHypothesisModification();
-    }
+  {
+    _localSize[entry] = localSize;
+    NotifySubMeshesHypothesisModification();
+  }
 }
 
 //=============================================================================
 /*!
- *  
+ *
  */
 //=============================================================================
 double NETGENPlugin_Hypothesis::GetLocalSizeOnEntry(const std::string& entry)
@@ -247,6 +247,20 @@ void NETGENPlugin_Hypothesis::UnsetLocalSizeOnEntry(const std::string& entry)
   NotifySubMeshesHypothesisModification();
 }
 
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+void NETGENPlugin_Hypothesis::SetMeshSizeFile(const std::string& fileName)
+{
+  if ( fileName != _meshSizeFile )
+  {
+    _meshSizeFile = fileName;
+    NotifySubMeshesHypothesisModification();
+  }
+}
+
 //=============================================================================
 /*!
  *  
@@ -347,6 +361,8 @@ ostream & NETGENPlugin_Hypothesis::SaveTo(ostream & save)
   save << " " << _surfaceCurvature;
   save << " " << _fuseEdges;
 
+  save << " " << _meshSizeFile.size() << " " << _meshSizeFile;
+
   return save;
 }
 
@@ -361,13 +377,13 @@ istream & NETGENPlugin_Hypothesis::LoadFrom(istream & load)
   int is;
   double val;
 
-  isOK = (load >> val);
+  isOK = static_cast<bool>(load >> val);
   if (isOK)
     _maxSize = val;
   else
     load.clear(ios::badbit | load.rdstate());
 
-  isOK = (load >> is);
+  isOK = static_cast<bool>(load >> is);
   if (isOK)
     SetFineness((Fineness) is);
   else
@@ -375,32 +391,32 @@ istream & NETGENPlugin_Hypothesis::LoadFrom(istream & load)
 
   if (_fineness == UserDefined)
   {
-    isOK = (load >> val);
+    isOK = static_cast<bool>(load >> val);
     if (isOK)
       _growthRate = val;
     else
       load.clear(ios::badbit | load.rdstate());
 
-    isOK = (load >> val);
+    isOK = static_cast<bool>(load >> val);
     if (isOK)
       _nbSegPerEdge = val;
     else
       load.clear(ios::badbit | load.rdstate());
 
-    isOK = (load >> val);
+    isOK = static_cast<bool>(load >> val);
     if (isOK)
       _nbSegPerRadius = val;
     else
       load.clear(ios::badbit | load.rdstate());
   }
 
-  isOK = (load >> is);
+  isOK = static_cast<bool>(load >> is);
   if (isOK)
     _secondOrder = (bool) is;
   else
     load.clear(ios::badbit | load.rdstate());
 
-  isOK = (load >> is);
+  isOK = static_cast<bool>(load >> is);
   if (isOK)
     _optimize = (bool) is;
   else
@@ -409,18 +425,18 @@ istream & NETGENPlugin_Hypothesis::LoadFrom(istream & load)
   std::string option_or_sm;
   bool hasLocalSize = false;
 
-  isOK = (load >> option_or_sm);
+  isOK = static_cast<bool>(load >> option_or_sm);
   if (isOK)
     if (option_or_sm == "__LOCALSIZE_BEGIN__")
       hasLocalSize = true;
 
   std::string smEntry, smValue;
   while (isOK && hasLocalSize) {
-    isOK = (load >> smEntry);
+    isOK = static_cast<bool>(load >> smEntry);
     if (isOK) {
       if (smEntry == "__LOCALSIZE_END__")
         break;
-      isOK = (load >> smValue);
+      isOK = static_cast<bool>(load >> smValue);
     }
     if (isOK) {
       std::istringstream tmp(smValue);
@@ -432,19 +448,34 @@ istream & NETGENPlugin_Hypothesis::LoadFrom(istream & load)
 
   if ( !hasLocalSize && !option_or_sm.empty() )
     _minSize = atof( option_or_sm.c_str() );
+  else
+    load >> _minSize;
 
-  isOK = ( load >> _quadAllowed );
-  if ( !isOK )
+  isOK = static_cast<bool>( load >> is );
+  if ( isOK )
+    _quadAllowed = (bool) is;
+  else
     _quadAllowed = GetDefaultQuadAllowed();
 
-  isOK = ( load >> _surfaceCurvature );
-  if ( !isOK )
+  isOK = static_cast<bool>( load >> is );
+  if ( isOK )
+    _surfaceCurvature = (bool) is;
+  else
     _surfaceCurvature = GetDefaultSurfaceCurvature();
 
-  isOK = ( 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 );
+  }
+
   return load;
 }