]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Update of MEDLoader for MED3 alpha3. V6_MEDFILE3
authorageay <ageay>
Mon, 28 Feb 2011 14:02:15 +0000 (14:02 +0000)
committerageay <ageay>
Mon, 28 Feb 2011 14:02:15 +0000 (14:02 +0000)
src/MEDLoader/MEDLoader.cxx

index e56d4e66556f0f6fdee8e04745d57f005edc2c3c..ef7afe9a9401939d59720d9ae4e0fb54adaf494d 100644 (file)
@@ -38,43 +38,53 @@ extern "C"
 #include <algorithm>
 #include <numeric>
 
-med_geometry_type typmai[MED_NOF_CELL_PREDEFINED_TYPES+2] = { MED_POINT1,
-                                                              MED_SEG2,
-                                                              MED_SEG3,
-                                                              MED_TRIA3,
-                                                              MED_TRIA6,
-                                                              MED_QUAD4,
-                                                              MED_QUAD8,
-                                                              MED_TETRA4,
-                                                              MED_TETRA10,
-                                                              MED_HEXA8,
-                                                              MED_HEXA20,
-                                                              MED_PENTA6,
-                                                              MED_PENTA15,
-                                                              MED_PYRA5,
-                                                              MED_PYRA13,
-                                                              MED_POLYGON,
-                                                              MED_POLYHEDRON };
+med_geometry_type typmai[MED_N_CELL_FIXED_GEO] = { MED_POINT1,
+                                                   MED_SEG2,
+                                                   MED_SEG3,
+                                                   MED_SEG4,
+                                                   MED_TRIA3,
+                                                   MED_TRIA6,
+                                                   MED_TRIA7,
+                                                   MED_QUAD4,
+                                                   MED_QUAD8,
+                                                   MED_QUAD9,
+                                                   MED_TETRA4,
+                                                   MED_TETRA10,
+                                                   MED_HEXA8,
+                                                   MED_HEXA20,
+                                                   MED_HEXA27,
+                                                   MED_PENTA6,
+                                                   MED_PENTA15,
+                                                   MED_PYRA5,
+                                                   MED_PYRA13,
+                                                   MED_OCTA12,
+                                                   MED_POLYGON,
+                                                   MED_POLYHEDRON };
 
 med_geometry_type typmainoeud[1] = { MED_NONE };
 
