[vtkusers] Get actual position of actor from an assembly after applying transforms

Bill Lorensen bill.lorensen at gmail.com
Thu Mar 29 12:58:21 EDT 2018


If you can provide a compilable example we can take a look.

On Thu, Mar 29, 2018, 9:54 AM Jay <jayavardhanravi at outlook.com> wrote:

> I am trying to obtain  the position of  the actor after the adding to
> assembly and making transforms.
>
> After each transformation I try to print the position and center but I
> always get the initial values or the values don't update as the transforms
> updates.
>
> Do I miss something ?
>
> The pseudo code:
>
> vtkSmartPointer<vtkCylinderSource> cyl =
> vtkSmartPointer<vtkCylinderSource>::New();
>         cyl->SetRadius(10);
>         cyl->SetHeight(50);
>         cyl->Update();
>         vtkSmartPointer<vtkPolyDataMapper> mapper =
> vtkSmartPointer<vtkPolyDataMapper>::New();
>         mapper->SetInputConnection(cyl->GetOutputPort());
>         vtkSmartPointer<vtkActor> act1 = vtkSmartPointer<vtkActor>::New();
>         act1->SetMapper(mapper);
>         vtkSmartPointer<vtkTransform> trans1 =
> vtkSmartPointer<vtkTransform>::New();
>         act1->SetUserTransform(trans1);
>
>         vtkSmartPointer<vtkCylinderSource> cyl1 =
> vtkSmartPointer<vtkCylinderSource>::New();
>         cyl1->SetRadius(10);
>         cyl1->SetHeight(50);
>         cyl1->Update();
>         vtkSmartPointer<vtkPolyDataMapper> mapper1 =
> vtkSmartPointer<vtkPolyDataMapper>::New();
>         mapper1->SetInputConnection(cyl1->GetOutputPort());
>         vtkSmartPointer<vtkActor> act2 = vtkSmartPointer<vtkActor>::New();
>         act2->SetMapper(mapper1);
>         vtkSmartPointer<vtkTransform> trans2 =
> vtkSmartPointer<vtkTransform>::New();
>         act2->SetUserTransform(trans2);
>
>         vtkSmartPointer<vtkAssembly> assembly =
> vtkSmartPointer<vtkAssembly>::New();
>         assembly->AddPart(act1);
>         assembly->AddPart(act2);
>         int count = 0;
>         while(count < 100)
>         {
>                 trans2->Identity();
>                 trans2->RotateX(30);
>                 trans2->RotateY(90);
>                 trans2->RotateZ(10);
>                 trans2->Update();
>                 renderer->AddActor(assembly);
>                 renderer->Render();
>                 count++;
>                 std::cout << "Center : " << act2->GetCenter()[0] << " & "
> <<
> act2->GetCenter()[1] << " & " << act2->GetCenter()[2];
>                 std::cout << "Position : " << act2->GetPosition()[0] << "
> & " <<
> act2->GetPosition()[1] << " & " << act2->GetPosition()[2];
>         }
>
> Any help or suggestions would be appreciated
>
> Regards,
> Jay
>
>
>
> --
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> _______________________________________________
> 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:
> https://vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180329/f9d5b097/attachment.html>


More information about the vtkusers mailing list