[vtkusers] Placement of actors in world coordinate system wierdness

zmantorn zmanvortex at gmail.com
Fri Aug 11 13:53:07 EDT 2017


Bill Lorensen wrote
> Looks OK to me. Have your printed the startpos elements?
> 
> 
> On Thu, Aug 10, 2017 at 2:59 PM, Mads M. Hansen <

> madsmh@

> > wrote:
>> Hello, I am attempting to placed number of actors (spheres) at various
>> positions throughout the scene with the following routine
>>
>> for (int i = 0; i < radii.size(); ++i) {
>>         vtkSmartPointer
> <vtkSphereSource>
>  sphereSource =
>> vtkSmartPointer
> <vtkSphereSource>
> ::New();
>>         sphereSource->SetRadius(radii[i]);
>>         sphereSource->SetPhiResolution(100);
>>         sphereSource->SetThetaResolution(100);
>>         sphereSource->Update();
>>
>>         vtkSmartPointer
> <vtkPolyDataMapper>
>  sphereMapper =
>> vtkSmartPointer
> <vtkPolyDataMapper>
> ::New();
>>         sphereMapper->SetInputConnection(sphereSource->GetOutputPort());
>>
>>         vtkSmartPointer
> <vtkActor>
>  actor = vtkSmartPointer
> <vtkActor>
> ::New();
>>         actor->SetPosition(start_pos[i].x(), start_pos[i].y(),
>> start_pos[i].z());
>>         actor->SetMapper(sphereMapper);
>>         actor->GetProperty()->SetInterpolationToFlat();
>>         actor->GetProperty()->SetFrontfaceCulling(true);
>>
>>         actors.push_back(actor);
>>
>>     }
>>
>> //Set up renderer
>>     vtkSmartPointer
> <vtkRenderer>
>  renderer =
>> vtkSmartPointer
> <vtkRenderer>
> ::New();
>>
>>
>>     // Create new camera
>>     vtkSmartPointer
> <vtkCamera>
>  camera = vtkSmartPointer
> <vtkCamera>
> ::New();
>>     renderer->SetActiveCamera(camera);
>>
>>     for (int j = 0; j < radii.size(); ++j) {
>>         renderer->AddActor(actors[j]);
>>     }
>> //Set up renderer
>>     vtkSmartPointer
> <vtkRenderer>
>  renderer =
>> vtkSmartPointer
> <vtkRenderer>
> ::New();
>>
>>
>>     // Create new camera
>>     vtkSmartPointer
> <vtkCamera>
>  camera = vtkSmartPointer
> <vtkCamera>
> ::New();
>>     renderer->SetActiveCamera(camera);
>>
>>     for (int j = 0; j < radii.size(); ++j) {
>>         renderer->AddActor(actors[j]);
>>     }
>>
>> ...
>>
>> this->ui->widget->GetRenderWindow()->AddRenderer(renderer);
>> }
>>
>> But when rendered I get all spheres superimposed on top of each other and
>> when the camera movies they appear to turn about their individual origins
>> -
>> which is not the desired outcome, rather that they should be placed at
>> their
>> respective coordinates in 3D space.
>>
>> Any help with this would be greatly appreciated
>>
>> .. Mads
>>
>> _______________________________________________
>> 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
>>
> 
> 
> 
> -- 
> Unpaid intern in BillsBasement at noware dot 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


It looks like you have doubled up creating renderer, camera, and adding
actors to the renderer. Look at the duplicated code at the end of your code
snippet.



--
View this message in context: http://vtk.1045678.n5.nabble.com/Placement-of-actors-in-world-coordinate-system-wierdness-tp5744363p5744382.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list