File: split_window.py

package info (click to toggle)
gmsh 4.15.1%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 52,880 kB
  • sloc: cpp: 440,657; ansic: 114,930; f90: 15,611; python: 13,907; yacc: 7,438; java: 3,491; lisp: 3,206; lex: 633; perl: 571; makefile: 500; xml: 414; sh: 407; javascript: 113; modula3: 32
file content (54 lines) | stat: -rw-r--r-- 1,545 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import gmsh
import sys

if '-nopopup' in sys.argv:
    exit(0)

gmsh.initialize(sys.argv)

# create simple geometry
gmsh.model.occ.addBox(-3, -2, -1, 6, 4, 2)
gmsh.model.occ.synchronize()

gmsh.option.setNumber("Mesh.SurfaceFaces", 1)

# launch GUI
gmsh.fltk.initialize()

# split window 50%-50% horizontally and change the rotation;
# rotation/translation/scale options are applied to the current subwindow (the
# last one created)
gmsh.fltk.splitCurrentWindow('h', 0.5)
gmsh.option.setNumber("General.Trackball", 0)
gmsh.option.setNumber("General.RotationX", -90)
gmsh.option.setNumber("General.RotationY", 0)
gmsh.option.setNumber("General.RotationZ", -90)

# split the current subwindow into two parts, vertically and change the rotation
gmsh.fltk.splitCurrentWindow('v', 0.5)
gmsh.option.setNumber("General.RotationX", -90)
gmsh.option.setNumber("General.RotationY", 0)
gmsh.option.setNumber("General.RotationZ", 180)

# change the current window to the original one (subwindows are indexed starting
# from 0; new subwindows created by splitCurrentWindow() are appended at the
# end), and adjust rotation
gmsh.fltk.setCurrentWindow(0)
gmsh.option.setNumber("General.RotationX", -75)
gmsh.option.setNumber("General.RotationY", -25)

# mesh the model
gmsh.model.mesh.generate(2)

# redraw
gmsh.graphics.draw()

# save all subwindows into a composite PNG
gmsh.option.setNumber("Print.CompositeWindows", 1)
gmsh.write("img_composite.png")

# restore single window
gmsh.fltk.splitCurrentWindow('u')
gmsh.write("img_single.png")

gmsh.finalize()