# visualize large amount of changing object(cubes, points, lines, etc) in real time

**URL:** https://discourse.vtk.org/t/visualize-large-amount-of-changing-object-cubes-points-lines-etc-in-real-time/12926
**Category:** Support
**Created:** [December 19, 2023, 1:14am UTC](https://discourse.vtk.org/t/visualize-large-amount-of-changing-object-cubes-points-lines-etc-in-real-time/12926 "2023-12-19T01:14:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![baker-Xie](https://discourse.vtk.org/user_avatar/discourse.vtk.org/baker-xie/32/8169_2.png) [@baker-Xie](https://discourse.vtk.org/u/baker-Xie)
#### Post date: [December 19, 2023, 1:14am UTC](https://discourse.vtk.org/t/visualize-large-amount-of-changing-object-cubes-points-lines-etc-in-real-time/12926/1 "2023-12-19T01:14:39Z")

</div>

Hi, I’m creating a visualization tool using vtk to visualize sensor’s data in self driving car. For now, I need to render 100000+ points and 2000+ objects (consist of cube, arrow, lines, etc), the points / objects position, size and color are determined by many external laser sensor or user’s algorithms.

For exmaple:

user’s algorithm 1: want to show A1 cubes, B1 lines, … (Each frame, the numbers of cubes, lines… are changing. And the position / orientation / size are also changing)  
user’s algorithm 2: want to show B2 lines, C2 arrows, D2 points  
user’s algorithm 3: want to show C3 points, D3 cubes  
…

My goal is:

1. receive all these data and render them in vtk
2. render them \>=20 frames per second
3. I can easily show / hide parts of input. For example, I can easily hide A1 cubes from algorithm1 when user click a button.

For now, I meet a performance problem. My solution is :

1. Use vtkPoints + vtkVertexGlyphFilter to render point cloud. When points change, I just modify the vtkPoints and call Modify(). This method seems work well.
2. For each object, make a source / a mapper and a actor. For example, if user need to show 2000 cubes, then I create 2000 vtkCubeSource and mapper and actor. This method is very slow. Create 2000 actors is slow and render is also very slow.

My question:

1. I find some possible solution like [how to render 10000 actors](https://discourse.vtk.org/t/vtk-is-slow-when-i-have-a-lot-of-actors-10000/2421/1), but using vtkGlyph3DMapper can only render one kind of object. So if I want to render different kind of objects (like cubes, lines, arrows), do I need to create several vtkGlyph3DMapper for each of them? For example, one vtkGlyph3DMapper to render all cubes, one vtkGlyph3DMapper to render all lines?
2. If I use the method above, how can I manage them? Because as I describled before, the cubes I need to visualize may provided by several algorithm, and I need to realize a function that I can easily hide/ show part of them.
3. Is there any better solution?
4. Should I use another 3d engine? Does vtk meet my needs？

Thanks

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [December 19, 2023, 9:16am UTC](https://discourse.vtk.org/t/visualize-large-amount-of-changing-object-cubes-points-lines-etc-in-real-time/12926/2 "2023-12-19T09:16:17Z")

</div>

> [@baker-Xie](#):
>
> vtkGlyph3DMapper

You can show different kind of object based on an index.

[https://vtk.org/doc/nightly/html/classvtkGlyph3DMapper.html#a4c497fc8bd5ec3911e1a131e34a8ecf4](https://vtk.org/doc/nightly/html/classvtkGlyph3DMapper.html#a4c497fc8bd5ec3911e1a131e34a8ecf4)

---

<div class="post-metadata">

### Author: ![baker-Xie](https://discourse.vtk.org/user_avatar/discourse.vtk.org/baker-xie/32/8169_2.png) [@baker-Xie](https://discourse.vtk.org/u/baker-Xie)
#### Post date: [December 19, 2023, 9:21am UTC](https://discourse.vtk.org/t/visualize-large-amount-of-changing-object-cubes-points-lines-etc-in-real-time/12926/3 "2023-12-19T09:21:55Z")

</div>

Thanks for your reply. I have more questions:

1. So can I use only one actor to render different kinds of object with different pos / orientation / color / scale?
2. If in that manner, how can I pick or select one of the object by mouse?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [December 19, 2023, 9:28am UTC](https://discourse.vtk.org/t/visualize-large-amount-of-changing-object-cubes-points-lines-etc-in-real-time/12926/4 "2023-12-19T09:28:03Z")

</div>

> So can I use only one actor to render different kinds of object with different pos / orientation / color / scale?

Yes

> If in that manner, how can I pick or select one of the object by mouse?

you should be able to recover information about the picked object (its index) and identify it this way

---

<div class="post-metadata">

### Author: ![baker-Xie](https://discourse.vtk.org/user_avatar/discourse.vtk.org/baker-xie/32/8169_2.png) [@baker-Xie](https://discourse.vtk.org/u/baker-Xie)
#### Post date: [December 19, 2023, 9:35am UTC](https://discourse.vtk.org/t/visualize-large-amount-of-changing-object-cubes-points-lines-etc-in-real-time/12926/5 "2023-12-19T09:35:01Z")

</div>

> So can I use only one actor to render different kinds of object with different pos / orientation / color / scale?

Can you provide some key word or web link about this technique? If it works, then you save my life.

> If in that manner, how can I pick or select one of the object by mouse?

Which component can I use to do the picking? Yes, I’ll do the rest , for example change the picked object’s color, show a 2D information, etc.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [December 19, 2023, 9:40am UTC](https://discourse.vtk.org/t/visualize-large-amount-of-changing-object-cubes-points-lines-etc-in-real-time/12926/6 "2023-12-19T09:40:45Z")

</div>

[https://vtk.org/doc/nightly/html/classvtkGlyph3DMapper.html#ade773b8a991ce35c0e758dd624acec88](https://vtk.org/doc/nightly/html/classvtkGlyph3DMapper.html#ade773b8a991ce35c0e758dd624acec88)

Here is how to do it for scaling
