我正在阅读一个stl文件,只是在屏幕上显示它(稍后会添加一些结果)。物体的转动和处理并不是很顺利。
让3dconnexion spacemouse工作以操纵objekt会很酷。可能吗?怎么样?
我必须添加到交互器中吗?
感谢您的帮助
Okapi的
import vtk
class VtkStl:
def __init__(self, filename):
self.filename = filename
self.vtkActor = vtk.vtkActor()
def addStl(self):
reader = vtk.vtkSTLReader()
reader.SetFileName(self.filename)
mapper = vtk.vtkPolyDataMapper()
if vtk.VTK_MAJOR_VERSION <= 5:
mapper.SetInput(reader.GetOutput())
else:
mapper.SetInputConnection(reader.GetOutputPort())
self.vtkActor.SetMapper(mapper)
Bock_stl=VtkStl('d:\trial.stl')
Bock_stl.addStl()
# Renderer
renderer = vtk.vtkRenderer()
renderer.AddActor(Bock_stl.vtkActor)
renderer.SetBackground(.2, .3, .4)
renderer.ResetCamera()
# Render Window
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
# Interactor
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
# Begin Interaction
renderWindow.Render()
renderWindowInteractor.Start()
del renderWindow, renderWindowInteractor
感谢您的帮助。