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

move writeTXT into generic IO

parent 99fd4e7a
Branches
Tags
No related merge requests found
......@@ -85,7 +85,7 @@ class PViewData {
// Returns the comp-th component (at the step-th time step)
// associated with the node-th node from the ele-th element in the
// ent-th entity
virtual void getValue(int ent, int ele, int node, int comp, int step, double &val) = 0;
virtual void getValue(int ent, int ele, int nod, int comp, int step, double &val) = 0;
// Returns the number of edges of the ele-th element in the ent-th
// entity
virtual int getNumEdges(int ent, int ele) = 0;
......@@ -105,9 +105,9 @@ class PViewData {
// I/O routines
virtual bool writeSTL(std::string name);
virtual bool writeTXT(std::string name);
virtual bool writePOS(std::string name, bool binary=false, bool parsed=true,
bool append=false){ return false; }
virtual bool writeTXT(std::string name){ return false; }
virtual bool writeMSH(std::string name){ return false; }
};
......
// $Id: PViewDataIO.cpp,v 1.1 2008-02-24 19:59:03 geuzaine Exp $
// $Id: PViewDataIO.cpp,v 1.2 2008-02-24 21:37:46 geuzaine Exp $
//
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
//
......@@ -82,3 +82,34 @@ bool PViewData::writeSTL(std::string name)
fclose(fp);
return true;
}
bool PViewDataList::writeTXT(std::string name)
{
FILE *fp = fopen(name.c_str(), "w");
if(!fp){
Msg(GERROR, "Unable to open file '%s'", name.c_str());
return false;
}
for(int ent = 0; ent < getNumEntities(); ent++){
for(int ele = 0; ele < getNumElements(ent); ele++){
for(int nod = 0; nod < getNumNodes(ent, ele); nod++){
double x, y, z;
getNode(ent, ele, nod, x, y, z);
fprintf(file, "%.16g %.16g %.16g ", x, y, z);
for(int step = 0; step < getNumTimeSteps(); step++){
for(int comp = 0; comp < getNumComponents(ent, ele); comp++){
double val;
getValue(ent, ele, nod, comp, step, val);
fprintf(file, "%.16g ", val);
}
}
}
fprintf(file, "\n");
}
fprintf(file, "\n");
}
fclose(fp);
return true;
}
......@@ -118,7 +118,6 @@ class PViewDataList : public PViewData {
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 writeTXT(std::string name);
bool writeMSH(std::string name);
};
......
// $Id: PViewDataListIO.cpp,v 1.10 2008-02-24 19:59:03 geuzaine Exp $
// $Id: PViewDataListIO.cpp,v 1.11 2008-02-24 21:37:46 geuzaine Exp $
//
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
//
......@@ -396,57 +396,6 @@ bool PViewDataList::writePOS(std::string name, bool binary, bool parsed, bool ap
return true;
}
static void writeElementTXT(FILE *file, int nbelm, List_T *list,
int nbnod, int nbcomp, int nbtime)
{
if(!nbelm) return;
int nb = List_Nbr(list) / nbelm;
for(int i = 0; i < List_Nbr(list); i += nb){
double *x = (double*)List_Pointer(list, i);
for(int j = 0; j < nbnod * (3 + nbcomp * nbtime); j++)
fprintf(file, "%.16g ", x[j]);
fprintf(file, "\n");
}
fprintf(file, "\n");
}
bool PViewDataList::writeTXT(std::string name)
{
FILE *fp = fopen(name.c_str(), "w");
if(!fp){
Msg(GERROR, "Unable to open file '%s'", name.c_str());
return false;
}
writeElementTXT(fp, NbSP, SP, 1, 1, NbTimeStep);
writeElementTXT(fp, NbVP, VP, 1, 3, NbTimeStep);
writeElementTXT(fp, NbTP, TP, 1, 9, NbTimeStep);
writeElementTXT(fp, NbSL, SL, 2, 1, NbTimeStep);
writeElementTXT(fp, NbVL, VL, 2, 3, NbTimeStep);
writeElementTXT(fp, NbTL, TL, 2, 9, NbTimeStep);
writeElementTXT(fp, NbST, ST, 3, 1, NbTimeStep);
writeElementTXT(fp, NbVT, VT, 3, 3, NbTimeStep);
writeElementTXT(fp, NbTT, TT, 3, 9, NbTimeStep);
writeElementTXT(fp, NbSQ, SQ, 4, 1, NbTimeStep);
writeElementTXT(fp, NbVQ, VQ, 4, 3, NbTimeStep);
writeElementTXT(fp, NbTQ, TQ, 4, 9, NbTimeStep);
writeElementTXT(fp, NbSS, SS, 4, 1, NbTimeStep);
writeElementTXT(fp, NbVS, VS, 4, 3, NbTimeStep);
writeElementTXT(fp, NbTS, TS, 4, 9, NbTimeStep);
writeElementTXT(fp, NbSH, SH, 8, 1, NbTimeStep);
writeElementTXT(fp, NbVH, VH, 8, 3, NbTimeStep);
writeElementTXT(fp, NbTH, TH, 8, 9, NbTimeStep);
writeElementTXT(fp, NbSI, SI, 6, 1, NbTimeStep);
writeElementTXT(fp, NbVI, VI, 6, 3, NbTimeStep);
writeElementTXT(fp, NbTI, TI, 6, 9, NbTimeStep);
writeElementTXT(fp, NbSY, SY, 5, 1, NbTimeStep);
writeElementTXT(fp, NbVY, VY, 5, 3, NbTimeStep);
writeElementTXT(fp, NbTY, TY, 5, 9, NbTimeStep);
fclose(fp);
return true;
}
class pVertex{
public:
int Num;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment