[vtkusers] fastest render method for spheres...?!
Liam Kurmos
quantum.leaf at googlemail.com
Thu Feb 4 12:30:48 EST 2010
if you want to render 10,000 sphere presumably the resolution could be
much lower that 30. With resolution of 30 i dont know how many
triangle youll have for each sphere but probably a lot. Try a much
lower number like 6.
Liam
On Thu, Feb 4, 2010 at 5:25 PM, Benjamin Frigan
<frigan at itap.physik.uni-stuttgart.de> wrote:
> Hi everyone,
>
> Which render 'method' for displaying a bunch of spheres/cubes/tubes is
> the fastest one?
> I already tried several things and also searched the user list. Anyway,
> I just want to render a few thousand spheres and all methods I tried so
> far were quite slow. My sphere resolution was only 30 (both phi & theta).
> First, I tried:
> sphereSource > mapper > actor > vActor.push_back(actor)
> i.e. I had a vector of actors and for each sphere I had one actor. For
> setting the position and radius of the spheres I used
> sphere->SetCenter(i,j,k) and sphere->SetRadius(...). However, I searched
> the user list and someone wrote that it's faster when you use
> actor->SetOrigion(i,j,k) and actor->SetScale(...). Honestly, I didn't
> see a difference.
> I also tried to use vtkglyph3D. But this seems to be slower. You can
> find my main() below.
>
> I know that chemists do something like that to display their molecules.
> So how do you solve that when you have, let's say 10,000 atoms?
>
> Thanks,
>
> Ben
>
>
>
>
> int main()
> {
> vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
> for(int i=0; i<15; i++)
> {
> for(int j=0; j<15; j++)
> {
> for(int k=0; k<15; k++)
> points->InsertNextPoint(i,j,k);
> }
> }
> vtkSmartPointer<vtkPolyData> polydata =
> vtkSmartPointer<vtkPolyData>::New();
> polydata->SetPoints(points);
>
> vtkSmartPointer<vtkSphereSource> sphereSource =
> vtkSmartPointer<vtkSphereSource>::New();
> sphereSource->SetRadius(.3);
> sphereSource->SetPhiResolution(30);
> sphereSource->SetThetaResolution(30);
>
> vtkSmartPointer<vtkGlyph3D> glyph3D = vtkSmartPointer<vtkGlyph3D>::New();
> glyph3D->SetSource(sphereSource->GetOutput());
> glyph3D->SetInput(polydata);
> glyph3D->Update();
>
> vtkSmartPointer<vtkPolyDataMapper> glyphMapper =
> vtkSmartPointer<vtkPolyDataMapper>::New();
> glyphMapper->SetInput(glyph3D->GetOutput());
>
> vtkSmartPointer<vtkActor> glyphActor = vtkSmartPointer<vtkActor>::New();
> glyphActor->SetMapper(glyphMapper);
>
> vtkSmartPointer<vtkRenderer> renderer =
> vtkSmartPointer<vtkRenderer>::New();
> vtkSmartPointer<vtkRenderWindow> renderWindow =
> vtkSmartPointer<vtkRenderWindow>::New();
> renderWindow->AddRenderer(renderer);
>
> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
> vtkSmartPointer<vtkRenderWindowInteractor>::New();
> renderWindowInteractor->SetRenderWindow(renderWindow);
>
> renderer->AddActor(glyphActor);
> renderer->SetBackground(0.1, 0.2, 0.4);
>
> renderWindow->Render();
>
> vtkSmartPointer<vtkInteractorStyleTrackballCamera> style =
> vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
> renderWindowInteractor->SetInteractorStyle( style );
> renderWindowInteractor->Start();
>
> return 0;
> }
>
>
>
> _______________________________________________
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list