diff --git a/tutorials/c++/t8.cpp b/tutorials/c++/t8.cpp index 3823bf98f22d44a2d41547ad80b39a7c3f2ea0b8..62253739242d010ef2bfb1b8397ad0058bc82343 100644 --- a/tutorials/c++/t8.cpp +++ b/tutorials/c++/t8.cpp @@ -75,10 +75,15 @@ int main(int argc, char **argv) // If we were to follow the geo example blindly, we would read the number of // views from the relevant option value, and use the gmsh::option::setNumber() // and gmsh::option::setString() functions. A nicer way is to use - // gmsh::view::getTags() and to use the gmsh::view::setNumber() and - // gmsh::view::setString() functions. + // gmsh::view::getTags() and to use the gmsh::view::option::setNumber() and + // gmsh::view::option::setString() functions. std::vector<int> v; gmsh::view::getTags(v); + if(v.size() != 4) { + gmsh::logger::write("Wrong number of views!", "error"); + gmsh::finalize(); + return 1; + } gmsh::view::option::setNumber(v[0], "IntervalsType", 2); gmsh::view::option::setNumber(v[0], "OffsetZ", 0.05); diff --git a/tutorials/c++/t9.cpp b/tutorials/c++/t9.cpp index 146d71e63cfb734bdfd30c0fdcaf3c38ad6a0adf..f2bafeb6eed1db509467cafc910ba24a5af3c133 100644 --- a/tutorials/c++/t9.cpp +++ b/tutorials/c++/t9.cpp @@ -35,6 +35,11 @@ int main(int argc, char **argv) std::vector<int> v; gmsh::view::getTags(v); + if(v.size() != 1) { + gmsh::logger::write("Wrong number of views!", "error"); + gmsh::finalize(); + return 1; + } // We then set some options for the `Isosurface' plugin (which extracts an // isosurface from a 3D scalar view), and run it: diff --git a/tutorials/python/t8.py b/tutorials/python/t8.py index 321ff2794fd60f0e75790170f821a8d647f7a602..69cf5e8fea20299664f0bbef37beb49d389f7068 100644 --- a/tutorials/python/t8.py +++ b/tutorials/python/t8.py @@ -70,11 +70,15 @@ if '-nopopup' not in sys.argv: # We also set some options for each post-processing view: # If we were to follow the geo example blindly, we would read the number of -# views from the relevant option value, and use the gmsh.option.setNumber() -# and gmsh.option.setString() functions. A nicer way is to use -# gmsh.view.getTags() and to use the gmsh.view.setNumber() and -# gmsh.view.setString() functions. +# views from the relevant option value, and use the gmsh.option.setNumber() and +# gmsh.option.setString() functions. A nicer way is to use gmsh.view.getTags() +# and to use the gmsh.view.option.setNumber() and gmsh.view.option.setString() +# functions. v = gmsh.view.getTags() +if len(v) != 4: + gmsh.logger.write("Wrong number of views!", "error") + gmsh.finalize() + exit() # We set some options for each post-processing view: gmsh.view.option.setNumber(v[0], "IntervalsType", 2) diff --git a/tutorials/python/t9.py b/tutorials/python/t9.py index 2ac7f5017f0fc4d1d0871c7b1173b4e37c0bd1fb..0974b646617d1a660b2c0ee1fc9bce68e060356c 100644 --- a/tutorials/python/t9.py +++ b/tutorials/python/t9.py @@ -25,6 +25,10 @@ gmsh.initialize() path = os.path.dirname(os.path.abspath(__file__)) gmsh.merge(os.path.join(path, os.pardir, 'view3.pos')) v = gmsh.view.getTags() +if len(v) != 1: + gmsh.logger.write("Wrong number of views!", "error") + gmsh.finalize() + exit() # We then set some options for the `Isosurface' plugin (which extracts an # isosurface from a 3D scalar view), and run it: