Skip to content
Snippets Groups Projects
Commit 18d58b61 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

const

parent 3598f86b
No related branches found
No related tags found
No related merge requests found
......@@ -96,7 +96,7 @@ PView::PView(const std::string &xname, const std::string &yname,
_options->axesLabel[0] = xname;
}
PView::PView(std::string name, std::string type,
PView::PView(const std::string &name, const std::string &type,
GModel *model, std::map<int, std::vector<double> > &data,
double time, int numComp)
{
......@@ -276,7 +276,7 @@ void PView::combine(bool time, int how, bool remove)
delete *it;
}
PView *PView::getViewByName(std::string name, int timeStep, int partition)
PView *PView::getViewByName(const std::string &name, int timeStep, int partition)
{
// search views from most recently to least recently added
for(int i = list.size() - 1; i >= 0; i--){
......@@ -288,6 +288,13 @@ PView *PView::getViewByName(std::string name, int timeStep, int partition)
return 0;
}
int PView::getViewIndexByName(const std::string &name, int timeStep, int partition)
{
PView *view = getViewByName(name, timeStep, partition);
if(view) return view->getIndex();
return -1;
}
PView *PView::getViewByNum(int num, int timeStep, int partition)
{
for(unsigned int i = 0; i < list.size(); i++){
......
......@@ -51,7 +51,7 @@ class PView{
PView(const std::string &xname, const std::string &yname,
std::vector<double> &x, std::vector<double> &y);
// construct a new mesh-based view from a bunch of data
PView(std::string name, std::string type, GModel *model,
PView(const std::string &name, const std::string &type, GModel *model,
std::map<int, std::vector<double> > &data, double time=0.,
int numComp = -1);
// add a new time step to a given mesh-based view
......@@ -99,18 +99,20 @@ class PView{
// find view by name or by number (if timeStep >= 0, return view
// only if it does *not* contain that timestep; if partition >= 0,
// return view only if it does *not* contain that partition)
static PView *getViewByName(std::string name, int timeStep=-1,
static PView *getViewByName(const std::string &name, int timeStep=-1,
int partition=-1);
static int getViewIndexByName(const std::string &name, int timeStep=-1,
int partition=-1);
static PView *getViewByNum(int num, int timeStep=-1, int partition=-1);
// IO read routines (these are global: they can create multiple
// views)
static bool readPOS(std::string fileName, int fileIndex=-1);
static bool readMSH(std::string fileName, int fileIndex=-1);
static bool readMED(std::string fileName, int fileIndex=-1);
static bool readPOS(const std::string &fileName, int fileIndex=-1);
static bool readMSH(const std::string &fileName, int fileIndex=-1);
static bool readMED(const std::string &fileName, int fileIndex=-1);
// IO write routine
bool write(std::string fileName, int format, bool append=false);
bool write(const std::string &fileName, int format, bool append=false);
// vertex arrays to draw the elements efficiently
VertexArray *va_points, *va_lines, *va_triangles, *va_vectors, *va_ellipses;
......
......@@ -59,11 +59,11 @@ class PViewData {
// get/set name
virtual std::string getName(){ return _name; }
virtual void setName(std::string val){ _name = val; }
virtual void setName(const std::string &val){ _name = val; }
// get/set (the main) filename containing the data
virtual std::string getFileName(int step=-1){ return _fileName; }
virtual void setFileName(std::string val){ _fileName = val; }
virtual void setFileName(const std::string &val){ _fileName = val; }
// get/set index of view data in file
virtual int getFileIndex(){ return _fileIndex; }
......@@ -252,12 +252,12 @@ class PViewData {
int step=-1, double *size=0);
// I/O routines
virtual bool writeSTL(std::string fileName);
virtual bool writeTXT(std::string fileName);
virtual bool writePOS(std::string fileName, bool binary=false, bool parsed=true,
virtual bool writeSTL(const std::string &fileName);
virtual bool writeTXT(const std::string &fileName);
virtual bool writePOS(const std::string &fileName, bool binary=false, bool parsed=true,
bool append=false);
virtual bool writeMSH(std::string fileName, bool binary=false, bool savemesh=true);
virtual bool writeMED(std::string fileName);
virtual bool writeMSH(const std::string &fileName, bool binary=false, bool savemesh=true);
virtual bool writeMED(const std::string &fileName);
virtual bool toVector(std::vector<std::vector<double> > &vec);
virtual bool fromVector(const std::vector<std::vector<double> > &vec);
};
......
......@@ -46,7 +46,7 @@ class stepData{
// 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,
stepData(GModel *model, int numComp, const std::string &fileName="", int fileIndex=-1,
double time=0., double min=VAL_INF, double max=-VAL_INF)
: _model(model), _fileName(fileName), _fileIndex(fileIndex), _time(time),
_min(min), _max(max), _numComp(numComp), _data(0)
......@@ -93,7 +93,7 @@ class stepData{
return _mult[index];
}
std::string getFileName(){ return _fileName; }
void setFileName(std::string name){ _fileName = name; }
void setFileName(const std::string &name){ _fileName = name; }
int getFileIndex(){ return _fileIndex; }
void setFileIndex(int index){ _fileIndex = index; }
double getTime(){ return _time; }
......@@ -235,12 +235,12 @@ class PViewDataGModel : public PViewData {
int step, double time, int partition, int numComp);
// I/O routines
bool readMSH(std::string fileName, int fileIndex, FILE *fp, bool binary,
bool readMSH(const std::string &fileName, int fileIndex, FILE *fp, bool binary,
bool swap, int step, double time, int partition,
int numComp, int numNodes, const std::string &interpolationScheme);
bool writeMSH(std::string fileName, bool binary=false, bool savemesh=true);
bool readMED(std::string fileName, int fileIndex);
bool writeMED(std::string fileName);
bool writeMSH(const std::string &fileName, bool binary=false, bool savemesh=true);
bool readMED(const std::string &fileName, int fileIndex);
bool writeMED(const std::string &fileName);
};
#endif
......@@ -45,7 +45,7 @@ bool PViewDataGModel::addData(GModel *model, std::map<int, std::vector<double> >
return true;
}
bool PViewDataGModel::readMSH(std::string fileName, int fileIndex, FILE *fp,
bool PViewDataGModel::readMSH(const std::string &fileName, int fileIndex, FILE *fp,
bool binary, bool swap, int step, double time,
int partition, int numComp, int numEnt,
const std::string &interpolationScheme)
......@@ -127,7 +127,7 @@ bool PViewDataGModel::readMSH(std::string fileName, int fileIndex, FILE *fp,
return true;
}
bool PViewDataGModel::writeMSH(std::string fileName, bool binary, bool savemesh)
bool PViewDataGModel::writeMSH(const std::string &fileName, bool binary, bool savemesh)
{
if(_steps.empty()) return true;
......@@ -301,7 +301,7 @@ extern "C" {
extern int med2mshElementType(med_geometrie_element med);
extern int med2mshNodeIndex(med_geometrie_element med, int k);
bool PViewDataGModel::readMED(std::string fileName, int fileIndex)
bool PViewDataGModel::readMED(const std::string &fileName, int fileIndex)
{
med_idt fid = MEDouvrir((char*)fileName.c_str(), MED_LECTURE);
if(fid < 0){
......@@ -610,7 +610,7 @@ bool PViewDataGModel::readMED(std::string fileName, int fileIndex)
return true;
}
bool PViewDataGModel::writeMED(std::string fileName)
bool PViewDataGModel::writeMED(const std::string &fileName)
{
if(_steps.empty()) return true;
......@@ -731,14 +731,14 @@ bool PViewDataGModel::writeMED(std::string fileName)
#else
bool PViewDataGModel::readMED(std::string fileName, int fileIndex)
bool PViewDataGModel::readMED(const std::string &fileName, int fileIndex)
{
Msg::Error("Gmsh must be compiled with MED support to read '%s'",
fileName.c_str());
return false;
}
bool PViewDataGModel::writeMED(std::string fileName)
bool PViewDataGModel::writeMED(const std::string &fileName)
{
Msg::Error("Gmsh must be compiled with MED support to write '%s'",
fileName.c_str());
......
......@@ -11,7 +11,7 @@
#include "PViewData.h"
#include "adaptiveData.h"
bool PViewData::writeSTL(std::string fileName)
bool PViewData::writeSTL(const std::string &fileName)
{
FILE *fp = fopen(fileName.c_str(), "w");
if(!fp){
......@@ -70,7 +70,7 @@ bool PViewData::writeSTL(std::string fileName)
return true;
}
bool PViewData::writeTXT(std::string fileName)
bool PViewData::writeTXT(const std::string &fileName)
{
FILE *fp = fopen(fileName.c_str(), "w");
if(!fp){
......@@ -102,7 +102,8 @@ bool PViewData::writeTXT(std::string fileName)
return true;
}
bool PViewData::writePOS(std::string fileName, bool binary, bool parsed, bool append)
bool PViewData::writePOS(const std::string &fileName, bool binary, bool parsed,
bool append)
{
if(_adaptive){
Msg::Warning("Writing adapted dataset (will only export current time step)");
......@@ -175,13 +176,13 @@ bool PViewData::writePOS(std::string fileName, bool binary, bool parsed, bool ap
return true;
}
bool PViewData::writeMSH(std::string fileName, bool binary, bool savemesh)
bool PViewData::writeMSH(const std::string &fileName, bool binary, bool savemesh)
{
Msg::Error("MSH export not implemented for this view type");
return false;
}
bool PViewData::writeMED(std::string fileName)
bool PViewData::writeMED(const std::string &fileName)
{
Msg::Error("MED export onnly available for mesh-based post-processing views");
return false;
......
......@@ -123,9 +123,9 @@ class PViewDataList : public PViewData {
// I/O routines
bool readPOS(FILE *fp, double version, bool binary);
bool writePOS(std::string fileName, bool binary=false, bool parsed=true,
bool writePOS(const std::string &fileName, bool binary=false, bool parsed=true,
bool append=false);
virtual bool writeMSH(std::string fileName, bool binary=false, bool savemesh=true);
virtual bool writeMSH(const std::string &fileName, bool binary=false, bool savemesh=true);
};
#endif
......@@ -341,7 +341,8 @@ static void writeTextPOS(FILE *fp, int nbc, int nb, std::vector<double> &TD,
}
}
bool PViewDataList::writePOS(std::string fileName, bool binary, bool parsed, bool append)
bool PViewDataList::writePOS(const std::string &fileName, bool binary, bool parsed,
bool append)
{
if(_adaptive){
Msg::Warning("Writing adapted dataset (will only export current time step)");
......@@ -524,7 +525,7 @@ static void createElements(std::vector<double> &list, int nbelm, int nbnod,
}
}
bool PViewDataList::writeMSH(std::string fileName, bool binary, bool savemesh)
bool PViewDataList::writeMSH(const std::string &fileName, bool binary, bool savemesh)
{
if(_adaptive){
Msg::Warning("Writing adapted dataset (will only export current time step)");
......
......@@ -11,7 +11,7 @@
#include "StringUtils.h"
#include "Context.h"
bool PView::readPOS(std::string fileName, int fileIndex)
bool PView::readPOS(const std::string &fileName, int fileIndex)
{
FILE *fp = fopen(fileName.c_str(), "rb");
if(!fp){
......@@ -81,7 +81,7 @@ bool PView::readPOS(std::string fileName, int fileIndex)
return true;
}
bool PView::readMSH(std::string fileName, int fileIndex)
bool PView::readMSH(const std::string &fileName, int fileIndex)
{
FILE *fp = fopen(fileName.c_str(), "rb");
if(!fp){
......@@ -241,7 +241,7 @@ extern "C" {
#include <med.h>
}
bool PView::readMED(std::string fileName, int fileIndex)
bool PView::readMED(const std::string &fileName, int fileIndex)
{
#if (MED_MAJOR_NUM == 3)
med_idt fid = MEDfileOpen(fileName.c_str(), MED_ACC_RDONLY);
......@@ -289,7 +289,7 @@ bool PView::readMED(std::string fileName, int fileIndex)
#else
bool PView::readMED(std::string fileName, int fileIndex)
bool PView::readMED(const std::string &fileName, int fileIndex)
{
Msg::Error("Gmsh must be compiled with MED support to read '%s'",
fileName.c_str());
......@@ -298,7 +298,7 @@ bool PView::readMED(std::string fileName, int fileIndex)
#endif
bool PView::write(std::string fileName, int format, bool append)
bool PView::write(const std::string &fileName, int format, bool append)
{
Msg::StatusBar(2, true, "Writing '%s'...", fileName.c_str());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment