From 478db82c701923587ad06be02e4f575d3e021174 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Wed, 13 May 2015 09:09:44 +0200 Subject: [PATCH] First try. --- .../IO/MEDFileFieldRepresentationTree.cxx | 16 ++++++++++++++++ .../IO/MEDFileFieldRepresentationTree.hxx | 3 +++ src/Plugins/MEDReader/IO/vtkMEDReader.cxx | 15 +++++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx index 32738af7..b3512390 100644 --- a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx +++ b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx @@ -535,6 +535,12 @@ bool MEDFileFieldRepresentationLeaves::containZeName(const char *name, int& id) return false; } +void MEDFileFieldRepresentationLeaves::dumpState(std::map& status) const +{ + for(std::vector::const_iterator it=_arrays.begin();it!=_arrays.end();it++) + status[(*it).getZeName()]=(*it).getStatus(); +} + bool MEDFileFieldRepresentationLeaves::isActivated() const { for(std::vector::const_iterator it=_arrays.begin();it!=_arrays.end();it++) @@ -1393,6 +1399,16 @@ void MEDFileFieldRepresentationTree::printMySelf(std::ostream& os) const os << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << std::endl; } +std::map MEDFileFieldRepresentationTree::dumpState() const +{ + std::map ret; + for(std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > >::const_iterator it0=_data_structure.begin();it0!=_data_structure.end();it0++) + for(std::vector< std::vector< MEDFileFieldRepresentationLeaves > >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) + for(std::vector< MEDFileFieldRepresentationLeaves >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) + (*it2).dumpState(ret); + return ret; +} + void MEDFileFieldRepresentationTree::AppendFieldFromMeshes(const ParaMEDMEM::MEDFileMeshes *ms, ParaMEDMEM::MEDFileFields *ret) { if(!ret) diff --git a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.hxx b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.hxx index 00a2623a..922ceb6a 100644 --- a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.hxx +++ b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.hxx @@ -28,6 +28,7 @@ #include "vtkType.h" #include +#include class vtkQuadratureSchemeDefinition; class vtkMutableDirectedGraph; @@ -108,6 +109,7 @@ public: void computeFullNameInLeaves(const std::string& tsName, const std::string& meshName, const std::string& comSupStr) const; bool containId(int id) const; bool containZeName(const char *name, int& id) const; + void dumpState(std::map& status) const; bool isActivated() const; void printMySelf(std::ostream& os) const; void activateAllArrays() const; @@ -148,6 +150,7 @@ public: std::vector getTimeSteps(int& lev0, const TimeKeeper& tk) const; vtkDataSet *buildVTKInstance(bool isStdOrMode, double timeReq, std::string& meshName, const TimeKeeper& tk) const; void printMySelf(std::ostream& os) const; + std::map dumpState() const; //non const methods void loadMainStructureOfFile(const char *fileName, bool isMEDOrSauv, int iPart, int nbOfParts); void removeEmptyLeaves(); diff --git a/src/Plugins/MEDReader/IO/vtkMEDReader.cxx b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx index 0dca27f6..d2eb1025 100644 --- a/src/Plugins/MEDReader/IO/vtkMEDReader.cxx +++ b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx @@ -50,6 +50,7 @@ #include "MEDFileFieldRepresentationTree.hxx" +#include #include #include #include @@ -185,7 +186,8 @@ public: // The property keeper is usable only in pvsm mode. PropertyKeeper PK; int MyMTime; - std::set _wonderful_set;// this set is used by SetFieldsStatus method to detect the fact that SetFieldsStatus has been called for all items ! Great ! + std::set _wonderful_set;// this set is used by SetFieldsStatus method to detect the fact that SetFieldsStatus has been called for all items ! Great Items are not sorted ! Why ? + std::map _wonderful_ref;// this map stores the state before a SetFieldsStatus status. private: unsigned char FirstCall0; }; @@ -366,6 +368,8 @@ void vtkMEDReader::SetFieldsStatus(const char* name, int status) this->Internal->PK.pushFieldStatusEntry(name,status); return ; } + if(this->Internal->_wonderful_set.empty()) + this->Internal->_wonderful_ref=this->Internal->Tree.dumpState();// start of SetFieldsStatus serie -> store ref to compare at the end of the SetFieldsStatus serie. this->Internal->_wonderful_set.insert(name); //not pvsm mode (general case) try @@ -373,11 +377,14 @@ void vtkMEDReader::SetFieldsStatus(const char* name, int status) this->Internal->Tree.changeStatusOfAndUpdateToHaveCoherentVTKDataSet(this->Internal->Tree.getIdHavingZeName(name),status); if(this->Internal->_wonderful_set.size()==GetNumberOfFieldsTreeArrays()) { - if(!this->Internal->PluginStart0()) + if(this->Internal->_wonderful_ref!=this->Internal->Tree.dumpState()) { - this->Modified(); + if(!this->Internal->PluginStart0()) + { + this->Modified(); + } + this->Internal->MyMTime++; } - this->Internal->MyMTime++; this->Internal->_wonderful_set.clear(); } } -- 2.39.2