[vtkusers] vtkThreshold with vertex points

D.M.P.Davies dmpd at onetel.net.uk
Fri Oct 18 16:12:43 EDT 2002


Sorry but I need help -

I've been trying to set up a set of vertex points with scalar values
representing each vertex. I then generate an unstructured grid and push
through a vtkThreshold .

I am unable to get the threshold to work either by using as point data
(results in no output) or as cell data (where no vertexes are removed).

The Tcl pipeline is in the attached file should some guru know the
answer.

Please could someone out there help

Dave Davies
-------------- next part --------------

############## SET UP SOME 5 SCALARS#######################################
vtkScalars   scalars
scalars SetNumberOfScalars  5
for {set i 0} {$i < 5} {incr i} {
scalars  InsertScalar $i $i
				}
scalars Modified
################## SAME NUMBER -5-  POINTS ###################################
vtkPoints   points
points SetNumberOfPoints  5
for {set i 0} {$i < 5} {incr i} {
points SetPoint $i [expr $i*20] [expr $i*20] [expr $i*20]
				}
points Modified
##################CREATE A SET OF 5  VERTEXES###################################
vtkVertex  vertex
[vertex  GetPointIds] SetNumberOfIds  5
for {set ii 0} {$ii < 5}  {incr ii} {
[vertex GetPointIds]  SetId  $ii   $ii
				}
vertex Modified
############ FEED INTO UNSTRUCTURED GRID #########################################
vtkUnstructuredGrid  unstruc
unstruc SetPoints points
for {set ii 0} {$ii < 5}  {incr ii} {
unstruc  InsertNextCell [vertex GetCellType]   [vertex GetPointIds]
				}
[unstruc GetPointData] SetScalars  scalars
[unstruc GetCellData] SetScalars  scalars
[unstruc GetPointData] Modified
[unstruc GetCellData] Modified
################# PUT INTO A THRESHOLD  TO REMOVE  1'st & last CELL####################################
vtkThreshold thresh
thresh  SetAttributeModeToUseCellData
thresh  SetInput unstruc 
thresh   ThresholdBetween  1 3
thresh   AllScalarsOn
[thresh GetOutput] Update
thresh Modified
######################THEN A MAPPER####################
vtkDataSetMapper   mapper
mapper SetScalarRange 0  4
mapper SetScalarModeToUsePointData
mapper SetInput [thresh GetOutput]
####################AND AN ACTOR ###########################
vtkActor   actor
actor SetMapper mapper
actor SetProperty property(alloy)
 [actor GetProperty]  SetPointSize 10
######### FINALLY RENDER  #############
puts "Output no of cells-PRE RENDER COMMAND  [thresh GetOutput]  - [[thresh GetOutput] GetNumberOfCells]"
puts "Output no of cells-UNSTRUCT GRID PRE RENDER COMMAND  unstruc    - [unstruc GetNumberOfCells]"
Renderer($widget) AddActor  actor
#################### Now The The Unstructured Grid #############
vtkDataSetMapper   mapper1
mapper1   SetScalarRange 0  4
mapper1 SetScalarModeToUsePointData
mapper1 SetInput  unstruc
vtkActor   actor1
actor1 SetMapper mapper1
actor1 SetPosition  50 0 0
actor1 SetProperty property(alloy)
[actor1 GetProperty]  SetPointSize 4
Renderer($widget) AddActor  actor1
#################################################################


More information about the vtkusers mailing list