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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
|
package require vtk
package require vtkinteraction
# Remove cullers so single vertex will render
vtkRenderer ren1
[ren1 GetCullers] RemoveAllItems
vtkRenderWindow renWin
renWin AddRenderer ren1
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
vtkGenericCell cell
vtkIdList ptIds
# 0D
vtkPoints ZeroDPts
ZeroDPts SetNumberOfPoints 1
ZeroDPts SetPoint 0 0 0 0
vtkStructuredGrid ZeroDGrid
ZeroDGrid SetDimensions 1 1 1
ZeroDGrid SetPoints ZeroDPts
ZeroDGrid GetCell 0
ZeroDGrid GetCell 0 cell
ZeroDGrid GetCellPoints 0 ptIds
vtkStructuredGridGeometryFilter ZeroDGeom
ZeroDGeom SetInput ZeroDGrid
ZeroDGeom SetExtent 0 2 0 2 0 2
vtkPolyDataMapper ZeroDMapper
ZeroDMapper SetInputConnection [ZeroDGeom GetOutputPort]
vtkActor ZeroDActor
ZeroDActor SetMapper ZeroDMapper
ZeroDActor SetPosition 0 0 0
ren1 AddActor ZeroDActor
# 1D - X
vtkPoints XPts
XPts SetNumberOfPoints 2
XPts SetPoint 0 0 0 0
XPts SetPoint 1 1 0 0
vtkStructuredGrid XGrid
XGrid SetDimensions 2 1 1
XGrid SetPoints XPts
XGrid GetCell 0
XGrid GetCell 0 cell
XGrid GetCellPoints 0 ptIds
vtkStructuredGridGeometryFilter XGeom
XGeom SetInput XGrid
XGeom SetExtent 0 2 0 2 0 2
vtkPolyDataMapper XMapper
XMapper SetInputConnection [XGeom GetOutputPort]
vtkActor XActor
XActor SetMapper XMapper
XActor SetPosition 2 0 0
ren1 AddActor XActor
# 1D - Y
vtkPoints YPts
YPts SetNumberOfPoints 2
YPts SetPoint 0 0 0 0
YPts SetPoint 1 0 1 0
vtkStructuredGrid YGrid
YGrid SetDimensions 1 2 1
YGrid SetPoints YPts
YGrid GetCell 0
YGrid GetCell 0 cell
YGrid GetCellPoints 0 ptIds
vtkStructuredGridGeometryFilter YGeom
YGeom SetInput YGrid
YGeom SetExtent 0 2 0 2 0 2
vtkPolyDataMapper YMapper
YMapper SetInputConnection [YGeom GetOutputPort]
vtkActor YActor
YActor SetMapper YMapper
YActor SetPosition 4 0 0
ren1 AddActor YActor
# 1D - Z
vtkPoints ZPts
ZPts SetNumberOfPoints 2
ZPts SetPoint 0 0 0 0
ZPts SetPoint 1 0 0 1
vtkStructuredGrid ZGrid
ZGrid SetDimensions 1 1 2
ZGrid SetPoints ZPts
ZGrid GetCell 0
ZGrid GetCell 0 cell
ZGrid GetCellPoints 0 ptIds
vtkStructuredGridGeometryFilter ZGeom
ZGeom SetInput ZGrid
ZGeom SetExtent 0 2 0 2 0 2
vtkPolyDataMapper ZMapper
ZMapper SetInputConnection [ZGeom GetOutputPort]
vtkActor ZActor
ZActor SetMapper ZMapper
ZActor SetPosition 6 0 0
ren1 AddActor ZActor
# 2D - XY
vtkPoints XYPts
XYPts SetNumberOfPoints 4
XYPts SetPoint 0 0 0 0
XYPts SetPoint 1 1 0 0
XYPts SetPoint 2 0 1 0
XYPts SetPoint 3 1 1 0
vtkStructuredGrid XYGrid
XYGrid SetDimensions 2 2 1
XYGrid SetPoints XYPts
XYGrid GetCell 0
XYGrid GetCell 0 cell
XYGrid GetCellPoints 0 ptIds
vtkStructuredGridGeometryFilter XYGeom
XYGeom SetInput XYGrid
XYGeom SetExtent 0 2 0 2 0 2
vtkPolyDataMapper XYMapper
XYMapper SetInputConnection [XYGeom GetOutputPort]
vtkActor XYActor
XYActor SetMapper XYMapper
XYActor SetPosition 0 2 0
ren1 AddActor XYActor
# 2D - YZ
vtkPoints YZPts
YZPts SetNumberOfPoints 4
YZPts SetPoint 0 0 0 0
YZPts SetPoint 1 0 1 0
YZPts SetPoint 2 0 0 1
YZPts SetPoint 3 0 1 1
vtkStructuredGrid YZGrid
YZGrid SetDimensions 1 2 2
YZGrid SetPoints YZPts
YZGrid GetCell 0
YZGrid GetCell 0 cell
YZGrid GetCellPoints 0 ptIds
vtkStructuredGridGeometryFilter YZGeom
YZGeom SetInput YZGrid
YZGeom SetExtent 0 2 0 2 0 2
vtkPolyDataMapper YZMapper
YZMapper SetInputConnection [YZGeom GetOutputPort]
vtkActor YZActor
YZActor SetMapper YZMapper
YZActor SetPosition 2 2 0
ren1 AddActor YZActor
# 2D - XZ
vtkPoints XZPts
XZPts SetNumberOfPoints 4
XZPts SetPoint 0 0 0 0
XZPts SetPoint 1 1 0 0
XZPts SetPoint 2 0 0 1
XZPts SetPoint 3 1 0 1
vtkStructuredGrid XZGrid
XZGrid SetDimensions 2 1 2
XZGrid SetPoints XZPts
XZGrid GetCell 0
XZGrid GetCell 0 cell
XZGrid GetCellPoints 0 ptIds
vtkStructuredGridGeometryFilter XZGeom
XZGeom SetInput XZGrid
XZGeom SetExtent 0 2 0 2 0 2
vtkPolyDataMapper XZMapper
XZMapper SetInputConnection [XZGeom GetOutputPort]
vtkActor XZActor
XZActor SetMapper XZMapper
XZActor SetPosition 4 2 0
ren1 AddActor XZActor
# 3D
vtkPoints XYZPts
XYZPts SetNumberOfPoints 8
XYZPts SetPoint 0 0 0 0
XYZPts SetPoint 1 1 0 0
XYZPts SetPoint 2 0 1 0
XYZPts SetPoint 3 1 1 0
XYZPts SetPoint 4 0 0 1
XYZPts SetPoint 5 1 0 1
XYZPts SetPoint 6 0 1 1
XYZPts SetPoint 7 1 1 1
vtkStructuredGrid XYZGrid
XYZGrid SetDimensions 2 2 2
XYZGrid SetPoints XYZPts
XYZGrid GetCell 0
XYZGrid GetCell 0 cell
XYZGrid GetCellPoints 0 ptIds
vtkStructuredGridGeometryFilter XYZGeom
XYZGeom SetInput XYZGrid
XYZGeom SetExtent 0 2 0 2 0 2
vtkPolyDataMapper XYZMapper
XYZMapper SetInputConnection [XYZGeom GetOutputPort]
vtkActor XYZActor
XYZActor SetMapper XYZMapper
XYZActor SetPosition 6 2 0
ren1 AddActor XYZActor
# render the image
#
renWin SetSize 300 150
set cam1 [ren1 GetActiveCamera]
$cam1 SetClippingRange 2.27407 14.9819
$cam1 SetFocalPoint 3.1957 1.74012 0.176603
$cam1 SetPosition -0.380779 6.13894 5.59404
$cam1 SetViewUp 0.137568 0.811424 -0.568037
renWin Render
iren AddObserver UserEvent {wm deiconify .vtkInteract}
iren Initialize
# prevent the tk window from showing up then start the event loop
wm withdraw .
|