[vtkusers] vtkContourFilter having problem with vtkScalarTree

Rooparam Choudhary rrc.iisc at gmail.com
Mon Apr 25 13:05:20 EDT 2011


Hi,
      I am facing a strange problem, actually i was implementing NOISE
algorithm for contour extraction. So i implemented a subclass of
vtkScalarTree (subclass name is vtkRRCKDTree). But when i do
UseScalarTreeOn, it seems like vtkContourFilter is actually not using
ScalarTree to get active contour cells. So i took one step backward and used
vtkSimpleScalarTree, but vtkContourFilter doesn't seem to use ScalarTree in
this case also. (PS: i am observing the visualization in TCL by pressing 'u'
when gui appears, then typing 'myTree Print' or 'contour Print')
     My code is as follows:

package require vtk
package require vtkinteraction

# create renderer, render window, and interactor
vtkRenderer aRenderer
vtkRenderWindow renWin
renWin AddRenderer aRenderer
renWin SetSize 640 480
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin

# create reader
vtkImageReader aReader
aReader SetFileName "engine.raw"
aReader SetFileDimensionality 3
aReader SetDataExtent 0 127 0 148 0 200
aReader SetDataSpacing 0.046766 0.046766 0.046766
aReader SetDataOrigin 0.0 0.0 0.0
aReader SetDataScalarTypeToUnsignedChar
aReader UpdateWholeExtent

# outline filter
vtkOutlineFilter outline
outline SetInputConnection [aReader GetOutputPort]
vtkPolyDataMapper outlineMapper
outlineMapper SetInputConnection [outline GetOutputPort]
vtkActor outlineActor
outlineActor SetMapper outlineMapper
[outlineActor GetProperty] SetColor 0 0 1

# create scalar tree
vtkSimpleScalarTree myTree
  myTree SetDataSet [aReader GetOutput]
# isosurface filter
vtkContourFilter contour
  contour SetInputConnection [aReader GetOutputPort]
  contour SetValue 0 1
  contour SetScalarTree myTree
  contour UseScalarTreeOn
  contour ComputeNormalsOn
  contour ComputeGradientsOn
vtkPolyDataMapper mcMapper
mcMapper SetInputConnection [contour GetOutputPort]
  eval mcMapper SetScalarRange [[aReader GetOutput] GetScalarRange]
mcMapper ScalarVisibilityOn
vtkActor mcActor
mcActor SetMapper mcMapper
[mcActor GetProperty] SetColor 1 1 1

# complete pipeline
aRenderer AddActor outlineActor
aRenderer AddActor mcActor
aRenderer ResetCamera
aRenderer ResetCameraClippingRange

# slider widget representation
vtkSliderRepresentation2D sliderRep
  sliderRep SetMinimumValue 0
  sliderRep SetMaximumValue 255
  sliderRep SetValue  1
  sliderRep SetTitleText  "isosurface value"
# position slider
  [sliderRep GetPoint1Coordinate] SetCoordinateSystemToNormalizedDisplay
  [sliderRep GetPoint1Coordinate] SetValue 0.1 0.1
  [sliderRep GetPoint2Coordinate] SetCoordinateSystemToNormalizedDisplay
  [sliderRep GetPoint2Coordinate] SetValue 0.9 0.1
# slider representation
  sliderRep SetSliderLength 0.02
  sliderRep SetSliderWidth  0.03
  sliderRep SetEndCapLength 0.01
  sliderRep SetEndCapWidth  0.03
  sliderRep SetTubeWidth  0.005
  sliderRep SetLabelFormat  "%3.0f"
# actual slider widget
vtkSliderWidget sliderWidget
  sliderWidget SetInteractor iren
  sliderWidget SetRepresentation sliderRep
  sliderWidget KeyPressActivationOff
  sliderWidget SetAnimationModeToAnimate
  sliderWidget AddObserver InteractionEvent callback

# start viz.
iren AddObserver UserEvent {wm deiconify .vtkInteract}
iren Initialize
renWin  Render
sliderWidget On
wm withdraw .

vtkMath math
proc callback { } {
  contour SetValue 0 [ eval math Round [ sliderRep GetValue ] ]
}

Thanks,
-- 
Rooparam Choudhary,
 M Tech (2010-2012)
 Computational Science,
 Supercomputer Education & Research Center,
 Indian Institute of Science,
 Bangalore - 560 012, INDIA
 Ph: (P) +91-94613-14938
 email:      rooparam at rishi.serc.iisc.ernet.in
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110425/f9c9bb9c/attachment.htm>


More information about the vtkusers mailing list