# vtk Delaunay2D is too expensive, how can i accelerate

**URL:** https://discourse.vtk.org/t/vtk-delaunay2d-is-too-expensive-how-can-i-accelerate/8887
**Category:** Dashboards
**Tags:** code
**Created:** [July 6, 2022, 10:26am UTC](https://discourse.vtk.org/t/vtk-delaunay2d-is-too-expensive-how-can-i-accelerate/8887 "2022-07-06T10:26:08Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![zzusunquan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zzusunquan/32/5449_2.png) [@zzusunquan](https://discourse.vtk.org/u/zzusunquan)
#### Post date: [July 6, 2022, 10:26am UTC](https://discourse.vtk.org/t/vtk-delaunay2d-is-too-expensive-how-can-i-accelerate/8887/1 "2022-07-06T10:26:08Z")

</div>

I use the following code

```auto
// _pd is a vtkPolyData object only with points
// the code is c# 
var delaunay = vtkDelaunay2D.New();
delaunay.SetTolerance(0.001);
delaunay.SetInput(_pd);
delaunay.Update();

```

the above code cost 100 millisecond level while the \_pd have 10,000 points,.  
So i use c++ CGAL build delaunay2D ， in c++ code, CGAL build delaunay2D cost 10 ms level with the same points. Then I Pass cell information to c#.  
I think I’m using it wrong, can you tell me how to speed up the delaunay2D of vtk? I just need cell and point information。

---

<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: [July 6, 2022, 11:18am UTC](https://discourse.vtk.org/t/vtk-delaunay2d-is-too-expensive-how-can-i-accelerate/8887/2 "2022-07-06T11:18:59Z")

</div>

This is a known issue with VTK delaunay implementation.

FYI @Tiffany_Chhim @Charles_Gueunet

---

<div class="post-metadata">

### Author: ![Charles\_Gueunet](https://discourse.vtk.org/user_avatar/discourse.vtk.org/charles_gueunet/32/239_2.png) [@Charles\_Gueunet](https://discourse.vtk.org/u/Charles_Gueunet)
#### Post date: [July 6, 2022, 11:23am UTC](https://discourse.vtk.org/t/vtk-delaunay2d-is-too-expensive-how-can-i-accelerate/8887/3 "2022-07-06T11:23:40Z")

</div>

We aim to improve the `vtkDelaunay2D` filter, I will keep you informed if we manage to get the time to do so.  
If you want to keep the VTK flexibility while having the CGAL performance, please have a look at the [Vespa project](https://gitlab.kitware.com/vtk-cgal/vespa). This is a collection of VTK filters relying internally on CGAL. It provides a [Delaunay2D](https://gitlab.kitware.com/vtk-cgal/vespa/-/tree/master/vespa/Delaunay) vtkAlgorithm.

---

<div class="post-metadata">

### Author: ![zzusunquan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zzusunquan/32/5449_2.png) [@zzusunquan](https://discourse.vtk.org/u/zzusunquan)
#### Post date: [July 6, 2022, 2:08pm UTC](https://discourse.vtk.org/t/vtk-delaunay2d-is-too-expensive-how-can-i-accelerate/8887/4 "2022-07-06T14:08:31Z")

</div>

Thank you very much for your prompt reply！  
Although CGAL’s delaunay is fast, there seems to be a problem.  
As you see, this fig is CGAL Delaunay，When the data is not closed like this, the edges will have strange triangles

 ![捕获.PNG](https://discourse.vtk.org/uploads/default/original/2X/8/812e9463e9dc960ac75291a64f11cb0df0bb376e.jpeg)  
the same data vtk is  
 ![捕获2.PNG](https://discourse.vtk.org/uploads/default/original/2X/3/37ea05f8563877a4393c8172b773cac28a1373c7.jpeg)  
I haven’t looked at the source code of vtk, but I want to ask if this is related to the  
delaunay.SetTolerance(0.001);  
set by vtk，  
I use [fast-vtk-delaunay2d](https://github.com/tatsuya-s/faster-vtk-delaunay2d), Its performance is the same as cgal, and the reconstruction of this kind of data is not good.  
As for the simultaneous use of vtk and cgal you said, I have already realized it. The point I’m struggling with now is this strange triangle, is there a good way to get rid of it?

---

<div class="post-metadata">

### Author: ![Charles\_Gueunet](https://discourse.vtk.org/user_avatar/discourse.vtk.org/charles_gueunet/32/239_2.png) [@Charles\_Gueunet](https://discourse.vtk.org/u/Charles_Gueunet)
#### Post date: [July 7, 2022, 6:35am UTC](https://discourse.vtk.org/t/vtk-delaunay2d-is-too-expensive-how-can-i-accelerate/8887/5 "2022-07-07T06:35:08Z")

</div>

Could you show use or share the point cloud you use ? Delaunay2D should be applied on planar data, or data that can trivially be projected onto a plan. Is it the case for you ?

---

<div class="post-metadata">

### Author: ![zzusunquan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zzusunquan/32/5449_2.png) [@zzusunquan](https://discourse.vtk.org/u/zzusunquan)
#### Post date: [July 7, 2022, 7:45am UTC](https://discourse.vtk.org/t/vtk-delaunay2d-is-too-expensive-how-can-i-accelerate/8887/6 "2022-07-07T07:45:05Z")

</div>

Thank you very much for your reply. I think I probably know where the problem is. It should be the problem of vtk and cgal for the accuracy of point coordinates. I converted my xy coordinates into int values to solve this strange triangle problem. in fact, the source data is originally int, because I used the depth map to generate point cloud, which went through a series of preprocessing into float.
