# vtkimplicitModeller very slow or making holes

**URL:** https://discourse.vtk.org/t/vtkimplicitmodeller-very-slow-or-making-holes/3070
**Category:** Support
**Created:** [April 16, 2020, 4:12pm UTC](https://discourse.vtk.org/t/vtkimplicitmodeller-very-slow-or-making-holes/3070 "2020-04-16T16:12:55Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![zandarina](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/z/4af34b/32.png) [@zandarina](https://discourse.vtk.org/u/zandarina)
#### Post date: [April 16, 2020, 4:12pm UTC](https://discourse.vtk.org/t/vtkimplicitmodeller-very-slow-or-making-holes/3070/1 "2020-04-16T16:12:55Z")

</div>

Hi,

I am trying to create a distance map and get  
the contour close to the surface (a few mm  
from the zero level of the contour).

So I got the bounds of the polydata I modified it with the bounds considering the  
thickness so that it fits in the output bounds  
and i calculated the dimensions. Doing  
this i get the thickness i want even  
the small one but it is very very slow.

SetSampleDimensions(dim)

And if i define a bigger spacing i cannot get the  
thin surface (e.g., 0.10 from the surface)

So i wonder how i can speed up the process  
to get a small thickness from the surface.

```
implicitModeller->SetModelBounds(bounds);
double spacing[3] = { 0.10,0.10,0.10 };
// compute dimensions
int dim[3];
for (int i = 0; i < 3; i++)
{
	dim[i] = static_cast<int>(ceil((bounds
  [i * 2 + 1] - bounds[i * 2]) / spacing[i]));
}
implicitModeller->SetSampleDimensions(dim);

```

In case i was doing level selts it would be  
impossible to get the zero level.

Any help with this filter?. Distance map is usally  
used for its speed so i am bit surprised  
of the slow speed of this filter.

Thank you very much  
Cheers

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [April 16, 2020, 5:33pm UTC](https://discourse.vtk.org/t/vtkimplicitmodeller-very-slow-or-making-holes/3070/2 "2020-04-16T17:33:13Z")

</div>

You should set [maximum distance](https://vtk.org/doc/nightly/html/classvtkImplicitModeller.html#a3ceef09e265ac88325fd6451e19a0bf3) to prevent computing distances across the whole volume. You may also need to have lots of physical RAM if your very fine resolution bitmap gets very big.

> [@zandarina](#):
>
> Any help with this filter?. Distance map is usally  
> used for its speed

Once you have constructed the distance map, it is very fast - but of course you need to compute the values first and it takes time.

Also, for shell generation from surface, the main advantage of using a distance map is _not_ the potential speed improvement but its robustness. Mesh-based methods often struggle with self-intersection, while this is not an issue with distance maps.

---

<div class="post-metadata">

### Author: ![zandarina](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/z/4af34b/32.png) [@zandarina](https://discourse.vtk.org/u/zandarina)
#### Post date: [April 17, 2020, 12:03pm UTC](https://discourse.vtk.org/t/vtkimplicitmodeller-very-slow-or-making-holes/3070/3 "2020-04-17T12:03:07Z")

</div>

Hi, thank you for answering. Sure, i am using the distance map to avoid the intersection of the faces and i avoid holes with this. Perfect, i will do that tocompute it at the beginning maybe in background to speed up. I just wanted to be sure i was using it well or if i could optimize it.

I found this vtkSignedDistance filter, it seems quite interesting. When i update the vtk, it will try it.

Thank you very much for all the help

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [April 17, 2020, 1:43pm UTC](https://discourse.vtk.org/t/vtkimplicitmodeller-very-slow-or-making-holes/3070/4 "2020-04-17T13:43:27Z")

</div>

Implicit modeller can only be used for creating symmetric surface (the original surface is not preserved), but works for open surfaces, while signed distance filter allows you to create shell from closed surface, while keeping the closed surface as inner or surface.
