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?
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:
Self intersection cells inside (because I need to use boolean operations on it later)
Some of extra extrusion is not desired. Basically, I only want more thickness towards the outside not inside
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.
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
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 …