From: ageay Date: Fri, 4 May 2012 11:06:07 +0000 (+0000) Subject: Profiles and Localization management. X-Git-Tag: V6_5_0~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=750a41d6d8f7ea9e4f30b540a47005cfb62199fd;p=tools%2Fmedcoupling.git Profiles and Localization management. --- diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 802139bd9..e993e283a 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -513,6 +513,30 @@ void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName) _localization=newLocName; } +void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< std::pair, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++) + { + if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end()) + { + _profile=(*it2).second; + return; + } + } +} + +void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< std::pair, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++) + { + if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end()) + { + _localization=(*it2).second; + return; + } + } +} + void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFieldFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const { if(type!=_type) @@ -955,6 +979,18 @@ std::vector MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() co return ret; } +void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++) + (*it1)->changePflsRefsNamesGen(mapOfModif); +} + +void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++) + (*it1)->changeLocsRefsNamesGen(mapOfModif); +} + MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception) { if(_field_pm_pt_pd.empty()) @@ -1403,6 +1439,18 @@ std::vector MEDFileFieldPerMesh::getLocsReallyUsedMulti() const return ret; } +void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + (*it)->changePflsRefsNamesGen(mapOfModif); +} + +void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + (*it)->changeLocsRefsNamesGen(mapOfModif); +} + MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFieldFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception) { if(_field_pm_pt.empty()) @@ -1930,6 +1978,46 @@ void MEDFieldFieldGlobs::setFileName(const char *fileName) _file_name=fileName; } +void MEDFieldFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_pfls.begin();it!=_pfls.end();it++) + { + DataArrayInt *elt(*it); + if(elt) + { + std::string name(elt->getName()); + for(std::vector< std::pair, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++) + { + if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end()) + { + elt->setName((*it2).second.c_str()); + return; + } + } + } + } +} + +void MEDFieldFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_locs.begin();it!=_locs.end();it++) + { + MEDFileFieldLoc *elt(*it); + if(elt) + { + std::string name(elt->getName()); + for(std::vector< std::pair, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++) + { + if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end()) + { + elt->setName((*it2).second.c_str()); + return; + } + } + } + } +} + int MEDFieldFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception) { if(locId<0 || locId>=(int)_locs.size()) @@ -1997,6 +2085,13 @@ const DataArrayInt *MEDFieldFieldGlobs::getProfile(const char *pflName) const th return *it; } +const DataArrayInt *MEDFieldFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception) +{ + if(pflId<0 || pflId>=(int)_pfls.size()) + throw INTERP_KERNEL::Exception("MEDFieldFieldGlobs::getProfileFromId : Invalid profile id !"); + return _pfls[pflId]; +} + MEDFileFieldLoc& MEDFieldFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception) { if(locId<0 || locId>=(int)_locs.size()) @@ -2023,6 +2118,37 @@ DataArrayInt *MEDFieldFieldGlobs::getProfile(const char *pflName) throw(INTERP_K return *it; } +DataArrayInt *MEDFieldFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception) +{ + if(pflId<0 || pflId>=(int)_pfls.size()) + throw INTERP_KERNEL::Exception("MEDFieldFieldGlobs::getProfileFromId : Invalid profile id !"); + return _pfls[pflId]; +} + +void MEDFieldFieldGlobs::killProfileIds(const std::vector& pflIds) throw(INTERP_KERNEL::Exception) +{ + std::vector< MEDCouplingAutoRefCountObjectPtr > newPfls; + int i=0; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++) + { + if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end()) + newPfls.push_back(*it); + } + _pfls=newPfls; +} + +void MEDFieldFieldGlobs::killLocalizationIds(const std::vector& locIds) throw(INTERP_KERNEL::Exception) +{ + std::vector< MEDCouplingAutoRefCountObjectPtr > newLocs; + int i=0; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++) + { + if(std::find(locIds.begin(),locIds.end(),i)==locIds.end()) + newLocs.push_back(*it); + } + _locs=newLocs; +} + std::vector MEDFieldFieldGlobs::getPfls() const { int sz=_pfls.size(); @@ -2055,6 +2181,51 @@ bool MEDFieldFieldGlobs::existsLoc(const char *locName) const return std::find(v.begin(),v.end(),s)!=v.end(); } +std::vector< std::vector > MEDFieldFieldGlobs::whichAreEqualProfiles() const +{ + std::map > m; + int i=0; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++) + { + const DataArrayInt *tmp=(*it); + if(tmp) + { + m[tmp->getHashCode()].push_back(i); + } + } + std::vector< std::vector > ret; + for(std::map >::const_iterator it2=m.begin();it2!=m.end();it2++) + { + if((*it2).second.size()>1) + { + std::vector ret0; + bool equalityOrNot=false; + for(std::vector::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++) + { + std::vector::const_iterator it4=it3; it4++; + for(;it4!=(*it2).second.end();it4++) + { + if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4])) + { + if(!equalityOrNot) + ret0.push_back(*it3); + ret0.push_back(*it4); + equalityOrNot=true; + } + } + } + if(!ret0.empty()) + ret.push_back(ret0); + } + } + return ret; +} + +std::vector< std::vector > MEDFieldFieldGlobs::whichAreEqualLocs(double eps) const +{ + throw INTERP_KERNEL::Exception("MEDFieldFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !"); +} + void MEDFieldFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception) { std::string name(pfl->getName()); @@ -2173,6 +2344,110 @@ void MEDFieldFieldGlobsReal::setFileName(const char *fileName) _globals->setFileName(fileName); } +std::vector< std::vector > MEDFieldFieldGlobsReal::whichAreEqualProfiles() const +{ + return _globals->whichAreEqualProfiles(); +} + +std::vector< std::vector > MEDFieldFieldGlobsReal::whichAreEqualLocs(double eps) const +{ + return _globals->whichAreEqualLocs(eps); +} + +void MEDFieldFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + _globals->changePflsNamesInStruct(mapOfModif); +} + +void MEDFieldFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + _globals->changeLocsNamesInStruct(mapOfModif); +} + +/*! + * This method is a generalization of MEDFieldFieldGlobsReal::changePflName. + * This method contrary to abstract method MEDFieldFieldGlobsReal::changePflsRefsNamesGen updates in addition of MEDFieldFieldGlobsReal::changePflsRefsNamesGen, + * the profiles themselves and not only leaves of field. + */ +void MEDFieldFieldGlobsReal::changePflsNames(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + changePflsRefsNamesGen(mapOfModif); + changePflsNamesInStruct(mapOfModif); +} + +/*! + * This method is a generalization of MEDFieldFieldGlobsReal::changePflName. + * This method contrary to abstract method MEDFieldFieldGlobsReal::changeLocsRefsNamesGen updates in addition of MEDFieldFieldGlobsReal::changeLocsRefsNamesGen, + * the localizations themselves and not only leaves of field. + */ +void MEDFieldFieldGlobsReal::changeLocsNames(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + changeLocsRefsNamesGen(mapOfModif); + changeLocsNamesInStruct(mapOfModif); +} + +/*! + * This method is a more friendly API but less general method than MEDFieldFieldGlobsReal::changePflsNames. + */ +void MEDFieldFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception) +{ + std::vector< std::pair, std::string > > mapOfModif(1); + std::pair, std::string > p(std::vector(1,std::string(oldName)),std::string(newName)); + mapOfModif[0]=p; + changePflsNames(mapOfModif); +} + +/*! + * This method is a more friendly API but less general method than MEDFieldFieldGlobsReal::changeLocsNames. + */ +void MEDFieldFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception) +{ + std::vector< std::pair, std::string > > mapOfModif(1); + std::pair, std::string > p(std::vector(1,std::string(oldName)),std::string(newName)); + mapOfModif[0]=p; + changeLocsNames(mapOfModif); +} + +std::vector< std::pair, std::string > > MEDFieldFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception) +{ + std::vector< std::vector > pseudoRet=whichAreEqualProfiles(); + std::vector< std::pair, std::string > > ret(pseudoRet.size()); + int i=0; + for(std::vector< std::vector >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++) + { + std::vector< std::string > tmp((*it).size()); + int j=0; + for(std::vector::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++) + tmp[j]=std::string(getProfileFromId(*it2)->getName()); + std::pair, std::string > p(tmp,tmp.front()); + ret[i]=p; + std::vector tmp2((*it).begin()+1,(*it).end()); + killProfileIds(tmp2); + } + changePflsRefsNamesGen(ret); + return ret; +} + +std::vector< std::pair, std::string > > MEDFieldFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception) +{ + std::vector< std::vector > pseudoRet=whichAreEqualLocs(eps); + std::vector< std::pair, std::string > > ret(pseudoRet.size()); + int i=0; + for(std::vector< std::vector >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++) + { + std::vector< std::string > tmp((*it).size()); + int j=0; + for(std::vector::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++) + tmp[j]=std::string(getLocalizationFromId(*it2).getName()); + std::pair, std::string > p(tmp,tmp.front()); + ret[i]=p; + std::vector tmp2((*it).begin()+1,(*it).end()); + killLocalizationIds(tmp2); + } + changeLocsRefsNamesGen(ret); + return ret; +} + int MEDFieldFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception) { return _globals->getNbOfGaussPtPerCell(locId); @@ -2208,6 +2483,11 @@ const DataArrayInt *MEDFieldFieldGlobsReal::getProfile(const char *pflName) cons return _globals->getProfile(pflName); } +const DataArrayInt *MEDFieldFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception) +{ + return _globals->getProfileFromId(pflId); +} + MEDFileFieldLoc& MEDFieldFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception) { return _globals->getLocalizationFromId(locId); @@ -2223,6 +2503,21 @@ DataArrayInt *MEDFieldFieldGlobsReal::getProfile(const char *pflName) throw(INTE return _globals->getProfile(pflName); } +DataArrayInt *MEDFieldFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception) +{ + return _globals->getProfileFromId(pflId); +} + +void MEDFieldFieldGlobsReal::killProfileIds(const std::vector& pflIds) throw(INTERP_KERNEL::Exception) +{ + _globals->killProfileIds(pflIds); +} + +void MEDFieldFieldGlobsReal::killLocalizationIds(const std::vector& locIds) throw(INTERP_KERNEL::Exception) +{ + _globals->killLocalizationIds(locIds); +} + void MEDFieldFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception) { _globals->appendProfile(pfl); @@ -2639,6 +2934,17 @@ std::vector MEDFileField1TSWithoutDAS::getLocsReallyUsedMulti2() co return ret; } +void MEDFileField1TSWithoutDAS::changePflsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) + (*it)->changePflsRefsNamesGen(mapOfModif); +} + +void MEDFileField1TSWithoutDAS::changeLocsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) + (*it)->changeLocsRefsNamesGen(mapOfModif); +} void MEDFileField1TSWithoutDAS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception) { @@ -3092,6 +3398,16 @@ std::vector MEDFileField1TS::getLocsReallyUsedMulti() const return getLocsReallyUsedMulti2(); } +void MEDFileField1TS::changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + changePflsRefsNamesGen2(mapOfModif); +} + +void MEDFileField1TS::changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + changeLocsRefsNamesGen2(mapOfModif); +} + /*! * This method requests underlying file to perform the job, for mesh reading. If the current instance is not coming from a file and has been constructed from scratch * an exception will be thrown. In this case you should use MEDFileField1TS::getFieldOnMeshAtLevel method instead. @@ -3600,6 +3916,18 @@ std::vector MEDFileFieldMultiTSWithoutDAS::getLocsReallyUsedMulti2( return ret; } +void MEDFileFieldMultiTSWithoutDAS::changePflsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutDAS > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) + (*it)->changePflsRefsNamesGen2(mapOfModif); +} + +void MEDFileFieldMultiTSWithoutDAS::changeLocsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutDAS > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) + (*it)->changeLocsRefsNamesGen2(mapOfModif); +} + MEDFileFieldMultiTS *MEDFileFieldMultiTS::New() { return new MEDFileFieldMultiTS; @@ -3800,6 +4128,16 @@ std::vector MEDFileFieldMultiTS::getLocsReallyUsedMulti() const return getLocsReallyUsedMulti2(); } +void MEDFileFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + changePflsRefsNamesGen2(mapOfModif); +} + +void MEDFileFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + changeLocsRefsNamesGen2(mapOfModif); +} + MEDFileFields *MEDFileFields::New() { return new MEDFileFields; @@ -3996,6 +4334,18 @@ std::vector MEDFileFields::getLocsReallyUsedMulti() const return ret; } +void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutDAS > >::iterator it=_fields.begin();it!=_fields.end();it++) + (*it)->changePflsRefsNamesGen2(mapOfModif); +} + +void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTSWithoutDAS > >::iterator it=_fields.begin();it!=_fields.end();it++) + (*it)->changeLocsRefsNamesGen2(mapOfModif); +} + void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception) { _fields.resize(newSize); diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index 531cfd75c..53ce15005 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -116,6 +116,8 @@ namespace ParaMEDMEM std::string getLocalization() const; void setLocalization(const char *newLocName); int getLocId() const { return _loc_id; } + void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); void getFieldAtLevel(TypeOfField type, const MEDFieldFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const; void fillValues(int discId, int& startEntryId, std::vector< std::pair,std::pair > >& entries) const; @@ -169,6 +171,8 @@ namespace ParaMEDMEM std::vector getLocsReallyUsed() const; std::vector getPflsReallyUsedMulti() const; std::vector getLocsReallyUsedMulti() const; + void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception); const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception); void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFieldFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const; @@ -221,6 +225,8 @@ namespace ParaMEDMEM std::vector getLocsReallyUsed() const; std::vector getPflsReallyUsedMulti() const; std::vector getLocsReallyUsedMulti() const; + void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDFieldFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception); DataArrayDouble *getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception); DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); @@ -271,17 +277,25 @@ namespace ParaMEDMEM std::vector getLocs() const; bool existsPfl(const char *pflName) const; bool existsLoc(const char *locName) const; + std::vector< std::vector > whichAreEqualProfiles() const; + std::vector< std::vector > whichAreEqualLocs(double eps) const; void setFileName(const char *fileName); + void changePflsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + void changeLocsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); int getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception); int getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception); const char *getFileName() const { return _file_name.c_str(); } std::string getFileName2() const { return _file_name; } const MEDFileFieldLoc& getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception); const MEDFileFieldLoc& getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception); + const DataArrayInt *getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception); const DataArrayInt *getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception); MEDFileFieldLoc& getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception); MEDFileFieldLoc& getLocalization(const char *locName) throw(INTERP_KERNEL::Exception); DataArrayInt *getProfile(const char *pflName) throw(INTERP_KERNEL::Exception); + DataArrayInt *getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception); + void killProfileIds(const std::vector& pflIds) throw(INTERP_KERNEL::Exception); + void killLocalizationIds(const std::vector& locIds) throw(INTERP_KERNEL::Exception); // void appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception); void appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& w) throw(INTERP_KERNEL::Exception); @@ -309,6 +323,8 @@ namespace ParaMEDMEM virtual std::vector getLocsReallyUsed() const = 0; virtual std::vector getPflsReallyUsedMulti() const = 0; virtual std::vector getLocsReallyUsedMulti() const = 0; + virtual void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) = 0; + virtual void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) = 0; virtual ~MEDFieldFieldGlobsReal(); // void loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception); @@ -320,17 +336,31 @@ namespace ParaMEDMEM std::vector getLocs() const; bool existsPfl(const char *pflName) const; bool existsLoc(const char *locName) const; + std::vector< std::vector > whichAreEqualProfiles() const; + std::vector< std::vector > whichAreEqualLocs(double eps) const; void setFileName(const char *fileName); + void changePflsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + void changeLocsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + void changePflsNames(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + void changeLocsNames(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + void changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception); + void changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception); + std::vector< std::pair, std::string > > zipPflsNames() throw(INTERP_KERNEL::Exception); + std::vector< std::pair, std::string > > zipLocsNames(double eps) throw(INTERP_KERNEL::Exception); int getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception); int getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception); const char *getFileName() const; std::string getFileName2() const; const MEDFileFieldLoc& getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception); const MEDFileFieldLoc& getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception); - const DataArrayInt *getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception); MEDFileFieldLoc& getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception); MEDFileFieldLoc& getLocalization(const char *locName) throw(INTERP_KERNEL::Exception); + const DataArrayInt *getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception); + const DataArrayInt *getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception); DataArrayInt *getProfile(const char *pflName) throw(INTERP_KERNEL::Exception); + DataArrayInt *getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception); + void killProfileIds(const std::vector& pflIds) throw(INTERP_KERNEL::Exception); + void killLocalizationIds(const std::vector& locIds) throw(INTERP_KERNEL::Exception); // void appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception); void appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& w) throw(INTERP_KERNEL::Exception); @@ -372,6 +402,8 @@ namespace ParaMEDMEM std::vector getLocsReallyUsed2() const; std::vector getPflsReallyUsedMulti2() const; std::vector getLocsReallyUsedMulti2() const; + void changePflsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + void changeLocsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); static void CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception); static std::vector CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception); // @@ -442,6 +474,8 @@ namespace ParaMEDMEM std::vector getLocsReallyUsed() const; std::vector getPflsReallyUsedMulti() const; std::vector getLocsReallyUsedMulti() const; + void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); MEDFileField1TS(); }; @@ -469,6 +503,8 @@ namespace ParaMEDMEM std::vector getLocsReallyUsed2() const; std::vector getPflsReallyUsedMulti2() const; std::vector getLocsReallyUsedMulti2() const; + void changePflsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + void changeLocsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); protected: const MEDFileField1TSWithoutDAS& getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception); MEDFileField1TSWithoutDAS& getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception); @@ -513,6 +549,8 @@ namespace ParaMEDMEM std::vector getLocsReallyUsed() const; std::vector getPflsReallyUsedMulti() const; std::vector getLocsReallyUsedMulti() const; + void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); private: MEDFileFieldMultiTS(); MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutDAS& other); @@ -546,6 +584,8 @@ namespace ParaMEDMEM std::vector getLocsReallyUsed() const; std::vector getPflsReallyUsedMulti() const; std::vector getLocsReallyUsedMulti() const; + void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); private: MEDFileFields(); MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception); diff --git a/src/MEDLoader/Swig/MEDLoader.i b/src/MEDLoader/Swig/MEDLoader.i index 697fbf8bb..3902da9b2 100644 --- a/src/MEDLoader/Swig/MEDLoader.i +++ b/src/MEDLoader/Swig/MEDLoader.i @@ -644,6 +644,10 @@ namespace ParaMEDMEM virtual std::vector getLocsReallyUsed() const = 0; virtual std::vector getPflsReallyUsedMulti() const = 0; virtual std::vector getLocsReallyUsedMulti() const = 0; + void killProfileIds(const std::vector& pflIds) throw(INTERP_KERNEL::Exception); + void killLocalizationIds(const std::vector& locIds) throw(INTERP_KERNEL::Exception); + void changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception); + void changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception); %extend { PyObject *getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception) @@ -654,6 +658,14 @@ namespace ParaMEDMEM return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); } + PyObject *getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception) + { + const DataArrayInt *ret=self->getProfileFromId(pflId); + if(ret) + ret->incrRef(); + return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); + } + PyObject *getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception) { const MEDFileFieldLoc *loc=&self->getLocalizationFromId(locId); @@ -667,6 +679,23 @@ namespace ParaMEDMEM loc->incrRef(); return SWIG_NewPointerObj(SWIG_as_voidptr(loc),SWIGTYPE_p_ParaMEDMEM__MEDFileFieldLoc, SWIG_POINTER_OWN | 0 ); } + + PyObject *zipPflsNames() throw(INTERP_KERNEL::Exception) + { + std::vector< std::pair, std::string > > ret=self->zipPflsNames(); + return convertVecPairVecStToPy(ret); + } + + PyObject *zipLocsNames(double eps) throw(INTERP_KERNEL::Exception) + { + std::vector< std::pair, std::string > > ret=self->zipLocsNames(eps); + return convertVecPairVecStToPy(ret); + } + + //void changePflsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + //void changeLocsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + //void changePflsNames(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + //void changeLocsNames(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); } }; diff --git a/src/MEDLoader/Swig/MEDLoaderTypemaps.i b/src/MEDLoader/Swig/MEDLoaderTypemaps.i index 0e2987b3c..08baefdec 100644 --- a/src/MEDLoader/Swig/MEDLoaderTypemaps.i +++ b/src/MEDLoader/Swig/MEDLoaderTypemaps.i @@ -186,3 +186,21 @@ static std::vector convertUMeshVecFromPy(P } return ret; } + +PyObject *convertVecPairVecStToPy(const std::vector< std::pair, std::string > >& vec) +{ + int sz=(int)vec.size(); + PyObject *ret=PyList_New(sz); + for(int i=0;i