From: ageay Date: Wed, 3 Nov 2010 06:45:11 +0000 (+0000) Subject: Bug correction on node profile. Small imps. X-Git-Tag: V5_1_5~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c0bbbc5ba8589964a831c51856863cef3f8ac769;p=tools%2Fmedcoupling.git Bug correction on node profile. Small imps. --- diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index 2aff1147c..eb89ed9d0 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -476,6 +476,29 @@ std::vector MEDLoader::GetTypesOfField(const char *file return ret; } +std::vector MEDLoader::GetAllFieldNames(const char *fileName) throw(INTERP_KERNEL::Exception) +{ + CheckFileForRead(fileName); + std::vector ret; + med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE); + med_int nbFields=MEDnChamp(fid,0); + med_type_champ typcha; + for(int i=0;i MEDLoader::GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception) { CheckFileForRead(fileName); @@ -1591,13 +1614,42 @@ ParaMEDMEM::MEDCouplingFieldDouble *MEDLoaderNS::readFieldDoubleLev2(const char DataArrayInt *da=0,*da2=0; if(newMesh) { - da=newMesh->getCellIdsFullyIncludedInNodeIds(&ci[0],&ci[ci.size()]); - mesh2=dynamic_cast(newMesh->buildPartAndReduceNodes(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems(),da2)); + if((int)ci.size()!=newMesh->getNumberOfNodes()) + { + da=newMesh->getCellIdsFullyIncludedInNodeIds(&ci[0],&ci[ci.size()]); + mesh2=dynamic_cast(newMesh->buildPartAndReduceNodes(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems(),da2)); + } } else { - da=mesh->getCellIdsFullyIncludedInNodeIds(&ci[0],&ci[ci.size()]); - mesh2=dynamic_cast(mesh->buildPartAndReduceNodes(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems(),da2)); + if((int)ci.size()!=mesh->getNumberOfNodes()) + { + da=mesh->getCellIdsFullyIncludedInNodeIds(&ci[0],&ci[ci.size()]); + mesh2=dynamic_cast(mesh->buildPartAndReduceNodes(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems(),da2)); + // + int nnodes=mesh2->getNumberOfNodes(); + DataArrayInt *da3=DataArrayInt::New(); + const int *da2Ptr=da2->getConstPointer(); + da3->alloc(nnodes,1); + int *da3Ptr=da3->getPointer(); + for(int i=0;i<(int)ci.size();i++) + { + int val=da2Ptr[ci[i]]; + if(val!=-1) + da3Ptr[val]=i; + } + mesh2->renumberNodes(da3->getConstPointer(),nnodes); + da3->decrRef(); + } + else + { + mesh2=mesh->clone(true); + da=DataArrayInt::New(); + da->alloc((int)ci.size(),1); + std::copy(ci.begin(),ci.end(),da->getPointer()); + da2=da->invertArrayO2N2N2O(ci.size()); + mesh2->renumberNodes(da2->getConstPointer(),(int)ci.size()); + } } if(da) da->decrRef(); diff --git a/src/MEDLoader/MEDLoader.hxx b/src/MEDLoader/MEDLoader.hxx index 48d95e6c5..68e1a0ab9 100644 --- a/src/MEDLoader/MEDLoader.hxx +++ b/src/MEDLoader/MEDLoader.hxx @@ -89,6 +89,7 @@ class MEDLOADER_EXPORT MEDLoader static std::vector GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception); static std::vector GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); static std::vector GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); + static std::vector GetAllFieldNames(const char *fileName) throw(INTERP_KERNEL::Exception); static std::vector GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); static std::vector GetTypesOfField(const char *fileName, const char *fieldName, const char *meshName) throw(INTERP_KERNEL::Exception); static std::vector GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);