From 2fd706f5d50b3854f365e89e0a29cf9781d19e7e Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 27 May 2011 11:37:32 +0000 Subject: [PATCH] basic .pos exporter (works for all formats) --- Post/PViewDataIO.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Post/PViewDataIO.cpp b/Post/PViewDataIO.cpp index deef4a0d0c..83d53cc967 100644 --- a/Post/PViewDataIO.cpp +++ b/Post/PViewDataIO.cpp @@ -143,21 +143,28 @@ bool PViewData::writePOS(std::string fileName, bool binary, bool parsed, bool ap case TYPE_PYR: s = (numComp == 9) ? "TY" : (numComp == 3) ? "VY" : "SY"; break; } if(s){ + fprintf(fp, "%s(", s); int numNod = getNumNodes(firstNonEmptyStep, ent, ele); - std::vector<double> x(numNod), y(numNod), z(numNod); - for(int nod = 0; nod < numNod; nod++) - getNode(firstNonEmptyStep, ent, ele, nod, x[nod], y[nod], z[nod]); + for(int nod = 0; nod < numNod; nod++){ + double x, y, z; + getNode(firstNonEmptyStep, ent, ele, nod, x, y, z); + fprintf(fp, "%.16g,%.16g,%.16g", x, y, z); + if(nod != numNod - 1) fprintf(fp, ","); + } + bool first = true; for(int step = 0; step < getNumTimeSteps(); step++){ if(hasTimeStep(step)){ for(int nod = 0; nod < numNod; nod++){ for(int comp = 0; comp < numComp; comp++){ double val; getValue(step, ent, ele, nod, comp, val); - printf("val = %g\n", val); + if(first){ fprintf(fp, "){%.16g", val); first = false; } + else fprintf(fp, ",%.16g", val); } } } } + fprintf(fp, "};\n"); } } } -- GitLab