mirror of
https://github.com/OpenFOAM/ThirdParty-6.git
synced 2025-12-08 06:57:43 +00:00
ParaView-5.0.1: Added the source-tree to ThirdParty-dev and patched as described in the README file
Resolves bug-report http://bugs.openfoam.org/view.php?id=2098
This commit is contained in:
@ -0,0 +1,146 @@
|
||||
# In this example we show the use of the vtkBandedPolyDataContourFilter.
|
||||
# This filter creates separate, constant colored bands for a range of scalar
|
||||
# values. Each band is bounded by two scalar values, and the cell data laying
|
||||
# within the value has the same cell scalar value.
|
||||
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
package require vtktesting
|
||||
|
||||
# The lookup table is similar to that used by maps. Two hues are used: a
|
||||
# brown for land, and a blue for water. The value of the hue is changed to
|
||||
# give the effect of elevation.
|
||||
set Scale 5
|
||||
vtkLookupTable lutWater
|
||||
lutWater SetNumberOfColors 10
|
||||
lutWater SetHueRange 0.58 0.58
|
||||
lutWater SetSaturationRange 0.5 0.1
|
||||
lutWater SetValueRange 0.5 1.0
|
||||
lutWater Build
|
||||
vtkLookupTable lutLand
|
||||
lutLand SetNumberOfColors 10
|
||||
lutLand SetHueRange 0.1 0.1
|
||||
lutLand SetSaturationRange 0.4 0.1
|
||||
lutLand SetValueRange 0.55 0.9
|
||||
lutLand Build
|
||||
|
||||
|
||||
# The DEM reader reads data and creates an output image.
|
||||
vtkDEMReader demModel
|
||||
demModel SetFileName $VTK_DATA_ROOT/Data/SainteHelens.dem
|
||||
demModel Update
|
||||
|
||||
# We shrink the terrain data down a bit to yield better performance for
|
||||
# this example.
|
||||
set shrinkFactor 4
|
||||
vtkImageShrink3D shrink
|
||||
shrink SetShrinkFactors $shrinkFactor $shrinkFactor 1
|
||||
shrink SetInputConnection [demModel GetOutputPort]
|
||||
shrink AveragingOn
|
||||
|
||||
# Convert the image into polygons.
|
||||
vtkImageDataGeometryFilter geom
|
||||
geom SetInputConnection [shrink GetOutputPort]
|
||||
|
||||
# Warp the polygons based on elevation.
|
||||
vtkWarpScalar warp
|
||||
warp SetInputConnection [geom GetOutputPort]
|
||||
warp SetNormal 0 0 1
|
||||
warp UseNormalOn
|
||||
warp SetScaleFactor $Scale
|
||||
|
||||
# Create the contour bands.
|
||||
vtkBandedPolyDataContourFilter bcf
|
||||
bcf SetInputConnection [warp GetOutputPort]
|
||||
eval bcf GenerateValues 15 [[demModel GetOutput] GetScalarRange]
|
||||
bcf SetScalarModeToIndex
|
||||
bcf GenerateContourEdgesOn
|
||||
|
||||
# Compute normals to give a better look.
|
||||
vtkPolyDataNormals normals
|
||||
normals SetInputConnection [bcf GetOutputPort]
|
||||
normals SetFeatureAngle 60
|
||||
normals ConsistencyOff
|
||||
normals SplittingOff
|
||||
|
||||
vtkPolyDataMapper demMapper
|
||||
demMapper SetInputConnection [normals GetOutputPort]
|
||||
eval demMapper SetScalarRange 0 10
|
||||
demMapper SetLookupTable lutLand
|
||||
demMapper SetScalarModeToUseCellData
|
||||
|
||||
vtkLODActor demActor
|
||||
demActor SetMapper demMapper
|
||||
|
||||
## Create contour edges
|
||||
vtkPolyDataMapper edgeMapper
|
||||
edgeMapper SetInputConnection [bcf GetOutputPort]
|
||||
edgeMapper SetResolveCoincidentTopologyToPolygonOffset
|
||||
vtkActor edgeActor
|
||||
edgeActor SetMapper edgeMapper
|
||||
[edgeActor GetProperty] SetColor 0 0 0
|
||||
|
||||
## Test clipping
|
||||
# Create the contour bands.
|
||||
vtkBandedPolyDataContourFilter bcf2
|
||||
bcf2 SetInputConnection [warp GetOutputPort]
|
||||
bcf2 ClippingOn
|
||||
eval bcf2 GenerateValues 10 1000 2000
|
||||
bcf2 SetScalarModeToValue
|
||||
|
||||
# Compute normals to give a better look.
|
||||
vtkPolyDataNormals normals2
|
||||
normals2 SetInputConnection [bcf2 GetOutputPort]
|
||||
normals2 SetFeatureAngle 60
|
||||
normals2 ConsistencyOff
|
||||
normals2 SplittingOff
|
||||
|
||||
vtkLookupTable lut
|
||||
lut SetNumberOfColors 10
|
||||
vtkPolyDataMapper demMapper2
|
||||
demMapper2 SetInputConnection [normals2 GetOutputPort]
|
||||
eval demMapper2 SetScalarRange [[demModel GetOutput] GetScalarRange]
|
||||
demMapper2 SetLookupTable lut
|
||||
demMapper2 SetScalarModeToUseCellData
|
||||
|
||||
vtkLODActor demActor2
|
||||
demActor2 SetMapper demMapper2
|
||||
demActor2 AddPosition 0 15000 0
|
||||
|
||||
# Create the RenderWindow, Renderer and both Actors
|
||||
#
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
# Add the actors to the renderer, set the background and size
|
||||
#
|
||||
ren1 AddActor demActor
|
||||
ren1 AddActor demActor2
|
||||
ren1 AddActor edgeActor
|
||||
|
||||
ren1 SetBackground .4 .4 .4
|
||||
renWin SetSize 375 200
|
||||
|
||||
vtkCamera cam
|
||||
cam SetPosition -17438.8 2410.62 25470.8
|
||||
cam SetFocalPoint 3985.35 11930.6 5922.14
|
||||
cam SetViewUp 0 0 1
|
||||
ren1 SetActiveCamera cam
|
||||
ren1 ResetCamera
|
||||
cam Zoom 2
|
||||
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
iren SetDesiredUpdateRate 1
|
||||
|
||||
proc TkCheckAbort {} {
|
||||
set foo [renWin GetEventPending]
|
||||
if {$foo != 0} {renWin SetAbortRender 1}
|
||||
}
|
||||
renWin AddObserver AbortCheckEvent {TkCheckAbort}
|
||||
renWin Render
|
||||
|
||||
wm withdraw .
|
||||
iren Start
|
||||
@ -0,0 +1,125 @@
|
||||
# In this example vtkClipPolyData is used to cut a polygonal model
|
||||
# of a cow in half. In addition, the open clip is closed by triangulating
|
||||
# the resulting complex polygons.
|
||||
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
package require vtktesting
|
||||
|
||||
# First start by reading a cow model. We also generate surface normals for
|
||||
# prettier rendering.
|
||||
vtkBYUReader cow
|
||||
cow SetGeometryFileName "$VTK_DATA_ROOT/Data/Viewpoint/cow.g"
|
||||
vtkPolyDataNormals cowNormals
|
||||
cowNormals SetInputConnection [cow GetOutputPort]
|
||||
|
||||
# We clip with an implicit function. Here we use a plane positioned near
|
||||
# the center of the cow model and oriented at an arbitrary angle.
|
||||
vtkPlane plane
|
||||
plane SetOrigin 0.25 0 0
|
||||
plane SetNormal -1 -1 0
|
||||
|
||||
# vtkClipPolyData requires an implicit function to define what it is to
|
||||
# clip with. Any implicit function, including complex boolean combinations
|
||||
# can be used. Notice that we can specify the value of the implicit function
|
||||
# with the SetValue method.
|
||||
vtkClipPolyData clipper
|
||||
clipper SetInputConnection [cowNormals GetOutputPort]
|
||||
clipper SetClipFunction plane
|
||||
clipper GenerateClipScalarsOn
|
||||
clipper GenerateClippedOutputOn
|
||||
clipper SetValue 0.5
|
||||
vtkPolyDataMapper clipMapper
|
||||
clipMapper SetInputConnection [clipper GetOutputPort]
|
||||
clipMapper ScalarVisibilityOff
|
||||
vtkProperty backProp
|
||||
eval backProp SetDiffuseColor $tomato
|
||||
vtkActor clipActor
|
||||
clipActor SetMapper clipMapper
|
||||
eval [clipActor GetProperty] SetColor $peacock
|
||||
clipActor SetBackfaceProperty backProp
|
||||
|
||||
# Here we are cutting the cow. Cutting creates lines where the cut function
|
||||
# intersects the model. (Clipping removes a portion of the model but the
|
||||
# dimension of the data does not change.)
|
||||
#
|
||||
# The reason we are cutting is to generate a closed polygon at the boundary
|
||||
# of the clipping process. The cutter generates line segments, the stripper
|
||||
# then puts them together into polylines. We then pull a trick and define
|
||||
# polygons using the closed line segements that the stripper created.
|
||||
#
|
||||
vtkCutter cutEdges; #Generate cut lines
|
||||
cutEdges SetInputConnection [cowNormals GetOutputPort]
|
||||
cutEdges SetCutFunction plane
|
||||
cutEdges GenerateCutScalarsOn
|
||||
cutEdges SetValue 0 0.5
|
||||
vtkStripper cutStrips; #Forms loops (closed polylines) from cutter
|
||||
cutStrips SetInputConnection [cutEdges GetOutputPort]
|
||||
cutStrips Update
|
||||
vtkPolyData cutPoly; #This trick defines polygons as polyline loop
|
||||
cutPoly SetPoints [[cutStrips GetOutput] GetPoints]
|
||||
cutPoly SetPolys [[cutStrips GetOutput] GetLines]
|
||||
|
||||
# Triangle filter is robust enough to ignore the duplicate point at the
|
||||
# beginning and end of the polygons and triangulate them.
|
||||
vtkTriangleFilter cutTriangles
|
||||
cutTriangles SetInputData cutPoly
|
||||
vtkPolyDataMapper cutMapper
|
||||
cutMapper SetInputData cutPoly
|
||||
cutMapper SetInputConnection [cutTriangles GetOutputPort]
|
||||
vtkActor cutActor
|
||||
cutActor SetMapper cutMapper
|
||||
eval [cutActor GetProperty] SetColor $peacock
|
||||
|
||||
# The clipped part of the cow is rendered wireframe.
|
||||
vtkPolyDataMapper restMapper
|
||||
restMapper SetInputConnection [clipper GetClippedOutputPort]
|
||||
restMapper ScalarVisibilityOff
|
||||
vtkActor restActor
|
||||
restActor SetMapper restMapper
|
||||
[restActor GetProperty] SetRepresentationToWireframe
|
||||
|
||||
# Create graphics stuff
|
||||
#
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
# Add the actors to the renderer, set the background and size
|
||||
ren1 AddActor clipActor
|
||||
ren1 AddActor cutActor
|
||||
ren1 AddActor restActor
|
||||
ren1 SetBackground 1 1 1
|
||||
ren1 ResetCamera
|
||||
[ren1 GetActiveCamera] Azimuth 30
|
||||
[ren1 GetActiveCamera] Elevation 30
|
||||
[ren1 GetActiveCamera] Dolly 1.5
|
||||
ren1 ResetCameraClippingRange
|
||||
|
||||
renWin SetSize 300 300
|
||||
iren Initialize
|
||||
|
||||
# render the image
|
||||
#
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
|
||||
# prevent the tk window from showing up then start the event loop
|
||||
wm withdraw .
|
||||
|
||||
# Lets you move the cut plane back and forth by invoking the proc Cut with
|
||||
# the appropriate plane value (essentially a distance from the original
|
||||
# plane.
|
||||
#
|
||||
proc Cut {v} {
|
||||
clipper SetValue $v
|
||||
cutEdges SetValue 0 $v
|
||||
cutStrips Update
|
||||
cutPoly SetPoints [[cutStrips GetOutput] GetPoints]
|
||||
cutPoly SetPolys [[cutStrips GetOutput] GetLines]
|
||||
cutMapper Update
|
||||
renWin Render
|
||||
}
|
||||
|
||||
iren Start
|
||||
@ -0,0 +1,87 @@
|
||||
# This example shows how to color an isosurface with other data. Basically
|
||||
# an isosurface is generated, and a data array is selected and used by the
|
||||
# mapper to color the surface.
|
||||
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
|
||||
# Read some data. The important thing here is to read a function as a data
|
||||
# array as well as the scalar and vector. (here function 153 is named
|
||||
# "Velocity Magnitude").Later this data array will be used to color the
|
||||
# isosurface.
|
||||
#
|
||||
vtkMultiBlockPLOT3DReader pl3d
|
||||
pl3d SetXYZFileName "$VTK_DATA_ROOT/Data/combxyz.bin"
|
||||
pl3d SetQFileName "$VTK_DATA_ROOT/Data/combq.bin"
|
||||
pl3d SetScalarFunctionNumber 100
|
||||
pl3d SetVectorFunctionNumber 202
|
||||
pl3d AddFunction 153
|
||||
pl3d Update
|
||||
pl3d DebugOn
|
||||
|
||||
set pl3dOutput [[pl3d GetOutput] GetBlock 0 ]
|
||||
|
||||
# The contoru filter uses the labeled scalar (function number 100
|
||||
# above to generate the contour surface; all other data is interpolated
|
||||
# during the contouring process.
|
||||
#
|
||||
vtkContourFilter iso
|
||||
iso SetInputData $pl3dOutput
|
||||
iso SetValue 0 .24
|
||||
|
||||
vtkPolyDataNormals normals
|
||||
normals SetInputConnection [iso GetOutputPort]
|
||||
normals SetFeatureAngle 45
|
||||
|
||||
# We indicate to the mapper to use the velcoity magnitude, which is a
|
||||
# vtkDataArray that makes up part of the point attribute data.
|
||||
#
|
||||
vtkPolyDataMapper isoMapper
|
||||
isoMapper SetInputConnection [normals GetOutputPort]
|
||||
isoMapper ScalarVisibilityOn
|
||||
isoMapper SetScalarRange 0 1500
|
||||
isoMapper SetScalarModeToUsePointFieldData
|
||||
isoMapper ColorByArrayComponent "VelocityMagnitude" 0
|
||||
|
||||
vtkLODActor isoActor
|
||||
isoActor SetMapper isoMapper
|
||||
isoActor SetNumberOfCloudPoints 1000
|
||||
|
||||
vtkStructuredGridOutlineFilter outline
|
||||
outline SetInputData $pl3dOutput
|
||||
vtkPolyDataMapper outlineMapper
|
||||
outlineMapper SetInputConnection [outline GetOutputPort]
|
||||
vtkActor outlineActor
|
||||
outlineActor SetMapper outlineMapper
|
||||
|
||||
# Create the usual rendering stuff.
|
||||
#
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
# Add the actors to the renderer, set the background and size
|
||||
#
|
||||
ren1 AddActor outlineActor
|
||||
ren1 AddActor isoActor
|
||||
ren1 SetBackground 1 1 1
|
||||
renWin SetSize 500 500
|
||||
ren1 SetBackground 0.1 0.2 0.4
|
||||
|
||||
set cam1 [ren1 GetActiveCamera]
|
||||
$cam1 SetClippingRange 3.95297 50
|
||||
$cam1 SetFocalPoint 9.71821 0.458166 29.3999
|
||||
$cam1 SetPosition 2.7439 -37.3196 38.7167
|
||||
$cam1 SetViewUp -0.16123 0.264271 0.950876
|
||||
|
||||
# render the image
|
||||
#
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
renWin Render
|
||||
|
||||
# prevent the tk window from showing up then start the event loop
|
||||
wm withdraw .
|
||||
iren Start
|
||||
|
||||
@ -0,0 +1,89 @@
|
||||
# This example shows how to use cutting (vtkCutter) and how it compares
|
||||
# with extracting a plane from a computational grid.
|
||||
#
|
||||
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
|
||||
# Read some data.
|
||||
vtkMultiBlockPLOT3DReader pl3d
|
||||
pl3d SetXYZFileName "$VTK_DATA_ROOT/Data/combxyz.bin"
|
||||
pl3d SetQFileName "$VTK_DATA_ROOT/Data/combq.bin"
|
||||
pl3d SetScalarFunctionNumber 100
|
||||
pl3d SetVectorFunctionNumber 202
|
||||
pl3d Update
|
||||
|
||||
set pl3dOutput [[pl3d GetOutput] GetBlock 0 ]
|
||||
|
||||
# The cutter uses an implicit function to perform the cutting.
|
||||
# Here we define a plane, specifying its center and normal.
|
||||
# Then we assign the plane to the cutter.
|
||||
vtkPlane plane
|
||||
eval plane SetOrigin [$pl3dOutput GetCenter]
|
||||
plane SetNormal -0.287 0 0.9579
|
||||
vtkCutter planeCut
|
||||
planeCut SetInputData $pl3dOutput
|
||||
planeCut SetCutFunction plane
|
||||
vtkPolyDataMapper cutMapper
|
||||
cutMapper SetInputConnection [planeCut GetOutputPort]
|
||||
eval cutMapper SetScalarRange \
|
||||
[[[$pl3dOutput GetPointData] GetScalars] GetRange]
|
||||
vtkActor cutActor
|
||||
cutActor SetMapper cutMapper
|
||||
|
||||
# Here we extract a computational plane from the structured grid.
|
||||
# We render it as wireframe.
|
||||
vtkStructuredGridGeometryFilter compPlane
|
||||
compPlane SetInputData $pl3dOutput
|
||||
compPlane SetExtent 0 100 0 100 9 9
|
||||
vtkPolyDataMapper planeMapper
|
||||
planeMapper SetInputConnection [compPlane GetOutputPort]
|
||||
planeMapper ScalarVisibilityOff
|
||||
vtkActor planeActor
|
||||
planeActor SetMapper planeMapper
|
||||
[planeActor GetProperty] SetRepresentationToWireframe
|
||||
[planeActor GetProperty] SetColor 0 0 0
|
||||
|
||||
# The outline of the data puts the data in context.
|
||||
vtkStructuredGridOutlineFilter outline
|
||||
outline SetInputData $pl3dOutput
|
||||
vtkPolyDataMapper outlineMapper
|
||||
outlineMapper SetInputConnection [outline GetOutputPort]
|
||||
vtkActor outlineActor
|
||||
outlineActor SetMapper outlineMapper
|
||||
set outlineProp [outlineActor GetProperty]
|
||||
eval $outlineProp SetColor 0 0 0
|
||||
|
||||
# Create the RenderWindow, Renderer and both Actors
|
||||
#
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
# Add the actors to the renderer, set the background and size
|
||||
#
|
||||
ren1 AddActor outlineActor
|
||||
ren1 AddActor planeActor
|
||||
ren1 AddActor cutActor
|
||||
|
||||
ren1 SetBackground 1 1 1
|
||||
renWin SetSize 400 300
|
||||
|
||||
set cam1 [ren1 GetActiveCamera]
|
||||
$cam1 SetClippingRange 11.1034 59.5328
|
||||
$cam1 SetFocalPoint 9.71821 0.458166 29.3999
|
||||
$cam1 SetPosition -2.95748 -26.7271 44.5309
|
||||
$cam1 SetViewUp 0.0184785 0.479657 0.877262
|
||||
iren Initialize
|
||||
|
||||
# render the image
|
||||
#
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
|
||||
# prevent the tk window from showing up then start the event loop
|
||||
wm withdraw .
|
||||
iren Start
|
||||
|
||||
|
||||
@ -0,0 +1,96 @@
|
||||
# This example demonstrates the use of vtkDepthSortPolyData. This is a
|
||||
# poor man's algorithm to sort polygons for proper transparent blending.
|
||||
# It sorts polygons based on a single point (i.e., centroid) so the sorting
|
||||
# may not work for overlapping or intersection polygons.
|
||||
#
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
|
||||
# Create a bunch of spheres that overlap and cannot be easily arranged
|
||||
# so that the blending works without sorting. They are appended into a
|
||||
# single vtkPolyData because the filter only sorts within a single
|
||||
# vtkPolyData input.
|
||||
#
|
||||
vtkSphereSource sphere
|
||||
sphere SetThetaResolution 80
|
||||
sphere SetPhiResolution 40
|
||||
sphere SetRadius 1
|
||||
sphere SetCenter 0 0 0
|
||||
vtkSphereSource sphere2
|
||||
sphere2 SetThetaResolution 80
|
||||
sphere2 SetPhiResolution 40
|
||||
sphere2 SetRadius 0.5
|
||||
sphere2 SetCenter 1 0 0
|
||||
vtkSphereSource sphere3
|
||||
sphere3 SetThetaResolution 80
|
||||
sphere3 SetPhiResolution 40
|
||||
sphere3 SetRadius 0.5
|
||||
sphere3 SetCenter -1 0 0
|
||||
vtkSphereSource sphere4
|
||||
sphere4 SetThetaResolution 80
|
||||
sphere4 SetPhiResolution 40
|
||||
sphere4 SetRadius 0.5
|
||||
sphere4 SetCenter 0 1 0
|
||||
vtkSphereSource sphere5
|
||||
sphere5 SetThetaResolution 80
|
||||
sphere5 SetPhiResolution 40
|
||||
sphere5 SetRadius 0.5
|
||||
sphere5 SetCenter 0 -1 0
|
||||
vtkAppendPolyData appendData
|
||||
appendData AddInputConnection [sphere GetOutputPort]
|
||||
appendData AddInputConnection [sphere2 GetOutputPort]
|
||||
appendData AddInputConnection [sphere3 GetOutputPort]
|
||||
appendData AddInputConnection [sphere4 GetOutputPort]
|
||||
appendData AddInputConnection [sphere5 GetOutputPort]
|
||||
|
||||
# The dephSort object is set up to generate scalars representing
|
||||
# the sort depth. A camera is assigned for the sorting. The camera
|
||||
# define the sort vector (position and focal point).
|
||||
vtkCamera camera
|
||||
vtkDepthSortPolyData depthSort
|
||||
depthSort SetInputConnection [appendData GetOutputPort]
|
||||
depthSort SetDirectionToBackToFront
|
||||
depthSort SetVector 1 1 1
|
||||
depthSort SetCamera camera
|
||||
depthSort SortScalarsOn
|
||||
depthSort Update
|
||||
|
||||
vtkPolyDataMapper mapper
|
||||
mapper SetInputConnection [depthSort GetOutputPort]
|
||||
mapper SetScalarRange 0 [[depthSort GetOutput] GetNumberOfCells]
|
||||
vtkActor actor
|
||||
actor SetMapper mapper
|
||||
[actor GetProperty] SetOpacity 0.5
|
||||
[actor GetProperty] SetColor 1 0 0
|
||||
actor RotateX -72
|
||||
|
||||
# If an Prop3D is supplied, then its transformation matrix is taken
|
||||
# into account during sorting.
|
||||
depthSort SetProp3D actor
|
||||
|
||||
# Create the RenderWindow, Renderer and both Actors
|
||||
#
|
||||
vtkRenderer ren1
|
||||
ren1 SetActiveCamera camera
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
# Add the actors to the renderer, set the background and size
|
||||
#
|
||||
ren1 AddActor actor
|
||||
ren1 SetBackground 1 1 1
|
||||
renWin SetSize 300 200
|
||||
|
||||
# render the image
|
||||
#
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
ren1 ResetCamera
|
||||
[ren1 GetActiveCamera] Zoom 2.2
|
||||
renWin Render
|
||||
|
||||
# prevent the tk window from showing up then start the event loop
|
||||
wm withdraw .
|
||||
|
||||
iren Start
|
||||
@ -0,0 +1,80 @@
|
||||
# This example shows how to extract a piece of a dataset using an implicit
|
||||
# function. In this case the implicit function is formed by the boolean
|
||||
# combination of two ellipsoids.
|
||||
#
|
||||
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
|
||||
# Here we create two ellipsoidal implicit functions and boolean them
|
||||
# together tto form a "cross" shaped implicit function.
|
||||
vtkQuadric quadric
|
||||
quadric SetCoefficients .5 1 .2 0 .1 0 0 .2 0 0
|
||||
vtkSampleFunction sample
|
||||
sample SetSampleDimensions 50 50 50
|
||||
sample SetImplicitFunction quadric
|
||||
sample ComputeNormalsOff
|
||||
vtkTransform trans
|
||||
trans Scale 1 .5 .333
|
||||
vtkSphere sphere
|
||||
sphere SetRadius 0.25
|
||||
sphere SetTransform trans
|
||||
vtkTransform trans2
|
||||
trans2 Scale .25 .5 1.0
|
||||
vtkSphere sphere2
|
||||
sphere2 SetRadius 0.25
|
||||
sphere2 SetTransform trans2
|
||||
vtkImplicitBoolean union
|
||||
union AddFunction sphere
|
||||
union AddFunction sphere2
|
||||
union SetOperationType 0;#union
|
||||
|
||||
|
||||
# Here is where it gets interesting. The implicit function is used to
|
||||
# extract those cells completely inside the function. They are then
|
||||
# shrunk to help show what was extracted.
|
||||
vtkExtractGeometry extract
|
||||
extract SetInputConnection [sample GetOutputPort]
|
||||
extract SetImplicitFunction union
|
||||
vtkShrinkFilter shrink
|
||||
shrink SetInputConnection [extract GetOutputPort]
|
||||
shrink SetShrinkFactor 0.5
|
||||
vtkDataSetMapper dataMapper
|
||||
dataMapper SetInputConnection [shrink GetOutputPort]
|
||||
vtkActor dataActor
|
||||
dataActor SetMapper dataMapper
|
||||
|
||||
# The outline gives context to the original data.
|
||||
vtkOutlineFilter outline
|
||||
outline SetInputConnection [sample GetOutputPort]
|
||||
vtkPolyDataMapper outlineMapper
|
||||
outlineMapper SetInputConnection [outline GetOutputPort]
|
||||
vtkActor outlineActor
|
||||
outlineActor SetMapper outlineMapper
|
||||
set outlineProp [outlineActor GetProperty]
|
||||
eval $outlineProp SetColor 0 0 0
|
||||
|
||||
# The usual rendering stuff is created.
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
# Add the actors to the renderer, set the background and size
|
||||
#
|
||||
ren1 AddActor outlineActor
|
||||
ren1 AddActor dataActor
|
||||
ren1 SetBackground 1 1 1
|
||||
renWin SetSize 500 500
|
||||
ren1 ResetCamera
|
||||
[ren1 GetActiveCamera] Zoom 1.5
|
||||
iren Initialize
|
||||
|
||||
# render the image
|
||||
#
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
|
||||
# prevent the tk window from showing up then start the event loop
|
||||
wm withdraw .
|
||||
iren Start
|
||||
@ -0,0 +1,90 @@
|
||||
# This example shows how to extract portions of an unstructured grid
|
||||
# using vtkExtractUnstructuredGrid. vtkConnectivityFilter is also used
|
||||
# to extract connected components.
|
||||
#
|
||||
# The data found here represents a blow molding process. Blow molding
|
||||
# requires a mold and parison (hot, viscous plastic) which is shaped
|
||||
# by the mold into the final form. The data file contains several steps
|
||||
# in time for the analysis.
|
||||
#
|
||||
|
||||
package require vtk
|
||||
|
||||
# Create a reader to read the unstructured grid data. We use a
|
||||
# vtkDataSetReader which means the type of the output is unknown until
|
||||
# the data file is read. SO we follow the reader with a vtkCastToConcrete
|
||||
# and cast the output to vtkUnstructuredGrid.
|
||||
vtkDataSetReader reader
|
||||
reader SetFileName "$VTK_DATA_ROOT/Data/blow.vtk"
|
||||
reader SetScalarsName "thickness9"
|
||||
reader SetVectorsName "displacement9"
|
||||
vtkCastToConcrete castToUnstructuredGrid
|
||||
castToUnstructuredGrid SetInputConnection [reader GetOutputPort]
|
||||
vtkWarpVector warp
|
||||
warp SetInputConnection [castToUnstructuredGrid GetOutputPort]
|
||||
|
||||
# The connectivity filter extracts the first two regions. These are
|
||||
# know to represent the mold.
|
||||
vtkConnectivityFilter connect
|
||||
connect SetInputConnection [warp GetOutputPort]
|
||||
connect SetExtractionModeToSpecifiedRegions
|
||||
connect AddSpecifiedRegion 0
|
||||
connect AddSpecifiedRegion 1
|
||||
vtkDataSetMapper moldMapper
|
||||
moldMapper SetInputConnection [reader GetOutputPort]
|
||||
moldMapper ScalarVisibilityOff
|
||||
vtkActor moldActor
|
||||
moldActor SetMapper moldMapper
|
||||
[moldActor GetProperty] SetColor .2 .2 .2
|
||||
[moldActor GetProperty] SetRepresentationToWireframe
|
||||
|
||||
# Another connectivity filter is used to extract the parison.
|
||||
vtkConnectivityFilter connect2
|
||||
connect2 SetInputConnection [warp GetOutputPort]
|
||||
connect2 SetExtractionModeToSpecifiedRegions
|
||||
connect2 AddSpecifiedRegion 2
|
||||
# We use vtkExtractUnstructuredGrid because we are interested in
|
||||
# looking at just a few cells. We use cell clipping via cell id to
|
||||
# extract the portion of the grid we are interested in.
|
||||
vtkExtractUnstructuredGrid extractGrid
|
||||
extractGrid SetInputConnection [connect2 GetOutputPort]
|
||||
extractGrid CellClippingOn
|
||||
extractGrid SetCellMinimum 0
|
||||
extractGrid SetCellMaximum 23
|
||||
vtkGeometryFilter parison
|
||||
parison SetInputConnection [extractGrid GetOutputPort]
|
||||
vtkPolyDataNormals normals2
|
||||
normals2 SetInputConnection [parison GetOutputPort]
|
||||
normals2 SetFeatureAngle 60
|
||||
vtkLookupTable lut
|
||||
lut SetHueRange 0.0 0.66667
|
||||
vtkPolyDataMapper parisonMapper
|
||||
parisonMapper SetInputConnection [normals2 GetOutputPort]
|
||||
parisonMapper SetLookupTable lut
|
||||
parisonMapper SetScalarRange 0.12 1.0
|
||||
vtkActor parisonActor
|
||||
parisonActor SetMapper parisonMapper
|
||||
|
||||
# graphics stuff
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
# Add the actors to the renderer, set the background and size
|
||||
#
|
||||
ren1 AddActor parisonActor
|
||||
ren1 AddActor moldActor
|
||||
ren1 SetBackground 1 1 1
|
||||
ren1 ResetCamera
|
||||
[ren1 GetActiveCamera] Azimuth 60
|
||||
[ren1 GetActiveCamera] Roll -90
|
||||
[ren1 GetActiveCamera] Dolly 2
|
||||
ren1 ResetCameraClippingRange
|
||||
renWin SetSize 500 375
|
||||
iren Initialize
|
||||
|
||||
# prevent the tk window from showing up then start the event loop
|
||||
wm withdraw .
|
||||
iren Start
|
||||
@ -0,0 +1,73 @@
|
||||
# This example shows how to generate and manipulate texture coordinates.
|
||||
# A random cloud of points is generated and then triangulated with
|
||||
# vtkDelaunay3D. Since these points do not have texture coordinates,
|
||||
# we generate them with vtkTextureMapToCylinder.
|
||||
|
||||
package require vtk
|
||||
|
||||
# Begin by generating 25 random points in the unit sphere.
|
||||
#
|
||||
vtkPointSource sphere
|
||||
sphere SetNumberOfPoints 25
|
||||
|
||||
# Triangulate the points with vtkDelaunay3D. This generates a convex hull
|
||||
# of tetrahedron.
|
||||
#
|
||||
vtkDelaunay3D del
|
||||
del SetInputConnection [sphere GetOutputPort]
|
||||
del SetTolerance 0.01
|
||||
|
||||
# The triangulation has texture coordinates generated so we can map
|
||||
# a texture onto it.
|
||||
#
|
||||
vtkTextureMapToCylinder tmapper
|
||||
tmapper SetInputConnection [del GetOutputPort]
|
||||
tmapper PreventSeamOn
|
||||
|
||||
# We scale the texture coordinate to get some repeat patterns.
|
||||
vtkTransformTextureCoords xform
|
||||
xform SetInputConnection [tmapper GetOutputPort]
|
||||
xform SetScale 4 4 1
|
||||
|
||||
# vtkDataSetMapper internally uses a vtkGeometryFilter to extract the
|
||||
# surface from the triangulation. The output (which is vtkPolyData) is
|
||||
# then passed to an internal vtkPolyDataMapper which does the
|
||||
# rendering.
|
||||
vtkDataSetMapper mapper
|
||||
mapper SetInputConnection [xform GetOutputPort]
|
||||
|
||||
# A texture is loaded using an image reader. Textures are simply images.
|
||||
# The texture is eventually associated with an actor.
|
||||
#
|
||||
vtkBMPReader bmpReader
|
||||
bmpReader SetFileName "$VTK_DATA_ROOT/Data/masonry.bmp"
|
||||
vtkTexture atext
|
||||
atext SetInputConnection [bmpReader GetOutputPort]
|
||||
atext InterpolateOn
|
||||
vtkActor triangulation
|
||||
triangulation SetMapper mapper
|
||||
triangulation SetTexture atext
|
||||
|
||||
# Create the standard rendering stuff.
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
# Add the actors to the renderer, set the background and size
|
||||
#
|
||||
ren1 AddActor triangulation
|
||||
ren1 SetBackground 1 1 1
|
||||
renWin SetSize 300 300
|
||||
renWin Render
|
||||
|
||||
# render the image
|
||||
#
|
||||
renWin Render
|
||||
|
||||
# prevent the tk window from showing up then start the event loop
|
||||
wm withdraw .
|
||||
|
||||
iren Start
|
||||
|
||||
@ -0,0 +1,80 @@
|
||||
# This example demonstrates the subsampling of a structured grid.
|
||||
|
||||
#
|
||||
# First we include the VTK Tcl packages which will make available
|
||||
# all of the vtk commands from Tcl. The vtkinteraction package defines
|
||||
# a simple Tcl/Tk interactor widget.
|
||||
#
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
|
||||
# Read some structured data.
|
||||
#
|
||||
vtkMultiBlockPLOT3DReader pl3d
|
||||
pl3d SetXYZFileName "$VTK_DATA_ROOT/Data/combxyz.bin"
|
||||
pl3d SetQFileName "$VTK_DATA_ROOT/Data/combq.bin"
|
||||
pl3d SetScalarFunctionNumber 100
|
||||
pl3d SetVectorFunctionNumber 202
|
||||
pl3d Update
|
||||
|
||||
set pl3dOutput [[pl3d GetOutput] GetBlock 0]
|
||||
|
||||
# Here we subsample the grid. The SetVOI method requires six values
|
||||
# specifying (imin,imax, jmin,jmax, kmin,kmax) extents. In this example
|
||||
# we extracting a plane. Note that the VOI is clamped to zero (min) and
|
||||
# the maximum i-j-k value; that way we can use the -1000,1000 specification
|
||||
# and be sure the values are clamped. The SampleRate specifies that we take
|
||||
# every point in the i-direction; every other point in the j-direction; and
|
||||
# every third point in the k-direction. IncludeBoundaryOn makes sure that we
|
||||
# get the boundary points even if the SampleRate does not coincident with
|
||||
# the boundary.
|
||||
#
|
||||
vtkExtractGrid extract
|
||||
extract SetInputData $pl3dOutput
|
||||
extract SetVOI 30 30 -1000 1000 -1000 1000
|
||||
extract SetSampleRate 1 2 3
|
||||
extract IncludeBoundaryOn
|
||||
vtkDataSetMapper mapper
|
||||
mapper SetInputConnection [extract GetOutputPort]
|
||||
mapper SetScalarRange .18 .7
|
||||
vtkActor actor
|
||||
actor SetMapper mapper
|
||||
|
||||
vtkStructuredGridOutlineFilter outline
|
||||
outline SetInputData $pl3dOutput
|
||||
vtkPolyDataMapper outlineMapper
|
||||
outlineMapper SetInputConnection [outline GetOutputPort]
|
||||
vtkActor outlineActor
|
||||
outlineActor SetMapper outlineMapper
|
||||
[outlineActor GetProperty] SetColor 0 0 0
|
||||
|
||||
# Add the usual rendering stuff.
|
||||
#
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
# Add the actors to the renderer, set the background and size
|
||||
#
|
||||
ren1 AddActor outlineActor
|
||||
ren1 AddActor actor
|
||||
|
||||
ren1 SetBackground 1 1 1
|
||||
renWin SetSize 300 180
|
||||
|
||||
set cam1 [ren1 GetActiveCamera]
|
||||
$cam1 SetClippingRange 2.64586 47.905
|
||||
$cam1 SetFocalPoint 8.931 0.358127 31.3526
|
||||
$cam1 SetPosition 29.7111 -0.688615 37.1495
|
||||
$cam1 SetViewUp -0.268328 0.00801595 0.963294
|
||||
|
||||
# render the image
|
||||
#
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
renWin Render
|
||||
|
||||
# prevent the tk window from showing up then start the event loop
|
||||
wm withdraw .
|
||||
iren Start
|
||||
@ -0,0 +1,154 @@
|
||||
# Load libraries for VTK
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
package require vtktesting
|
||||
|
||||
# This example shows how to use a transparent texture map to perform
|
||||
# thresholding. The key is the vtkThresholdTextureCoords filter which
|
||||
# creates texture coordinates based on a threshold value. These texture
|
||||
# coordinates are used in conjuntion with a texture map with varying
|
||||
# opacity and intensity to create an inside, transition, and outside
|
||||
# region.
|
||||
#
|
||||
|
||||
# Begin by reading some structure grid data.
|
||||
vtkMultiBlockPLOT3DReader pl3d
|
||||
pl3d SetXYZFileName "$VTK_DATA_ROOT/Data/bluntfinxyz.bin"
|
||||
pl3d SetQFileName "$VTK_DATA_ROOT/Data/bluntfinq.bin"
|
||||
pl3d SetScalarFunctionNumber 100
|
||||
pl3d SetVectorFunctionNumber 202
|
||||
pl3d Update
|
||||
|
||||
set pl3dOutput [[pl3d GetOutput] GetBlock 0]
|
||||
|
||||
# Now extract surfaces from the grid corresponding to boundary geometry.
|
||||
# First the wall.
|
||||
vtkStructuredGridGeometryFilter wall
|
||||
wall SetInputData $pl3dOutput
|
||||
wall SetExtent 0 100 0 0 0 100
|
||||
vtkPolyDataMapper wallMap
|
||||
wallMap SetInputConnection [wall GetOutputPort]
|
||||
wallMap ScalarVisibilityOff
|
||||
vtkActor wallActor
|
||||
wallActor SetMapper wallMap
|
||||
eval [wallActor GetProperty] SetColor 0.8 0.8 0.8
|
||||
|
||||
# Now the fin.
|
||||
#
|
||||
vtkStructuredGridGeometryFilter fin
|
||||
fin SetInputData $pl3dOutput
|
||||
fin SetExtent 0 100 0 100 0 0
|
||||
vtkPolyDataMapper finMap
|
||||
finMap SetInputConnection [fin GetOutputPort]
|
||||
finMap ScalarVisibilityOff
|
||||
vtkActor finActor
|
||||
finActor SetMapper finMap
|
||||
eval [finActor GetProperty] SetColor 0.8 0.8 0.8
|
||||
|
||||
# Extract planes to threshold. Start by reading the specially
|
||||
# designed texture map that has three regions: an inside, boundary,
|
||||
# and outside region. The opacity and intensity of this texture map
|
||||
# are varied.
|
||||
vtkStructuredPointsReader tmap
|
||||
tmap SetFileName "$VTK_DATA_ROOT/Data/texThres2.vtk"
|
||||
vtkTexture texture
|
||||
texture SetInputConnection [tmap GetOutputPort]
|
||||
texture InterpolateOff
|
||||
texture RepeatOff
|
||||
|
||||
# Here are the three planes which will be texture thresholded.
|
||||
#
|
||||
vtkStructuredGridGeometryFilter plane1
|
||||
plane1 SetInputData $pl3dOutput
|
||||
plane1 SetExtent 10 10 0 100 0 100
|
||||
vtkThresholdTextureCoords thresh1
|
||||
thresh1 SetInputConnection [plane1 GetOutputPort]
|
||||
thresh1 ThresholdByUpper 1.5
|
||||
vtkDataSetMapper plane1Map
|
||||
plane1Map SetInputConnection [thresh1 GetOutputPort]
|
||||
eval plane1Map SetScalarRange [$pl3dOutput GetScalarRange]
|
||||
vtkActor plane1Actor
|
||||
plane1Actor SetMapper plane1Map
|
||||
plane1Actor SetTexture texture
|
||||
[plane1Actor GetProperty] SetOpacity 0.999
|
||||
|
||||
vtkStructuredGridGeometryFilter plane2
|
||||
plane2 SetInputData $pl3dOutput
|
||||
plane2 SetExtent 30 30 0 100 0 100
|
||||
vtkThresholdTextureCoords thresh2
|
||||
thresh2 SetInputConnection [plane2 GetOutputPort]
|
||||
thresh2 ThresholdByUpper 1.5
|
||||
vtkDataSetMapper plane2Map
|
||||
plane2Map SetInputConnection [thresh2 GetOutputPort]
|
||||
eval plane2Map SetScalarRange [$pl3dOutput GetScalarRange]
|
||||
vtkActor plane2Actor
|
||||
plane2Actor SetMapper plane2Map
|
||||
plane2Actor SetTexture texture
|
||||
[plane2Actor GetProperty] SetOpacity 0.999
|
||||
|
||||
vtkStructuredGridGeometryFilter plane3
|
||||
plane3 SetInputData $pl3dOutput
|
||||
plane3 SetExtent 35 35 0 100 0 100
|
||||
vtkThresholdTextureCoords thresh3
|
||||
thresh3 SetInputConnection [plane3 GetOutputPort]
|
||||
thresh3 ThresholdByUpper 1.5
|
||||
vtkDataSetMapper plane3Map
|
||||
plane3Map SetInputConnection [thresh3 GetOutputPort]
|
||||
eval plane3Map SetScalarRange [$pl3dOutput GetScalarRange]
|
||||
vtkActor plane3Actor
|
||||
plane3Actor SetMapper plane3Map
|
||||
plane3Actor SetTexture texture
|
||||
[plane3Actor GetProperty] SetOpacity 0.999
|
||||
|
||||
# For context create an outline around the data.
|
||||
#
|
||||
vtkStructuredGridOutlineFilter outline
|
||||
outline SetInputData $pl3dOutput
|
||||
vtkPolyDataMapper outlineMapper
|
||||
outlineMapper SetInputConnection [outline GetOutputPort]
|
||||
vtkActor outlineActor
|
||||
outlineActor SetMapper outlineMapper
|
||||
set outlineProp [outlineActor GetProperty]
|
||||
eval $outlineProp SetColor 0 0 0
|
||||
|
||||
# Create the RenderWindow, Renderer and both Actors
|
||||
#
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
# Add the actors to the renderer, set the background and size
|
||||
#
|
||||
ren1 AddActor outlineActor
|
||||
ren1 AddActor wallActor
|
||||
ren1 AddActor finActor
|
||||
ren1 AddActor plane1Actor
|
||||
ren1 AddActor plane2Actor
|
||||
ren1 AddActor plane3Actor
|
||||
ren1 SetBackground 1 1 1
|
||||
renWin SetSize 500 500
|
||||
|
||||
# Set up a nice view.
|
||||
#
|
||||
vtkCamera cam1
|
||||
cam1 SetClippingRange 1.51176 75.5879
|
||||
cam1 SetFocalPoint 2.33749 2.96739 3.61023
|
||||
cam1 SetPosition 10.8787 5.27346 15.8687
|
||||
cam1 SetViewAngle 30
|
||||
cam1 SetViewUp -0.0610856 0.987798 -0.143262
|
||||
ren1 SetActiveCamera cam1
|
||||
|
||||
iren Initialize
|
||||
|
||||
# Set up an observer to invoke a proc when the UserEvent (keypress-u)
|
||||
# is invoked.
|
||||
#
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
|
||||
# prevent the tk window from showing up then start the event loop
|
||||
wm withdraw .
|
||||
|
||||
iren Start
|
||||
|
||||
@ -0,0 +1,452 @@
|
||||
#
|
||||
# This example shows how to generate and manipulate texture coordinates.
|
||||
# The user can interact with the vtkTransformTextureCoords object to
|
||||
# modify the texture coordinates interactively. Different objects, textures
|
||||
# and texture mappers can be selected.
|
||||
#
|
||||
|
||||
#
|
||||
# First we include the VTK Tcl packages which will make available
|
||||
# all of the vtk commands to Tcl.
|
||||
#
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
|
||||
#
|
||||
# These are the different choices made available to the user.
|
||||
# They include: models, textures (relative to VTK_DATA_ROOT)
|
||||
# and mapper types.
|
||||
#
|
||||
set models { \
|
||||
"teapot.g" \
|
||||
"Viewpoint/cow.g" \
|
||||
"motor.g" \
|
||||
}
|
||||
|
||||
set textures { \
|
||||
"vtk.png" \
|
||||
"masonry.bmp" \
|
||||
"earth.ppm" \
|
||||
"B.pgm" \
|
||||
"beach.jpg" \
|
||||
"fran_cut.png" \
|
||||
}
|
||||
|
||||
set texture_mapper_types { \
|
||||
vtkTextureMapToPlane \
|
||||
vtkTextureMapToSphere \
|
||||
vtkTextureMapToCylinder \
|
||||
}
|
||||
|
||||
#
|
||||
# A 3D model is loaded using an BYU reader.
|
||||
# Compute normals, in case they are not provided with the model.
|
||||
#
|
||||
vtkBYUReader model_reader
|
||||
model_reader SetGeometryFileName "$VTK_DATA_ROOT/Data/[lindex $models 0]"
|
||||
|
||||
vtkPolyDataNormals model_normals
|
||||
model_normals SetInputConnection [model_reader GetOutputPort]
|
||||
|
||||
#
|
||||
# Create all texture coordinates generators/mappers and use the first one
|
||||
# for the current pipeline.
|
||||
#
|
||||
foreach texture_mapper_type $texture_mapper_types {
|
||||
set texture_mapper \
|
||||
[$texture_mapper_type [string tolower $texture_mapper_type]]
|
||||
$texture_mapper SetInputConnection [model_normals GetOutputPort]
|
||||
}
|
||||
|
||||
#
|
||||
# Create a texture coordinate transformer, which can be used to
|
||||
# translate, scale or flip the texture.
|
||||
#
|
||||
set texture_mapper_type [lindex $texture_mapper_types 0]
|
||||
vtkTransformTextureCoords transform_texture
|
||||
transform_texture SetInputConnection [[string tolower $texture_mapper_type] GetOutputPort]
|
||||
|
||||
#
|
||||
# Create polydata mapper.
|
||||
#
|
||||
vtkPolyDataMapper mapper
|
||||
mapper SetInputConnection [transform_texture GetOutputPort]
|
||||
|
||||
#
|
||||
# A texture is loaded using an image reader.
|
||||
# Textures are simply images.
|
||||
# The texture is eventually associated with an actor.
|
||||
#
|
||||
set filename "$VTK_DATA_ROOT/Data/[lindex $textures 0]"
|
||||
vtkImageReader2Factory create_reader
|
||||
set texture_reader [create_reader CreateImageReader2 $filename]
|
||||
$texture_reader SetFileName $filename
|
||||
|
||||
vtkTexture texture
|
||||
texture SetInputConnection [$texture_reader GetOutputPort]
|
||||
texture InterpolateOn
|
||||
|
||||
vtkActor actor
|
||||
actor SetMapper mapper
|
||||
actor SetTexture texture
|
||||
|
||||
#
|
||||
# Create a triangle filter that will feed the model geometry to
|
||||
# the feature edge extractor. Create the corresponding mapper
|
||||
# and actor.
|
||||
#
|
||||
vtkTriangleFilter triangle_filter
|
||||
triangle_filter SetInputConnection [model_normals GetOutputPort]
|
||||
|
||||
vtkFeatureEdges edges_extractor
|
||||
edges_extractor SetInputConnection [triangle_filter GetOutputPort]
|
||||
edges_extractor ColoringOff
|
||||
edges_extractor BoundaryEdgesOn
|
||||
edges_extractor ManifoldEdgesOn
|
||||
edges_extractor NonManifoldEdgesOn
|
||||
|
||||
vtkPolyDataMapper edges_mapper
|
||||
edges_mapper SetInputConnection [edges_extractor GetOutputPort]
|
||||
edges_mapper SetResolveCoincidentTopologyToPolygonOffset
|
||||
|
||||
vtkActor edges_actor
|
||||
edges_actor SetMapper edges_mapper
|
||||
eval [edges_actor GetProperty] SetColor 0 0 0
|
||||
eval [edges_actor GetProperty] SetLineStipplePattern 4369
|
||||
edges_actor VisibilityOff
|
||||
|
||||
#
|
||||
# Create the standard rendering stuff.
|
||||
#
|
||||
vtkRenderer ren1
|
||||
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
|
||||
#
|
||||
# Add the actors to the renderer, set the background
|
||||
#
|
||||
ren1 AddActor actor
|
||||
ren1 AddActor edges_actor
|
||||
ren1 SetBackground 1 1 1
|
||||
|
||||
#
|
||||
# Create the Tk widget, associate it with the renderwindow.
|
||||
#
|
||||
set vtkw [vtkTkRenderWidget .ren \
|
||||
-width 500 \
|
||||
-height 400 \
|
||||
-rw renWin]
|
||||
|
||||
#
|
||||
# Pack the Tk widget.
|
||||
#
|
||||
pack $vtkw -side top -fill both -expand yes
|
||||
|
||||
#
|
||||
# Sets event handlers
|
||||
#
|
||||
::vtk::bind_tk_render_widget $vtkw
|
||||
|
||||
#
|
||||
# Create a menubar.
|
||||
#
|
||||
set menubar [menu .menubar]
|
||||
. config -menu $menubar
|
||||
|
||||
#
|
||||
# Create a "File" menu.
|
||||
#
|
||||
set file_menu [menu $menubar.file]
|
||||
|
||||
$file_menu add command \
|
||||
-label "Quit" \
|
||||
-command ::vtk::cb_exit
|
||||
|
||||
$menubar add cascade -label "File" -menu $file_menu
|
||||
|
||||
#
|
||||
# Create a "Model" menu.
|
||||
# Each model is a radio menu entry, associated to
|
||||
# the load_model callback.
|
||||
#
|
||||
set model_menu [menu $menubar.model]
|
||||
|
||||
set gui_vars(model_reader,filename) \
|
||||
[model_reader GetGeometryFileName]
|
||||
|
||||
foreach model $models {
|
||||
set filename "$VTK_DATA_ROOT/Data/$model"
|
||||
$model_menu add radio \
|
||||
-label $model \
|
||||
-command [list load_model $filename] \
|
||||
-value $filename \
|
||||
-variable gui_vars(model_reader,filename)
|
||||
}
|
||||
|
||||
proc load_model {filename} {
|
||||
model_reader SetGeometryFileName $filename
|
||||
ren1 ResetCamera
|
||||
renWin Render
|
||||
}
|
||||
|
||||
$menubar add cascade -label "Model" -menu $model_menu
|
||||
|
||||
#
|
||||
# Create a "Texture" menu.
|
||||
# Each texture is a radio menu entry, associated to
|
||||
# the load_texture callback.
|
||||
#
|
||||
set texture_menu [menu $menubar.texture]
|
||||
|
||||
set gui_vars(texture_reader,filename) \
|
||||
[[[texture GetInputConnection 0 0] GetProducer] GetFileName]
|
||||
|
||||
foreach texture $textures {
|
||||
set filename "$VTK_DATA_ROOT/Data/$texture"
|
||||
$texture_menu add radio \
|
||||
-label $texture \
|
||||
-command [list load_texture $filename] \
|
||||
-value $filename \
|
||||
-variable gui_vars(texture_reader,filename)
|
||||
}
|
||||
|
||||
proc load_texture {filename} {
|
||||
set texture_reader [create_reader CreateImageReader2 $filename]
|
||||
$texture_reader SetFileName $filename
|
||||
texture SetInputConnection [$texture_reader GetOutputPort]
|
||||
renWin Render
|
||||
}
|
||||
|
||||
$menubar add cascade -label "Texture" -menu $texture_menu
|
||||
|
||||
#
|
||||
# Create a "Mapper" menu.
|
||||
# Each mapper type is a radio menu entry, associated to
|
||||
# the use_texture_mapper_type callback.
|
||||
#
|
||||
set texture_mapper_type_menu [menu $menubar.texture_mapper_type]
|
||||
|
||||
set gui_vars(texture_mapper_type) \
|
||||
[[[transform_texture GetInputConnection 0 0] GetProducer] GetClassName]
|
||||
|
||||
foreach texture_mapper_type $texture_mapper_types {
|
||||
$texture_mapper_type_menu add radio \
|
||||
-label $texture_mapper_type \
|
||||
-command [list use_texture_mapper_type $texture_mapper_type] \
|
||||
-value $texture_mapper_type \
|
||||
-variable gui_vars(texture_mapper_type)
|
||||
}
|
||||
|
||||
proc use_texture_mapper_type {texture_mapper_type} {
|
||||
transform_texture SetInputConnection \
|
||||
[[string tolower $texture_mapper_type] GetOutputPort]
|
||||
renWin Render
|
||||
}
|
||||
|
||||
$menubar add cascade -label "Mapper" -menu $texture_mapper_type_menu
|
||||
|
||||
#
|
||||
# Create a "View" menu.
|
||||
# It stores various properties.
|
||||
#
|
||||
set view_menu [menu $menubar.view]
|
||||
|
||||
set gui_vars(view,edges) [edges_actor GetVisibility]
|
||||
|
||||
$view_menu add radio \
|
||||
-label "Edges" \
|
||||
-command toggle_edges_visibility \
|
||||
-value 1 \
|
||||
-variable gui_vars(view,edges)
|
||||
|
||||
proc toggle_edges_visibility {} {
|
||||
if {[edges_actor GetVisibility]} {
|
||||
edges_actor VisibilityOff
|
||||
} else {
|
||||
edges_actor VisibilityOn
|
||||
}
|
||||
set gui_vars(view,edges) [edges_actor GetVisibility]
|
||||
renWin Render
|
||||
}
|
||||
|
||||
$menubar add cascade -label "View" -menu $view_menu
|
||||
|
||||
#
|
||||
# Create the vtkTransformTextureCoords gui.
|
||||
#
|
||||
# Each entry in the following array describe a "control" in the GUI:
|
||||
# - unique name of the control,
|
||||
# - title for the control,
|
||||
# - texture coordinates parametrized by that control,
|
||||
# - name of the corresponding vtkTransformTextureCoords attribute,
|
||||
# - start, end, increment value of each Tk scale widget in the control.
|
||||
#
|
||||
set transform_texture_coords_gui_controls \
|
||||
{ \
|
||||
position "Texture position" {r s} Position 0.0 2.0 0.01 \
|
||||
scale "Texture scale" {r s} Scale 0.0 5.0 0.05 \
|
||||
origin "Texture origin" {r s} Origin 0.0 1.0 0.01 \
|
||||
}
|
||||
|
||||
proc create_transform_texture_coords_gui {parent obj} {
|
||||
|
||||
global gui_vars transform_texture_coords_gui_controls
|
||||
|
||||
#
|
||||
# Create a main frame
|
||||
#
|
||||
if {$parent == "."} {
|
||||
set main_frame [frame .main]
|
||||
} else {
|
||||
set main_frame [frame $parent.main]
|
||||
}
|
||||
|
||||
set scale_width 9
|
||||
set command [list update_transform_texture_from_gui_vars $obj]
|
||||
|
||||
#
|
||||
# Loop over each "control" description
|
||||
#
|
||||
foreach {control label coords obj_method scale_from scale_to scale_res} \
|
||||
$transform_texture_coords_gui_controls {
|
||||
|
||||
#
|
||||
# Create a frame for the control, a label for its title, and a
|
||||
# sub-frame that will hold all Tk scale widgets.
|
||||
#
|
||||
upvar ${control}_frame control_frame
|
||||
set control_frame [frame $main_frame.$control -relief groove -border 2]
|
||||
|
||||
upvar ${control}_label control_label
|
||||
set control_label [label $control_frame.label \
|
||||
-text "$label:" -anchor w]
|
||||
|
||||
upvar ${control}_rst control_rst
|
||||
set control_rst [frame $control_frame.rst]
|
||||
|
||||
#
|
||||
# Add (r,s,t) texture coordinate widgets to the control.
|
||||
# Each one is made of a label for the coordinate's name, a label
|
||||
# for the coordinate's value and a Tk scale widget to control
|
||||
# that value.
|
||||
# All scale widgets are associated to the same callback:
|
||||
# update_transform_texture_from_gui_vars
|
||||
#
|
||||
for {set i 0} {$i < [llength $coords]} {incr i} {
|
||||
|
||||
set coord [lindex $coords $i]
|
||||
|
||||
label $control_rst.${coord}_label \
|
||||
-text "$coord:" -anchor w
|
||||
|
||||
set gui_vars($obj,$control,$coord) \
|
||||
[lindex [$obj Get$obj_method] $i]
|
||||
|
||||
scale $control_rst.${coord}_scale \
|
||||
-from $scale_from -to $scale_to -resolution $scale_res \
|
||||
-orient horizontal \
|
||||
-width $scale_width \
|
||||
-showvalue false \
|
||||
-var gui_vars($obj,$control,$coord) \
|
||||
-command $command
|
||||
|
||||
label $control_rst.${coord}_value \
|
||||
-textvariable gui_vars($obj,$control,$coord)
|
||||
|
||||
#
|
||||
# For "origin", add flip checkbuttons.
|
||||
# Pack the 3 (or 5) elements into a single row.
|
||||
#
|
||||
if {$control == "origin"} {
|
||||
|
||||
label $control_rst.${coord}_flip_label \
|
||||
-text "Flip:" -anchor w
|
||||
|
||||
set get_flip "GetFlip[string toupper $coord]"
|
||||
set gui_vars($obj,$control,${coord}_flip) [$obj $get_flip]
|
||||
|
||||
checkbutton $control_rst.${coord}_flip \
|
||||
-variable gui_vars($obj,$control,${coord}_flip) \
|
||||
-borderwidth 0 -padx 0 -pady 0 \
|
||||
-command $command
|
||||
|
||||
grid $control_rst.${coord}_label \
|
||||
$control_rst.${coord}_value \
|
||||
$control_rst.${coord}_scale \
|
||||
$control_rst.${coord}_flip_label \
|
||||
$control_rst.${coord}_flip \
|
||||
-sticky news
|
||||
} else {
|
||||
grid $control_rst.${coord}_label \
|
||||
$control_rst.${coord}_value \
|
||||
$control_rst.${coord}_scale \
|
||||
-sticky news
|
||||
}
|
||||
|
||||
#
|
||||
# Allow the scale widgets to grow when the GUI is expanded.
|
||||
#
|
||||
grid columnconfigure $control_rst 2 -weight 1
|
||||
}
|
||||
|
||||
#
|
||||
# Pack everything
|
||||
#
|
||||
pack $control_frame \
|
||||
-side top -fill x -expand true -padx 1 -pady 2
|
||||
|
||||
pack $control_label \
|
||||
$control_rst \
|
||||
-side top -fill x -expand true
|
||||
}
|
||||
|
||||
return $main_frame
|
||||
}
|
||||
|
||||
#
|
||||
# This callback is used whenever the value of a Tk scale is changed.
|
||||
# It recovers the gui values from the gui_vars global array, and
|
||||
# change the corresponding vtkTransformTextureCoords attribute.
|
||||
# The render window is re-rendered.
|
||||
#
|
||||
proc update_transform_texture_from_gui_vars {obj args} {
|
||||
|
||||
global gui_vars transform_texture_coords_gui_controls
|
||||
|
||||
foreach {control label coords obj_method scale_from scale_to scale_res} \
|
||||
$transform_texture_coords_gui_controls {
|
||||
set values [$obj Get$obj_method]
|
||||
for {set i 0} {$i < [llength $coords]} {incr i} {
|
||||
set coord [lindex $coords $i]
|
||||
set values [lreplace $values $i $i $gui_vars($obj,$control,$coord)]
|
||||
|
||||
if {$control == "origin"} {
|
||||
set flip_method "Flip[string toupper $coord]"
|
||||
$obj Set$flip_method $gui_vars($obj,$control,${coord}_flip)
|
||||
}
|
||||
}
|
||||
eval $obj Set$obj_method $values
|
||||
}
|
||||
renWin Render
|
||||
}
|
||||
|
||||
#
|
||||
# Create the gui and pack it.
|
||||
#
|
||||
set gui [create_transform_texture_coords_gui . transform_texture]
|
||||
|
||||
pack $gui -side top -anchor s -fill x -expand yes
|
||||
|
||||
#
|
||||
# We set the window manager (wm command) so that it registers a
|
||||
# command to handle the WM_DELETE_WINDOW protocal request..
|
||||
#
|
||||
wm title . "Texture mapper/transform demo"
|
||||
wm protocol . WM_DELETE_WINDOW ::vtk::cb_exit
|
||||
|
||||
#
|
||||
# You only need this line if you run this script from a Tcl shell
|
||||
# (tclsh) instead of a Tk shell (wish)
|
||||
#
|
||||
tkwait window .
|
||||
@ -0,0 +1,65 @@
|
||||
# This example demonstrates the use of the contour filter, and the use of
|
||||
# the vtkSampleFunction to generate a volume of data samples from an
|
||||
# implicit function.
|
||||
|
||||
#
|
||||
# First we include the VTK Tcl packages which will make available
|
||||
# all of the vtk commands from Tcl. The vtkinteraction package defines
|
||||
# a simple Tcl/Tk interactor widget.
|
||||
#
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
|
||||
# VTK supports implicit functions of the form f(x,y,z)=constant. These
|
||||
# functions can represent things spheres, cones, etc. Here we use a
|
||||
# general form for a quadric to create an elliptical data field.
|
||||
vtkQuadric quadric
|
||||
quadric SetCoefficients .5 1 .2 0 .1 0 0 .2 0 0
|
||||
|
||||
# vtkSampleFunction samples an implicit function over the x-y-z range
|
||||
# specified (here it defaults to -1,1 in the x,y,z directions).
|
||||
vtkSampleFunction sample
|
||||
sample SetSampleDimensions 30 30 30
|
||||
sample SetImplicitFunction quadric
|
||||
|
||||
# Create five surfaces F(x,y,z) = constant between range specified. The
|
||||
# GenerateValues() method creates n isocontour values between the range
|
||||
# specified.
|
||||
vtkContourFilter contours
|
||||
contours SetInputConnection [sample GetOutputPort]
|
||||
contours GenerateValues 5 0.0 1.2
|
||||
|
||||
vtkPolyDataMapper contMapper
|
||||
contMapper SetInputConnection [contours GetOutputPort]
|
||||
contMapper SetScalarRange 0.0 1.2
|
||||
|
||||
vtkActor contActor
|
||||
contActor SetMapper contMapper
|
||||
|
||||
# We'll put a simple outline around the data.
|
||||
vtkOutlineFilter outline
|
||||
outline SetInputConnection [sample GetOutputPort]
|
||||
|
||||
vtkPolyDataMapper outlineMapper
|
||||
outlineMapper SetInputConnection [outline GetOutputPort]
|
||||
|
||||
vtkActor outlineActor
|
||||
outlineActor SetMapper outlineMapper
|
||||
eval [outlineActor GetProperty] SetColor 0 0 0
|
||||
|
||||
# The usual rendering stuff.
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
ren1 SetBackground 1 1 1
|
||||
ren1 AddActor contActor
|
||||
ren1 AddActor outlineActor
|
||||
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
iren Initialize
|
||||
|
||||
wm withdraw .
|
||||
iren Start
|
||||
@ -0,0 +1,61 @@
|
||||
# This example shows how to use decimation to reduce a polygonal mesh. We also
|
||||
# use mesh smoothing and generate surface normals to give a pleasing result.
|
||||
#
|
||||
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
|
||||
# We start by reading some data that was originally captured from
|
||||
# a Cyberware laser digitizing system.
|
||||
#
|
||||
vtkPolyDataReader fran
|
||||
fran SetFileName "$VTK_DATA_ROOT/Data/fran_cut.vtk"
|
||||
|
||||
# We want to preserve topology (not let any cracks form). This may limit
|
||||
# the total reduction possible, which we have specified at 90%.
|
||||
#
|
||||
vtkDecimatePro deci
|
||||
deci SetInputConnection [fran GetOutputPort]
|
||||
deci SetTargetReduction 0.9
|
||||
deci PreserveTopologyOn
|
||||
vtkPolyDataNormals normals
|
||||
normals SetInputConnection [deci GetOutputPort]
|
||||
normals FlipNormalsOn
|
||||
vtkPolyDataMapper franMapper
|
||||
franMapper SetInputConnection [normals GetOutputPort]
|
||||
vtkActor franActor
|
||||
franActor SetMapper franMapper
|
||||
eval [franActor GetProperty] SetColor 1.0 0.49 0.25
|
||||
|
||||
# Create the RenderWindow, Renderer and both Actors
|
||||
#
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
# Add the actors to the renderer, set the background and size
|
||||
#
|
||||
ren1 AddActor franActor
|
||||
ren1 SetBackground 1 1 1
|
||||
renWin SetSize 250 250
|
||||
|
||||
# render the image
|
||||
#
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
|
||||
vtkCamera cam1
|
||||
cam1 SetClippingRange 0.0475572 2.37786
|
||||
cam1 SetFocalPoint 0.052665 -0.129454 -0.0573973
|
||||
cam1 SetPosition 0.327637 -0.116299 -0.256418
|
||||
cam1 SetViewUp -0.0225386 0.999137 0.034901
|
||||
ren1 SetActiveCamera cam1
|
||||
|
||||
iren Initialize
|
||||
|
||||
# prevent the tk window from showing up then start the event loop
|
||||
wm withdraw .
|
||||
iren Start
|
||||
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
# This example shows how to combine data from both the imaging
|
||||
# and graphics pipelines. The vtkMergeData filter is used to
|
||||
# merge the data from each together.
|
||||
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
|
||||
# Read in an image and compute a luminance value. The image is extracted
|
||||
# as a set of polygons (vtkImageDataGeometryFilter). We then will
|
||||
# warp the plane using the scalar (luminance) values.
|
||||
#
|
||||
vtkBMPReader reader
|
||||
reader SetFileName $VTK_DATA_ROOT/Data/masonry.bmp
|
||||
vtkImageLuminance luminance
|
||||
luminance SetInputConnection [reader GetOutputPort]
|
||||
vtkImageDataGeometryFilter geometry
|
||||
geometry SetInputConnection [luminance GetOutputPort]
|
||||
vtkWarpScalar warp
|
||||
warp SetInputConnection [geometry GetOutputPort]
|
||||
warp SetScaleFactor -0.1
|
||||
|
||||
# Use vtkMergeFilter to combine the original image with the warped geometry.
|
||||
#
|
||||
vtkMergeFilter merge
|
||||
merge SetGeometryConnection [warp GetOutputPort]
|
||||
merge SetScalarsConnection [reader GetOutputPort]
|
||||
vtkDataSetMapper mapper
|
||||
mapper SetInputConnection [merge GetOutputPort]
|
||||
mapper SetScalarRange 0 255
|
||||
mapper ImmediateModeRenderingOff
|
||||
vtkActor actor
|
||||
actor SetMapper mapper
|
||||
|
||||
# Create renderer stuff
|
||||
#
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
# Add the actors to the renderer, set the background and size
|
||||
#
|
||||
ren1 AddActor actor
|
||||
ren1 ResetCamera
|
||||
[ren1 GetActiveCamera] Azimuth 20
|
||||
[ren1 GetActiveCamera] Elevation 30
|
||||
ren1 SetBackground 0.1 0.2 0.4
|
||||
ren1 ResetCameraClippingRange
|
||||
|
||||
renWin SetSize 250 250
|
||||
|
||||
# render the image
|
||||
#
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
set cam1 [ren1 GetActiveCamera]
|
||||
$cam1 Zoom 1.4
|
||||
renWin Render
|
||||
|
||||
# prevent the tk window from showing up then start the event loop
|
||||
wm withdraw .
|
||||
|
||||
iren Start
|
||||
@ -0,0 +1,310 @@
|
||||
# This example demonstrates the use of a single streamline and the tube
|
||||
# filter to create a streamtube.
|
||||
|
||||
#
|
||||
# First we include the VTK Tcl packages which will make available
|
||||
# all of the vtk commands from Tcl. The vtkinteraction package defines
|
||||
# a simple Tcl/Tk interactor widget.
|
||||
#
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
package require vtktesting
|
||||
|
||||
# We read a data file the is a CFD analysis of airflow in an office (with
|
||||
# ventilation and a burning cigarette). We force an update so that we
|
||||
# can query the output for its length, i.e., the length of the diagonal
|
||||
# of the bounding box. This is useful for normalizing the data.
|
||||
#
|
||||
vtkStructuredGridReader reader
|
||||
reader SetFileName "$VTK_DATA_ROOT/Data/office.binary.vtk"
|
||||
reader Update;#force a read to occur
|
||||
|
||||
set length [[reader GetOutput] GetLength]
|
||||
|
||||
set maxVelocity \
|
||||
[[[[reader GetOutput] GetPointData] GetVectors] GetMaxNorm]
|
||||
set maxTime [expr 35.0 * $length / $maxVelocity]
|
||||
|
||||
# Now we will generate a single streamline in the data. We select the
|
||||
# integration order to use (RungeKutta order 4) and associate it with
|
||||
# the streamer. The start position is the position in world space where
|
||||
# we want to begin streamline integration; and we integrate in both
|
||||
# directions. The step length is the length of the line segments that
|
||||
# make up the streamline (i.e., related to display). The
|
||||
# IntegrationStepLength specifies the integration step length as a
|
||||
# fraction of the cell size that the streamline is in.
|
||||
vtkRungeKutta4 integ
|
||||
vtkStreamTracer streamer
|
||||
streamer SetInputConnection [reader GetOutputPort]
|
||||
streamer SetStartPosition 0.1 2.1 0.5
|
||||
streamer SetMaximumPropagation 500
|
||||
streamer SetInitialIntegrationStep 0.05
|
||||
streamer SetIntegrationDirectionToBoth
|
||||
streamer SetIntegrator integ
|
||||
|
||||
# The tube is wrapped around the generated streamline. By varying the radius
|
||||
# by the inverse of vector magnitude, we are creating a tube whose radius is
|
||||
# proportional to mass flux (in incompressible flow).
|
||||
vtkTubeFilter streamTube
|
||||
streamTube SetInputConnection [streamer GetOutputPort]
|
||||
streamTube SetInputArrayToProcess 1 0 0 vtkDataObject::FIELD_ASSOCIATION_POINTS vectors
|
||||
streamTube SetRadius 0.02
|
||||
streamTube SetNumberOfSides 12
|
||||
streamTube SetVaryRadiusToVaryRadiusByVector
|
||||
vtkPolyDataMapper mapStreamTube
|
||||
mapStreamTube SetInputConnection [streamTube GetOutputPort]
|
||||
eval mapStreamTube SetScalarRange \
|
||||
[[[[reader GetOutput] GetPointData] GetScalars] GetRange]
|
||||
vtkActor streamTubeActor
|
||||
streamTubeActor SetMapper mapStreamTube
|
||||
[streamTubeActor GetProperty] BackfaceCullingOn
|
||||
|
||||
# From here on we generate a whole bunch of planes which correspond to
|
||||
# the geometry in the analysis; tables, bookshelves and so on.
|
||||
vtkStructuredGridGeometryFilter table1
|
||||
table1 SetInputConnection [reader GetOutputPort]
|
||||
table1 SetExtent 11 15 7 9 8 8
|
||||
vtkPolyDataMapper mapTable1
|
||||
mapTable1 SetInputConnection [table1 GetOutputPort]
|
||||
mapTable1 ScalarVisibilityOff
|
||||
vtkActor table1Actor
|
||||
table1Actor SetMapper mapTable1
|
||||
[table1Actor GetProperty] SetColor .59 .427 .392
|
||||
|
||||
vtkStructuredGridGeometryFilter table2
|
||||
table2 SetInputConnection [reader GetOutputPort]
|
||||
table2 SetExtent 11 15 10 12 8 8
|
||||
vtkPolyDataMapper mapTable2
|
||||
mapTable2 SetInputConnection [table2 GetOutputPort]
|
||||
mapTable2 ScalarVisibilityOff
|
||||
vtkActor table2Actor
|
||||
table2Actor SetMapper mapTable2
|
||||
[table2Actor GetProperty] SetColor .59 .427 .392
|
||||
|
||||
vtkStructuredGridGeometryFilter FilingCabinet1
|
||||
FilingCabinet1 SetInputConnection [reader GetOutputPort]
|
||||
FilingCabinet1 SetExtent 15 15 7 9 0 8
|
||||
vtkPolyDataMapper mapFilingCabinet1
|
||||
mapFilingCabinet1 SetInputConnection [FilingCabinet1 GetOutputPort]
|
||||
mapFilingCabinet1 ScalarVisibilityOff
|
||||
vtkActor FilingCabinet1Actor
|
||||
FilingCabinet1Actor SetMapper mapFilingCabinet1
|
||||
[FilingCabinet1Actor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter FilingCabinet2
|
||||
FilingCabinet2 SetInputConnection [reader GetOutputPort]
|
||||
FilingCabinet2 SetExtent 15 15 10 12 0 8
|
||||
vtkPolyDataMapper mapFilingCabinet2
|
||||
mapFilingCabinet2 SetInputConnection [FilingCabinet2 GetOutputPort]
|
||||
mapFilingCabinet2 ScalarVisibilityOff
|
||||
vtkActor FilingCabinet2Actor
|
||||
FilingCabinet2Actor SetMapper mapFilingCabinet2
|
||||
[FilingCabinet2Actor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf1Top
|
||||
bookshelf1Top SetInputConnection [reader GetOutputPort]
|
||||
bookshelf1Top SetExtent 13 13 0 4 0 11
|
||||
vtkPolyDataMapper mapBookshelf1Top
|
||||
mapBookshelf1Top SetInputConnection [bookshelf1Top GetOutputPort]
|
||||
mapBookshelf1Top ScalarVisibilityOff
|
||||
vtkActor bookshelf1TopActor
|
||||
bookshelf1TopActor SetMapper mapBookshelf1Top
|
||||
[bookshelf1TopActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf1Bottom
|
||||
bookshelf1Bottom SetInputConnection [reader GetOutputPort]
|
||||
bookshelf1Bottom SetExtent 20 20 0 4 0 11
|
||||
vtkPolyDataMapper mapBookshelf1Bottom
|
||||
mapBookshelf1Bottom SetInputConnection [bookshelf1Bottom GetOutputPort]
|
||||
mapBookshelf1Bottom ScalarVisibilityOff
|
||||
vtkActor bookshelf1BottomActor
|
||||
bookshelf1BottomActor SetMapper mapBookshelf1Bottom
|
||||
[bookshelf1BottomActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf1Front
|
||||
bookshelf1Front SetInputConnection [reader GetOutputPort]
|
||||
bookshelf1Front SetExtent 13 20 0 0 0 11
|
||||
vtkPolyDataMapper mapBookshelf1Front
|
||||
mapBookshelf1Front SetInputConnection [bookshelf1Front GetOutputPort]
|
||||
mapBookshelf1Front ScalarVisibilityOff
|
||||
vtkActor bookshelf1FrontActor
|
||||
bookshelf1FrontActor SetMapper mapBookshelf1Front
|
||||
[bookshelf1FrontActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf1Back
|
||||
bookshelf1Back SetInputConnection [reader GetOutputPort]
|
||||
bookshelf1Back SetExtent 13 20 4 4 0 11
|
||||
vtkPolyDataMapper mapBookshelf1Back
|
||||
mapBookshelf1Back SetInputConnection [bookshelf1Back GetOutputPort]
|
||||
mapBookshelf1Back ScalarVisibilityOff
|
||||
vtkActor bookshelf1BackActor
|
||||
bookshelf1BackActor SetMapper mapBookshelf1Back
|
||||
[bookshelf1BackActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf1LHS
|
||||
bookshelf1LHS SetInputConnection [reader GetOutputPort]
|
||||
bookshelf1LHS SetExtent 13 20 0 4 0 0
|
||||
vtkPolyDataMapper mapBookshelf1LHS
|
||||
mapBookshelf1LHS SetInputConnection [bookshelf1LHS GetOutputPort]
|
||||
mapBookshelf1LHS ScalarVisibilityOff
|
||||
vtkActor bookshelf1LHSActor
|
||||
bookshelf1LHSActor SetMapper mapBookshelf1LHS
|
||||
[bookshelf1LHSActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf1RHS
|
||||
bookshelf1RHS SetInputConnection [reader GetOutputPort]
|
||||
bookshelf1RHS SetExtent 13 20 0 4 11 11
|
||||
vtkPolyDataMapper mapBookshelf1RHS
|
||||
mapBookshelf1RHS SetInputConnection [bookshelf1RHS GetOutputPort]
|
||||
mapBookshelf1RHS ScalarVisibilityOff
|
||||
vtkActor bookshelf1RHSActor
|
||||
bookshelf1RHSActor SetMapper mapBookshelf1RHS
|
||||
[bookshelf1RHSActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf2Top
|
||||
bookshelf2Top SetInputConnection [reader GetOutputPort]
|
||||
bookshelf2Top SetExtent 13 13 15 19 0 11
|
||||
vtkPolyDataMapper mapBookshelf2Top
|
||||
mapBookshelf2Top SetInputConnection [bookshelf2Top GetOutputPort]
|
||||
mapBookshelf2Top ScalarVisibilityOff
|
||||
vtkActor bookshelf2TopActor
|
||||
bookshelf2TopActor SetMapper mapBookshelf2Top
|
||||
[bookshelf2TopActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf2Bottom
|
||||
bookshelf2Bottom SetInputConnection [reader GetOutputPort]
|
||||
bookshelf2Bottom SetExtent 20 20 15 19 0 11
|
||||
vtkPolyDataMapper mapBookshelf2Bottom
|
||||
mapBookshelf2Bottom SetInputConnection [bookshelf2Bottom GetOutputPort]
|
||||
mapBookshelf2Bottom ScalarVisibilityOff
|
||||
vtkActor bookshelf2BottomActor
|
||||
bookshelf2BottomActor SetMapper mapBookshelf2Bottom
|
||||
[bookshelf2BottomActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf2Front
|
||||
bookshelf2Front SetInputConnection [reader GetOutputPort]
|
||||
bookshelf2Front SetExtent 13 20 15 15 0 11
|
||||
vtkPolyDataMapper mapBookshelf2Front
|
||||
mapBookshelf2Front SetInputConnection [bookshelf2Front GetOutputPort]
|
||||
mapBookshelf2Front ScalarVisibilityOff
|
||||
vtkActor bookshelf2FrontActor
|
||||
bookshelf2FrontActor SetMapper mapBookshelf2Front
|
||||
[bookshelf2FrontActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf2Back
|
||||
bookshelf2Back SetInputConnection [reader GetOutputPort]
|
||||
bookshelf2Back SetExtent 13 20 19 19 0 11
|
||||
vtkPolyDataMapper mapBookshelf2Back
|
||||
mapBookshelf2Back SetInputConnection [bookshelf2Back GetOutputPort]
|
||||
mapBookshelf2Back ScalarVisibilityOff
|
||||
vtkActor bookshelf2BackActor
|
||||
bookshelf2BackActor SetMapper mapBookshelf2Back
|
||||
[bookshelf2BackActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf2LHS
|
||||
bookshelf2LHS SetInputConnection [reader GetOutputPort]
|
||||
bookshelf2LHS SetExtent 13 20 15 19 0 0
|
||||
vtkPolyDataMapper mapBookshelf2LHS
|
||||
mapBookshelf2LHS SetInputConnection [bookshelf2LHS GetOutputPort]
|
||||
mapBookshelf2LHS ScalarVisibilityOff
|
||||
vtkActor bookshelf2LHSActor
|
||||
bookshelf2LHSActor SetMapper mapBookshelf2LHS
|
||||
[bookshelf2LHSActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf2RHS
|
||||
bookshelf2RHS SetInputConnection [reader GetOutputPort]
|
||||
bookshelf2RHS SetExtent 13 20 15 19 11 11
|
||||
vtkPolyDataMapper mapBookshelf2RHS
|
||||
mapBookshelf2RHS SetInputConnection [bookshelf2RHS GetOutputPort]
|
||||
mapBookshelf2RHS ScalarVisibilityOff
|
||||
vtkActor bookshelf2RHSActor
|
||||
bookshelf2RHSActor SetMapper mapBookshelf2RHS
|
||||
[bookshelf2RHSActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter window
|
||||
window SetInputConnection [reader GetOutputPort]
|
||||
window SetExtent 20 20 6 13 10 13
|
||||
vtkPolyDataMapper mapWindow
|
||||
mapWindow SetInputConnection [window GetOutputPort]
|
||||
mapWindow ScalarVisibilityOff
|
||||
vtkActor windowActor
|
||||
windowActor SetMapper mapWindow
|
||||
[windowActor GetProperty] SetColor .3 .3 .5
|
||||
|
||||
vtkStructuredGridGeometryFilter outlet
|
||||
outlet SetInputConnection [reader GetOutputPort]
|
||||
outlet SetExtent 0 0 9 10 14 16
|
||||
vtkPolyDataMapper mapOutlet
|
||||
mapOutlet SetInputConnection [outlet GetOutputPort]
|
||||
mapOutlet ScalarVisibilityOff
|
||||
vtkActor outletActor
|
||||
outletActor SetMapper mapOutlet
|
||||
[outletActor GetProperty] SetColor 0 0 0
|
||||
|
||||
vtkStructuredGridGeometryFilter inlet
|
||||
inlet SetInputConnection [reader GetOutputPort]
|
||||
inlet SetExtent 0 0 9 10 0 6
|
||||
vtkPolyDataMapper mapInlet
|
||||
mapInlet SetInputConnection [inlet GetOutputPort]
|
||||
mapInlet ScalarVisibilityOff
|
||||
vtkActor inletActor
|
||||
inletActor SetMapper mapInlet
|
||||
[inletActor GetProperty] SetColor 0 0 0
|
||||
|
||||
vtkStructuredGridOutlineFilter outline
|
||||
outline SetInputConnection [reader GetOutputPort]
|
||||
vtkPolyDataMapper mapOutline
|
||||
mapOutline SetInputConnection [outline GetOutputPort]
|
||||
vtkActor outlineActor
|
||||
outlineActor SetMapper mapOutline
|
||||
[outlineActor GetProperty] SetColor 0 0 0
|
||||
|
||||
# Now create the usual graphics stuff.
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
ren1 AddActor table1Actor
|
||||
ren1 AddActor table2Actor
|
||||
ren1 AddActor FilingCabinet1Actor
|
||||
ren1 AddActor FilingCabinet2Actor
|
||||
ren1 AddActor bookshelf1TopActor
|
||||
ren1 AddActor bookshelf1BottomActor
|
||||
ren1 AddActor bookshelf1FrontActor
|
||||
ren1 AddActor bookshelf1BackActor
|
||||
ren1 AddActor bookshelf1LHSActor
|
||||
ren1 AddActor bookshelf1RHSActor
|
||||
ren1 AddActor bookshelf2TopActor
|
||||
ren1 AddActor bookshelf2BottomActor
|
||||
ren1 AddActor bookshelf2FrontActor
|
||||
ren1 AddActor bookshelf2BackActor
|
||||
ren1 AddActor bookshelf2LHSActor
|
||||
ren1 AddActor bookshelf2RHSActor
|
||||
ren1 AddActor windowActor
|
||||
ren1 AddActor outletActor
|
||||
ren1 AddActor inletActor
|
||||
ren1 AddActor outlineActor
|
||||
ren1 AddActor streamTubeActor
|
||||
|
||||
eval ren1 SetBackground $slate_grey
|
||||
|
||||
# Here we specify a particular view.
|
||||
vtkCamera aCamera
|
||||
aCamera SetClippingRange 0.726079 36.3039
|
||||
aCamera SetFocalPoint 2.43584 2.15046 1.11104
|
||||
aCamera SetPosition -4.76183 -10.4426 3.17203
|
||||
aCamera SetViewUp 0.0511273 0.132773 0.989827
|
||||
aCamera SetViewAngle 18.604;
|
||||
aCamera Zoom 1.2
|
||||
|
||||
ren1 SetActiveCamera aCamera
|
||||
|
||||
renWin SetSize 500 300
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
iren Initialize
|
||||
|
||||
# interact with data
|
||||
wm withdraw .
|
||||
iren Start
|
||||
@ -0,0 +1,316 @@
|
||||
# This example demonstrates the use of streamlines generated from seeds,
|
||||
# combined with a tube filter to create several streamtubes.
|
||||
|
||||
#
|
||||
# First we include the VTK Tcl packages which will make available
|
||||
# all of the vtk commands from Tcl. The vtkinteraction package defines
|
||||
# a simple Tcl/Tk interactor widget.
|
||||
#
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
package require vtktesting
|
||||
|
||||
# We read a data file the is a CFD analysis of airflow in an office (with
|
||||
# ventilation and a burning cigarette). We force an update so that we
|
||||
# can query the output for its length, i.e., the length of the diagonal
|
||||
# of the bounding box. This is useful for normalizing the data.
|
||||
#
|
||||
vtkStructuredGridReader reader
|
||||
reader SetFileName "$VTK_DATA_ROOT/Data/office.binary.vtk"
|
||||
reader Update;#force a read to occur
|
||||
|
||||
set length [[reader GetOutput] GetLength]
|
||||
|
||||
set maxVelocity \
|
||||
[[[[reader GetOutput] GetPointData] GetVectors] GetMaxNorm]
|
||||
set maxTime [expr 35.0 * $length / $maxVelocity]
|
||||
|
||||
# Now we will generate multiple streamlines in the data. We create a random
|
||||
# cloud of points and then use those as integration seeds. We select the
|
||||
# integration order to use (RungeKutta order 4) and associate it with the
|
||||
# streamer. The start position is the position in world space where we want
|
||||
# to begin streamline integration; and we integrate in both directions. The
|
||||
# step length is the length of the line segments that make up the streamline
|
||||
# (i.e., related to display). The IntegrationStepLength specifies the
|
||||
# integration step length as a fraction of the cell size that the streamline
|
||||
# is in.
|
||||
# Create source for streamtubes
|
||||
vtkPointSource seeds
|
||||
seeds SetRadius 0.15
|
||||
eval seeds SetCenter 0.1 2.1 0.5
|
||||
seeds SetNumberOfPoints 6
|
||||
vtkRungeKutta4 integ
|
||||
vtkStreamTracer streamer
|
||||
streamer SetInputConnection [reader GetOutputPort]
|
||||
streamer SetSourceConnection [seeds GetOutputPort]
|
||||
streamer SetMaximumPropagation 500
|
||||
streamer SetInitialIntegrationStep 0.05
|
||||
streamer SetIntegrationDirectionToBoth
|
||||
streamer SetIntegrator integ
|
||||
|
||||
# The tube is wrapped around the generated streamline. By varying the radius
|
||||
# by the inverse of vector magnitude, we are creating a tube whose radius is
|
||||
# proportional to mass flux (in incompressible flow).
|
||||
vtkTubeFilter streamTube
|
||||
streamTube SetInputConnection [streamer GetOutputPort]
|
||||
streamTube SetInputArrayToProcess 1 0 0 vtkDataObject::FIELD_ASSOCIATION_POINTS vectors
|
||||
streamTube SetRadius 0.02
|
||||
streamTube SetNumberOfSides 12
|
||||
streamTube SetVaryRadiusToVaryRadiusByVector
|
||||
vtkPolyDataMapper mapStreamTube
|
||||
mapStreamTube SetInputConnection [streamTube GetOutputPort]
|
||||
eval mapStreamTube SetScalarRange \
|
||||
[[[[reader GetOutput] GetPointData] GetScalars] GetRange]
|
||||
vtkActor streamTubeActor
|
||||
streamTubeActor SetMapper mapStreamTube
|
||||
[streamTubeActor GetProperty] BackfaceCullingOn
|
||||
|
||||
# From here on we generate a whole bunch of planes which correspond to
|
||||
# the geometry in the analysis; tables, bookshelves and so on.
|
||||
vtkStructuredGridGeometryFilter table1
|
||||
table1 SetInputConnection [reader GetOutputPort]
|
||||
table1 SetExtent 11 15 7 9 8 8
|
||||
vtkPolyDataMapper mapTable1
|
||||
mapTable1 SetInputConnection [table1 GetOutputPort]
|
||||
mapTable1 ScalarVisibilityOff
|
||||
vtkActor table1Actor
|
||||
table1Actor SetMapper mapTable1
|
||||
[table1Actor GetProperty] SetColor .59 .427 .392
|
||||
|
||||
vtkStructuredGridGeometryFilter table2
|
||||
table2 SetInputConnection [reader GetOutputPort]
|
||||
table2 SetExtent 11 15 10 12 8 8
|
||||
vtkPolyDataMapper mapTable2
|
||||
mapTable2 SetInputConnection [table2 GetOutputPort]
|
||||
mapTable2 ScalarVisibilityOff
|
||||
vtkActor table2Actor
|
||||
table2Actor SetMapper mapTable2
|
||||
[table2Actor GetProperty] SetColor .59 .427 .392
|
||||
|
||||
vtkStructuredGridGeometryFilter FilingCabinet1
|
||||
FilingCabinet1 SetInputConnection [reader GetOutputPort]
|
||||
FilingCabinet1 SetExtent 15 15 7 9 0 8
|
||||
vtkPolyDataMapper mapFilingCabinet1
|
||||
mapFilingCabinet1 SetInputConnection [FilingCabinet1 GetOutputPort]
|
||||
mapFilingCabinet1 ScalarVisibilityOff
|
||||
vtkActor FilingCabinet1Actor
|
||||
FilingCabinet1Actor SetMapper mapFilingCabinet1
|
||||
[FilingCabinet1Actor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter FilingCabinet2
|
||||
FilingCabinet2 SetInputConnection [reader GetOutputPort]
|
||||
FilingCabinet2 SetExtent 15 15 10 12 0 8
|
||||
vtkPolyDataMapper mapFilingCabinet2
|
||||
mapFilingCabinet2 SetInputConnection [FilingCabinet2 GetOutputPort]
|
||||
mapFilingCabinet2 ScalarVisibilityOff
|
||||
vtkActor FilingCabinet2Actor
|
||||
FilingCabinet2Actor SetMapper mapFilingCabinet2
|
||||
[FilingCabinet2Actor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf1Top
|
||||
bookshelf1Top SetInputConnection [reader GetOutputPort]
|
||||
bookshelf1Top SetExtent 13 13 0 4 0 11
|
||||
vtkPolyDataMapper mapBookshelf1Top
|
||||
mapBookshelf1Top SetInputConnection [bookshelf1Top GetOutputPort]
|
||||
mapBookshelf1Top ScalarVisibilityOff
|
||||
vtkActor bookshelf1TopActor
|
||||
bookshelf1TopActor SetMapper mapBookshelf1Top
|
||||
[bookshelf1TopActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf1Bottom
|
||||
bookshelf1Bottom SetInputConnection [reader GetOutputPort]
|
||||
bookshelf1Bottom SetExtent 20 20 0 4 0 11
|
||||
vtkPolyDataMapper mapBookshelf1Bottom
|
||||
mapBookshelf1Bottom SetInputConnection [bookshelf1Bottom GetOutputPort]
|
||||
mapBookshelf1Bottom ScalarVisibilityOff
|
||||
vtkActor bookshelf1BottomActor
|
||||
bookshelf1BottomActor SetMapper mapBookshelf1Bottom
|
||||
[bookshelf1BottomActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf1Front
|
||||
bookshelf1Front SetInputConnection [reader GetOutputPort]
|
||||
bookshelf1Front SetExtent 13 20 0 0 0 11
|
||||
vtkPolyDataMapper mapBookshelf1Front
|
||||
mapBookshelf1Front SetInputConnection [bookshelf1Front GetOutputPort]
|
||||
mapBookshelf1Front ScalarVisibilityOff
|
||||
vtkActor bookshelf1FrontActor
|
||||
bookshelf1FrontActor SetMapper mapBookshelf1Front
|
||||
[bookshelf1FrontActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf1Back
|
||||
bookshelf1Back SetInputConnection [reader GetOutputPort]
|
||||
bookshelf1Back SetExtent 13 20 4 4 0 11
|
||||
vtkPolyDataMapper mapBookshelf1Back
|
||||
mapBookshelf1Back SetInputConnection [bookshelf1Back GetOutputPort]
|
||||
mapBookshelf1Back ScalarVisibilityOff
|
||||
vtkActor bookshelf1BackActor
|
||||
bookshelf1BackActor SetMapper mapBookshelf1Back
|
||||
[bookshelf1BackActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf1LHS
|
||||
bookshelf1LHS SetInputConnection [reader GetOutputPort]
|
||||
bookshelf1LHS SetExtent 13 20 0 4 0 0
|
||||
vtkPolyDataMapper mapBookshelf1LHS
|
||||
mapBookshelf1LHS SetInputConnection [bookshelf1LHS GetOutputPort]
|
||||
mapBookshelf1LHS ScalarVisibilityOff
|
||||
vtkActor bookshelf1LHSActor
|
||||
bookshelf1LHSActor SetMapper mapBookshelf1LHS
|
||||
[bookshelf1LHSActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf1RHS
|
||||
bookshelf1RHS SetInputConnection [reader GetOutputPort]
|
||||
bookshelf1RHS SetExtent 13 20 0 4 11 11
|
||||
vtkPolyDataMapper mapBookshelf1RHS
|
||||
mapBookshelf1RHS SetInputConnection [bookshelf1RHS GetOutputPort]
|
||||
mapBookshelf1RHS ScalarVisibilityOff
|
||||
vtkActor bookshelf1RHSActor
|
||||
bookshelf1RHSActor SetMapper mapBookshelf1RHS
|
||||
[bookshelf1RHSActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf2Top
|
||||
bookshelf2Top SetInputConnection [reader GetOutputPort]
|
||||
bookshelf2Top SetExtent 13 13 15 19 0 11
|
||||
vtkPolyDataMapper mapBookshelf2Top
|
||||
mapBookshelf2Top SetInputConnection [bookshelf2Top GetOutputPort]
|
||||
mapBookshelf2Top ScalarVisibilityOff
|
||||
vtkActor bookshelf2TopActor
|
||||
bookshelf2TopActor SetMapper mapBookshelf2Top
|
||||
[bookshelf2TopActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf2Bottom
|
||||
bookshelf2Bottom SetInputConnection [reader GetOutputPort]
|
||||
bookshelf2Bottom SetExtent 20 20 15 19 0 11
|
||||
vtkPolyDataMapper mapBookshelf2Bottom
|
||||
mapBookshelf2Bottom SetInputConnection [bookshelf2Bottom GetOutputPort]
|
||||
mapBookshelf2Bottom ScalarVisibilityOff
|
||||
vtkActor bookshelf2BottomActor
|
||||
bookshelf2BottomActor SetMapper mapBookshelf2Bottom
|
||||
[bookshelf2BottomActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf2Front
|
||||
bookshelf2Front SetInputConnection [reader GetOutputPort]
|
||||
bookshelf2Front SetExtent 13 20 15 15 0 11
|
||||
vtkPolyDataMapper mapBookshelf2Front
|
||||
mapBookshelf2Front SetInputConnection [bookshelf2Front GetOutputPort]
|
||||
mapBookshelf2Front ScalarVisibilityOff
|
||||
vtkActor bookshelf2FrontActor
|
||||
bookshelf2FrontActor SetMapper mapBookshelf2Front
|
||||
[bookshelf2FrontActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf2Back
|
||||
bookshelf2Back SetInputConnection [reader GetOutputPort]
|
||||
bookshelf2Back SetExtent 13 20 19 19 0 11
|
||||
vtkPolyDataMapper mapBookshelf2Back
|
||||
mapBookshelf2Back SetInputConnection [bookshelf2Back GetOutputPort]
|
||||
mapBookshelf2Back ScalarVisibilityOff
|
||||
vtkActor bookshelf2BackActor
|
||||
bookshelf2BackActor SetMapper mapBookshelf2Back
|
||||
[bookshelf2BackActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf2LHS
|
||||
bookshelf2LHS SetInputConnection [reader GetOutputPort]
|
||||
bookshelf2LHS SetExtent 13 20 15 19 0 0
|
||||
vtkPolyDataMapper mapBookshelf2LHS
|
||||
mapBookshelf2LHS SetInputConnection [bookshelf2LHS GetOutputPort]
|
||||
mapBookshelf2LHS ScalarVisibilityOff
|
||||
vtkActor bookshelf2LHSActor
|
||||
bookshelf2LHSActor SetMapper mapBookshelf2LHS
|
||||
[bookshelf2LHSActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter bookshelf2RHS
|
||||
bookshelf2RHS SetInputConnection [reader GetOutputPort]
|
||||
bookshelf2RHS SetExtent 13 20 15 19 11 11
|
||||
vtkPolyDataMapper mapBookshelf2RHS
|
||||
mapBookshelf2RHS SetInputConnection [bookshelf2RHS GetOutputPort]
|
||||
mapBookshelf2RHS ScalarVisibilityOff
|
||||
vtkActor bookshelf2RHSActor
|
||||
bookshelf2RHSActor SetMapper mapBookshelf2RHS
|
||||
[bookshelf2RHSActor GetProperty] SetColor .8 .8 .6
|
||||
|
||||
vtkStructuredGridGeometryFilter window
|
||||
window SetInputConnection [reader GetOutputPort]
|
||||
window SetExtent 20 20 6 13 10 13
|
||||
vtkPolyDataMapper mapWindow
|
||||
mapWindow SetInputConnection [window GetOutputPort]
|
||||
mapWindow ScalarVisibilityOff
|
||||
vtkActor windowActor
|
||||
windowActor SetMapper mapWindow
|
||||
[windowActor GetProperty] SetColor .3 .3 .5
|
||||
|
||||
vtkStructuredGridGeometryFilter outlet
|
||||
outlet SetInputConnection [reader GetOutputPort]
|
||||
outlet SetExtent 0 0 9 10 14 16
|
||||
vtkPolyDataMapper mapOutlet
|
||||
mapOutlet SetInputConnection [outlet GetOutputPort]
|
||||
mapOutlet ScalarVisibilityOff
|
||||
vtkActor outletActor
|
||||
outletActor SetMapper mapOutlet
|
||||
[outletActor GetProperty] SetColor 0 0 0
|
||||
|
||||
vtkStructuredGridGeometryFilter inlet
|
||||
inlet SetInputConnection [reader GetOutputPort]
|
||||
inlet SetExtent 0 0 9 10 0 6
|
||||
vtkPolyDataMapper mapInlet
|
||||
mapInlet SetInputConnection [inlet GetOutputPort]
|
||||
mapInlet ScalarVisibilityOff
|
||||
vtkActor inletActor
|
||||
inletActor SetMapper mapInlet
|
||||
[inletActor GetProperty] SetColor 0 0 0
|
||||
|
||||
vtkStructuredGridOutlineFilter outline
|
||||
outline SetInputConnection [reader GetOutputPort]
|
||||
vtkPolyDataMapper mapOutline
|
||||
mapOutline SetInputConnection [outline GetOutputPort]
|
||||
vtkActor outlineActor
|
||||
outlineActor SetMapper mapOutline
|
||||
[outlineActor GetProperty] SetColor 0 0 0
|
||||
|
||||
# Now create the usual graphics stuff.
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
ren1 AddActor table1Actor
|
||||
ren1 AddActor table2Actor
|
||||
ren1 AddActor FilingCabinet1Actor
|
||||
ren1 AddActor FilingCabinet2Actor
|
||||
ren1 AddActor bookshelf1TopActor
|
||||
ren1 AddActor bookshelf1BottomActor
|
||||
ren1 AddActor bookshelf1FrontActor
|
||||
ren1 AddActor bookshelf1BackActor
|
||||
ren1 AddActor bookshelf1LHSActor
|
||||
ren1 AddActor bookshelf1RHSActor
|
||||
ren1 AddActor bookshelf2TopActor
|
||||
ren1 AddActor bookshelf2BottomActor
|
||||
ren1 AddActor bookshelf2FrontActor
|
||||
ren1 AddActor bookshelf2BackActor
|
||||
ren1 AddActor bookshelf2LHSActor
|
||||
ren1 AddActor bookshelf2RHSActor
|
||||
ren1 AddActor windowActor
|
||||
ren1 AddActor outletActor
|
||||
ren1 AddActor inletActor
|
||||
ren1 AddActor outlineActor
|
||||
ren1 AddActor streamTubeActor
|
||||
|
||||
eval ren1 SetBackground $slate_grey
|
||||
|
||||
# Here we specify a particular view.
|
||||
vtkCamera aCamera
|
||||
aCamera SetClippingRange 0.726079 36.3039
|
||||
aCamera SetFocalPoint 2.43584 2.15046 1.11104
|
||||
aCamera SetPosition -4.76183 -10.4426 3.17203
|
||||
aCamera SetViewUp 0.0511273 0.132773 0.989827
|
||||
aCamera SetViewAngle 18.604;
|
||||
aCamera Zoom 1.2
|
||||
|
||||
ren1 SetActiveCamera aCamera
|
||||
|
||||
renWin SetSize 500 300
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
iren Initialize
|
||||
|
||||
# interact with data
|
||||
wm withdraw .
|
||||
iren Start
|
||||
@ -0,0 +1,129 @@
|
||||
# This shows how to probe a dataset with a plane. The probed data is then
|
||||
# contoured.
|
||||
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
|
||||
# create pipeline
|
||||
#
|
||||
vtkMultiBlockPLOT3DReader pl3d
|
||||
pl3d SetXYZFileName "$VTK_DATA_ROOT/Data/combxyz.bin"
|
||||
pl3d SetQFileName "$VTK_DATA_ROOT/Data/combq.bin"
|
||||
pl3d SetScalarFunctionNumber 100
|
||||
pl3d SetVectorFunctionNumber 202
|
||||
pl3d Update
|
||||
|
||||
set pl3dOutput [[pl3d GetOutput] GetBlock 0]
|
||||
|
||||
# We create three planes and position them in the correct position
|
||||
# using transform filters. They are then appended together and used as
|
||||
# a probe.
|
||||
vtkPlaneSource plane
|
||||
plane SetResolution 50 50
|
||||
vtkTransform transP1
|
||||
transP1 Translate 3.7 0.0 28.37
|
||||
transP1 Scale 5 5 5
|
||||
transP1 RotateY 90
|
||||
vtkTransformPolyDataFilter tpd1
|
||||
tpd1 SetInputConnection [plane GetOutputPort]
|
||||
tpd1 SetTransform transP1
|
||||
vtkOutlineFilter outTpd1
|
||||
outTpd1 SetInputConnection [tpd1 GetOutputPort]
|
||||
vtkPolyDataMapper mapTpd1
|
||||
mapTpd1 SetInputConnection [outTpd1 GetOutputPort]
|
||||
vtkActor tpd1Actor
|
||||
tpd1Actor SetMapper mapTpd1
|
||||
[tpd1Actor GetProperty] SetColor 0 0 0
|
||||
|
||||
vtkTransform transP2
|
||||
transP2 Translate 9.2 0.0 31.20
|
||||
transP2 Scale 5 5 5
|
||||
transP2 RotateY 90
|
||||
vtkTransformPolyDataFilter tpd2
|
||||
tpd2 SetInputConnection [plane GetOutputPort]
|
||||
tpd2 SetTransform transP2
|
||||
vtkOutlineFilter outTpd2
|
||||
outTpd2 SetInputConnection [tpd2 GetOutputPort]
|
||||
vtkPolyDataMapper mapTpd2
|
||||
mapTpd2 SetInputConnection [outTpd2 GetOutputPort]
|
||||
vtkActor tpd2Actor
|
||||
tpd2Actor SetMapper mapTpd2
|
||||
[tpd2Actor GetProperty] SetColor 0 0 0
|
||||
|
||||
vtkTransform transP3
|
||||
transP3 Translate 13.27 0.0 33.30
|
||||
transP3 Scale 5 5 5
|
||||
transP3 RotateY 90
|
||||
vtkTransformPolyDataFilter tpd3
|
||||
tpd3 SetInputConnection [plane GetOutputPort]
|
||||
tpd3 SetTransform transP3
|
||||
vtkOutlineFilter outTpd3
|
||||
outTpd3 SetInputConnection [tpd3 GetOutputPort]
|
||||
vtkPolyDataMapper mapTpd3
|
||||
mapTpd3 SetInputConnection [outTpd3 GetOutputPort]
|
||||
vtkActor tpd3Actor
|
||||
tpd3Actor SetMapper mapTpd3
|
||||
[tpd3Actor GetProperty] SetColor 0 0 0
|
||||
|
||||
vtkAppendPolyData appendF
|
||||
appendF AddInputConnection [tpd1 GetOutputPort]
|
||||
appendF AddInputConnection [tpd2 GetOutputPort]
|
||||
appendF AddInputConnection [tpd3 GetOutputPort]
|
||||
|
||||
# The vtkProbeFilter takes two inputs. One is a dataset to use as the probe
|
||||
# geometry (SetInputConnection); the other is the data to probe
|
||||
# (SetSourceConnection). The output dataset structure (geometry and
|
||||
# topology) of the probe is the same as the structure of the input. The
|
||||
# probing process generates new data values resampled from the source.
|
||||
vtkProbeFilter probe
|
||||
probe SetInputConnection [appendF GetOutputPort]
|
||||
probe SetSourceData $pl3dOutput
|
||||
|
||||
vtkContourFilter contour
|
||||
contour SetInputConnection [probe GetOutputPort]
|
||||
eval contour GenerateValues 50 [$pl3dOutput GetScalarRange]
|
||||
vtkPolyDataMapper contourMapper
|
||||
contourMapper SetInputConnection [contour GetOutputPort]
|
||||
eval contourMapper SetScalarRange [$pl3dOutput GetScalarRange]
|
||||
vtkActor planeActor
|
||||
planeActor SetMapper contourMapper
|
||||
|
||||
vtkStructuredGridOutlineFilter outline
|
||||
outline SetInputData $pl3dOutput
|
||||
vtkPolyDataMapper outlineMapper
|
||||
outlineMapper SetInputConnection [outline GetOutputPort]
|
||||
vtkActor outlineActor
|
||||
outlineActor SetMapper outlineMapper
|
||||
[outlineActor GetProperty] SetColor 0 0 0
|
||||
|
||||
# create planes
|
||||
# Create the RenderWindow, Renderer and both Actors
|
||||
#
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
ren1 AddActor outlineActor
|
||||
ren1 AddActor planeActor
|
||||
ren1 AddActor tpd1Actor
|
||||
ren1 AddActor tpd2Actor
|
||||
ren1 AddActor tpd3Actor
|
||||
ren1 SetBackground 1 1 1
|
||||
renWin SetSize 400 400
|
||||
|
||||
ren1 ResetCamera
|
||||
set cam1 [ren1 GetActiveCamera]
|
||||
$cam1 SetClippingRange 3.95297 50
|
||||
$cam1 SetFocalPoint 8.88908 0.595038 29.3342
|
||||
$cam1 SetPosition -12.3332 31.7479 41.2387
|
||||
$cam1 SetViewUp 0.060772 -0.319905 0.945498
|
||||
iren Initialize
|
||||
|
||||
|
||||
# prevent the tk window from showing up then start the event loop
|
||||
wm withdraw .
|
||||
|
||||
iren Start
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
# This example shows how to use decimation to reduce a polygonal mesh. We also
|
||||
# use mesh smoothing and generate surface normals to give a pleasing result.
|
||||
#
|
||||
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
|
||||
# We start by reading some data that was originally captured from
|
||||
# a Cyberware laser digitizing system.
|
||||
#
|
||||
vtkPolyDataReader fran
|
||||
fran SetFileName "$VTK_DATA_ROOT/Data/fran_cut.vtk"
|
||||
|
||||
# We want to preserve topology (not let any cracks form). This may limit
|
||||
# the total reduction possible, which we have specified at 90%.
|
||||
#
|
||||
vtkDecimatePro deci
|
||||
deci SetInputConnection [fran GetOutputPort]
|
||||
deci SetTargetReduction 0.9
|
||||
deci PreserveTopologyOn
|
||||
vtkSmoothPolyDataFilter smoother
|
||||
smoother SetInputConnection [deci GetOutputPort]
|
||||
smoother SetNumberOfIterations 50
|
||||
vtkPolyDataNormals normals
|
||||
normals SetInputConnection [smoother GetOutputPort]
|
||||
normals FlipNormalsOn
|
||||
vtkPolyDataMapper franMapper
|
||||
franMapper SetInputConnection [normals GetOutputPort]
|
||||
vtkActor franActor
|
||||
franActor SetMapper franMapper
|
||||
eval [franActor GetProperty] SetColor 1.0 0.49 0.25
|
||||
|
||||
# Create the RenderWindow, Renderer and both Actors
|
||||
#
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
# Add the actors to the renderer, set the background and size
|
||||
#
|
||||
ren1 AddActor franActor
|
||||
ren1 SetBackground 1 1 1
|
||||
renWin SetSize 250 250
|
||||
|
||||
# render the image
|
||||
#
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
|
||||
vtkCamera cam1
|
||||
cam1 SetClippingRange 0.0475572 2.37786
|
||||
cam1 SetFocalPoint 0.052665 -0.129454 -0.0573973
|
||||
cam1 SetPosition 0.327637 -0.116299 -0.256418
|
||||
cam1 SetViewUp -0.0225386 0.999137 0.034901
|
||||
ren1 SetActiveCamera cam1
|
||||
|
||||
iren Initialize
|
||||
|
||||
# prevent the tk window from showing up then start the event loop
|
||||
wm withdraw .
|
||||
|
||||
iren Start
|
||||
@ -0,0 +1,94 @@
|
||||
# This example demonstrates the use of glyphing. We also use a mask filter
|
||||
# to select a subset of points to glyph.
|
||||
|
||||
#
|
||||
# First we include the VTK Tcl packages which will make available
|
||||
# all of the vtk commands from Tcl. The vtkinteraction package defines
|
||||
# a simple Tcl/Tk interactor widget.
|
||||
#
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
package require vtktesting
|
||||
|
||||
# Read a data file. This originally was a Cyberware laser digitizer scan
|
||||
# of Fran J.'s face. Surface normals are generated based on local geometry
|
||||
# (i.e., the polygon normals surrounding eash point are averaged). We flip
|
||||
# the normals because we want them to point out from Fran's face.
|
||||
#
|
||||
vtkPolyDataReader fran
|
||||
fran SetFileName "$VTK_DATA_ROOT/Data/fran_cut.vtk"
|
||||
vtkPolyDataNormals normals
|
||||
normals SetInputConnection [fran GetOutputPort]
|
||||
normals FlipNormalsOn
|
||||
vtkPolyDataMapper franMapper
|
||||
franMapper SetInputConnection [normals GetOutputPort]
|
||||
vtkActor franActor
|
||||
franActor SetMapper franMapper
|
||||
eval [franActor GetProperty] SetColor 1.0 0.49 0.25
|
||||
|
||||
# We subsample the dataset because we want to glyph just a subset of
|
||||
# the points. Otherwise the display is cluttered and cannot be easily
|
||||
# read. The RandonModeOn and SetOnRatio combine to random select one out
|
||||
# of every 10 points in the dataset.
|
||||
#
|
||||
vtkMaskPoints ptMask
|
||||
ptMask SetInputConnection [normals GetOutputPort]
|
||||
ptMask SetOnRatio 10
|
||||
ptMask RandomModeOn
|
||||
|
||||
# In this case we are using a cone as a glyph. We transform the cone so
|
||||
# its base is at 0,0,0. This is the point where glyph rotation occurs.
|
||||
vtkConeSource cone
|
||||
cone SetResolution 6
|
||||
vtkTransform transform
|
||||
transform Translate 0.5 0.0 0.0
|
||||
vtkTransformPolyDataFilter transformF
|
||||
transformF SetInputConnection [cone GetOutputPort]
|
||||
transformF SetTransform transform
|
||||
|
||||
# vtkGlyph3D takes two inputs: the input point set (SetInputConnection)
|
||||
# which can be any vtkDataSet; and the glyph (SetSourceConnection) which
|
||||
# must be a vtkPolyData. We are interested in orienting the glyphs by the
|
||||
# surface normals that we previosuly generated.
|
||||
vtkGlyph3D glyph
|
||||
glyph SetInputConnection [ptMask GetOutputPort]
|
||||
glyph SetSourceConnection [transformF GetOutputPort]
|
||||
glyph SetVectorModeToUseNormal
|
||||
glyph SetScaleModeToScaleByVector
|
||||
glyph SetScaleFactor 0.004
|
||||
vtkPolyDataMapper spikeMapper
|
||||
spikeMapper SetInputConnection [glyph GetOutputPort]
|
||||
vtkActor spikeActor
|
||||
spikeActor SetMapper spikeMapper
|
||||
eval [spikeActor GetProperty] SetColor 0.0 0.79 0.34
|
||||
|
||||
# Create the RenderWindow, Renderer and both Actors
|
||||
#
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
# Add the actors to the renderer, set the background and size
|
||||
#
|
||||
ren1 AddActor franActor
|
||||
ren1 AddActor spikeActor
|
||||
|
||||
renWin SetSize 500 500
|
||||
ren1 SetBackground 0.1 0.2 0.4
|
||||
|
||||
# render the image
|
||||
#
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
renWin Render
|
||||
|
||||
set cam1 [ren1 GetActiveCamera]
|
||||
$cam1 Zoom 1.4
|
||||
$cam1 Azimuth 110
|
||||
iren Initialize
|
||||
|
||||
# prevent the tk window from showing up then start the event loop
|
||||
wm withdraw .
|
||||
|
||||
iren Start
|
||||
@ -0,0 +1,93 @@
|
||||
# This example demonstrates the generation of a streamsurface.
|
||||
|
||||
#
|
||||
# First we include the VTK Tcl packages which will make available
|
||||
# all of the vtk commands from Tcl. The vtkinteraction package defines
|
||||
# a simple Tcl/Tk interactor widget.
|
||||
#
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
package require vtktesting
|
||||
|
||||
# Read the data and specify which scalars and vectors to read.
|
||||
#
|
||||
vtkMultiBlockPLOT3DReader pl3d
|
||||
pl3d SetXYZFileName "$VTK_DATA_ROOT/Data/combxyz.bin"
|
||||
pl3d SetQFileName "$VTK_DATA_ROOT/Data/combq.bin"
|
||||
pl3d SetScalarFunctionNumber 100
|
||||
pl3d SetVectorFunctionNumber 202
|
||||
pl3d Update
|
||||
|
||||
set pl3dOutput [[pl3d GetOutput] GetBlock 0]
|
||||
|
||||
# We use a rake to generate a series of streamline starting points
|
||||
# scattered along a line. Each point will generate a streamline. These
|
||||
# streamlines are then fed to the vtkRuledSurfaceFilter which stitches
|
||||
# the lines together to form a surface.
|
||||
#
|
||||
vtkLineSource rake
|
||||
rake SetPoint1 15 -5 32
|
||||
rake SetPoint2 15 5 32
|
||||
rake SetResolution 21
|
||||
vtkPolyDataMapper rakeMapper
|
||||
rakeMapper SetInputConnection [rake GetOutputPort]
|
||||
vtkActor rakeActor
|
||||
rakeActor SetMapper rakeMapper
|
||||
|
||||
vtkRungeKutta4 integ
|
||||
vtkStreamTracer sl
|
||||
sl SetInputData $pl3dOutput
|
||||
sl SetSourceConnection [rake GetOutputPort]
|
||||
sl SetIntegrator integ
|
||||
sl SetMaximumPropagation 100
|
||||
sl SetInitialIntegrationStep 0.1
|
||||
sl SetIntegrationDirectionToBackward
|
||||
|
||||
#
|
||||
# The ruled surface stiches together lines with triangle strips.
|
||||
# Note the SetOnRatio method. It turns on every other strip that
|
||||
# the filter generates (only when multiple lines are input).
|
||||
#
|
||||
vtkRuledSurfaceFilter scalarSurface
|
||||
scalarSurface SetInputConnection [sl GetOutputPort]
|
||||
scalarSurface SetOffset 0
|
||||
scalarSurface SetOnRatio 2
|
||||
scalarSurface PassLinesOn
|
||||
scalarSurface SetRuledModeToPointWalk
|
||||
scalarSurface SetDistanceFactor 30
|
||||
vtkPolyDataMapper mapper
|
||||
mapper SetInputConnection [scalarSurface GetOutputPort]
|
||||
eval mapper SetScalarRange [$pl3dOutput GetScalarRange]
|
||||
vtkActor actor
|
||||
actor SetMapper mapper
|
||||
|
||||
# Put an outline around for context.
|
||||
#
|
||||
vtkStructuredGridOutlineFilter outline
|
||||
outline SetInputData $pl3dOutput
|
||||
vtkPolyDataMapper outlineMapper
|
||||
outlineMapper SetInputConnection [outline GetOutputPort]
|
||||
vtkActor outlineActor
|
||||
outlineActor SetMapper outlineMapper
|
||||
[outlineActor GetProperty] SetColor 0 0 0
|
||||
|
||||
# Now create the usual graphics stuff.
|
||||
vtkRenderer ren
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
ren AddActor rakeActor
|
||||
ren AddActor actor
|
||||
ren AddActor outlineActor
|
||||
ren SetBackground 1 1 1
|
||||
|
||||
renWin SetSize 300 300
|
||||
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
iren Initialize
|
||||
|
||||
# interact with data
|
||||
wm withdraw .
|
||||
iren Start
|
||||
@ -0,0 +1,104 @@
|
||||
# This example demonstrates how to extract "computational planes" from a
|
||||
# structured dataset. Structured data has a natural, logical coordinate
|
||||
# system based on i-j-k indices. Specifying imin,imax, jmin,jmax, kmin,kmax
|
||||
# pairs can indicate a point, line, plane, or volume of data.
|
||||
#
|
||||
# In this example, we extract three planes and warp them using scalar values
|
||||
# in the direction of the local normal at each point. This gives a sort of
|
||||
# "velocity profile" that indicates the nature of the flow.
|
||||
|
||||
#
|
||||
# First we include the VTK Tcl packages which will make available
|
||||
# all of the vtk commands from Tcl. The vtkinteraction package defines
|
||||
# a simple Tcl/Tk interactor widget.
|
||||
#
|
||||
package require vtk
|
||||
package require vtkinteraction
|
||||
|
||||
# Here we read data from a annular combustor. A combustor burns fuel and air
|
||||
# in a gas turbine (e.g., a jet engine) and the hot gas eventually makes its
|
||||
# way to the turbine section.
|
||||
#
|
||||
vtkMultiBlockPLOT3DReader pl3d
|
||||
pl3d SetXYZFileName "$VTK_DATA_ROOT/Data/combxyz.bin"
|
||||
pl3d SetQFileName "$VTK_DATA_ROOT/Data/combq.bin"
|
||||
pl3d SetScalarFunctionNumber 100
|
||||
pl3d SetVectorFunctionNumber 202
|
||||
pl3d Update
|
||||
|
||||
set pl3dOutput [[pl3d GetOutput] GetBlock 0]
|
||||
|
||||
# Planes are specified using a imin,imax, jmin,jmax, kmin,kmax coordinate
|
||||
# specification. Min and max i,j,k values are clamped to 0 and maximum value.
|
||||
#
|
||||
vtkStructuredGridGeometryFilter plane
|
||||
plane SetInputData $pl3dOutput
|
||||
plane SetExtent 10 10 1 100 1 100
|
||||
vtkStructuredGridGeometryFilter plane2
|
||||
plane2 SetInputData $pl3dOutput
|
||||
plane2 SetExtent 30 30 1 100 1 100
|
||||
vtkStructuredGridGeometryFilter plane3
|
||||
plane3 SetInputData $pl3dOutput
|
||||
plane3 SetExtent 45 45 1 100 1 100
|
||||
|
||||
# We use an append filter because that way we can do the warping, etc. just
|
||||
# using a single pipeline and actor.
|
||||
#
|
||||
vtkAppendPolyData appendF
|
||||
appendF AddInputConnection [plane GetOutputPort]
|
||||
appendF AddInputConnection [plane2 GetOutputPort]
|
||||
appendF AddInputConnection [plane3 GetOutputPort]
|
||||
vtkWarpScalar warp
|
||||
warp SetInputConnection [appendF GetOutputPort]
|
||||
warp UseNormalOn
|
||||
warp SetNormal 1.0 0.0 0.0
|
||||
warp SetScaleFactor 2.5
|
||||
vtkPolyDataNormals normals
|
||||
normals SetInputConnection [warp GetOutputPort]
|
||||
normals SetFeatureAngle 60
|
||||
vtkPolyDataMapper planeMapper
|
||||
planeMapper SetInputConnection [normals GetOutputPort]
|
||||
eval planeMapper SetScalarRange [$pl3dOutput GetScalarRange]
|
||||
vtkActor planeActor
|
||||
planeActor SetMapper planeMapper
|
||||
|
||||
# The outline provides context for the data and the planes.
|
||||
vtkStructuredGridOutlineFilter outline
|
||||
outline SetInputData $pl3dOutput
|
||||
vtkPolyDataMapper outlineMapper
|
||||
outlineMapper SetInputConnection [outline GetOutputPort]
|
||||
vtkActor outlineActor
|
||||
outlineActor SetMapper outlineMapper
|
||||
[outlineActor GetProperty] SetColor 0 0 0
|
||||
|
||||
# Create the usual graphics stuff/
|
||||
#
|
||||
vtkRenderer ren1
|
||||
vtkRenderWindow renWin
|
||||
renWin AddRenderer ren1
|
||||
vtkRenderWindowInteractor iren
|
||||
iren SetRenderWindow renWin
|
||||
|
||||
ren1 AddActor outlineActor
|
||||
ren1 AddActor planeActor
|
||||
ren1 SetBackground 1 1 1
|
||||
renWin SetSize 500 500
|
||||
|
||||
# Create an initial view.
|
||||
set cam1 [ren1 GetActiveCamera]
|
||||
$cam1 SetClippingRange 3.95297 50
|
||||
$cam1 SetFocalPoint 8.88908 0.595038 29.3342
|
||||
$cam1 SetPosition -12.3332 31.7479 41.2387
|
||||
$cam1 SetViewUp 0.060772 -0.319905 0.945498
|
||||
iren Initialize
|
||||
|
||||
# render the image
|
||||
#
|
||||
iren AddObserver UserEvent {wm deiconify .vtkInteract}
|
||||
renWin Render
|
||||
|
||||
# prevent the tk window from showing up then start the event loop
|
||||
wm withdraw .
|
||||
iren Start
|
||||
|
||||
|
||||
Reference in New Issue
Block a user