-
Notifications
You must be signed in to change notification settings - Fork 1
/
mylib_save.py
executable file
·95 lines (75 loc) · 2.69 KB
/
mylib_save.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python
#
# Author: Patrick Brockmann
# Contact: [email protected]
# $Date: $
# $Name: $
# $Revision: $
# History:
# Modification:
#
import __main__
import vtk
from mylib_misc import *
##################################
def SavePNG():
png_number = __main__.png_number
option_verbose = __main__.option_verbose
option_prefix = __main__.option_prefix
renwin = __main__.renwin
rtTimer = vtk.vtkTimerLog
my_print(option_verbose, '----------------------------')
my_print(option_verbose, 'Saving PNG')
rtStartCPU = rtTimer.GetCPUTime()
w2i = vtk.vtkWindowToImageFilter()
w2i.SetInput(renwin)
w2i.Update()
filepng = option_prefix+'_%03d.png' % png_number
my_print(option_verbose, 'Start writing PNG file', filepng)
pngw = vtk.vtkPNGWriter()
pngw.SetInputConnection(w2i.GetOutputPort())
pngw.SetFileName(filepng)
pngw.Write()
rtEndCPU = rtTimer.GetCPUTime()
my_print(option_verbose, 'End writing PNG file')
my_print(option_verbose, 'CPU time:', rtEndCPU-rtStartCPU)
__main__.png_number = png_number+1
##################################
def SavePDF():
pdf_number = __main__.pdf_number
option_verbose = __main__.option_verbose
option_prefix = __main__.option_prefix
renwin = __main__.renwin
rtTimer = vtk.vtkTimerLog
my_print(option_verbose, '----------------------------')
my_print(option_verbose, 'Saving PDF')
rtStartCPU = rtTimer.GetCPUTime()
filepdf = option_prefix+'_%03d' % pdf_number
my_print(option_verbose, 'Start writing PDF file', filepdf+'.pdf')
psw = vtk.vtkGL2PSExporter()
psw.SetInput(renwin)
# psw.SetFileFormatToPS()
psw.SetFileFormatToPDF()
# psw.SetFileFormatToEPS()
psw.SetSortToOff()
if __main__.option_projection == 'linear':
psw.LandscapeOff()
psw.SetFilePrefix(filepdf)
psw.Write()
rtEndCPU = rtTimer.GetCPUTime()
my_print(option_verbose, 'End writing PDF file')
my_print(option_verbose, 'CPU time:', rtEndCPU-rtStartCPU)
__main__.pdf_number = pdf_number+1
##################################
def SavePoly():
option_verbose = __main__.option_verbose
my_print(option_verbose, '----------------------------')
my_print(option_verbose, 'Saving VTK object')
polywriter = vtk.vtkPolyDataWriter()
polywriter.SetFileName('out_poly.vtk')
# polywriter.SetInputConnection(__main__.boundariespolydata.GetOutputPort())
# polywriter.SetInputConnection(__main__.polydata2.GetOutputPort())
polywriter.SetInputConnection(__main__.clean.GetOutputPort())
# polywriter.SetInputConnection(__main__.continentspolydata.GetOutputPort())
polywriter.Write()
##################################