From 6af64fadd7857809c96137d12d2e0f0f8de094d4 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 27 Mar 2010 12:09:10 +0000 Subject: [PATCH] store partition ids per stepData (this should fix reading of separate multistep, multipartition datasets) --- Post/PView.cpp | 4 ++-- Post/PViewData.h | 2 +- Post/PViewDataGModel.cpp | 6 ++++-- Post/PViewDataGModel.h | 7 ++++--- Post/PViewDataGModelIO.cpp | 6 +++--- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Post/PView.cpp b/Post/PView.cpp index e595c21407..da83000e24 100644 --- a/Post/PView.cpp +++ b/Post/PView.cpp @@ -278,7 +278,7 @@ PView *PView::getViewByName(std::string name, int timeStep, int partition) for(unsigned int i = 0; i < list.size(); i++){ if(list[i]->getData()->getName() == name && ((timeStep < 0 || !list[i]->getData()->hasTimeStep(timeStep)) || - (partition < 0 || !list[i]->getData()->hasPartition(partition)))) + (partition < 0 || !list[i]->getData()->hasPartition(timeStep, partition)))) return list[i]; } return 0; @@ -289,7 +289,7 @@ PView *PView::getViewByNum(int num, int timeStep, int partition) for(unsigned int i = 0; i < list.size(); i++){ if(list[i]->getNum() == num && ((timeStep < 0 || !list[i]->getData()->hasTimeStep(timeStep)) || - (partition < 0 || !list[i]->getData()->hasPartition(partition)))) + (partition < 0 || !list[i]->getData()->hasPartition(timeStep, partition)))) return list[i]; } return 0; diff --git a/Post/PViewData.h b/Post/PViewData.h index ab542330d5..e97dc2bb04 100644 --- a/Post/PViewData.h +++ b/Post/PViewData.h @@ -164,7 +164,7 @@ class PViewData { // check if the data has the given step/partition/etc. virtual bool hasTimeStep(int step){ return step >= 0 && step < getNumTimeSteps(); } - virtual bool hasPartition(int part){ return false; } + virtual bool hasPartition(int step, int part){ return false; } virtual bool hasMultipleMeshes(){ return false; } virtual bool hasModel(GModel *model, int step=-1){ return false; } diff --git a/Post/PViewDataGModel.cpp b/Post/PViewDataGModel.cpp index bb8b310305..926a081002 100644 --- a/Post/PViewDataGModel.cpp +++ b/Post/PViewDataGModel.cpp @@ -500,9 +500,11 @@ bool PViewDataGModel::hasTimeStep(int step) return false; } -bool PViewDataGModel::hasPartition(int part) +bool PViewDataGModel::hasPartition(int step, int part) { - return _partitions.find(part) != _partitions.end(); + if(step < 0 || step >= getNumTimeSteps()) + return false; + return _steps[step]->getPartitions().find(part) != _steps[step]->getPartitions().end(); } bool PViewDataGModel::hasMultipleMeshes() diff --git a/Post/PViewDataGModel.h b/Post/PViewDataGModel.h index 293c79b344..49118a32d1 100644 --- a/Post/PViewDataGModel.h +++ b/Post/PViewDataGModel.h @@ -38,6 +38,8 @@ class stepData{ // a vector, indexed by MSH element type, of Gauss point locations // in parametric space std::vector<std::vector<double> > _gaussPoints; + // a set of all "partitions" encountered in the data + std::set<int> _partitions; public: stepData(GModel *model, int numComp, std::string fileName="", int fileIndex=-1, double time=0., double min=VAL_INF, double max=-VAL_INF) @@ -101,6 +103,7 @@ class stepData{ if((int)_gaussPoints.size() <= msh) _gaussPoints.resize(msh + 1); return _gaussPoints[msh]; } + std::set<int> &getPartitions(){ return _partitions; } }; // The data container using elements from one or more GModel(s). @@ -117,8 +120,6 @@ class PViewDataGModel : public PViewData { std::vector<stepData<double>*> _steps; // the global min/max of the view double _min, _max; - // a set of all "partitions" encountered in the input data - std::set<int> _partitions; // the type of the dataset DataType _type; // cache last element to speed up loops @@ -168,7 +169,7 @@ class PViewDataGModel : public PViewData { bool skipEntity(int step, int ent); bool skipElement(int step, int ent, int ele, bool checkVisibility=false); bool hasTimeStep(int step); - bool hasPartition(int part); + bool hasPartition(int step, int part); bool hasMultipleMeshes(); bool hasModel(GModel *model, int step=-1); bool useGaussPoints(){ return _type == GaussPointData; } diff --git a/Post/PViewDataGModelIO.cpp b/Post/PViewDataGModelIO.cpp index 5315c00013..69ed6c2ca8 100644 --- a/Post/PViewDataGModelIO.cpp +++ b/Post/PViewDataGModelIO.cpp @@ -39,7 +39,7 @@ bool PViewDataGModel::addData(GModel *model, std::map<int, std::vector<double> > for(int j = 0; j < numComp; j++) d[j] = it->second[j]; } - _partitions.insert(partition); + _steps[step]->getPartitions().insert(partition); finalize(); return true; } @@ -49,7 +49,7 @@ bool PViewDataGModel::readMSH(std::string fileName, int fileIndex, FILE *fp, int partition, int numComp, int numEnt) { Msg::Info("Reading step %d (time %g) partition %d: %d records", - step, time, partition, numEnt); + step, time, partition, numEnt); while(step >= (int)_steps.size()) _steps.push_back(new stepData<double>(GModel::current(), numComp)); @@ -100,7 +100,7 @@ bool PViewDataGModel::readMSH(std::string fileName, int fileIndex, FILE *fp, Msg::ProgressMeter(i + 1, numEnt, "Reading data"); } - _partitions.insert(partition); + _steps[step]->getPartitions().insert(partition); finalize(); return true; -- GitLab