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

ishantembhekar ishan.tembhekar at caltech.edu
Wed Jul 22 13:58:28 EDT 2015


<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.


More information about the vtkusers mailing list