# LOD and closest neighbour with vtk octree

**URL:** https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300
**Category:** Support
**Created:** [November 30, 2021, 10:36am UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300 "2021-11-30T10:36:18Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Julienchz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julienchz/32/4106_2.png) [@Julienchz](https://discourse.vtk.org/u/Julienchz)
#### Post date: [November 30, 2021, 10:36am UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300/1 "2021-11-30T10:36:18Z")

</div>

Hello 😃  
I am creating a 3D viewer to display large point cloud, I want to add octree structure to my viewer. This octree must allow me :

- To display the number of level I want
- To find the closest neighbour point

Is there a vtk class that allows me to have this both functionnality in a single octree structure (according to what I found vtk octree is used to find closest neighbour) or should I use potree library ( or create my own octree algorithm and data structure) ?

Thanks for your help

---

<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: [November 30, 2021, 12:46pm UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300/2 "2021-11-30T12:46:22Z")

</div>

vtkStaticPointLocator ?

---

<div class="post-metadata">

### Author: ![Julienchz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julienchz/32/4106_2.png) [@Julienchz](https://discourse.vtk.org/u/Julienchz)
#### Post date: [November 30, 2021, 12:49pm UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300/3 "2021-11-30T12:49:15Z")

</div>

@mwestphal with vtkStaticPointLocator you can locate a point but I also want to choose de LOD to render to optimize performance and according to the documentation this class does not have such a functionnality or maybe I don’t look at the doc correctly

---

<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: [November 30, 2021, 1:00pm UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300/4 "2021-11-30T13:00:52Z")

</div>

Indeed, LOD would need to be performed using a dedicated filter for LOD.

---

<div class="post-metadata">

### Author: ![Julienchz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julienchz/32/4106_2.png) [@Julienchz](https://discourse.vtk.org/u/Julienchz)
#### Post date: [November 30, 2021, 1:12pm UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300/5 "2021-11-30T13:12:15Z")

</div>

@mwestphal do you know what kind of filter ? Could I use the same octree with this filter that I create with vtkStaticPointLocator? I am starting to use vtk, it’s not easy to see the power of filters

---

<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: [November 30, 2021, 1:17pm UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300/6 "2021-11-30T13:17:26Z")

</div>

[https://vtk.org/doc/nightly/html/classvtkDecimatePro.html#details](https://vtk.org/doc/nightly/html/classvtkDecimatePro.html#details)

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [November 30, 2021, 1:19pm UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300/7 "2021-11-30T13:19:09Z")

</div>

There are several decimators. Also check out vtkBinnedDecimation (which is similar to what ParaView uses).

---

<div class="post-metadata">

### Author: ![Julienchz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julienchz/32/4106_2.png) [@Julienchz](https://discourse.vtk.org/u/Julienchz)
#### Post date: [November 30, 2021, 1:39pm UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300/8 "2021-11-30T13:39:01Z")

</div>

Paraview uses vtkBinnedDecimation as filter to display LOD ? Because Paraview octrees seem to be very efficient. I should maybe go deeper inside the paraview source code to see how octrees are managed

---

<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: [November 30, 2021, 1:39pm UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300/9 "2021-11-30T13:39:47Z")

</div>

ParaView use VTKm provided decimator.

---

<div class="post-metadata">

### Author: ![Julienchz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julienchz/32/4106_2.png) [@Julienchz](https://discourse.vtk.org/u/Julienchz)
#### Post date: [November 30, 2021, 2:04pm UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300/10 "2021-11-30T14:04:22Z")

</div>

@mwestphal So with a decimator filter, LODMapper and LODActor I should be able to have performance equivalent to paraview octree ?

---

<div class="post-metadata">

### Author: ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)
#### Post date: [November 30, 2021, 9:53pm UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300/11 "2021-11-30T21:53:33Z")

</div>

Probable a bit basic for you but some of the octree examples may help e.g. [OctreeVisualize](https://kitware.github.io/vtk-examples/site/Cxx/DataStructures/OctreeVisualize/), there are nine other examples there.

---

<div class="post-metadata">

### Author: ![Julienchz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julienchz/32/4106_2.png) [@Julienchz](https://discourse.vtk.org/u/Julienchz)
#### Post date: [December 1, 2021, 8:13am UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300/12 "2021-12-01T08:13:05Z")

</div>

Yes I’ve already seen this example, it displays an octree representation according to the choosen level but you can’t display the corresponding point. I am running through the vtk documentation and examples and honestly for now I’m not totally convinced that using the vtk classes allows me to generate a real octree structure for displaying and finding points.

---

<div class="post-metadata">

### Author: ![Julienchz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julienchz/32/4106_2.png) [@Julienchz](https://discourse.vtk.org/u/Julienchz)
#### Post date: [December 1, 2021, 3:34pm UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300/13 "2021-12-01T15:34:59Z")

</div>

When I use vtkBinnedDecimation, I get the error “no data to decimate”, is it posible to apply such a decimator with vtkPoints ?

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [December 1, 2021, 4:11pm UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300/14 "2021-12-01T16:11:32Z")

</div>

No, it’s a mesh decimation algorithm

---

<div class="post-metadata">

### Author: ![Julienchz](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julienchz/32/4106_2.png) [@Julienchz](https://discourse.vtk.org/u/Julienchz)
#### Post date: [December 1, 2021, 4:38pm UTC](https://discourse.vtk.org/t/lod-and-closest-neighbour-with-vtk-octree/7300/15 "2021-12-01T16:38:05Z")

</div>

If I want to decimate a pointcloud (vtkpoints), is there some vtk tools to do that or should I do that by my own ?
