diff --git a/Post/PViewData.h b/Post/PViewData.h index 94b8284aa57c2dd9b4f3286a37d4b115ab4a3d1a..751b7ac473c388cffcd226a66b86ea0b1480560e 100644 --- a/Post/PViewData.h +++ b/Post/PViewData.h @@ -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; } }; diff --git a/Post/PViewDataIO.cpp b/Post/PViewDataIO.cpp index 5866a046d46382e73f1e19a456f287244f3ef047..7a410336e4cf025d3c8aef674e64b77ddbaf7f8e 100644 --- a/Post/PViewDataIO.cpp +++ b/Post/PViewDataIO.cpp @@ -1,4 +1,4 @@ -// $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; +} diff --git a/Post/PViewDataList.h b/Post/PViewDataList.h index ad1c766de12b11a123ef85a080eeb2fd6118229a..191b1a95c1aaba8e57b5fc09aa4dc9b461197cc4 100644 --- a/Post/PViewDataList.h +++ b/Post/PViewDataList.h @@ -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); }; diff --git a/Post/PViewDataListIO.cpp b/Post/PViewDataListIO.cpp index b86d1cfabc0de65bd4b221ef183bb1636899e3c7..1f457e32aee6003ccfeb3574fa358baecb5c2e17 100644 --- a/Post/PViewDataListIO.cpp +++ b/Post/PViewDataListIO.cpp @@ -1,4 +1,4 @@ -// $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;