[vtkusers] Is clipping really that hard in VTK???

D.M.P.Davies dmpd at onetel.net.uk
Thu Aug 29 14:35:06 EDT 2002


Bertwim

I've just done exactly this in my  tcl/tk general purpose display package using vtk3.2.

Steps were as follows :

###  Define a suitable implicit function to cut unstructured grid#####
vtkCylinder $CC
  $CC SetCenter  0 0 0
  $CC SetRadius 100

vtkSphere $CS
  $CS SetCenter  0 0 0
  $CS SetRadius 100

vtkPlane $CP
    $CP  SetOrigin 0 0 0
    $CP SetNormal -1 -1 .5
#CN

set imp $CC
set imp $CP

############### Now Clip The Unstuctured Grid Boundary (i.e after vtkGeometryFilter)
##############
vtkClipPolyData $CN
    $CN  SetInput [$boundary GetOutput]
    $CN  SetClipFunction $imp
    $CN  GenerateClipScalarsOff
    $CN  SetValue 0.5
$CN Update
###### Also for in front of implicit function#####
vtkClipPolyData $Cn
    $Cn  SetInput [$boundary GetOutput]
    $Cn  SetClipFunction $imp
    $Cn  GenerateClipScalarsOff
    $Cn  SetInsideOut 1
    $Cn  SetValue 0.5
$Cn Update
########## Now Cut The Full Structure to get better cut mesh ##############

vtkCutter $CE; #Generate cut lines
   $CE SetInput [$thresh GetOutput]
   $CE SetCutFunction $imp
  $CE GenerateCutScalarsOff
  $CE SetValue 0 0.5

######## Now Append cutter mesh  to front and back clipped Polys and map them ############
vtkAppendPolyData $AP
  $AP AddInput [$CN GetOutput]
  $AP AddInput [$CE GetOutput]

vtkDataSetMapper $CL
$CL SetInput [$AP GetOutput]
$CL SetLookupTable  vTK_LUT($LUT(no))
$CL SetScalarRange $LUT($LUT(no),bot)  $LUT($LUT(no),top)
$CL SetScalarModeToUsePointData

vtkAppendPolyData $Ap
  $Ap AddInput [$Cn GetOutput]
  $Ap AddInput [$CE GetOutput]
#
vtkDataSetMapper $Cl
$Cl SetInput [$Ap GetOutput]
$Cl SetLookupTable  vTK_LUT($LUT(no))
$Cl SetScalarRange $LUT($LUT(no),bot)  $LUT($LUT(no),top)
$Cl SetScalarModeToUsePointData
###################Actors For Front and Back###################################
vtkActor $CA
    $CA SetMapper $CL
    $CA SetProperty property(front)
vtkActor $Ca
    $Ca SetMapper $Cl
    $Ca SetProperty property(back)
##################Finally Render the actors #############################
Renderer($widget) AddActor $CA
Renderer($widget) AddActor $Ca

It Works Well for me with dials in control of the implicit funtion positioning running under a
vtkTkRenderWidget's $widget.


Bertwim van Beest wrote:

> I simply don't understand how to do the following:
>
> I have a certain UnstructuredGrid, with one data value per cell.
> ,
> Bertwim
>
> _______________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020829/2694e287/attachment.htm>


More information about the vtkusers mailing list