From aef7d369647d40e787016658e0ccfa0afd4ecefc Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@uliege.be>
Date: Wed, 23 Sep 2020 17:49:20 +0200
Subject: [PATCH] -nopopup for c++ tutos

---
 CMakeLists.txt      |  2 +-
 tutorial/c++/t4.cpp |  8 ++++----
 tutorial/c++/t7.cpp |  8 ++++----
 tutorial/c++/t8.cpp | 11 +++++------
 tutorial/c++/t9.cpp |  8 ++++----
 tutorial/c++/x3.cpp |  8 ++++----
 tutorial/c++/x4.cpp |  8 ++++----
 7 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cb23d478dd..85525ce1d0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2118,7 +2118,7 @@ if(NOT DISABLE_GMSH_TESTS)
         endif()
         set_target_properties(${TEST} PROPERTIES LINK_FLAGS "${FLAGS}")
       endif()
-      add_test(${TEST}_cpp ${TEST})
+      add_test(${TEST}_cpp ${TEST} -nopopup)
     endforeach()
   endif()
   # enable this once we have worked out the path issues on the build machines
diff --git a/tutorial/c++/t4.cpp b/tutorial/c++/t4.cpp
index c678860ed5..54a2d67e72 100644
--- a/tutorial/c++/t4.cpp
+++ b/tutorial/c++/t4.cpp
@@ -6,7 +6,7 @@
 //
 // -----------------------------------------------------------------------------
 
-#include <algorithm>
+#include <set>
 #include <math.h>
 #include <gmsh.h>
 
@@ -168,9 +168,9 @@ int main(int argc, char **argv)
   gmsh::write("t4.msh");
 
   // Launch the GUI to see the results:
-  std::vector<std::string> args(argv + 1, argv + argc);
-  if(!std::count(args.begin(), args.end(), "-nopopup"))
-    gmsh::fltk::run();
+  std::set<std::string> args;
+  for(int i = 1; i < argc; i++) args.insert(argv[i]);
+  if(args.find("-nopopup") == args.end()) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/t7.cpp b/tutorial/c++/t7.cpp
index abf18cd5e2..777a2db871 100644
--- a/tutorial/c++/t7.cpp
+++ b/tutorial/c++/t7.cpp
@@ -6,7 +6,7 @@
 //
 // -----------------------------------------------------------------------------
 
-#include <algorithm>
+#include <set>
 #include <gmsh.h>
 
 // Mesh sizes can be specified very accurately by providing a background mesh,
@@ -65,9 +65,9 @@ int main(int argc, char **argv)
   gmsh::write("t7.msh");
 
   // Launch the GUI to see the results:
-  std::vector<std::string> args(argv + 1, argv + argc);
-  if(!std::count(args.begin(), args.end(), "-nopopup"))
-    gmsh::fltk::run();
+  std::set<std::string> args;
+  for(int i = 1; i < argc; i++) args.insert(argv[i]);
+  if(args.find("-nopopup") == args.end()) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/t8.cpp b/tutorial/c++/t8.cpp
index 132333fedb..8b445c95b6 100644
--- a/tutorial/c++/t8.cpp
+++ b/tutorial/c++/t8.cpp
@@ -6,7 +6,7 @@
 //
 // -----------------------------------------------------------------------------
 
-#include <algorithm>
+#include <set>
 #include <gmsh.h>
 
 // In addition to creating geometries and meshes, the C++ API can also be used
@@ -73,9 +73,9 @@ int main(int argc, char **argv)
   gmsh::option::setNumber("General.SmallAxes", 0);
 
   // Show the GUI
-  std::vector<std::string> args(argv + 1, argv + argc);
-  if(!std::count(args.begin(), args.end(), "-nopopup"))
-    gmsh::fltk::initialize();
+  std::set<std::string> args;
+  for(int i = 1; i < argc; i++) args.insert(argv[i]);
+  if(args.find("-nopopup") == args.end()) gmsh::fltk::initialize();
 
   // We also set some options for each post-processing view:
   gmsh::option::setNumber("View[0].IntervalsType", 2);
@@ -164,8 +164,7 @@ int main(int argc, char **argv)
     }
   }
 
-  if(!std::count(args.begin(), args.end(), "-nopopup"))
-    gmsh::fltk::run();
+  if(args.find("-nopopup") == args.end()) gmsh::fltk::run();
 
   gmsh::finalize();
 
diff --git a/tutorial/c++/t9.cpp b/tutorial/c++/t9.cpp
index 9bf8142dc0..cab6ffdfd6 100644
--- a/tutorial/c++/t9.cpp
+++ b/tutorial/c++/t9.cpp
@@ -15,7 +15,7 @@
 // namespace, or from the graphical interface (right click on the view button,
 // then `Plugins').
 
-#include <algorithm>
+#include <set>
 #include <gmsh.h>
 
 int main(int argc, char **argv)
@@ -76,9 +76,9 @@ int main(int argc, char **argv)
   gmsh::option::setNumber("View[2].IntervalsType", 2);
 
   // show the GUI at the end
-  std::vector<std::string> args(argv + 1, argv + argc);
-  if(!std::count(args.begin(), args.end(), "-nopopup"))
-    gmsh::fltk::run();
+  std::set<std::string> args;
+  for(int i = 1; i < argc; i++) args.insert(argv[i]);
+  if(args.find("-nopopup") == args.end()) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/x3.cpp b/tutorial/c++/x3.cpp
index 2b07534c30..114c92cd26 100644
--- a/tutorial/c++/x3.cpp
+++ b/tutorial/c++/x3.cpp
@@ -6,7 +6,7 @@
 //
 // -----------------------------------------------------------------------------
 
-#include <algorithm>
+#include <set>
 #include <gmsh.h>
 
 int main(int argc, char **argv)
@@ -142,9 +142,9 @@ int main(int argc, char **argv)
   gmsh::option::setNumber("View[1].MaxRecursionLevel", 5);
 
   // Launch the GUI to see the results:
-  std::vector<std::string> args(argv + 1, argv + argc);
-  if(!std::count(args.begin(), args.end(), "-nopopup"))
-    gmsh::fltk::run();
+  std::set<std::string> args;
+  for(int i = 1; i < argc; i++) args.insert(argv[i]);
+  if(args.find("-nopopup") == args.end()) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
diff --git a/tutorial/c++/x4.cpp b/tutorial/c++/x4.cpp
index 484020d85a..214aff563d 100644
--- a/tutorial/c++/x4.cpp
+++ b/tutorial/c++/x4.cpp
@@ -6,7 +6,7 @@
 //
 // -----------------------------------------------------------------------------
 
-#include <algorithm>
+#include <set>
 #include <gmsh.h>
 
 int main(int argc, char **argv)
@@ -92,9 +92,9 @@ int main(int argc, char **argv)
   gmsh::view::write(t2, "x4_t2.msh");
 
   // Launch the GUI to see the results:
-  std::vector<std::string> args(argv + 1, argv + argc);
-  if(!std::count(args.begin(), args.end(), "-nopopup"))
-    gmsh::fltk::run();
+  std::set<std::string> args;
+  for(int i = 1; i < argc; i++) args.insert(argv[i]);
+  if(args.find("-nopopup") == args.end()) gmsh::fltk::run();
 
   gmsh::finalize();
   return 0;
-- 
GitLab