[vtkusers] image masking pb

dean.inglis at camris.ca dean.inglis at camris.ca
Mon Dec 15 23:26:36 EST 2003


Hi David,

I tried vtkImplicitSelectionLoop in a tcl/tk
tester pipeline:

vtkPolyData spoly
vtkPoints spoints

vtkImplicitSelectionLoop loop
  loop SetLoop spoints
  loop SetNormal 1 0 0
  loop AutomaticNormalGenerationOn  

vtkImplicitFunctionToImageStencil if2is
  if2is SetInput loop

vtkImageStencil stencil
    stencil SetInput [extract GetOutput]
    stencil SetStencil [if2is GetOutput] 
    stencil ReverseStencilOn
    stencil SetBackgroundValue 128
    stencil ReleaseDataFlagOff 

which gets passed onto a vtkImageActor when
the points making up the loop are defined by a 
closed splinewidget.  The stencil works once and
either it or the vtkImageActor refuses to update
when the points change (their number is the same
but their positions change).  

What seems to work faster and does update with 
changed point positions is this pipeline:

vtkPolyData spoly

vtkLinearExtrusionFilter extrude
  extrude SetInput spoly
  extrude SetScaleFactor 1 
  extrude SetExtrusionTypeToNormalExtrusion 
  extrude SetVector 1 0 0 

vtkPolyDataToImageStencil dataToStencil
dataToStencil SetInput [extrude GetOutput]

vtkImageStencil stencil
stencil SetInput [extract GetOutput]
stencil SetStencil [dataToStencil GetOutput]
stencil ReverseStencilOff
stencil SetBackgroundValue 128

Any idea why the first pipeline refuses to
update?

thanks for your help,
Dean

> 
> The vtkImplicitSelectionLoop works good for this, but it there isn't
> any filter to convert a vtkPolyData into a SelectionLoop, you have to
> do it by hand.
> 
> Once you have a vtkImplicitSelectionLoop, you can convert it into a
> "stencil" with the vtkImplicitFunctionToImageStencil filter.  A "stencil"
> is essentially a masked region that has been compressed into run-lengths,
> a few of the image filters take a stencil as an additional input.
> 
> There is also a vtkPolyDataToImageStencil filter, but it is meant for
> closed polyhedral surfaces, not for closed 2D polygons.
> 
>  - David





More information about the vtkusers mailing list