Salome HOME
CaseReader: minor bug fix in reg exp ...
[tools/medcoupling.git] / src / MEDLoader / MEDFileData.cxx
index 6add25ef62b5fc3888ee4bf7ef6ec94730b03c47..8c3c171731f00fd79044121a476ac23f361b4747 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2019  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
@@ -21,6 +21,7 @@
 #include "MEDFileData.hxx"
 #include "MEDLoaderBase.hxx"
 #include "MEDFileSafeCaller.txx"
+#include "MEDFileBlowStrEltUp.hxx"
 
 #include "InterpKernelAutoPtr.hxx"
 
@@ -69,6 +70,8 @@ std::vector<const BigMemoryObject *> MEDFileData::getDirectChildrenWithNull() co
   ret.push_back((const MEDFileFields *)_fields);
   ret.push_back((const MEDFileMeshes *)_meshes);
   ret.push_back((const MEDFileParameters *)_params);
+  ret.push_back((const MEDFileMeshSupports *)_mesh_supports);
+  ret.push_back((const MEDFileStructureElements *)_struct_elems);
   return ret;
 
 }
@@ -229,6 +232,15 @@ bool MEDFileData::unPolyzeMeshes()
   return !meshesImpacted.empty();
 }
 
+void MEDFileData::dealWithStructureElements()
+{
+  if(_struct_elems.isNull())
+    throw INTERP_KERNEL::Exception("MEDFileData::dealWithStructureElements : no structure elements in this !");
+  if(_meshes.isNull() || _fields.isNull())
+    throw INTERP_KERNEL::Exception("MEDFileData::dealWithStructureElements : meshes and fields must be not null !");
+  MEDFileBlowStrEltUp::DealWithSE(_fields,_meshes,_struct_elems);
+}
+
 /*!
  * Precondition : all instances in \a mfds should have a single mesh with fields on it. If there is an instance with not exactly one mesh an exception will be thrown.
  * You can invoke MEDFileFields::partOfThisLyingOnSpecifiedMeshName method to make it work.
@@ -305,7 +317,9 @@ MEDFileData::MEDFileData(med_idt fid)
 try
 {
   readHeader(fid);
-  _fields=MEDFileFields::New(fid);
+  _mesh_supports=MEDFileMeshSupports::New(fid);
+  _struct_elems=MEDFileStructureElements::New(fid,_mesh_supports);
+  _fields=MEDFileFields::NewWithDynGT(fid,_struct_elems,true);
   _meshes=MEDFileMeshes::New(fid);
   _params=MEDFileParameters::New(fid);
 }
@@ -317,15 +331,16 @@ catch(INTERP_KERNEL::Exception& e)
 void MEDFileData::writeLL(med_idt fid) const
 {
   writeHeader(fid);
-  const MEDFileMeshes *ms(_meshes);
-  if(ms)
-    ms->writeLL(fid);
-  const MEDFileFields *fs(_fields);
-  if(fs)
-    fs->writeLL(fid);
-  const MEDFileParameters *ps(_params);
-  if(ps)
-    ps->writeLL(fid);
+  if(_meshes.isNotNull())
+    _meshes->writeLL(fid);
+  if(_fields.isNotNull())
+    _fields->writeLL(fid);
+  if(_params.isNotNull())
+    _params->writeLL(fid);
+  if(_mesh_supports.isNotNull())
+    _mesh_supports->writeLL(fid);
+  if(_struct_elems.isNotNull())
+    _struct_elems->writeLL(fid);
 }
 
 std::string MEDFileData::getHeader() const
@@ -342,8 +357,9 @@ void MEDFileData::setHeader(const std::string& header)
 void MEDFileData::readHeader(med_idt fid)
 {
   INTERP_KERNEL::AutoPtr<char> header(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE));
-  MEDFILESAFECALLERRD0(MEDfileCommentRd,(fid,header));
-  _header=MEDLoaderBase::buildStringFromFortran(header,MED_COMMENT_SIZE);
+  int ret(MEDfileCommentRd(fid,header));
+  if(ret==0)
+    _header=MEDLoaderBase::buildStringFromFortran(header,MED_COMMENT_SIZE);
 }
 
 void MEDFileData::writeHeader(med_idt fid) const