We have written a program as you can see in image: program_image. We added spheres on the object to get information about the place. Now the problem is, although we can place them with no issue, we could not remove them. We want to delete them. We tried so many methods like vtkObjectBase.Delete()
etc. None of which has worked. Added them with this function:
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()
The major point is removing them from the map(I don't know the lingo), visually especially. Thanks.
Edit1:
Regarding the suggestion I added this function just above the def cagir()
function with the same indentation,
def dene(*vecto):
#print("dene e girildi")
actor = vtk.vtkActor()
self.ren.RemoveActor(actor)
self.renWin.Render()
and I got these,
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
I'm a beginner VTK user, so if I'm making funny mistakes, I'm sorry. But for long days, I'm struggling with this code.
Edit2:
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()
Still having similar errors, and when I use dene()
although all object which we put these little spheres on it disappears but spheres still stays on their places:image2. Could you please write dene()
function for me regarding cagir()
function. Thanks.
You should remove it from the mapper Renderer
renderer.RemoveActor(actor)
You should keep a reference / a variable pointing to the actor you want to remove. In my code, actor
refer to the actor created in your cagir()
method, not to a new vtkActor
.