[vtkusers] Writing a rotated vtkcubesource in a .vtp file

Cory Quammen cory.quammen at kitware.com
Wed Jul 22 14:18:30 EDT 2015


You'll need to translate your cube by the negated center of the cube, then
rotate. You can do this all in the same vtkTransform object.

- Cory

On Wed, Jul 22, 2015 at 1:58 PM, ishantembhekar <ishan.tembhekar at caltech.edu
> wrote:

> <
> http://vtk.1045678.n5.nabble.com/file/n5733047/Screen_Shot_2015-07-22_at_10.png
> >
>
> Hi Cory,
>
> Thank you so much for your immediate response! The
> vtkTransformPolyDataFilter worked and it now gives me a rotated cube. I
> replaced the mapper and the actor with the following lines:
>
> //create a rotation object
>     vtkSmartPointer<vtkTransform> rotation =
>       vtkSmartPointer<vtkTransform>::New();
>     //the angle is measured in degrees for some reason
>     rotation->RotateZ(45.);
>  //use this rotation object in a transformFilter
>     vtkSmartPointer<vtkTransformPolyDataFilter> transformFilter =
>       vtkSmartPointer<vtkTransformPolyDataFilter>::New();
>     transformFilter->SetInputConnection(cubeSource->GetOutputPort());
>     transformFilter->SetTransform(rotation);
>     transformFilter->Update();
>
> However, it is rotating about the z-axis and the origin (as shown in the
> image I attached). What can I do for it to rotate about the center of the
> cube? I tried using SetCenter for both the vtkTransform and the
> PolyDataFilter but they do not have that method. Any ideas?
>
> Thanks once again!
>
> -Ishan
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/Writing-a-rotated-vtkcubesource-in-a-vtp-file-tp5733044p5733047.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>



-- 
Cory Quammen
R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150722/c9b052da/attachment.html>


More information about the vtkusers mailing list