# self intersections from extrusion

**URL:** https://discourse.vtk.org/t/self-intersections-from-extrusion/2919
**Category:** Support
**Created:** [March 30, 2020, 8:15pm UTC](https://discourse.vtk.org/t/self-intersections-from-extrusion/2919 "2020-03-30T20:15:39Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mikewho](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/f1d935/32.png) [@mikewho](https://discourse.vtk.org/u/mikewho)
#### Post date: [March 30, 2020, 8:15pm UTC](https://discourse.vtk.org/t/self-intersections-from-extrusion/2919/1 "2020-03-30T20:15:39Z")

</div>

I’m attempting to extrude and then make a solid voxel representation of a surface in VTK. The initial surface is well-behaved, not self-intersecting. The general pipeline is vtkLinearExtrusionFilter -\> vtkPolyDatatoImageStencil -\> vtkImageStencilToImage. This works as expected, except that the extrusion causes some self-intersections because I must extrude in the normal direction for this particular project. The vtkPolyDatatoImageStencil filter then does not count those self-intersecting parts as being “inside” the surface, so I end up with holes in the final mask volume. What would be the best way to address this problem? Thanks!

Mike

---

<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: [March 31, 2020, 4:35am UTC](https://discourse.vtk.org/t/self-intersections-from-extrusion/2919/2 "2020-03-31T04:35:29Z")

</div>

You can easily and very robustly grow/shrink a surface when it is represented as a mask volume, so you can solve this by converting to volume first.

You can check out how this all works in 3D Slicer’s Segment editor: you can load a surface as a segmentation, then use “Margin” effect to grow/shrink or “Hollow” effect to create a hollow shell.

---

<div class="post-metadata">

### Author: ![mikewho](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/f1d935/32.png) [@mikewho](https://discourse.vtk.org/u/mikewho)
#### Post date: [March 31, 2020, 3:26pm UTC](https://discourse.vtk.org/t/self-intersections-from-extrusion/2919/3 "2020-03-31T15:26:33Z")

</div>

Thanks for the feedback. Unfortunately the “Margin” effect grows in all directions. Also it seems to need a closed surface. I need to specifically only grow in the normal direction (only on one side of the surface). My initial surface is a shell, not a closed surface. Think of a half of a sphere as an example. In the case of a half sphere, I need it to extrude in the normal direction (outwards), and not inwards.

---

<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: [March 31, 2020, 3:41pm UTC](https://discourse.vtk.org/t/self-intersections-from-extrusion/2919/4 "2020-03-31T15:41:02Z")

</div>

> [@mikewho](#):
>
> Unfortunately the “Margin” effect grows in all directions.

Hollow effect creates a shell. It can grow central, towards inside, or towards outside, by combining the grown volumes with the original volumes.

> [@mikewho](#):
>
> My initial surface is a shell, not a closed surface.

We have run into this issue, too, when processing surface scans.

Our solution then was to close the surface by offsetting the surface by a large distance and connecting edges with a triangle strip.

If you cannot easily find a offset direction where extruded boundary edges would not overlap then you can close the surface using “Wrap Solidify” effect (provided by [SurfaceWrapSolidify extension](https://github.com/sebastianandress/Slicer-SurfaceWrapSolidify)). Wrap Solidify effect also has the option for directly creating a thick shell from a surface.

---

<div class="post-metadata">

### Author: ![mikewho](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/f1d935/32.png) [@mikewho](https://discourse.vtk.org/u/mikewho)
#### Post date: [March 31, 2020, 5:07pm UTC](https://discourse.vtk.org/t/self-intersections-from-extrusion/2919/5 "2020-03-31T17:07:18Z")

</div>

Thanks I’ll look into the Surface wrap method. The other thing I might look into is using a signed distance field to extrude at the same time as converting to the volume.

---

<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: [March 31, 2020, 5:32pm UTC](https://discourse.vtk.org/t/self-intersections-from-extrusion/2919/6 "2020-03-31T17:32:49Z")

</div>

> [@mikewho](#):
>
> The other thing I might look into is using a signed distance field to extrude at the same time as converting to the volume.

While computing unsigned distance map is trivial (that’s what vtkImplicitModeller computes), I don’t think signed distance can be robustly computed for an open surface.

Also note that usually distance map is usually computed _after_ conversion to volume. For example, we use signed distance map in Margin effect (because morphological operations would be magnitudes slower for large kernel sizes).

---

<div class="post-metadata">

### Author: ![mikewho](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/f1d935/32.png) [@mikewho](https://discourse.vtk.org/u/mikewho)
#### Post date: [March 31, 2020, 7:52pm UTC](https://discourse.vtk.org/t/self-intersections-from-extrusion/2919/7 "2020-03-31T19:52:26Z")

</div>

Good point. I suppose a third alternative is I could try to modify the extrusion filter code to avoid self-intersections somehow.
