From: Romulo Pinho Date: Mon, 16 May 2011 09:28:34 +0000 (+0200) Subject: clitkMeshViewer X-Git-Tag: v1.3.0~347^2~1 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=b3eecd3967b56f80ea37364f469ce692d2f6ef6e;p=clitk.git clitkMeshViewer - adjustments in command line options --- diff --git a/tools/clitkMeshViewer.cxx b/tools/clitkMeshViewer.cxx index 25db426..3cfffbb 100644 --- a/tools/clitkMeshViewer.cxx +++ b/tools/clitkMeshViewer.cxx @@ -30,6 +30,9 @@ #include "vtkProperty.h" #include "vtkInteractorStyle.h" +#include "clitkCommon.h" +#include "clitkMeshViewer_ggo.h" + #include #include #include @@ -39,7 +42,7 @@ typedef vtkSmartPointer MapperType; typedef vtkSmartPointer ActorType; -void run(int argc, char** argv); +long run(const args_info_clitkMeshViewer& argsInfo); // Adapted from vtkAnimationCue example... class CueAnimator @@ -200,30 +203,34 @@ public: int main(int argc, char** argv) { - if (argc == 0) - std::cout << "Usage: clitkMeshViewer FILE1 FILE2 ... [--animate]" << std::endl; + GGO(clitkMeshViewer, args_info); - run(argc, argv); - - return EXIT_SUCCESS; + return run(args_info); } -void run(int argc, char** argv) +long run(const args_info_clitkMeshViewer& argsInfo) { std::vector objs; std::vector mappers; std::vector actors; - int nfiles = argc; - std::string animate = argv[argc-1]; - if (animate == "--animate") - nfiles = argc-1; + bool verbose = argsInfo.verbose_flag; + + int nfiles = argsInfo.inputs_num; + if (nfiles == 0) + { + std::cout << "At leas one mesh (.OBJ) file must be given. See clitkMeshViewer -h." << std::endl; + return -1; + } + + if (verbose) + std::cout << nfiles << " file(s) to be loaded..." << std::endl; vtkSmartPointer aRenderer = vtkRenderer::New(); - for (int i = 1; i < nfiles; i++) { - std::string file = argv[i]; - - //std::cout << "Reading " << file << std::endl; + for (int i = 0; i < nfiles; i++) { + std::string file = argsInfo.inputs[i]; + if (verbose) + std::cout << "Reading " << file << std::endl; vtkSmartPointer preader = vtkOBJReader::New(); preader->SetFileName(file.c_str()); @@ -268,10 +275,11 @@ void run(int argc, char** argv) vtkSmartPointer window_observer; CueAnimator animator(actors); - double fps = 4; - animator.SetFps(fps); + bool animate = argsInfo.animate_flag; + if (animate) { + double fps = argsInfo.fps_arg; + animator.SetFps(fps); - if (animate == "--animate") { // Create an Animation Scene scene=vtkAnimationScene::New(); scene->SetModeToRealTime(); @@ -304,6 +312,7 @@ void run(int argc, char** argv) } iren->Start(); + return 0; }