[vtkusers] plot a huge amount of spheres

curator curator at gmx.de
Mon Aug 26 09:04:58 EDT 2013


Hi and thanks for your help.

I read some pages about vtkGlyph3D and came up up with following solution.

m_vtkCenterPoints = vtkPoints::New();
m_vtkCenterPolyData = vtkPolyData::New();
m_vtkSphereSource = vtkSphereSource::New();
m_vtkGlyph3D = vtkGlyph3D::New();

m_vtkCenterPolyData->SetPoints(m_vtkCenterPoints);
m_vtkGlyph3D->SetSourceConnection(m_vtkSphereSource->GetOutputPort());
m_vtkGlyph3D->SetInputData(m_vtkCenterPolyData);
m_vtkGlyph3D->GeneratePointIdsOn();

m_vtkMapper->SetInputConnection(m_vtkGlyph3D->GetOutputPort());

....
addData(...)
{
m_vtkCenterPoints->InsertNextPoint(i_Position.x,i_Position.y,i_Position.z);
     m_Data.push_back("I am some information");
}
.....
m_vtkGlyph3D->Update();

So, this works. I have to point out that I have different vtkGlyphs 
plotted simultainiously. Nevertheless, I now would like to use a picker, 
which means that I would like give some text output of the current sphere.

Therefore, during mouseover, I already managed to determine the current 
vtkActor and, hence, are already in the "correct" glyph. Now my idea is, 
that during the "addData" call, a stl::vector is filled with 
information. The number of elements should be identical to the number of 
points, as both is extended by one with each call. My aim is something like

...
int ID = i_dont_know() // id of current sphere
printf("Your information is %d\n",m_Data[ID]);
...
I tried around with vtkCellPicker and vtkPointPicker, which seem to work 
in general, but are not very accurate, which means that some sometimes 
come up with wrong data as output.
if ( m_PointPicker->Pick( i_X, i_Y, 0, i_Renderer ) )
     {
         // something is picked
         int ID2 =m_PointPicker->GetPointId();

         vtkDataArray *p_Array = 
m_vtkGlyph3D->GetOutput()->GetPointData()->GetArray("InputPointIds");
         int ID = int(p_Array->GetTuple1(p_ID2 ));
     }
or
if ( m_CellPicker->Pick( i_X, i_Y, 0, i_Renderer ) )
     {
         // something is picked
         int ID2 =m_CellPicker->GetCellId();

         vtkDataArray *p_Array = 
m_vtkGlyph3D->GetOutput()->GetPointData()->GetArray("InputPointIds");
         int ID = int(p_Array->GetTuple1(p_ID2 ));
     }

Is there a more correct approach?

regards,
curator
Am 22.08.2013 16:55, schrieb David E DeMarle:
> Use a vtkPolyData with points on the locations, and a VTK_VERTEX cell 
> refering to each one.
>
> Then send that into vtkGlyph to have the CPU makes the spheres which 
> then get send to the card.
>
> Better yet, draw it with vtkGlyph3dMapper to make the spheres via 
> vertex programs on the GPU instead of the CPU.
>
> Better still, bring ParaView's point sprite plugin over, which will 
> draw the spheres via fragment programs on the GPU.
>
>
> David E DeMarle
> Kitware, Inc.
> R&D Engineer
> 21 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-881-4909
>
>
> On Thu, Aug 22, 2013 at 10:45 AM, Gib Bogle <g.bogle at auckland.ac.nz 
> <mailto:g.bogle at auckland.ac.nz>> wrote:
>
>     You need only multiple actors, all using the same mapper.
>
>
>     On 23/08/2013 2:39 a.m., curator wrote:
>
>         Hi all,
>
>         I am able to draw a vtkSphere with its own vtkSphere, vtkActor
>         and vtkMapper equipped together. Now if I need several
>         spheres, I add multiple instances of this stuff for each
>         sphere and add them all up to the same renderer - so far, so good.
>
>         Now I need to draw a really huge amount of spheres, which are
>         all identical except the position. Is there any more efficient
>         way to to that than just creating N vtkActors, N vtkMappers
>         and N vtkSpheres?
>
>         regards,
>         curator
>         _______________________________________________
>         Powered by www.kitware.com <http://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
>
>
>
>     -- 
>     Dr. Gib Bogle
>     Senior Research Fellow
>     Auckland Bioengineering Institute
>     University of Auckland
>     New Zealand
>
>     http://www.bioeng.auckland.ac.nz
>
>     g.bogle at auckland.ac.nz <mailto:g.bogle at auckland.ac.nz>
>     (64-9) 373-7599 Ext. 87030
>
>
>     _______________________________________________
>     Powered by www.kitware.com <http://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
>
>
>
>
> _______________________________________________
> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130826/18cf393d/attachment.htm>


More information about the vtkusers mailing list