[vtkusers] Re: Using vtkCutter on a transformed model
Goodwin Lawlor
goodwin.lawlor at ucd.ie
Thu Dec 15 10:09:57 EST 2005
Clare Fitzpatrick wrote:
> Hi, I am trying to orientate a 3D model so that a particular vector is
> aligned with the z-axis in world coordinates.
> I have tried:
>
> vtkSTLReader model
> model SetFileName "C:/myFile"
> ...
> I am applying an instance of vtkCutter to this model.
>
> vtkCutter cutter1
> cutter1 SetInput [model GetOutput]
> ...
> then when I transform the model using
>
> modelActor RotateWXYZ angle1 0 0 1
> modelActor RotateWXYZ angle2 0 1 0
>
> the model is transforming correctly but cutter1 is not cutting the model
> anymore.
>
> When I use a transform:
> vtkTransform modelTransform
>
> vtkTransformPolyDataFilter modTransform
> modTransform SetTransform modelTransform
> modTransform SetInput [model GetOutput]
>
> and then
> cutter1 SetInput [modelTransform GetOutput]
> ...
> and then transform the model using
> modelTransform RotateWXYZ angle1 0 0 1
> modelTransform RotateWXYZ angle2 0 1 0
>
> its producing the wrong output - i think it might be using the model
> coordinates instead of the world ones.
>
> Any ideas on how to set the cutter to work on the (correctly)
> transformed model??
>
> Clare
>
Hi Clare,
vtkProp3D::RotateWXYZ uses a PostMultiply transform whereas
vtkTransform::RotateWZYZ uses PreMultiply by default. Try:
modTransform PostMultiply
and you should get the same output.
Here's a trick to get the the output of the cutter to keep up with an
actors transform: use vtkImplicitFunction::SetTransform and
vtkProp3D::SetUserTransform to share a common vtkTransform.
So...
vtkSTLReader model
model SetFileName filename.stl
vtkTransform actorTranform
vtkPlane cutterPlane
cutterPlane SetTransform actorTransform
vtkCutter cutter
cutter SetCutFunction cutterPlane
cutter SetInput [model GetOutput]
vtkPolyDataMapper cutterMapper
cutterMapper SetInput [cutter GetOutput]
vtkActor cutterActor
cutterActor SetMapper cutterMapper
vtkPolyDataMapper mapper
mapper SetInput [model GetOutput]
vtkActor actor
actor SetMapper mapper
actor SetUserTransform actorTransform
actorTransform PostMultiply
actorTranform RotateWXYZ 30 0 0 1
hth
Goodwin
More information about the vtkusers
mailing list