From d7667b5730b0c778c811fc9fc18f3af1450f5521 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Mon, 2 May 2011 15:12:09 +0000 Subject: [PATCH] fix mpeg export of "sparse" time data --- Common/CreateFile.cpp | 4 ++-- Common/Options.cpp | 14 ++++++++++++++ Common/Options.h | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Common/CreateFile.cpp b/Common/CreateFile.cpp index c83066c564..475a8fd5fe 100644 --- a/Common/CreateFile.cpp +++ b/Common/CreateFile.cpp @@ -461,10 +461,10 @@ void CreateOutputFile(std::string fileName, int format) } int numViews = (int)opt_post_nb_views(0, GMSH_GET, 0), numSteps = 0; - // FIXME: this does not handle empty time steps! for(int i = 0; i < numViews; i++){ if(opt_view_visible(i, GMSH_GET, 0)) - numSteps = std::max(numSteps, (int)opt_view_nb_timestep(i, GMSH_GET, 0)); + numSteps = std::max(numSteps, + (int)opt_view_nb_non_empty_timestep(i, GMSH_GET, 0)); } std::vector<std::string> frames; for(int i = 0; i < (CTX::instance()->post.animCycle ? numViews : numSteps); i++){ diff --git a/Common/Options.cpp b/Common/Options.cpp index 341765d31b..931c14bf60 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -6525,6 +6525,20 @@ double opt_view_nb_timestep(OPT_ARGS_NUM) #endif } +double opt_view_nb_non_empty_timestep(OPT_ARGS_NUM) +{ +#if defined(HAVE_POST) + GET_VIEW(0.); + if(!data) return 0; + int n = 0; + for(unsigned int i = 0; i < data->getNumTimeSteps(); i++) + if(data->hasTimeStep(i)) n++; + return n; +#else + return 0.; +#endif +} + double opt_view_timestep(OPT_ARGS_NUM) { #if defined(HAVE_POST) diff --git a/Common/Options.h b/Common/Options.h index 9db8fcb1de..1f13d6f411 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -617,6 +617,7 @@ double opt_post_plugins(OPT_ARGS_NUM); double opt_post_nb_views(OPT_ARGS_NUM); double opt_post_file_format(OPT_ARGS_NUM); double opt_view_nb_timestep(OPT_ARGS_NUM); +double opt_view_nb_non_empty_timestep(OPT_ARGS_NUM); double opt_view_timestep(OPT_ARGS_NUM); double opt_view_min(OPT_ARGS_NUM); double opt_view_max(OPT_ARGS_NUM); -- GitLab