Salome HOME
Indices are stored as mcIdType type instead of int to support switch to 64bits indexing
[tools/medcoupling.git] / src / MEDPartitioner / MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx
index 9a7df8f5c94531acfd83922c2fda1aed794c83f4..79a47276427e76804b5ebf7d660d3350e1c02c0a 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2012  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
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -169,7 +169,7 @@ int MeshCollectionMedXmlDriver::read(const char* filename, ParaDomainSelector* d
       //to know nb of cells on each proc to compute global cell ids from locally global
       domainSelector->gatherNbOf(_collection->getMesh());
     }
-  _collection->setTopology(aPT);
+  _collection->setTopology(aPT, true);
   _collection->setDomainNames(_collection->getName());
   return 0;
 }
@@ -200,7 +200,7 @@ void MeshCollectionMedXmlDriver::write(const char* filename, ParaDomainSelector*
 
   //Description tag
   time_t present; 
-  char date[6];
+  char date[20];
 #ifndef WIN32
   time( &present);
   struct tm *time_asc = localtime(&present);
@@ -242,10 +242,22 @@ void MeshCollectionMedXmlDriver::write(const char* filename, ParaDomainSelector*
   xmlNodePtr mesh_node = xmlNewChild(node, 0, BAD_CAST "mesh",0);
   xmlNewProp(mesh_node, BAD_CAST "name", BAD_CAST _collection->getName().c_str());
 
-  int nbdomains= _collection->getMesh().size();
+  int nbdomains= _collection->getNbOfGlobalMeshes();
 
   //loop on the domains
-  std::string finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName=");
+  std::string finalMeshName="";
+  if (MyGlobals::_General_Informations.size()!=0)
+    {
+      std::size_t found=MyGlobals::_General_Informations[0].find("finalMeshName=");
+     if ((found!=std::string::npos) && (found>0))
+       {
+         finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName=");
+       }
+    }
+  if (finalMeshName.empty())
+    {
+      finalMeshName=_collection->getName();
+    }
   for (int idomain=nbdomains-1; idomain>=0;idomain--)
     {
       std::string distfilename;
@@ -277,7 +289,7 @@ void MeshCollectionMedXmlDriver::write(const char* filename, ParaDomainSelector*
           node = xmlNewChild(mesh_node,0, BAD_CAST "chunk",0);
           xmlNewProp(node, BAD_CAST "subdomain", BAD_CAST buff);
           xmlNewChild(node,0,BAD_CAST "name", BAD_CAST finalMeshName.c_str());
-          //xmlNewChild(node,0,BAD_CAST "name", BAD_CAST (_collection->getMesh())[idomain]->getName());
+          //xmlNewChild(node,0,BAD_CAST "name", BAD_CAST ((_collection->getMesh())[idomain]->getName()).c_str());
         }
     }