RINGMesh  Version 5.0.0
A programming library for geological model meshes
test-ringmeshview.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2017, Association Scientifique pour la Geologie et ses
3  * Applications (ASGA). All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of ASGA nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ASGA BE LIABLE FOR ANY DIRECT,
20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * http://www.ring-team.org
28  *
29  * RING Project
30  * Ecole Nationale Superieure de Geologie - GeoRessources
31  * 2 Rue du Doyen Marcel Roubault - TSA 70605
32  * 54518 VANDOEUVRE-LES-NANCY
33  * FRANCE
34  */
35 
36 #include <ringmesh/ringmesh_tests_config.h>
37 
38 #include <chrono>
39 #include <future>
40 
41 #include <geogram/basic/command_line.h>
42 #include <geogram/basic/logger.h>
43 
44 #include <ringmesh/basic/common.h>
45 
46 #ifdef RINGMESH_TEST_GRAPHICS
47 
48 #include <geogram/basic/process.h>
49 
51 
56 namespace RINGMesh
57 {
58  void open_viewer_load_geomodel_then_close(
59  const int argc, char** argv, const std::string& glup_profile )
60  {
61  RINGMeshApplication app( argc, argv );
62 
63  GEO::CmdLine::set_arg( "GLUP_profile", glup_profile );
64 
65  // Create the tasks for launching the app window
66  // and the one for closing the window
67  std::future< void > start =
68  std::async( std::launch::async, &RINGMeshApplication::start, &app );
69  std::this_thread::sleep_for( std::chrono::seconds( 3 ) );
70  std::future< void > end =
71  std::async( std::launch::async, &RINGMeshApplication::quit, &app );
72  }
73 }
74 
75 int main()
76 {
77  using namespace RINGMesh;
78 
79  try
80  {
81  char ringmesh_view[] = "ringmesh-view";
82  std::string input_model_file_name( ringmesh_test_data_path );
83  input_model_file_name += "modelA6.ml";
84  char* input_model = &input_model_file_name[0];
85 
86  char* argv[2] = { ringmesh_view, input_model };
87 
88  // Two arguments: one for 'ringmeshview' and one for the input file
89  const int argc = 2;
90 
91  std::vector< std::string > GLUP_profiles( 1, "" );
92  GLUP_profiles[0] = "auto";
93  // GLUP_profiles[1] = "GLUP150" ;
94  // GLUP_profiles[2] = "GLUP440" ;
95  // GLUP_profiles[3] = "VanillaGL" ;
96 
97  for( const std::string& profile : GLUP_profiles )
98  {
99  open_viewer_load_geomodel_then_close( argc, argv, profile );
100  }
101  }
102  catch( const RINGMeshException& e )
103  {
104  Logger::err( e.category(), e.what() );
105  return 1;
106  }
107  catch( const std::exception& e )
108  {
109  Logger::err( "Exception", e.what() );
110  return 1;
111  }
112  Logger::out( "TEST", "SUCCESS" );
113  return 0;
114 }
115 
116 #else
117 int main()
118 {
119  using namespace RINGMesh;
120 
122  Logger::out( "RINGMeshView",
123  "To test RINGMesh viewer you need to configure ",
124  "the project with the RINGMESH_TEST_GRAPHICS option ON" );
125  return 0;
126 }
127 #endif
int main()
static void err(const std::string &feature, const Args &... args)
Definition: logger.h:68
static void out(const std::string &feature, const Args &... args)
Definition: logger.h:61
const std::string & category() const
Definition: common.h:165
Classes to build GeoModel from various inputs.
Definition: algorithm.h:48
void RINGMESH_API default_configure()
Definition: common.cpp:99