From: geay Date: Wed, 26 Mar 2014 10:27:21 +0000 (+0100) Subject: Ready for field renaming. X-Git-Tag: V7_4_0a1^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=be53c49c05e29e2237d4afb36d5f70728d11765a;p=modules%2Fparavis.git Ready for field renaming. --- diff --git a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx index 8832df19..0721775a 100644 --- a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx +++ b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx @@ -1376,6 +1376,74 @@ ParaMEDMEM::MEDFileFields *MEDFileFieldRepresentationTree::BuildFieldFromMeshes( return ret.retn(); } +std::vector MEDFileFieldRepresentationTree::SplitFieldNameIntoParts(const std::string& fullFieldName, char sep) +{ + std::vector ret; + std::size_t pos(0); + while(pos!=std::string::npos) + { + std::size_t curPos(fullFieldName.find_first_of(sep,pos)); + std::string elt(fullFieldName.substr(pos,curPos!=std::string::npos?curPos-pos:std::string::npos)); + ret.push_back(elt); + pos=fullFieldName.find_first_not_of(sep,curPos); + } + return ret; +} + +/*! + * Here the non regression tests. + * const char inp0[]=""; + * const char exp0[]=""; + * const char inp1[]="field"; + * const char exp1[]="field"; + * const char inp2[]="_________"; + * const char exp2[]="_________"; + * const char inp3[]="field_p"; + * const char exp3[]="field_p"; + * const char inp4[]="field__p"; + * const char exp4[]="field_p"; + * const char inp5[]="field_p__"; + * const char exp5[]="field_p"; + * const char inp6[]="field_p_"; + * const char exp6[]="field_p"; + * const char inp7[]="field_____EDFGEG//sdkjf_____PP_______________"; + * const char exp7[]="field_EDFGEG//sdkjf_PP"; + * const char inp8[]="field_____EDFGEG//sdkjf_____PP"; + * const char exp8[]="field_EDFGEG//sdkjf_PP"; + * const char inp9[]="_field_____EDFGEG//sdkjf_____PP_______________"; + * const char exp9[]="field_EDFGEG//sdkjf_PP"; + * const char inp10[]="___field_____EDFGEG//sdkjf_____PP_______________"; + * const char exp10[]="field_EDFGEG//sdkjf_PP"; +*/ +std::string MEDFileFieldRepresentationTree::PostProcessFieldName(const std::string& fullFieldName) +{ + static const char SEP('_'); + std::vector v(SplitFieldNameIntoParts(fullFieldName,SEP)); + if(v.empty()) + return fullFieldName;//should never happen + if(v.size()==1) + { + if(v[0].empty()) + return fullFieldName; + else + return v[0]; + } + std::string ret(v[0]); + for(std::size_t i=1;i& compInfos); + static std::string PostProcessFieldName(const std::string& fullFieldName); public: static const char ROOT_OF_GRPS_IN_TREE[]; static const char ROOT_OF_FAM_IDS_IN_TREE[]; @@ -156,6 +157,7 @@ private: const MEDFileFieldRepresentationLeaves& getTheSingleActivated(int& lev0, int& lev1, int& lev2) const; static ParaMEDMEM::MEDFileFields *BuildFieldFromMeshes(const ParaMEDMEM::MEDFileMeshes *ms); static void AppendFieldFromMeshes(const ParaMEDMEM::MEDFileMeshes *ms, ParaMEDMEM::MEDFileFields *ret); + static std::vector SplitFieldNameIntoParts(const std::string& fullFieldName, char sep); private: // 1st : timesteps, 2nd : meshName, 3rd : common support std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > > _data_structure;