From 299a9c8ab40057f9e218103d699817712de03e37 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Mon, 18 Feb 2008 18:32:54 +0000 Subject: [PATCH] more work for PViewDataGModel --- Geo/MVertex.h | 6 +----- Post/PView.cpp | 36 +++++++++++++++++++++++++++++------- Post/PViewDataGModel.cpp | 8 +++++++- Post/PViewDataGModel.h | 1 + Post/PViewDataList.h | 2 +- Post/PViewDataListIO.cpp | 4 ++-- 6 files changed, 41 insertions(+), 16 deletions(-) diff --git a/Geo/MVertex.h b/Geo/MVertex.h index b3b1cabf25..0929985797 100644 --- a/Geo/MVertex.h +++ b/Geo/MVertex.h @@ -42,11 +42,10 @@ class MVertex{ char _visible, _order; double _x, _y, _z; GEntity *_ge; - //void *_data; public : MVertex(double x, double y, double z, GEntity *ge=0, int num=0) - : _visible(true), _order(1), _x(x), _y(y), _z(z), _ge(ge) //, _data(0) + : _visible(true), _order(1), _x(x), _y(y), _z(z), _ge(ge) { if(num){ _num = num; @@ -103,9 +102,6 @@ class MVertex{ std::set<MVertex*, MVertexLessThanLexicographic>::iterator linearSearch(std::set<MVertex*, MVertexLessThanLexicographic> &pos); - // Get the data associated with this vertex - virtual void *getData(){ return 0 /* _data*/ ; } - // IO routines void writeMSH(FILE *fp, bool binary=false, double scalingFactor=1.0); void writeMSH(FILE *fp, double version, bool binary, int num, diff --git a/Post/PView.cpp b/Post/PView.cpp index 7d532fb60f..1f984158be 100644 --- a/Post/PView.cpp +++ b/Post/PView.cpp @@ -1,4 +1,4 @@ -// $Id: PView.cpp,v 1.15 2008-02-17 08:48:08 geuzaine Exp $ +// $Id: PView.cpp,v 1.16 2008-02-18 18:32:54 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -26,6 +26,7 @@ #include <algorithm> #include "PView.h" #include "PViewDataList.h" +#include "PViewDataGModel.h" #include "VertexArray.h" #include "SmoothData.h" #include "Message.h" @@ -262,16 +263,16 @@ bool PView::readPOS(std::string filename, int fileIndex) index++; if(fileIndex < 0 || fileIndex == index){ - PView *p = new PView(false); - PViewDataList *d = dynamic_cast<PViewDataList*>(p->getData()); - if(!d || !d->read(fp, version, format, size)){ + PViewDataList *d = new PViewDataList(false); + if(!d->readPOS(fp, version, format, size)){ Msg(GERROR, "Could not read data in list format"); - delete p; + delete d; return false; } else{ d->setFileName(filename); d->setFileIndex(index); + new PView(d); } } @@ -293,8 +294,29 @@ bool PView::readPOS(std::string filename, int fileIndex) bool PView::readMSH(std::string filename, int fileIndex) { - Msg(INFO, "Reading post-pro data from msh file"); - return false; + FILE *fp = fopen(filename.c_str(), "rb"); + if(!fp){ + Msg(GERROR, "Unable to open file '%s'", filename.c_str()); + return false; + } + + Msg(INFO, "Reading post-processing data from MSH file..."); + + // FIXME: to be implemented! + int index = 0; + PViewDataGModel *d = new PViewDataGModel(); + if(!d->readMSH(fp)){ + Msg(GERROR, "Could not read data in msh file"); + delete d; + return false; + } + else{ + d->setFileName(filename); + d->setFileIndex(index); + new PView(d); + } + + return true; } bool PView::write(std::string filename, int format, bool append) diff --git a/Post/PViewDataGModel.cpp b/Post/PViewDataGModel.cpp index 983864ee5f..b26b69fef6 100644 --- a/Post/PViewDataGModel.cpp +++ b/Post/PViewDataGModel.cpp @@ -1,4 +1,4 @@ -// $Id: PViewDataGModel.cpp,v 1.9 2008-02-17 08:48:08 geuzaine Exp $ +// $Id: PViewDataGModel.cpp,v 1.10 2008-02-18 18:32:54 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -24,6 +24,12 @@ #include "PViewDataGModel.h" +bool PViewDataGModel::readMSH(FILE *fp) +{ + Msg(INFO, "Filling PViewDataGModel..."); + return false; +} + bool PViewDataGModel::writePOS(std::string name, bool binary, bool parsed, bool append) { diff --git a/Post/PViewDataGModel.h b/Post/PViewDataGModel.h index 45a06b44de..90f3ca3ba4 100644 --- a/Post/PViewDataGModel.h +++ b/Post/PViewDataGModel.h @@ -46,6 +46,7 @@ class PViewDataGModel : public PViewData { int getNumEdges(int ele){ return 0; } // I/O routines + bool readMSH(FILE *fp); bool writePOS(std::string name, bool binary=false, bool parsed=true, bool append=false); bool writeSTL(std::string name); diff --git a/Post/PViewDataList.h b/Post/PViewDataList.h index 6c38499390..8675548a6d 100644 --- a/Post/PViewDataList.h +++ b/Post/PViewDataList.h @@ -106,7 +106,7 @@ class PViewDataList : public PViewData { void getRawData(int type, List_T **l, int **ne, int *nc, int *nn); // I/O routines - bool read(FILE *fp, double version, int format, int size); + bool readPOS(FILE *fp, double version, int format, int size); bool writePOS(std::string name, bool binary=false, bool parsed=true, bool append=false); bool writeSTL(std::string name); diff --git a/Post/PViewDataListIO.cpp b/Post/PViewDataListIO.cpp index 1137127057..865328dfb7 100644 --- a/Post/PViewDataListIO.cpp +++ b/Post/PViewDataListIO.cpp @@ -1,4 +1,4 @@ -// $Id: PViewDataListIO.cpp,v 1.7 2008-02-17 08:48:08 geuzaine Exp $ +// $Id: PViewDataListIO.cpp,v 1.8 2008-02-18 18:32:54 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -31,7 +31,7 @@ extern Context_T CTX; -bool PViewDataList::read(FILE *fp, double version, int format, int size) +bool PViewDataList::readPOS(FILE *fp, double version, int format, int size) { char name[256]; int t2l, t3l; -- GitLab