From 34d3013bdd3f0618bbaf56df994329a91d85960b Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 6 Dec 2012 19:35:03 +0000 Subject: [PATCH] import() raw data into PViewDataList --- Post/PViewDataList.cpp | 16 ++++++++++++++-- Post/PViewDataList.h | 5 +++-- Post/PViewDataListIO.cpp | 7 ++++--- Post/PViewIO.cpp | 6 ++++-- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Post/PViewDataList.cpp b/Post/PViewDataList.cpp index 335edf3da5..12ad9664de 100644 --- a/Post/PViewDataList.cpp +++ b/Post/PViewDataList.cpp @@ -825,7 +825,7 @@ bool PViewDataList::combineTime(nameData &nd) } int PViewDataList::_getRawData(int idxtype, std::vector<double> **l, int **ne, - int *nc, int *nn) + int *nc, int *nn) { int type = 0; // No constant nn for polygons! @@ -883,7 +883,7 @@ void PViewDataList::setOrder2(int type) case TYPE_TET: typeMSH = MSH_TET_10; break; case TYPE_HEX: typeMSH = MSH_HEX_27; break; case TYPE_PRI: typeMSH = MSH_PRI_18; break; -// case TYPE_PYR: typeMSH = MSH_PYR_14; break; + // case TYPE_PYR: typeMSH = MSH_PYR_14; break; } const polynomialBasis *fs = (polynomialBasis*)BasisFactory::create(typeMSH); if(!fs){ @@ -959,3 +959,15 @@ std::vector<double> *PViewDataList::incrementList(int numComp, int type, int num } return 0; } + +void PViewDataList::import(int N[24], std::vector<double> *V[24]) +{ + for(int i = 0; i < 24; i++){ + std::vector<double> *list = 0; + int *nbe = 0, nbc, nbn; + _getRawData(i, &list, &nbe, &nbc, &nbn); + *nbe = N[i]; + *list = *V[i]; + } + finalize(); +} diff --git a/Post/PViewDataList.h b/Post/PViewDataList.h index 322593d3bf..4423b131f3 100644 --- a/Post/PViewDataList.h +++ b/Post/PViewDataList.h @@ -120,13 +120,14 @@ class PViewDataList : public PViewData { // specific to list-based data sets void setOrder2(int type); std::vector<double> *incrementList(int numComp, int type, int numNodes = 0); + void import(int N[24], std::vector<double> *V[24]); // I/O routines bool readPOS(FILE *fp, double version, bool binary); bool writePOS(const std::string &fileName, bool binary=false, bool parsed=true, bool append=false); - virtual bool writeMSH(const std::string &fileName, double version=2.2, bool binary=false, bool savemesh=true, - bool multipleView=false); + virtual bool writeMSH(const std::string &fileName, double version=2.2, bool binary=false, + bool savemesh=true, bool multipleView=false); }; #endif diff --git a/Post/PViewDataListIO.cpp b/Post/PViewDataListIO.cpp index a3f3021cb5..be49981d8c 100644 --- a/Post/PViewDataListIO.cpp +++ b/Post/PViewDataListIO.cpp @@ -525,8 +525,8 @@ static void createElements(std::vector<double> &list, int nbelm, int nbnod, } } -bool PViewDataList::writeMSH(const std::string &fileName, double version, bool binary, bool savemesh, - bool multipleView) +bool PViewDataList::writeMSH(const std::string &fileName, double version, bool binary, + bool savemesh, bool multipleView) { if(_adaptive){ Msg::Warning("Writing adapted dataset (will only export current time step)"); @@ -581,7 +581,8 @@ bool PViewDataList::writeMSH(const std::string &fileName, double version, bool b fprintf(fp, "%d\n", (int)elements.size()); for(unsigned int i = 0; i < elements.size(); i++){ if(version > 2.2) - Msg::Warning("PViewDataList: Unable to writeMSH in version '%d'. Version 2.2 selected.", version); + Msg::Warning("Unable to write file in version '%g': using version 2.2", + version); elements[i]->writeMSH2(fp, 2.2, false, i + 1); } fprintf(fp, "$EndElements\n"); diff --git a/Post/PViewIO.cpp b/Post/PViewIO.cpp index 484726b40e..8cb054ab73 100644 --- a/Post/PViewIO.cpp +++ b/Post/PViewIO.cpp @@ -309,7 +309,8 @@ bool PView::write(const std::string &fileName, int format, bool append) case 2: ret = _data->writePOS(fileName, false, true, append); break; // parsed case 3: ret = _data->writeSTL(fileName); break; case 4: ret = _data->writeTXT(fileName); break; - case 5: ret = _data->writeMSH(fileName, CTX::instance()->mesh.mshFileVersion, CTX::instance()->mesh.binary); break; + case 5: ret = _data->writeMSH(fileName, CTX::instance()->mesh.mshFileVersion, + CTX::instance()->mesh.binary); break; case 6: ret = _data->writeMED(fileName); break; case 10: { @@ -319,7 +320,8 @@ bool PView::write(const std::string &fileName, int format, bool append) else if(ext == ".stl") ret = _data->writeSTL(fileName); else if(ext == ".msh") - ret = _data->writeMSH(fileName, CTX::instance()->mesh.mshFileVersion, CTX::instance()->mesh.binary); + ret = _data->writeMSH(fileName, CTX::instance()->mesh.mshFileVersion, + CTX::instance()->mesh.binary); else if(ext == ".med") ret = _data->writeMED(fileName); else -- GitLab