Salome HOME
Fix compilation error due API modification (returned type) of ReadField
[modules/med.git] / src / MEDCalculator / MEDCalculatorBrowserField.cxx
old mode 100755 (executable)
new mode 100644 (file)
index a221f0e..e26b1d3
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -29,7 +29,7 @@
 #include <algorithm>
 #include <functional>
 
-using namespace ParaMEDMEM;
+using namespace MEDCoupling;
 
 //  Default constructor
 //  Set field name to nm and selection to flase
@@ -50,25 +50,29 @@ MEDCalculatorBrowserField::~MEDCalculatorBrowserField()
 //  Then, read the Med structur to fill time steps, components and meshes
 MEDCalculatorBrowserField::MEDCalculatorBrowserField(const char *fname, const char *fieldName) : _name(fieldName), _file_name(fname), _selection(false)
 {
-  std::vector< std::string > meshNames=MEDLoader::GetMeshNamesOnField(fname,fieldName);
-  std::vector< std::pair< std::pair<int,int>, double > > dtits=MEDLoader::GetAllFieldIterations(fname, fieldName);
+  std::vector< std::string > meshNames=GetMeshNamesOnField(fname,fieldName);
+  std::vector< std::pair< std::pair<int,int>, double > > dtits=GetAllFieldIterations(fname, fieldName);
   for(std::vector<std::pair< std::pair<int,int>, double > >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
     {
       _steps.push_back(MEDCalculatorBrowserStep((*iter).first.first,(*iter).first.second,(*iter).second,meshNames[0]));
     }
-  std::vector<TypeOfField> types=MEDLoader::GetTypesOfField(fname,meshNames[0].c_str(),fieldName);
+  std::vector<TypeOfField> types=GetTypesOfField(fname,meshNames[0].c_str(),fieldName);
   if(types.empty())
-    throw INTERP_KERNEL::Exception("MEDCalculatorBrowserField::MEDCalculatorBrowserField : the file is not loadable using MED File 3 API ! Problably presence of field on edges faces...");
+    throw INTERP_KERNEL::Exception("MEDCalculatorBrowserField::MEDCalculatorBrowserField : the file is not loadable using MED File 3 API ! Probably presence of field on edges faces...");
   _type=types[0];//To improve
-  MEDCouplingFieldDouble *tmpf=0;
+  MCAuto<MEDCouplingFieldDouble> tmpf;
   try
     {
-      tmpf=MEDLoader::ReadField(_type,fname,meshNames[0].c_str(),0,fieldName,dtits[0].first.first,dtits[0].first.second);
+      MCAuto<MEDCouplingField> tmpf2(ReadField(_type,fname,meshNames[0].c_str(),0,fieldName,dtits[0].first.first,dtits[0].first.second));
+      tmpf=DynamicCast<MEDCouplingField,MEDCouplingFieldDouble>(tmpf2);
     }
   catch(INTERP_KERNEL::Exception& e)
     {
       if(_type==ON_CELLS)
-        tmpf=MEDLoader::ReadField(_type,fname,meshNames[0].c_str(),-1,fieldName,dtits[0].first.first,dtits[0].first.second);
+        {
+          MCAuto<MEDCouplingField> tmpf2(ReadField(_type,fname,meshNames[0].c_str(),-1,fieldName,dtits[0].first.first,dtits[0].first.second));
+          tmpf=DynamicCast<MEDCouplingField,MEDCouplingFieldDouble>(tmpf2);
+        }
       else
         throw e;
     }
@@ -80,8 +84,7 @@ MEDCalculatorBrowserField::MEDCalculatorBrowserField(const char *fname, const ch
         c="-noname-";
       _components.push_back(c);
     }
-  tmpf->decrRef();
-  _corresponding_meshes=MEDLoader::GetMeshNamesOnField(fname,fieldName);
+  _corresponding_meshes=GetMeshNamesOnField(fname,fieldName);
 }
 
 //  Equal to string operator,