[vtkusers] Elevation profile
Roger Blum
rogerblum at hawaii.rr.com
Mon May 26 22:15:21 EDT 2008
Hello,
I am trying to extract an elevation profile from some sample data given
in a data file (see attachement).
The following TCL script reads the data and probes the data with 2 lines
(diagonals from corner to corner).
The result should be displayed with a vtkXYPlotActor.
The test output also shows the elevation data used.
My problem is that the probe filters do not return the desired result.
All values are 0. What am I doing wrong?
I have searched the mailing list but wasn't able to find a solution.
I'm using vtk 5.0.3 with TCL 8.4.
Thanks in advance for any hint to solve this problem,
Roger
== Test Script ==
package require vtk
package require vtkinteraction
# Create the standard renderer, render window
# and interactor
vtkRenderer ren1
vtkRenderWindow renWin
renWin AddRenderer ren1
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
# Create the reader for the source data
vtkPolyDataReader reader
reader SetFileName elevData.vtk
reader Update
set elevData [reader GetOutput]
puts "Reader Num points: [$elevData GetNumberOfPoints]"
# Do some calculations
set bounds [$elevData GetBounds]
puts "Bounds: $bounds"
set x0 [lindex $bounds 0]
set x1 [lindex $bounds 1]
set y0 [lindex $bounds 2]
set y1 [lindex $bounds 3]
set z0 [lindex $bounds 4]
set z1 [lindex $bounds 5]
set dist [expr {sqrt(pow($x0 - $x1, 2) + pow($y0 - $y1, 2))}]
puts "Distance: $dist"
set res [expr {int($dist / 25)}]
puts "Resolution: $res"
# Create a PolyData writer
vtkPolyDataWriter PDW
# Create first probe
vtkLineSource LS1
LS1 SetPoint1 $x0 $y0 0
LS1 SetPoint2 $x1 $y1 0
LS1 SetResolution $res
vtkProbeFilter probe1
probe1 SetInput [LS1 GetOutput]
probe1 SetSource $elevData
# Write probe 1
probe1 Update
PDW SetFileName probe1.vtk
PDW SetInput [probe1 GetOutput]
#PDW Write
# Create 2nd probe
vtkLineSource LS2
LS2 SetPoint1 $x0 $y1 0
LS2 SetPoint2 $x1 $y0 0
LS2 SetResolution $res
vtkProbeFilter probe2
probe2 SetInput [LS2 GetOutput]
probe2 SetSource $elevData
# Write probe 2
probe2 Update
PDW SetFileName probe2.vtk
PDW SetInput [probe2 GetOutput]
#PDW Write
# Create XY plot and add 2 probes
vtkXYPlotActor XYPA
XYPA AddInput [probe1 GetOutput]
XYPA AddInput [probe2 GetOutput]
XYPA SetXValuesToIndex
XYPA SetDataObjectPlotModeToRows
[XYPA GetPositionCoordinate] SetValue 0.0 0.67 0
[XYPA GetPosition2Coordinate] SetValue 1.0 0.33 0;#relative to Position
XYPA SetXRange 0 $res
XYPA SetYRange $z0 $z1
XYPA SetLabelFormat "%#6.0f"
XYPA SetNumberOfXLabels 5
XYPA SetNumberOfYLabels 5
ren1 AddActor XYPA
# Show elevation data
vtkPolyDataMapper mapper
mapper SetInput [reader GetOutput]
vtkActor actor
actor SetMapper mapper
ren1 AddActor actor
# Show line 1
vtkPolyDataMapper LM1
LM1 SetInput [LS1 GetOutput]
vtkActor LA1
LA1 SetMapper LM1
#ren1 AddActor LA1
# Show line 2
vtkPolyDataMapper LM2
LM2 SetInput [LS2 GetOutput]
vtkActor LA2
LA2 SetMapper LM2
#ren1 AddActor LA2
# Update window
ren1 ResetCamera
ren1 ResetCameraClippingRange
renWin Render
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: elevData.vtk
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080526/aed32e45/attachment.asc>
More information about the vtkusers
mailing list