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

better fix for skipping empty steps

parent ad4df402
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <string.h> #include <string.h>
#include "GmshConfig.h" #include "GmshConfig.h"
#include "GmshMessage.h" #include "GmshMessage.h"
#include "Options.h"
#include "Geo.h" #include "Geo.h"
#include "GModel.h" #include "GModel.h"
#include "Numeric.h" #include "Numeric.h"
...@@ -341,20 +342,14 @@ int MergeFile(std::string fileName, bool warnIfMissing) ...@@ -341,20 +342,14 @@ int MergeFile(std::string fileName, bool warnIfMissing)
if(!strncmp(header, "$PTS", 4) || !strncmp(header, "$NO", 3) || if(!strncmp(header, "$PTS", 4) || !strncmp(header, "$NO", 3) ||
!strncmp(header, "$PARA", 5) || !strncmp(header, "$ELM", 4) || !strncmp(header, "$PARA", 5) || !strncmp(header, "$ELM", 4) ||
!strncmp(header, "$MeshFormat", 11) || !strncmp(header, "$Comments", 9)) { !strncmp(header, "$MeshFormat", 11) || !strncmp(header, "$Comments", 9)) {
// mesh matcher
// MATCHER if(CTX::instance()->geom.matchGeomAndMesh && !GModel::current()->empty()){
if(CTX::instance()->geom.matchGeomAndMesh && !GModel::current()->empty() ) { GModel* tmp = new GModel();
GModel* current_mod = GModel::current(); tmp->readMSH(fileName);
GModel* tmp_model = new GModel(); if(GeomMeshMatcher::instance()->match(GModel::current(), tmp))
tmp_model->readMSH(fileName);
int match_status = GeomMeshMatcher::instance()->match(current_mod, tmp_model);
if (match_status)
fileName = "out.msh"; fileName = "out.msh";
delete tmp_model; delete tmp;
} }
// MATCHER END
status = GModel::current()->readMSH(fileName); status = GModel::current()->readMSH(fileName);
#if defined(HAVE_POST) #if defined(HAVE_POST)
if(status > 1) status = PView::readMSH(fileName); if(status > 1) status = PView::readMSH(fileName);
...@@ -383,8 +378,22 @@ int MergeFile(std::string fileName, bool warnIfMissing) ...@@ -383,8 +378,22 @@ int MergeFile(std::string fileName, bool warnIfMissing)
CTX::instance()->mesh.changed = ENT_ALL; CTX::instance()->mesh.changed = ENT_ALL;
#if defined(HAVE_FLTK) && defined(HAVE_POST) #if defined(HAVE_FLTK) && defined(HAVE_POST)
if(FlGui::available()) if(FlGui::available()){
FlGui::instance()->updateViews(numViewsBefore != (int)PView::list.size()); bool newViews = numViewsBefore != (int)PView::list.size();
if(newViews){
// go directly to the first non-empty step
for(unsigned int i = 0; i < PView::list.size(); i++){
for(int j = 0; j < (int)opt_view_nb_timestep(i, GMSH_GET, 0); j++){
int step = (int)opt_view_timestep(i, GMSH_GET, 0);
if(PView::list[i]->getData()->hasTimeStep(step))
break;
else
opt_view_timestep(i, GMSH_SET | GMSH_GUI, step + 1);
}
}
}
FlGui::instance()->updateViews(newViews);
}
#endif #endif
if(!status) Msg::Error("Error loading '%s'", fileName.c_str()); if(!status) Msg::Error("Error loading '%s'", fileName.c_str());
......
...@@ -220,7 +220,7 @@ void status_options_cb(Fl_Widget *w, void *data) ...@@ -220,7 +220,7 @@ void status_options_cb(Fl_Widget *w, void *data)
static int stop_anim = 0, view_in_cycle = -1; static int stop_anim = 0, view_in_cycle = -1;
void status_play_manual(int time, int step) void status_play_manual(int time, int incr)
{ {
// avoid firing this routine recursively (can happen e.g when // avoid firing this routine recursively (can happen e.g when
// keeping the finger down on the arrow key: if the system generates // keeping the finger down on the arrow key: if the system generates
...@@ -232,32 +232,32 @@ void status_play_manual(int time, int step) ...@@ -232,32 +232,32 @@ void status_play_manual(int time, int step)
if(time) { if(time) {
for(unsigned int i = 0; i < PView::list.size(); i++){ for(unsigned int i = 0; i < PView::list.size(); i++){
if(opt_view_visible(i, GMSH_GET, 0)){ if(opt_view_visible(i, GMSH_GET, 0)){
// skip any empty steps (useful when merging only some steps) // skip empty steps
int newStep = (int)opt_view_timestep(i, GMSH_GET, 0) + step; int step = (int)opt_view_timestep(i, GMSH_GET, 0) + incr;
int totalSteps = (int)opt_view_nb_timestep(i, GMSH_GET, 0); int numSteps = (int)opt_view_nb_timestep(i, GMSH_GET, 0);
for(int j = 0; j < totalSteps; j++){ for(int j = 0; j < numSteps; j++){
if(PView::list[i]->getData()->hasTimeStep(newStep)) if(PView::list[i]->getData()->hasTimeStep(step))
break; break;
else else
newStep += step; step += incr;
if(newStep < 0) newStep = totalSteps - 1; if(step < 0) step = numSteps - 1;
if(newStep > totalSteps - 1) newStep = 0; if(step > numSteps - 1) step = 0;
} }
opt_view_timestep(i, GMSH_SET | GMSH_GUI, newStep); opt_view_timestep(i, GMSH_SET | GMSH_GUI, step);
} }
} }
} }
else { // hide all views except view_in_cycle else { // hide all views except view_in_cycle
if(step > 0) { if(incr > 0) {
if((view_in_cycle += step) >= (int)PView::list.size()) if((view_in_cycle += incr) >= (int)PView::list.size())
view_in_cycle = 0; view_in_cycle = 0;
for(int i = 0; i < (int)PView::list.size(); i += step) for(int i = 0; i < (int)PView::list.size(); i += incr)
opt_view_visible(i, GMSH_SET | GMSH_GUI, (i == view_in_cycle)); opt_view_visible(i, GMSH_SET | GMSH_GUI, (i == view_in_cycle));
} }
else { else {
if((view_in_cycle += step) < 0) if((view_in_cycle += incr) < 0)
view_in_cycle = PView::list.size() - 1; view_in_cycle = PView::list.size() - 1;
for(int i = PView::list.size() - 1; i >= 0; i += step) for(int i = PView::list.size() - 1; i >= 0; i += incr)
opt_view_visible(i, GMSH_SET | GMSH_GUI, (i == view_in_cycle)); opt_view_visible(i, GMSH_SET | GMSH_GUI, (i == view_in_cycle));
} }
} }
......
...@@ -36,6 +36,6 @@ class graphicWindow{ ...@@ -36,6 +36,6 @@ class graphicWindow{
void status_xyz1p_cb(Fl_Widget *w, void *data); void status_xyz1p_cb(Fl_Widget *w, void *data);
void status_options_cb(Fl_Widget *w, void *data); void status_options_cb(Fl_Widget *w, void *data);
void status_play_manual(int time, int step); void status_play_manual(int time, int incr);
#endif #endif
...@@ -163,7 +163,7 @@ class PViewData { ...@@ -163,7 +163,7 @@ class PViewData {
bool checkVisibility=false){ return false; } bool checkVisibility=false){ return false; }
// check if the data has the given step/partition/etc. // check if the data has the given step/partition/etc.
virtual bool hasTimeStep(int step){ return step < getNumTimeSteps(); } virtual bool hasTimeStep(int step){ return step >= 0 && step < getNumTimeSteps(); }
virtual bool hasPartition(int part){ return false; } virtual bool hasPartition(int part){ return false; }
virtual bool hasMultipleMeshes(){ return false; } virtual bool hasMultipleMeshes(){ return false; }
virtual bool hasModel(GModel *model, int step=-1){ return false; } virtual bool hasModel(GModel *model, int step=-1){ return false; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment