diff --git a/Fltk/graphicWindow.cpp b/Fltk/graphicWindow.cpp index ddb1bc108ed9e390c792941e11e46d635182e3b9..5406800492121c05522aea2888beb0a139e8efc6 100644 --- a/Fltk/graphicWindow.cpp +++ b/Fltk/graphicWindow.cpp @@ -378,15 +378,7 @@ static void status_rewind_cb(Fl_Widget *w, void *data) { if(!CTX::instance()->post.animCycle) { for(unsigned int i = 0; i < PView::list.size(); i++) { - // skip empty steps - int numSteps = (int)opt_view_nb_timestep(i, GMSH_GET, 0); - int step = 0; - while(step < numSteps){ - if(PView::list[i]->getData()->hasTimeStep(step)) - break; - else - step++; - } + int step = PView::list[i]->getData()->getFirstNonEmptyTimeStep(); opt_view_timestep(i, GMSH_SET | GMSH_GUI, step); } } diff --git a/Geo/MElementOctree.cpp b/Geo/MElementOctree.cpp index 391437909a424b1c7c831de11a1002865b7f00d2..6b496d961cc9cec1ca0b0dccd1c0d57f44e794a5 100644 --- a/Geo/MElementOctree.cpp +++ b/Geo/MElementOctree.cpp @@ -83,7 +83,7 @@ MElementOctree::MElementOctree(std::vector<MElement*> &v) : _gm(0) SBoundingBox3d bb; for (unsigned int i = 0; i < v.size(); i++){ for(int j = 0; j < v[i]->getNumVertices(); j++){ - // if (!_gm) _gm = v[i]->getVertex(j)->onWhat()->model(); + if (!_gm) _gm = v[i]->getVertex(j)->onWhat()->model(); bb += SPoint3(v[i]->getVertex(j)->x(), v[i]->getVertex(j)->y(), v[i]->getVertex(j)->z()); diff --git a/Mesh/HighOrder.cpp b/Mesh/HighOrder.cpp index 8372d0cd8c3558b44bff747f6e4abde742cd309d..aaa02290e3f338529e610513fa639ca980f91a36 100644 --- a/Mesh/HighOrder.cpp +++ b/Mesh/HighOrder.cpp @@ -1237,7 +1237,7 @@ void SetOrderN(GModel *m, int order, bool linear, bool incomplete) // printJacobians(m, "smoothness.pos"); // m->writeMSH("SMOOTHED.msh"); - if (0 && !linear){ + if (!linear){ hot.ensureMinimumDistorsion(0.1); checkHighOrderTriangles("Final mesh", m, bad, worst); checkHighOrderTetrahedron("Final mesh", m, bad, worst); diff --git a/Mesh/meshGFaceDelaunayInsertion.cpp b/Mesh/meshGFaceDelaunayInsertion.cpp index 8f2cc8b99af0804b07a9eca482f5325cc7179e0d..85b2f1b6fba7963950541cef620842d749194974 100644 --- a/Mesh/meshGFaceDelaunayInsertion.cpp +++ b/Mesh/meshGFaceDelaunayInsertion.cpp @@ -635,21 +635,6 @@ void _printTris(char *name, std::set<MTri3*, compareTri3Ptr> &AllTris, fclose (ff); } -static MTri3* search4Triangle (MTri3 *t, double pt[2], - std::vector<double> &Us, std::vector<double> &Vs, - std::set<MTri3*,compareTri3Ptr> &AllTris) { - - double uv[2]; - bool inside = invMapUV(t->tri(), pt, Us, Vs, uv, 1.e-8); - if (inside) return starting_point; - while (1){ - for (int i=0;i<3;i++){ - MTri3 *tn = t->getNeigh(0); - - } - } -} - static bool insertAPoint(GFace *gf, std::set<MTri3*,compareTri3Ptr>::iterator it, double center[2], double metric[3], std::vector<double> &Us, std::vector<double> &Vs, diff --git a/Plugin/Levelset.cpp b/Plugin/Levelset.cpp index 75097b880eccd4dfdc43551913d74b46e79c511b..079750ded8e4df1d0425dbc798e7888d7555b0ee 100644 --- a/Plugin/Levelset.cpp +++ b/Plugin/Levelset.cpp @@ -440,13 +440,7 @@ PView *GMSH_LevelsetPlugin::execute(PView *v) if(_valueIndependent) { // create a single output view containing the (possibly // multi-step) levelset - int firstNonEmptyStep = 0; - for(int step = 0; step < vdata->getNumTimeSteps(); step++){ - if(vdata->hasTimeStep(step)){ - firstNonEmptyStep = step; - break; - } - } + int firstNonEmptyStep = vdata->getFirstNonEmptyTimeStep(); PViewDataList *out = getDataList(new PView()); for(int ent = 0; ent < vdata->getNumEntities(firstNonEmptyStep); ent++){ for(int ele = 0; ele < vdata->getNumElements(firstNonEmptyStep, ent); ele++){ diff --git a/Plugin/MathEval.cpp b/Plugin/MathEval.cpp index 8b1569f2f30c2f69806622b5ddf49e3cfc70062f..cae488ed07fd71e668db37fb3f90ff61c8977808 100644 --- a/Plugin/MathEval.cpp +++ b/Plugin/MathEval.cpp @@ -173,14 +173,7 @@ PView *GMSH_MathEvalPlugin::execute(PView *view) timeStep = - data1->getNumTimeSteps(); } - int firstNonEmptyStep = 0; - for(int step = 0; step < data1->getNumTimeSteps(); step++){ - if(data1->hasTimeStep(step)){ - firstNonEmptyStep = step; - break; - } - } - + int firstNonEmptyStep = data1->getFirstNonEmptyTimeStep(); int timeBeg = (timeStep < 0) ? firstNonEmptyStep : timeStep; int timeEnd = (timeStep < 0) ? -timeStep : timeStep + 1; for(int ent = 0; ent < data1->getNumEntities(timeBeg); ent++){ diff --git a/Plugin/Skin.cpp b/Plugin/Skin.cpp index dfff3a0cc07c48dd01c3e0c1b46d952c3abb58ee..f4d7aedbea9809e712d8d88f5b32bc971f175905 100644 --- a/Plugin/Skin.cpp +++ b/Plugin/Skin.cpp @@ -156,14 +156,7 @@ PView *GMSH_SkinPlugin::execute(PView *v) std::set<ElmData, ElmDataLessThan> skin; ElmDataLessThan::tolerance = CTX::instance()->lc * 1.e-12; - int firstNonEmptyStep = 0; - for(int step = 0; step < data1->getNumTimeSteps(); step++){ - if(data1->hasTimeStep(step)){ - firstNonEmptyStep = step; - break; - } - } - + int firstNonEmptyStep = data1->getFirstNonEmptyTimeStep(); for(int ent = 0; ent < data1->getNumEntities(firstNonEmptyStep); ent++){ if(visible && data1->skipEntity(firstNonEmptyStep, ent)) continue; for(int ele = 0; ele < data1->getNumElements(firstNonEmptyStep, ent); ele++){ diff --git a/Post/PViewData.h b/Post/PViewData.h index bbf47d872c3b7908eb24084d14135b69da3f6bcc..17b339a4a95aa4db7b37319ddd9817e897b0abc7 100644 --- a/Post/PViewData.h +++ b/Post/PViewData.h @@ -68,6 +68,7 @@ class PViewData { // get number of time steps in the data virtual int getNumTimeSteps() = 0; + virtual int getFirstNonEmptyTimeStep(){ return 0; } // get the time value associated with the step-th time step virtual double getTime(int step){ return 0.; } diff --git a/Post/PViewDataGModel.cpp b/Post/PViewDataGModel.cpp index 35622352eb1912ef5b03e2c74625a06b93d3791c..9383a174f75ee793659b8c9622afec4e976d3294 100644 --- a/Post/PViewDataGModel.cpp +++ b/Post/PViewDataGModel.cpp @@ -209,6 +209,13 @@ int PViewDataGModel::getNumTimeSteps() return _steps.size(); } +int PViewDataGModel::getFirstNonEmptyTimeStep() +{ + for(unsigned int i = 0; i < _steps.size(); i++) + if(_steps[i]->getNumData()) return i; + return 0; +} + double PViewDataGModel::getTime(int step) { if(_steps.empty()) return 0.; diff --git a/Post/PViewDataGModel.h b/Post/PViewDataGModel.h index 783c7cad6b4f0453e4d54c40123fa8c5f5329146..4731430c8256edb753dda3e2128be47c5c737882 100644 --- a/Post/PViewDataGModel.h +++ b/Post/PViewDataGModel.h @@ -172,6 +172,7 @@ class PViewDataGModel : public PViewData { bool finalize(bool computeMinMax=true, const std::string &interpolationScheme=""); std::string getFileName(int step=-1); int getNumTimeSteps(); + int getFirstNonEmptyTimeStep(); double getTime(int step); double getMin(int step=-1, bool onlyVisible=false); double getMax(int step=-1, bool onlyVisible=false); diff --git a/Post/PViewDataIO.cpp b/Post/PViewDataIO.cpp index 20cc1eba771915a5f0fec76a399f784df56d301a..deef4a0d0caacfd60a6f5aa37fbbe14f0b165aa1 100644 --- a/Post/PViewDataIO.cpp +++ b/Post/PViewDataIO.cpp @@ -6,8 +6,10 @@ #include <stdio.h> #include <string.h> #include "GmshMessage.h" +#include "GmshDefines.h" #include "Numeric.h" #include "PViewData.h" +#include "adaptiveData.h" bool PViewData::writeSTL(std::string fileName) { @@ -22,7 +24,7 @@ bool PViewData::writeSTL(std::string fileName) return false; } - int step = 0; + int step = getFirstNonEmptyTimeStep(); fprintf(fp, "solid Created by Gmsh\n"); for(int ent = 0; ent < getNumEntities(step); ent++){ @@ -102,8 +104,67 @@ bool PViewData::writeTXT(std::string fileName) bool PViewData::writePOS(std::string fileName, bool binary, bool parsed, bool append) { - Msg::Error("POS export not implemented for this view type"); - return false; + if(_adaptive){ + Msg::Warning("Writing adapted dataset (will only export current time step)"); + return _adaptive->getData()->writePOS(fileName, binary, parsed, append); + } + if(hasMultipleMeshes()){ + Msg::Error("Cannot export multi-mesh datasets in .pos format"); + return false; + } + if(haveInterpolationMatrices()) + Msg::Warning("Discarding interpolation matrices when saving in .pos format"); + if(binary || !parsed) + Msg::Warning("Only parsed .pos files can be exported for this view type"); + + FILE *fp = fopen(fileName.c_str(), append ? "a" : "w"); + if(!fp){ + Msg::Error("Unable to open file '%s'", fileName.c_str()); + return false; + } + + fprintf(fp, "View \"%s\" {\n", getName().c_str()); + + int firstNonEmptyStep = getFirstNonEmptyTimeStep(); + for(int ent = 0; ent < getNumEntities(firstNonEmptyStep); ent++){ + for(int ele = 0; ele < getNumElements(firstNonEmptyStep, ent); ele++){ + if(skipElement(firstNonEmptyStep, ent, ele)) continue; + int type = getType(firstNonEmptyStep, ent, ele); + int numComp = getNumComponents(firstNonEmptyStep, ent, ele); + const char *s = 0; + switch(type){ + case TYPE_PNT: s = (numComp == 9) ? "TP" : (numComp == 3) ? "VP" : "SP"; break; + case TYPE_LIN: s = (numComp == 9) ? "TL" : (numComp == 3) ? "VL" : "SL"; break; + case TYPE_TRI: s = (numComp == 9) ? "TT" : (numComp == 3) ? "VT" : "ST"; break; + case TYPE_QUA: s = (numComp == 9) ? "TQ" : (numComp == 3) ? "VQ" : "SQ"; break; + case TYPE_TET: s = (numComp == 9) ? "TS" : (numComp == 3) ? "VS" : "SS"; break; + case TYPE_HEX: s = (numComp == 9) ? "TH" : (numComp == 3) ? "VH" : "SH"; break; + case TYPE_PRI: s = (numComp == 9) ? "TI" : (numComp == 3) ? "VI" : "SI"; break; + case TYPE_PYR: s = (numComp == 9) ? "TY" : (numComp == 3) ? "VY" : "SY"; break; + } + if(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 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); + } + } + } + } + } + } + } + + fprintf(fp, "};\n"); + + return true; } bool PViewData::writeMSH(std::string fileName, bool binary, bool savemesh)