-INTERP_KERNEL::NormalizedCellType typmai2[MED_NOF_CELL_PREDEFINED_TYPES+2] = { INTERP_KERNEL::NORM_POINT0,
-                                                                               INTERP_KERNEL::NORM_SEG2,
-                                                                               INTERP_KERNEL::NORM_SEG3,
-                                                                               INTERP_KERNEL::NORM_TRI3,
-                                                                               INTERP_KERNEL::NORM_TRI6,
-                                                                               INTERP_KERNEL::NORM_QUAD4,
-                                                                               INTERP_KERNEL::NORM_QUAD8,
-                                                                               INTERP_KERNEL::NORM_TETRA4,
-                                                                               INTERP_KERNEL::NORM_TETRA10,
-                                                                               INTERP_KERNEL::NORM_HEXA8,
-                                                                               INTERP_KERNEL::NORM_HEXA20,
-                                                                               INTERP_KERNEL::NORM_PENTA6,
-                                                                               INTERP_KERNEL::NORM_PENTA15,
-                                                                               INTERP_KERNEL::NORM_PYRA5,
-                                                                               INTERP_KERNEL::NORM_PYRA13,
-                                                                               INTERP_KERNEL::NORM_POLYGON,
-                                                                               INTERP_KERNEL::NORM_POLYHED };
+INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO] = { INTERP_KERNEL::NORM_POINT0,
+                                                                    INTERP_KERNEL::NORM_SEG2,
+                                                                    INTERP_KERNEL::NORM_SEG3,
+                                                                    INTERP_KERNEL::NORM_ERROR,//SEG4
+                                                                    INTERP_KERNEL::NORM_TRI3,
+                                                                    INTERP_KERNEL::NORM_TRI6,
+                                                                    INTERP_KERNEL::NORM_ERROR,//TRI7
+                                                                    INTERP_KERNEL::NORM_QUAD4,
+                                                                    INTERP_KERNEL::NORM_QUAD8,
+                                                                    INTERP_KERNEL::NORM_ERROR,//QUAD9
+                                                                    INTERP_KERNEL::NORM_TETRA4,
+                                                                    INTERP_KERNEL::NORM_TETRA10,
+                                                                    INTERP_KERNEL::NORM_HEXA8,
+                                                                    INTERP_KERNEL::NORM_HEXA20,
+                                                                    INTERP_KERNEL::NORM_ERROR,//HEXA27
+                                                                    INTERP_KERNEL::NORM_PENTA6,
+                                                                    INTERP_KERNEL::NORM_PENTA15,
+                                                                    INTERP_KERNEL::NORM_PYRA5,
+                                                                    INTERP_KERNEL::NORM_PYRA13,
+                                                                    INTERP_KERNEL::NORM_ERROR,//OCTA12
+                                                                    INTERP_KERNEL::NORM_POLYGON,
+                                                                    INTERP_KERNEL::NORM_POLYHED };
 
 med_geometry_type typmai3[32] = { MED_POINT1,//0
                                   MED_SEG2,//1
@@ -296,7 +306,12 @@ void MEDLoaderNS::fillGaussDataOnField(const char *fileName, const std::list<MED
       med_int spaceDim;
       for(;idLoc<=nloc;idLoc++)
         {
-          MEDlocalizationInfo(fid,idLoc,locName,&typeGeo,&spaceDim,&nbOfGaussPt);
+          char geointerpname[MED_NAME_SIZE+1]="";
+          char ipointstructmeshname[MED_NAME_SIZE+1]="";
+          med_int nsectionmeshcell;
+          med_geometry_type sectiongeotype;
+          MEDlocalizationInfo(fid,idLoc,locName,&typeGeo,&spaceDim,&nbOfGaussPt, geointerpname, ipointstructmeshname, &nsectionmeshcell,
+                              &sectiongeotype);
           if(loc==locName)
             break;
         }
@@ -453,7 +468,7 @@ std::vector<ParaMEDMEM::TypeOfField> MEDLoader::GetTypesOfField(const char *file
                     }
                 }
               bool found=false;
-              for(int j=0;j<MED_NBR_GEOMETRIE_MAILLE+2 && !found;j++)
+              for(int j=0;j<MED_N_CELL_FIXED_GEO && !found;j++)
                 {
                   if(nbPdt>0)
                     {
@@ -523,7 +538,7 @@ std::vector<std::string> MEDLoader::GetAllFieldNamesOnMesh(const char *fileName,
                 }
             }
           //
-          for(int j=0;j<MED_NBR_GEOMETRIE_MAILLE+2 && !found;j++)
+          for(int j=0;j<MED_N_CELL_FIXED_GEO && !found;j++)
             {
               if(nbPdt>0)
                 {
@@ -590,7 +605,7 @@ std::vector<std::string> MEDLoader::GetCellFieldNamesOnMesh(const char *fileName
       if(curMeshName==meshName)
         {
           bool found=false;
-          for(int j=0;j<MED_NBR_GEOMETRIE_MAILLE+2 && !found;j++)
+          for(int j=0;j<MED_N_CELL_FIXED_GEO && !found;j++)
             {
               if(nbPdt>0)
                 {
@@ -700,7 +715,7 @@ std::vector< std::pair<int,int> > MEDLoader::GetCellFieldIterations(const char *
       if(curFieldName==fieldName)
         {
           bool found=false;
-          for(int j=0;j<MED_NBR_GEOMETRIE_MAILLE+2 && !found;j++)
+          for(int j=0;j<MED_N_CELL_FIXED_GEO && !found;j++)
             {
               for(int k=0;k<nbPdt;k++)
                 {
@@ -794,16 +809,16 @@ void MEDLoaderNS::readFieldDoubleDataInMedFile(const char *fileName, const char
   med_bool localmesh;
   tabEnt[ON_CELLS]=MED_CELL;
   tabType[ON_CELLS]=typmai;
-  tabTypeLgth[ON_CELLS]=MED_NBR_GEOMETRIE_MAILLE+2;
+  tabTypeLgth[ON_CELLS]=MED_N_CELL_FIXED_GEO;
   tabEnt[ON_NODES]=MED_NODE;
   tabType[ON_NODES]=typmainoeud;
   tabTypeLgth[ON_NODES]=1;
   tabEnt[ON_GAUSS_PT]=MED_CELL;
   tabType[ON_GAUSS_PT]=typmai;
-  tabTypeLgth[ON_GAUSS_PT]=MED_NBR_GEOMETRIE_MAILLE+2;
+  tabTypeLgth[ON_GAUSS_PT]=MED_N_CELL_FIXED_GEO;
   tabEnt[ON_GAUSS_NE]=MED_NODE_ELEMENT;
   tabType[ON_GAUSS_NE]=typmai;
-  tabTypeLgth[ON_GAUSS_NE]=MED_NBR_GEOMETRIE_MAILLE+2;
+  tabTypeLgth[ON_GAUSS_NE]=MED_N_CELL_FIXED_GEO;
   //
   for(int i=0;i<nbFields;i++)
     {
@@ -1014,7 +1029,7 @@ int MEDLoaderNS::readUMeshDimFromFile(const char *fileName, const char *meshName
   delete [] dt_unit;
   delete [] axisname;
   delete [] axisunit;
-  for(int i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+  for(int i=0;i<MED_N_CELL_GEO_FIXED_CON;i++)
     {
       med_geometry_type curMedType=typmai[i];
       med_bool changement,transformation;
@@ -1082,7 +1097,7 @@ void MEDLoaderNS::readUMeshDataInMedFile(med_idt fid, med_int meshId, DataArrayD
     }
   delete [] comp;
   delete [] unit;
-  for(int i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++)
+  for(int i=0;i<MED_N_CELL_GEO_FIXED_CON;i++)
     {
       med_geometry_type curMedType=typmai[i];
       med_entity_type whichEntity;
@@ -1125,10 +1140,18 @@ void MEDLoaderNS::readUMeshDataInMedFile(med_idt fid, med_int meshId, DataArrayD
       int *globArr=new int[curNbOfPolyElem];
       MEDLoader::MEDConnOfOneElemType elem(INTERP_KERNEL::NORM_POLYGON,locConn,index,fam,curNbOfPolyElem,arraySize);
       MEDmeshPolygonRd(fid,nommaa,numdt,numit,MED_CELL,MED_NODAL,index,locConn);
-      if(MEDmeshEntityFamilyNumberRd(fid,nommaa,numdt,numit,whichPolyEntity,MED_POLYGON,fam)!=0)
-        std::fill(fam,fam+curNbOfPolyElem,0);
-      if(MEDmeshEntityNumberRd(fid,nommaa,numdt,numit,whichPolyEntity,MED_POLYGON,globArr)==0)
-        elem.setGlobal(globArr);
+      if(MEDmeshnEntity(fid,nommaa,numdt,numit,MED_CELL,MED_POLYGON,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
+        {
+          if(MEDmeshEntityFamilyNumberRd(fid,nommaa,numdt,numit,MED_CELL,MED_POLYGON,fam)!=0)
+            std::fill(fam,fam+curNbOfPolyElem,0);
+        }
+      if(MEDmeshnEntity(fid,nommaa,numdt,numit,MED_CELL,MED_POLYGON,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
+        {
+          if(MEDmeshEntityNumberRd(fid,nommaa,numdt,numit,whichPolyEntity,MED_POLYGON,globArr)==0)
+            elem.setGlobal(globArr);
+          else
+            delete [] globArr;
+        }
       else
         delete [] globArr;
       conn.push_back(elem);
@@ -1145,7 +1168,7 @@ void MEDLoaderNS::readUMeshDataInMedFile(med_idt fid, med_int meshId, DataArrayD
       int *fam=new int[curNbOfPolyElem];
       int *globArr=new int[curNbOfPolyElem];
       MEDmeshPolyhedronRd(fid,nommaa,numdt,numit,MED_CELL,MED_NODAL,index,indexFace,locConn);
-      if(MEDmeshnEntity(fid,nommaa,numdt,numit,whichPolyEntity,MED_POLYHEDRON,MED_FAMILY_NUMBER,MED_NO_CMODE,&changement,&transformation)==0)
+      if(MEDmeshnEntity(fid,nommaa,numdt,numit,whichPolyEntity,MED_POLYHEDRON,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)==0)
         //if(MEDmeshEntityFamilyNumberRd(fid,nommaa,numdt,numit,whichPolyEntity,MED_POLYHEDRON,fam)!=0)
         std::fill(fam,fam+curNbOfPolyElem,0);
       else
@@ -1171,8 +1194,13 @@ void MEDLoaderNS::readUMeshDataInMedFile(med_idt fid, med_int meshId, DataArrayD
       delete [] locConn;
       delete [] indexFace;
       MEDLoader::MEDConnOfOneElemType elem(INTERP_KERNEL::NORM_POLYHED,finalConn,finalIndex,fam,curNbOfPolyElem,arraySize);
-      if(MEDmeshEntityNumberRd(fid,nommaa,numdt,numit,whichPolyEntity,MED_POLYHEDRON,globArr)==0)
-        elem.setGlobal(globArr);
+      if(MEDmeshnEntity(fid,nommaa,numdt,numit,MED_CELL,MED_POLYHEDRON,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
+        {
+          if(MEDmeshEntityNumberRd(fid,nommaa,numdt,numit,whichPolyEntity,MED_POLYHEDRON,globArr)==0)
+            elem.setGlobal(globArr);
+          else
+            delete [] globArr;
+        }
       else
         delete [] globArr;
       conn.push_back(elem);
@@ -1890,7 +1918,7 @@ void MEDLoaderNS::writeUMeshesDirectly(const char *fileName, const std::vector<c
   std::set<INTERP_KERNEL::NormalizedCellType> allTypes;
   for(std::vector<const ParaMEDMEM::MEDCouplingUMesh *>::const_iterator iter=mesh.begin();iter!=mesh.end();iter++)
     {
-      isRenumbering|=!(*iter)->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_NBR_GEOMETRIE_MAILLE+2);
+      isRenumbering|=!(*iter)->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_N_CELL_FIXED_GEO);
       isFamilies&=(families[std::distance(mesh.begin(),iter)]!=0);
       conn.push_back((*iter)->getNodalConnectivity());
       connIndex.push_back((*iter)->getNodalConnectivityIndex());
@@ -1917,7 +1945,7 @@ void MEDLoaderNS::writeUMeshesDirectly(const char *fileName, const std::vector<c
   MEDmeshCr(fid,maa,spaceDim,meshDim,MED_UNSTRUCTURED_MESH,desc,"",MED_SORT_DTIT,MED_CARTESIAN,comp,unit);
   for(std::vector<const ParaMEDMEM::MEDCouplingUMesh *>::const_iterator iter=mesh.begin();iter!=mesh.end();iter++)
     {
-      for(int i=0;i<MED_NBR_GEOMETRIE_MAILLE+2;i++)
+      for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
         {
           med_geometry_type curMedType=typmai[i];
           INTERP_KERNEL::NormalizedCellType curType=typmai2[i];
@@ -2135,11 +2163,11 @@ void MEDLoaderNS::appendFieldDirectly(const char *fileName, const ParaMEDMEM::ME
   const MEDCouplingUMesh *meshC=dynamic_cast<const MEDCouplingUMesh *>(mesh);
   if(!meshC)
     throw INTERP_KERNEL::Exception("Not implemented yet for not unstructured mesh !");
-  bool renum=!meshC->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_NBR_GEOMETRIE_MAILLE+2);
+  bool renum=!meshC->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_N_CELL_FIXED_GEO);
   if(renum)
     {
       ParaMEDMEM::MEDCouplingFieldDouble *f3=f2->clone(true);
-      DataArrayInt *da=meshC->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_NBR_GEOMETRIE_MAILLE+2);
+      DataArrayInt *da=meshC->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_N_CELL_FIXED_GEO);
       f3->renumberCells(da->getConstPointer(),false);
       da->decrRef();
       f=f3;
@@ -2184,7 +2212,7 @@ void MEDLoaderNS::appendFieldDirectly(const char *fileName, const ParaMEDMEM::ME
             int id=f->getGaussLocalizationIdOfOneType((*iter).getType());
             const MEDCouplingGaussLocalization& gl=f->getGaussLocalization(id);
             MEDlocalizationWr(fid,nomGauss,typmai3[(int)(*iter).getType()],mesh->getMeshDimension(),&gl.getRefCoords()[0],MED_FULL_INTERLACE,
-                              gl.getNumberOfGaussPt(),&gl.getGaussCoords()[0],&gl.getWeights()[0]);
+                              gl.getNumberOfGaussPt(),&gl.getGaussCoords()[0],&gl.getWeights()[0],MED_NO_INTERPOLATION, MED_NO_MESH_SUPPORT);
             int nbOfEntity=f->getMesh()->getNumberOfCellsWithType((*iter).getType());
             int nbOfValues=gl.getNumberOfGaussPt()*nbOfEntity;
             char *fieldname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
@@ -2232,7 +2260,7 @@ void MEDLoaderNS::prepareCellFieldDoubleForWriting(const ParaMEDMEM::MEDCoupling
   const MEDCouplingUMesh *meshC=dynamic_cast<const MEDCouplingUMesh *>(mesh);
   if(!meshC)
     throw INTERP_KERNEL::Exception("Not implemented yet for not unstructured mesh !");
-  if(!meshC->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_NBR_GEOMETRIE_MAILLE+2))
+  if(!meshC->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_N_CELL_FIXED_GEO))
     throw INTERP_KERNEL::Exception("Unstructuded mesh has not consecutive cell types !");
   const int *connI=meshC->getNodalConnectivityIndex()->getConstPointer();
   const int *conn=meshC->getNodalConnectivity()->getConstPointer();
@@ -2273,7 +2301,7 @@ void MEDLoaderNS::writeFieldAndMeshDirectly(const char *fileName, const ParaMEDM
       if(isRenumbering)
         {
           ParaMEDMEM::MEDCouplingFieldDouble *f2=f->clone(true);
-          DataArrayInt *da=mesh->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_NBR_GEOMETRIE_MAILLE+2);
+          DataArrayInt *da=mesh->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_N_CELL_FIXED_GEO);
           f2->renumberCells(da->getConstPointer(),false);
           da->decrRef();
           appendFieldDirectly(fileName,f2);