diff --git a/Fltk/fileDialogs.cpp b/Fltk/fileDialogs.cpp index db5b526ba05aadaf2ef95f469d94ba209fd081f1..58ba153981ed60f35358f1d7bf64b39f0ad7a39c 100644 --- a/Fltk/fileDialogs.cpp +++ b/Fltk/fileDialogs.cpp @@ -1179,6 +1179,8 @@ int posFileDialog(const char *name) static Fl_Menu_Item formatmenu[] = { {"Parsed", 0, 0, 0}, {"Mesh-based", 0, 0, 0}, + {"Legacy ASCII", 0, 0, 0}, + {"Legacy Binary", 0, 0, 0}, {0} }; @@ -1210,7 +1212,13 @@ int posFileDialog(const char *name) Fl_Widget* o = Fl::readqueue(); if (!o) break; if (o == dialog->ok) { - int format = (dialog->c[1]->value() == 1) ? 5 : 2; + int format = 2; + switch(dialog->c[1]->value()){ + case 0: format = 2; + case 1: format = 5; + case 2: format = 0; + case 3: format = 1; + } bool canAppend = (format == 2) ? true : false; _saveViews(name, dialog->c[0]->value(), format, canAppend); dialog->window->hide(); diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp index e4c1a524ccafa2b66a97189874f864a675214ac7..d2f64cc6292933daa689de61d78c46801cf469e7 100644 --- a/Fltk/menuWindow.cpp +++ b/Fltk/menuWindow.cpp @@ -416,9 +416,6 @@ static void file_save_as_cb(Fl_Widget *w, void *data) } } -#undef TT -#undef NN - static void file_options_save_cb(Fl_Widget *w, void *data) { std::string str((const char*)data), fileName; @@ -2195,12 +2192,20 @@ static void view_remove_cb(Fl_Widget *w, void *data) drawContext::global()->draw(); } -static void view_save_as(int index, const char *title, int format) +static void view_save_cb(Fl_Widget *w, void *data) { - PView *view = PView::list[index]; - + static const char *formats = + "Gmsh Parsed" TT "*.pos" NN + "Gmsh Mesh-based" TT "*.pos" NN + "Gmsh Legacy ASCII" TT "*.pos" NN + "Gmsh Legacy Binary" TT "*.pos" NN + "MED" TT "*.rmed" NN + "STL Surface" TT "*.stl" NN + "Generic TXT" TT "*.txt" NN; + + PView *view = PView::list[(intptr_t)data]; test: - if(fileChooser(FILE_CHOOSER_CREATE, title, "*", + if(fileChooser(FILE_CHOOSER_CREATE, "Save As", formats, view->getData()->getFileName().c_str())){ std::string name = fileChooserGetName(1); if(CTX::instance()->confirmOverwrite) { @@ -2209,44 +2214,22 @@ static void view_save_as(int index, const char *title, int format) "Cancel", "Replace", 0, name.c_str())) goto test; } + int format = 0; + switch(fileChooserGetFilter()){ + case 0: format = 2; break; + case 1: format = 5; break; + case 2: format = 0; break; + case 3: format = 1; break; + case 4: format = 6; break; + case 5: format = 3; break; + case 6: format = 4; break; + } view->write(name, format); } } -static void view_save_ascii_cb(Fl_Widget *w, void *data) -{ - view_save_as((intptr_t)data, "Save As ASCII View", 0); -} - -static void view_save_binary_cb(Fl_Widget *w, void *data) -{ - view_save_as((intptr_t)data, "Save As Binary View", 1); -} - -static void view_save_parsed_cb(Fl_Widget *w, void *data) -{ - view_save_as((intptr_t)data, "Save As Parsed View", 2); -} - -static void view_save_stl_cb(Fl_Widget *w, void *data) -{ - view_save_as((intptr_t)data, "Save As STL Triangulation", 3); -} - -static void view_save_txt_cb(Fl_Widget *w, void *data) -{ - view_save_as((intptr_t)data, "Save As Raw Text", 4); -} - -static void view_save_msh_cb(Fl_Widget *w, void *data) -{ - view_save_as((intptr_t)data, "Save As Gmsh Mesh", 5); -} - -static void view_save_med_cb(Fl_Widget *w, void *data) -{ - view_save_as((intptr_t)data, "Save As MED file", 6); -} +#undef TT +#undef NN static void view_alias_cb(Fl_Widget *w, void *data) { @@ -2316,9 +2299,8 @@ static void view_all_visible_cb(Fl_Widget *w, void *data) static void view_applybgmesh_cb(Fl_Widget *w, void *data) { int index = (intptr_t)data; - if(index >= 0 && index < (int)PView::list.size()){ + if(index >= 0 && index < (int)PView::list.size()) GModel::current()->getFields()->setBackgroundMesh(index); - } } // The static menus (we cannot use the 'g', 'm' 's' and 'p' mnemonics @@ -2963,24 +2945,10 @@ void menuWindow::setContext(contextItem *menu_asked, int flag) (Fl_Callback *) view_all_visible_cb, (void *)0, 0); p[j]->add("Set Visibility/Invert", 0, (Fl_Callback *) view_all_visible_cb, (void *)-1, 0); - p[j]->add("Save As/Parsed View...", 0, - (Fl_Callback *) view_save_parsed_cb, (void *)nb, 0); - p[j]->add("Save As/ASCII View...", 0, - (Fl_Callback *) view_save_ascii_cb, (void *)nb, 0); - p[j]->add("Save As/Binary View...", 0, - (Fl_Callback *) view_save_binary_cb, (void *)nb, 0); - p[j]->add("Save As/STL Triangulation...", 0, - (Fl_Callback *) view_save_stl_cb, (void *)nb, 0); - p[j]->add("Save As/Raw Text...", 0, - (Fl_Callback *) view_save_txt_cb, (void *)nb, 0); - p[j]->add("Save As/Gmsh Mesh...", 0, - (Fl_Callback *) view_save_msh_cb, (void *)nb, 0); -#if defined(HAVE_MED) - p[j]->add("Save As/MED file...", 0, - (Fl_Callback *) view_save_med_cb, (void *)nb, 0); -#endif p[j]->add("Apply As Background Mesh", 0, - (Fl_Callback *) view_applybgmesh_cb, (void *)nb, FL_MENU_DIVIDER); + (Fl_Callback *) view_applybgmesh_cb, (void *)nb, 0); + p[j]->add("Save As...", 0, + (Fl_Callback *) view_save_cb, (void *)nb, FL_MENU_DIVIDER); p[j]->add("Options", 'o', (Fl_Callback *) view_options_cb, (void *)nb, 0); p[j]->add("Plugins", 'p', diff --git a/Mesh/BackgroundMesh.cpp b/Mesh/BackgroundMesh.cpp index 48aa0a2a0bd8bd0663e0819a6aaded5ff243a4a0..165c55a73ede40950b8ce57bfb155281e0972eb1 100644 --- a/Mesh/BackgroundMesh.cpp +++ b/Mesh/BackgroundMesh.cpp @@ -33,7 +33,8 @@ // CTX::instance()->mesh.minCircPoints tells the minimum number of points per // radius of curvature -SMetric3 buildMetricTangentToCurve (SVector3 &t, double curvature, double &lambda){ +SMetric3 buildMetricTangentToCurve (SVector3 &t, double curvature, double &lambda) +{ lambda = 1.e22; if (curvature == 0.0)return SMetric3(1.e-22); SVector3 a; @@ -85,7 +86,8 @@ SMetric3 max_edge_curvature_metric(const GVertex *gv, double &length) return val; } -SMetric3 max_edge_curvature_metric(const GEdge *ge, double u, double &l){ +SMetric3 max_edge_curvature_metric(const GEdge *ge, double u, double &l) +{ SVector3 t = ge->firstDer(u); t.normalize(); return buildMetricTangentToCurve(t,ge->curvature(u),l); @@ -577,7 +579,8 @@ void backgroundMesh::propagate1dMesh(GFace *_gf) // C R O S S F I E L D S -crossField2d :: crossField2d (MVertex* v, GEdge* ge){ +crossField2d::crossField2d(MVertex* v, GEdge* ge) +{ double p; bool success = reparamMeshVertexOnEdge(v, ge, p); if (!success){ @@ -591,9 +594,6 @@ crossField2d :: crossField2d (MVertex* v, GEdge* ge){ crossField2d::normalizeAngle (_angle); } - - - void backgroundMesh::propagatecrossField(GFace *_gf) { std::map<MVertex*,double> _cosines4,_sines4; @@ -681,7 +681,6 @@ void backgroundMesh::propagatecrossField(GFace *_gf) } - void backgroundMesh::updateSizes(GFace *_gf) { std::map<MVertex*,double>::iterator itv = _sizes.begin(); @@ -725,7 +724,7 @@ double backgroundMesh::operator() (double u, double v, double w) const return itv1->second * (1-uv2[0]-uv2[1]) + itv2->second * uv2[0] + itv3->second * uv2[1]; } -double backgroundMesh::getAngle (double u, double v, double w) const +double backgroundMesh::getAngle(double u, double v, double w) const { double uv[3] = {u, v, w}; double uv2[3]; @@ -752,8 +751,8 @@ double backgroundMesh::getAngle (double u, double v, double w) const return angle; } - -void backgroundMesh::print (const std::string &filename, GFace *gf, const std::map<MVertex*,double> &_whatToPrint) const +void backgroundMesh::print(const std::string &filename, GFace *gf, + const std::map<MVertex*,double> &_whatToPrint) const { FILE *f = fopen (filename.c_str(),"w"); fprintf(f,"View \"Background Mesh\"{\n"); diff --git a/Post/PView.cpp b/Post/PView.cpp index 8b42271458390fcab909a75e0c62cbbe6612b487..1e9e71deb439382194162b902c0a426ab599313d 100644 --- a/Post/PView.cpp +++ b/Post/PView.cpp @@ -142,7 +142,7 @@ void PView::addStep(GModel *model, std::map<int, std::vector<double> > &data, { PViewDataGModel *d = dynamic_cast<PViewDataGModel*>(_data); if(d) d->addData(model, data, d->getNumTimeSteps(), time, 1, numComp); - else Msg::Error("Can only add step data to model-based datasets"); + else Msg::Error("Can only add step data to mesh-based datasets"); } PView::~PView() @@ -264,7 +264,7 @@ void PView::combine(bool time, int how, bool remove) data = new PViewDataGModel(d2->getType()); } else{ - Msg::Error("Cannot combine hybrid list/model-based datasets"); + Msg::Error("Cannot combine hybrid list/mesh-based datasets"); continue; } PView *p = new PView(data); diff --git a/Post/PView.h b/Post/PView.h index f37d8a744349d02fea49de006ca6ffcb8934cede..bb7b6a26087db455288295ec1a9cd10cfc50647b 100644 --- a/Post/PView.h +++ b/Post/PView.h @@ -50,11 +50,11 @@ class PView{ // construct a new list-based view from a simple 2D dataset PView(std::string xname, std::string yname, std::vector<double> &x, std::vector<double> &y); - // construct a new model-based view from a bunch of data + // construct a new mesh-based view from a bunch of data PView(std::string name, 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 model-based view + // add a new time step to a given mesh-based view void addStep(GModel *model, std::map<int, std::vector<double> > &data, double time=0.,int numComp = -1); diff --git a/Post/PViewDataIO.cpp b/Post/PViewDataIO.cpp index a388f59e995d0b98eccf6f7e71f1e601c5b15bc7..4d30d61f87fbc081a28ca4db5521e1adf8fc5105 100644 --- a/Post/PViewDataIO.cpp +++ b/Post/PViewDataIO.cpp @@ -182,6 +182,6 @@ bool PViewData::writeMSH(std::string fileName, bool binary, bool savemesh) bool PViewData::writeMED(std::string fileName) { - Msg::Error("MED export onnly available for model-based post-processing views"); + Msg::Error("MED export onnly available for mesh-based post-processing views"); return false; } diff --git a/Post/PViewDataListIO.cpp b/Post/PViewDataListIO.cpp index 60efa68e91c5670452fabdddebd50fc6688846a1..acf26593e51c8c1c912ae2cf696f69558af8dd0c 100644 --- a/Post/PViewDataListIO.cpp +++ b/Post/PViewDataListIO.cpp @@ -346,9 +346,11 @@ bool PViewDataList::writePOS(std::string fileName, bool binary, bool parsed, boo Msg::Warning("Writing adapted dataset (will only export current time step)"); return _adaptive->getData()->writePOS(fileName, binary, parsed, append); } - else if(haveInterpolationMatrices()){ - Msg::Error("Cannot (yet) export datasets with interpolation matrices: use"); - Msg::Error("'Adapt visualization grid' before exporting!"); + + if(haveInterpolationMatrices()){ + Msg::Error("Cannot export datasets with interpolation matrices in old POS format: " + "consider using the new mesh-based format instead, or select 'Adapt " + "post-processing data' before exporting"); return false; }