VTK extrusion normal has self intersection cells

Hi, I have a very irregular surface and then called the extrusion with the normal direction. And then I found that it has all the self intersection cells. I can’t just remove them because the whole polydata will be removed. Is there a good way to avoid it?

The red part is the self intersection cells

1675265019489

Perhaps a filter like: https://vtk.org/doc/nightly/html/classvtkCleanPolyData.html?

Yeah. I tried that already. It is not working

Most concave surfaces will self-intersect when extruded, what do you expect to happen? What are you trying to accomplish?

To solve it you’d have to use advanced techniques like isocontouring a distance function.


1675367192569

Basically, I have this kind of surface. What I want to do is to add a thickness to it. What I use is extrusion with the normal direction, which looks perfect from outside with two issue:

  1. Self intersection cells inside (because I need to use boolean operations on it later)
  2. Some of extra extrusion is not desired. Basically, I only want more thickness towards the outside not inside

VTK has a signed distance function class (that I have never used):
https://vtk.org/doc/nightly/html/classvtkSignedDistance.html, you might be able to use that and then isocontour it, like @will.schroeder mentioned.

Can you explain a little more?

If I understand the vtkSignedDistanceFunction class, it determines a normal distance field from the surface, and it determines an “inside” and “outside”. You would then find an isosurface of the result in order to get a surface that is everywhere “d” units away from your input surface. I’ll see if I can get an example working, and I’ll post it back … if I can figure it out.

Thank you!

If it works, is there a method we can use to connect these two surfaces and make it one polydata?
Actually, I can also try the scale from vtkTransform too

Ok this doesn’t work … but here is what I was thinking:


import vtk

# I think that vtkSignedDistance samples values in a cube?
SUBDIVISIONS  = 128 # cube edge subdivisions
WIDTH = 2           # cube width
OFFSET = 0.2        # signed distance offset

f = vtk.vtkParametricBoy()

s = vtk.vtkParametricFunctionSource()
s.SetParametricFunction(f)
s.SetUResolution(50)
s.SetVResolution(50)
s.GenerateTextureCoordinatesOn()
s.Update()

n = vtk.vtkPolyDataNormals()
n.SetInputConnection(s.GetOutputPort())
n.Update()

# if you write out the file here - you get an object 
d = vtk.vtkSignedDistance()
d.SetInputConnection(n.GetOutputPort())
d.SetRadius(0.1) # just a guess
d.SetDimensions(SUBDIVISIONS, SUBDIVISIONS, SUBDIVISIONS)
d.SetBounds(-WIDTH/2, WIDTH/2,
            -WIDTH/2, WIDTH/2,
            -WIDTH/2, WIDTH/2)

g = vtk.vtkContourFilter()
g.SetValue(0, OFFSET)
g.SetInputConnection(d.GetOutputPort())

w = vtk.vtkPolyDataWriter()
w.SetInputConnection(g.GetOutputPort())
w.SetFileName('test.vtk')
w.Write()

# sadly - I get no surface here and don't have time to figure out why

Also, your question about appending the data: I think the documentation for vtkSignedDistance indicates that it appends the data as a side effect.

Thank you though, that is a good try.

Yeah. I tried vtkSignedDistance several examples, it did not work

The only thing that I can think of is that the example I was using as a reference used vtkImageMapToColors … but I was way over my head at that point. I’m sort of hoping that one of the experts will chime in …

Is there qny further solution?I meet the same problem