Python VTK: How to use the filter vtkFeatureEdges() with a PolyData() method?

Dear VTK community,

I am trying to plot the Boundary Edges of a 3D solid. For my example, I am using a cube that is generated manually (instead of the vtkCubeSource() method) and as a part of the pipeline, the filter vtkFeatureEdges() is used but when the render is launched, the borders are not generated.

The example that I found in the VTK Github used the filter vtkFeatureEdges() together with the vtkCubeSource() method and it works properly. However, I can not use the after-mentioned method as my final goal is to plot a different geometry that will be provided manually. Then, I need to find a way to use the filter or another one that will plot the borders of my solid.

#Case A
#Boundary Edges (defined with vtkCubeSource()) --> Works
featureEdges = vtk.vtkFeatureEdges()
featureEdges.SetInputConnection(cube.GetOutputPort()) 

#Case B
#Boundary Edges (defined with vtkPolyData()) --> Compiles, but do not show borders
featureEdges = vtk.vtkFeatureEdges()
featureEdges.SetInputData(cube)  

The expected output is to plot the solid and its border, however at the moment, only the solid is rendered.

Remark: Please, note that I do not want to use the option

cubeActor.GetProperty().EdgeVisibilityOn()

As the solid info comes from a FEM file and that option will display the mesh of my solid and not only the border of the part.

Thanks in advance for your help.

Perhaps you want something like this example from vtki:

Note that vtki is simply a streamlined Python interface to the VTK library and that example uses the extract_edges filter which is implemented with a vtkFeatureEdges filter

And here’s an example with a cube using vtki:

import vtki

cube = vtki.Cube()

edges = cube.extract_edges(20)

p = vtki.Plotter()
p.add_mesh(cube, color=True)
p.add_mesh(edges, color='red', line_width=5)
p.show()

1 Like