X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkMeshViewer.cxx;h=c21bc4e43f31cf7e9d64936076b1411ad4562d48;hb=HEAD;hp=25db426fcad9f0df44ff4e1a32162b13a3bffe62;hpb=b12811bce7849ea9ddb36782266d5dc64a7c0a28;p=clitk.git diff --git a/tools/clitkMeshViewer.cxx b/tools/clitkMeshViewer.cxx index 25db426..c21bc4e 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 @@ -72,7 +75,7 @@ public: m_rActors[m_CurrentActor]->SetVisibility(0); - int step = round(m_Fps * info->AnimationTime); + int step = lrint(m_Fps * info->AnimationTime); int actor = step % m_rActors.size(); //if (actor != m_CurrentActor) std::cout << "Showing frame: " << m_CurrentActor << std::endl; @@ -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; }