如图所示,我们编写了一个程序:program_image。我们在对象上添加了球体以获取有关该地点的信息。现在的问题是,虽然我们可以毫无问题地放置它们,但我们无法移除它们。我们想删除它们。我们尝试了很多方法,例如vtkObjectBase.Delete()
等等,但都没有奏效。使用此功能添加它们:
def cagir(*vecto):
global oldvecto,distance,etiket
#print('cagir geldi')
source = vtk.vtkSphereSource()
source.SetCenter(vecto[0][i][0],vecto[0][i][1],vecto[0][i][2])
source.SetRadius(0.01)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
self.ren.AddActor(actor)
etiket.append(i)
self.renWin.Render()
重点是将它们从地图中删除(我不知道行话),尤其是视觉上。谢谢。Edit1:关于我在def cagir()
具有相同缩进的函数上方添加此函数的建议,
def dene(*vecto):
#print("dene e girildi")
actor = vtk.vtkActor()
self.ren.RemoveActor(actor)
self.renWin.Render()
我得到了这些,
2021-10-04 14:50:05.754 (5750.642s) [ ]vtkWin32OpenGLRenderWin:217 ERR| vtkWin32OpenGLRenderWindow (00000216F5B1C430): wglMakeCurrent failed in MakeCurrent(), error: The requested resource is in use.
2021-10-04 14:50:05.767 (5750.655s) [ ]vtkOpenGLVertexBufferOb:280 ERR| vtkOpenGLVertexBufferObjectGroup (00000216FF4586E0): Error setting 'normalMC' in shader VAO.
2021-10-04 14:50:05.767 (5750.655s) [ ]vtkOpenGLVertexArrayObj:296 ERR| vtkOpenGLVertexArrayObject (00000216FF3C6C40): attempt to add attribute when not ready for attribute vertexMC
我是初学者VTK用户,所以如果我犯了有趣的错误,我很抱歉。但是很长一段时间,我都在为这段代码苦苦挣扎。
编辑2:
def dene(*vecto):
source = vtk.vtkSphereSource()
self.ren.RemoveActor(actor)
self.renWin.Render()
mapper = vtk.vtkPolyDataMapper()
actor.SetMapper(mapper)
mapper.SetInputConnection(source.GetOutputPort())
def cagir(*vecto):
global oldvecto, distance, etiket,actor
# print('cagir geldi')
source = vtk.vtkSphereSource()
source.SetCenter(vecto[0][i][0], vecto[0][i][1], vecto[0][i][2])
source.SetRadius(0.01)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
self.ren.AddActor(actor)
etiket.append(i)
self.renWin.Render()
仍然有类似的错误,当我使用时,dene()
虽然我们将这些小球体放在上面的所有对象都消失了,但球体仍然留在它们的位置:image2。您能否dene()
为我编写有关功能的cagir()
功能。谢谢。