File: TestRectilinearGridToTetrahedra.tcl

package info (click to toggle)
vtk7 7.1.1%2Bdfsg2-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 127,396 kB
  • sloc: cpp: 1,539,584; ansic: 124,382; 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: 126; objc: 83
file content (97 lines) | stat: -rw-r--r-- 2,812 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
package require vtk
package require vtkinteraction
package require vtktesting

### SetUp the pipeline

vtkRectilinearGridToTetrahedra FormMesh
  FormMesh SetInput 4 2 2 1 1 1 0.001
  FormMesh RememberVoxelIdOn
vtkExtractEdges TetraEdges
  TetraEdges SetInputConnection [FormMesh GetOutputPort]
vtkTubeFilter tubes
  tubes SetInputConnection [TetraEdges GetOutputPort]
  tubes SetRadius 0.05
  tubes SetNumberOfSides 6

### Run the pipeline 3 times, with different conversions to TetMesh

vtkPolyData Tubes1
  FormMesh SetTetraPerCellTo5
  tubes Update
  Tubes1 DeepCopy [tubes GetOutput]
vtkPolyData Tubes2
  FormMesh SetTetraPerCellTo6
  tubes Update
  Tubes2 DeepCopy [tubes GetOutput]
vtkPolyData Tubes3
  FormMesh SetTetraPerCellTo12
  tubes Update
  Tubes3 DeepCopy [tubes GetOutput]

### Run the pipeline once more, this time converting some cells to
### 5 and some data to 12 TetMesh

### Determine which cells are which
vtkIntArray DivTypes
  set numCell [[FormMesh GetInput] GetNumberOfCells]
  DivTypes SetNumberOfValues $numCell
  for {set i 0} {$i<$numCell} {incr i 1} {
    DivTypes SetValue $i [expr 5 + (7* ( $i % 4))]
  }

### Finish this pipeline
vtkPolyData Tubes4
  FormMesh SetTetraPerCellTo5And12
  [[FormMesh GetInput] GetCellData] SetScalars DivTypes
  tubes Update
  Tubes4 DeepCopy [tubes GetOutput]

### Finish the 4 pipelines
for {set i 1} {$i<5} {incr i 1} {
  vtkPolyDataMapper mapEdges$i
      mapEdges$i SetInputData Tubes$i
  vtkActor edgeActor$i
    edgeActor$i SetMapper mapEdges$i
    eval [edgeActor$i GetProperty] SetColor $peacock
    [edgeActor$i GetProperty] SetSpecularColor 1 1 1
    [edgeActor$i GetProperty] SetSpecular 0.3
    [edgeActor$i GetProperty] SetSpecularPower 20
    [edgeActor$i GetProperty] SetAmbient 0.2
    [edgeActor$i GetProperty] SetDiffuse 0.8
  vtkRenderer ren$i
    ren$i AddActor edgeActor$i
    ren$i SetBackground 0 0 0
    ren$i ResetCamera
    [ren$i GetActiveCamera] Zoom 1
    [ren$i GetActiveCamera] SetPosition 1.73906 12.7987 -0.257808
    [ren$i GetActiveCamera] SetViewUp 0.992444 0.00890284 -0.122379
    [ren$i GetActiveCamera] SetClippingRange 9.36398 15.0496
}

# Create graphics objects
# Create the rendering window, renderer, and interactive renderer
vtkRenderWindow renWin
    renWin AddRenderer ren1
    renWin AddRenderer ren2
    renWin AddRenderer ren3
    renWin AddRenderer ren4
    renWin SetSize 600 300
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin

# Add the actors to the renderer, set the background and size

ren1 SetViewport .75 0 1 1
ren2 SetViewport .50 0 .75 1
ren3 SetViewport .25 0 .50 1
ren4 SetViewport 0 0 .25 1

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

iren Initialize

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