[vtkusers] Rotation of PolyData

Pablo Rubi pabloarubi at gmail.com
Wed Jun 17 09:17:08 EDT 2015


The only way I've found to do that is calling win->Render() again after the
changes are done. Optimally, you want this to be called once per frame,
after all changes have been done. You could set a bool flag like
needsUpdating and set it to true if you call Drawing::translate()

I'm not an expert at VTK though, and I also expected at first that the
pipeline would know when it needed to be re-rendered. Maybe it has that
functionality and I haven't been able to trigger it. If you find out, let
us know.

2015-06-17 7:58 GMT-03:00 Lonni Besançon <lonni.besancon at gmail.com>:

> Turns out I am now using the Actor directly to set rotation translation and
> scale. It does work fine except that I need to click on the window for the
> changes to appear. Would anyone know the reason why?
> Don't know if this is useful but here is my code now:
>
> void Drawing::translate(float x, float y, float z){
>         cout << "Translate: " << x << " - " << " - " << y << " - " << z <<
> endl ;
>         vtkSmartPointer<vtkTransform> transform1a =
> vtkSmartPointer<vtkTransform>::New();
>         //transform1a->Translate(x,y,z);
>         //transformFilter->SetTransform(transform1a);
>         //transformFilter->Update();
>         double* position = mainActor->GetPosition();
>         mainActor->SetPosition(position[0]+x,position[1]+y,position[2]+z);
> }
>
> void Drawing::read(){
>
>         std::string filename = BUNNY;
>         // Read all the data from the file
>         vtkSmartPointer<vtkXMLPolyDataReader> reader
> =vtkSmartPointer<vtkXMLPolyDataReader>::New();
>         reader->SetFileName(filename.c_str());
>         reader->Update();
>         inputPolyData = reader->GetOutput();
>
>         cout << "File Found and Loaded : " << filename << endl ;
>
>         vtkSmartPointer<vtkTransform> translation =
> vtkSmartPointer<vtkTransform>::New();
>         translation->Translate(0.3, -0.05, 0);
>         transformFilter =
> vtkSmartPointer<vtkTransformPolyDataFilter>::New();
>         //transformFilter->SetInputConnection(reader->GetOutputPort());
>         transformFilter->SetInputData(inputPolyData);
>         transformFilter->SetTransform(translation);
>         //transformFilter->Update();
>
>         vtkSmartPointer<vtkPolyDataMapper> mapper =
> vtkSmartPointer<vtkPolyDataMapper>::New();
>         mapper->SetInputConnection(transformFilter->GetOutputPort());
>
>         mainActor = vtkSmartPointer<vtkActor>::New();
>         mainActor->SetMapper(mapper);
>
>         ren->AddActor(mainActor);
>
>         vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>         iren->SetRenderWindow(win);
>         vtkInteractorStyleMultiTouchCamera *style =
>         vtkInteractorStyleMultiTouchCamera::New();
>         iren->SetInteractorStyle(style);
>
>         //Start the event loop
>         iren->Initialize();
>         iren->Start();
>
>         defineClipping();
>         win->PolygonSmoothingOn();
>         win->Render();
>         win->Start();
> }
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/Rotation-of-PolyData-tp5732340p5732400.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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150617/abe723f7/attachment.html>


More information about the vtkusers mailing list