代码拉取完成,页面将自动刷新
同步操作将从 zzthfut/CAM 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import vtk
from Polyline import Polyline
class VtkAdaptor:
def __init__(self, bgClr=(0.95, 0.95, 0.95)):
self.renderer = vtk.vtkRenderer()
self.renderer.SetBackground(bgClr)
self.window = vtk.vtkRenderWindow()
self.window.AddRenderer(self.renderer)
self.window.SetSize(900, 600)
self.interactor = vtk.vtkRenderWindowInteractor()
self.interactor.SetRenderWindow(self.window)
self.interactor.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
self.interactor.Initialize()
def display(self):
self.interactor.Start()
def SetBackgroundColor(self, r, g, b):
return self.renderer.SetBackground(r, g, b)
def drawAxes(self, length=100.0, shaftType=0, cylinderRadius=0.01, coneRadius=0.2):
axes = vtk.vtkAxesActor()
axes.SetTotalLength(length, length, length)
axes.SetShaftType(shaftType)
axes.SetCylinderRadius(cylinderRadius)
axes.SetConeRadius(coneRadius)
axes.SetAxisLabels(0)
self.renderer.AddActor(axes)
return axes
def drawActor(self, actor):
self.renderer.AddActor(actor)
return actor
def drawPdSrc(self, pdSrc):
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(pdSrc.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
return self.drawActor(actor)
def drawStlModel(self, stlFilePath):
reader = vtk.vtkSTLReader()
reader.SetFileName(stlFilePath)
return self.drawPdSrc(reader)
def removeActor(self, actor):
self.renderer.removeActor(actor)
def drawPoint(self, point, radius=2.0):
src = vtk.vtkSphereSource()
src.SetCenter(point.x, point.y, point.z)
src.SetRadius(radius)
return self.drawPdSrc(src)
def drawSegment(self, seg):
src = vtk.vtkLineSource()
src.SetPoint1(seg.A.x, seg.A.y, seg.A.z)
src.SetPoint2(seg.B.x, seg.B.y, seg.B.z)
return self.drawPdSrc(src)
def drawPolyline(self, polyline: Polyline):
src = vtk.vtkLineSource()
points = vtk.vtkPoints()
for i in range(polyline.count()):
pt = polyline.point(i)
points.InsertNextPoint((pt.x, pt.y, pt.z))
src.SetPoints(points)
return self.drawPdSrc(src)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。