Hi,
I have an .obj file and I’m trying to find points on the file that intersect a given plane.
I did try to use vtkIntersectionPolyDataFilter. I did this by trying to create a plane using
import object
reader = vtk.vtkOBJReader()
reader.SetFileName(fpath)
reader.Update()
mapper = vtk.vtkPolyDataMapper()
if vtk.VTK_MAJOR_VERSION <= 5:
mapper.SetInput(reader.GetOutput())
else:
mapper.SetInputConnection(reader.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
plane1
center1= [x,y,z]
plane1 = vtk.vtkPlaneSource()
plane1.SetCenter(centre1)
plane1.SetNormal(0.0, 0.0, 1.0)
mapper1 = vtk.vtkPolyDataMapper()
mapper1.SetInput(plane1.GetOutput())
actor1 = vtk.vtkActor()
actor1.SetMapper(mapper)
intersection_operation = vtk.vtkIntersectionPolyDataFilter()
intersection_operation.SetInputData(1, actor)
intersection_operation.SetInputData(0, actor1)
intersection_operation.Update()
print("# of crosses: " + str(intersection_operation.GetNumberOfIntersectionPoints()))
However when I run this I get:
AttributeError: ‘vtkmodules.vtkRenderingOpenGL2.vtkOpenGLPolyDataMa’ object has no attribute ‘SetInput’
I’m not sure if there is an easier way to do what I’m trying to do, but I’m pretty lost as to why this is happening. I’m pretty new to python and to vtk. Any help would be greatly appreciated.