From: ageay Date: Mon, 28 Feb 2011 14:02:15 +0000 (+0000) Subject: Update of MEDLoader for MED3 alpha3. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5069728685056a9e82ac46565adedf85d60beaa2;p=tools%2Fmedcoupling.git Update of MEDLoader for MED3 alpha3. --- diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index e56d4e665..ef7afe9a9 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -38,43 +38,53 @@ extern "C" #include #include -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 MEDLoader::GetTypesOfField(const char *file } } bool found=false; - for(int j=0;j0) { @@ -523,7 +538,7 @@ std::vector MEDLoader::GetAllFieldNamesOnMesh(const char *fileName, } } // - for(int j=0;j0) { @@ -590,7 +605,7 @@ std::vector MEDLoader::GetCellFieldNamesOnMesh(const char *fileName if(curMeshName==meshName) { bool found=false; - for(int j=0;j0) { @@ -700,7 +715,7 @@ std::vector< std::pair > MEDLoader::GetCellFieldIterations(const char * if(curFieldName==fieldName) { bool found=false; - for(int j=0;j0) + { + 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 allTypes; for(std::vector::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::const_iterator iter=mesh.begin();iter!=mesh.end();iter++) { - for(int i=0;i(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(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);