problem in using vtkextrusion for 3D files

I used vtkextrusion to extrude a 3D STL of bone. But after using the code below it just duplicated it for me.

this is my code:

import vtk

filename = "the file"



#First STL file
reader = vtk.vtkSTLReader()
reader.SetFileName(filename)

        
extrude = vtk.vtkLinearExtrusionFilter()
extrude.SetInputConnection(reader.GetOutputPort())
extrude.SetExtrusionTypeToNormalExtrusion()
extrude.SetVector(0, 50, 1)
extrude.Update()


mapper = vtk.vtkPolyDataMapper()
if vtk.VTK_MAJOR_VERSION <= 5:
    mapper.SetInput(extrude.GetOutput())
else:
    mapper.SetInputConnection(extrude.GetOutputPort())

actor = vtk.vtkActor()
actor.SetMapper(mapper)


# Create a rendering window and renderer
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
 
# Create a renderwindowinteractor
iren = vtk.vtkRenderWindowInteractor()
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballActor())
iren.SetRenderWindow(renWin)

# Assign actor to the renderer
ren.AddActor(actor)

# Enable user interface interactor
ren.ResetCamera()
iren.Initialize()
renWin.Render()
iren.Start()

and here is the output

STL files cannot store surface normals. You need to insert a vtkPolyDataNormals between the STL reader and the extrusion filter. Note that you may get self-intersecting mesh near sharp edges. If you really need to grow a shell around the entire bone then it is more robust to do the margin growing on the segmentation and then convert to mesh.

If you plan to generate 3D-printable patient-specific surgical guides then you may be interested in participating in this project: https://github.com/lassoan/SlicerBoneReconstructionPlanner. It is being actively developed, but we can already create surgical plan and generate cutting guides like this automatically: