[vtkusers] How to make series of transformation?

Dženan Zukić dzenanz at gmail.com
Thu Mar 15 04:49:16 EDT 2012


First of all, doing 3 transformations on a polydata like that
is inefficient. Try this:

vtkSmartPointer<vtkTransform> ntrans = vtkSmartPointer<vtkTransform>::New();
ntrans->Translate(np);
ntrans->RotateZ(rot_angle);
ntrans->Translate(pp);
//perhaps do this in reverse order (or turn on postMultiply)
//also take a look at matrix returned by ntrans->GetMatrix(), it is helpful
for debugging

vtkSmartPointer<vtkTransformPolyDataFilter> nTranslateFilter =
       vtkSmartPointer<vtkTransformPolyDataFilter>::New();
nTranslateFilter->SetInput( polyData );   // polyData is an object of type
vtkPolyData
nTranslateFilter->SetTransform(ntrans);
nTranslateFilter->Update();

vtkSmartPointer<vtkPolyDataMapper> pdmapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
pdmapper->SetInputConnection(nTranslateFilter->GetOutputPort() );
pdmapper->ScalarVisibilityOff();

vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(pdmapper);

On Thu, Mar 15, 2012 at 04:31, rakesh patil <prakeshofficial at gmail.com>wrote:

> Hello,
>
> I am using this particular code to perform the following set of
> transformations
>
> Translate -> Rotate -> Translate
>
> vtkSmartPointer<vtkTransform> ntrans =
> vtkSmartPointer<vtkTransform>::New();
> ntrans->Translate(np);
>
> vtkSmartPointer<vtkTransform> ptrans =
> vtkSmartPointer<vtkTransform>::New();
> ptrans->Translate(pp);
>
> vtkSmartPointer<vtkTransform> rotateTrans =
> vtkSmartPointer<vtkTransform>::New();
> rotateTrans->RotateZ(rot_angle);
>
> vtkSmartPointer<vtkTransformPolyDataFilter> nTranslateFilter =
>        vtkSmartPointer<vtkTransformPolyDataFilter>::New();
> nTranslateFilter->SetInput( polyData );   // polyData is an object of type
> vtkPolyData
> nTranslateFilter->SetTransform(ntrans);
> nTranslateFilter->Update();
>
> vtkSmartPointer<vtkTransformPolyDataFilter> rotateFilter =
>        vtkSmartPointer<vtkTransformPolyDataFilter>::New();
> rotateFilter->SetInputConnection( nTranslateFilter->GetOutputPort() );
> rotateFilter->SetTransform(rotateTrans);
> rotateFilter->Update();
>
> vtkSmartPointer<vtkTransformPolyDataFilter> pTranslateFilter =
>        vtkSmartPointer<vtkTransformPolyDataFilter>::New();
> pTranslateFilter->SetInputConnection( rotateFilter->GetOutputPort() );
> pTranslateFilter->SetTransform(ptrans);
> pTranslateFilter->Update();
>
> vtkSmartPointer<vtkPolyDataMapper> pdmapper =
> vtkSmartPointer<vtkPolyDataMapper>::New();
> pdmapper->SetInputConnection(pTranslateFilter->GetOutputPort() );
> pdmapper->ScalarVisibilityOff();
>
> vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
> actor->SetMapper(pdmapper);
>
>
> With this code, I can see that the transformation is done only till
> rotation. Next translation is not shown. Can anyone point out where I am
> going wrong?
>
> Thanks in advance
>
> Regards
> Rakesh Patil
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120315/5f82fd16/attachment.htm>


More information about the vtkusers mailing list