File: TestPolygonWriters.tcl

package info (click to toggle)
vtk7 7.1.1%2Bdfsg1-12
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 125,776 kB
  • sloc: cpp: 1,539,582; ansic: 106,521; python: 78,038; tcl: 47,013; xml: 8,142; yacc: 5,040; java: 4,439; perl: 3,132; lex: 1,926; sh: 1,500; makefile: 122; objc: 83
file content (151 lines) | stat: -rw-r--r-- 3,796 bytes parent folder | download | duplicates (12)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package require vtk
package require vtkinteraction

# Create the RenderWindow, Renderer and both Actors
#
vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin

# read data
#
vtkPolyDataReader input
  input SetFileName "$VTK_DATA_ROOT/Data/brainImageSmooth.vtk"

#
# generate vectors
vtkCleanPolyData clean
  clean SetInputConnection [input GetOutputPort]

vtkWindowedSincPolyDataFilter smooth
  smooth SetInputConnection [clean GetOutputPort]
  smooth GenerateErrorVectorsOn
  smooth GenerateErrorScalarsOn
  smooth Update

vtkPolyDataMapper mapper
  mapper SetInputConnection [smooth GetOutputPort]
  eval mapper SetScalarRange [[smooth GetOutput] GetScalarRange]

vtkActor brain
  brain SetMapper mapper


# Add the actors to the renderer, set the background and size
#
ren1 AddActor brain

renWin SetSize 320 240

[ren1 GetActiveCamera] SetPosition 149.653 -65.3464 96.0401
[ren1 GetActiveCamera] SetFocalPoint 146.003 22.3839 0.260541
[ren1 GetActiveCamera] SetViewAngle 30
[ren1 GetActiveCamera] SetViewUp -0.255578 -0.717754 -0.647695
[ren1 GetActiveCamera] SetClippingRange 79.2526 194.052

iren Initialize
renWin Render

# render the image
#
iren AddObserver UserEvent {wm deiconify .vtkInteract}

# prevent the tk window from showing up then start the event loop
wm withdraw .

#
# If the current directory is writable, then test the witers
#

if {[catch {set channel [open "test.tmp" "w"]}] == 0 } {
   close $channel
   file delete -force "test.tmp"

   #
   #
   # test the writers
   vtkDataSetWriter dsw
   dsw SetInputConnection [smooth GetOutputPort]
   dsw SetFileName "brain.dsw"
   dsw Write
   file delete -force "brain.dsw"

   vtkPolyDataWriter pdw
   pdw SetInputConnection [smooth GetOutputPort]
   pdw SetFileName "brain.pdw"
   pdw Write
   file delete -force "brain.pdw"

   if { [info command "vtkIVWriter"] != "" } {
      vtkIVWriter iv
      iv SetInputConnection [smooth GetOutputPort]
      iv SetFileName "brain.iv"
      iv Write
      file delete -force "brain.iv"
   }

   #
   # the next writers only handle triangles
   vtkTriangleFilter triangles
   triangles SetInputConnection [smooth GetOutputPort]

   if { [info command "vtkIVWriter"] != "" } {
      vtkIVWriter iv2
      iv2 SetInputConnection [triangles GetOutputPort]
      iv2 SetFileName "brain2.iv"
      iv2 Write
      file delete -force "brain2.iv"
   }

   if { [info command "vtkIVWriter"] != "" } {
      vtkExtractEdges edges
      edges SetInputConnection [triangles GetOutputPort]
      vtkIVWriter iv3
      iv3 SetInputConnection [edges GetOutputPort]
      iv3 SetFileName "brain3.iv"
      iv3 Write
      file delete -force "brain3.iv"
   }

   vtkBYUWriter byu
   byu SetGeometryFileName "brain.g"
   byu SetScalarFileName "brain.s"
   byu SetDisplacementFileName "brain.d"
   byu SetInputConnection [triangles GetOutputPort]
   byu Write
   file delete -force "brain.g"
   file delete -force "brain.s"
   file delete -force "brain.d"

   vtkMCubesWriter mcubes
   mcubes SetInputConnection [triangles GetOutputPort]
   mcubes SetFileName "brain.tri"
   mcubes SetLimitsFileName "brain.lim"
   mcubes Write
   file delete -force "brain.lim"
   file delete -force "brain.tri"

   vtkSTLWriter stl
   stl SetInputConnection [triangles GetOutputPort]
   stl SetFileName "brain.stl"
   stl Write
   file delete -force "brain.stl"

   vtkSTLWriter stlBinary
   stlBinary SetInputConnection [triangles GetOutputPort]
   stlBinary SetFileName "brainBinary.stl"
   stlBinary SetFileType 2
   stlBinary Write
   file delete -force "brainBinary.stl"

#   vtkCGMWriter cgm
#   cgm SetInputConnection [triangles GetOutputPort]
#   cgm SetFileName "brain.cgm"
#   cgm Write
#   file delete -force "brain.cgm"
}