Skip to content

Commit

Permalink
clear(deep=...)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed Dec 15, 2022
1 parent e14f67d commit 70a16da
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion vedo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __setitem__(self, key, input_array):
elif self.association == 2:
data = self.actor.inputdata().GetFieldData()

if isinstance(input_array[0], str):
if utils.is_sequence(input_array) and isinstance(input_array[0], str):
varr = vtk.vtkStringArray()
varr.SetName(key)
varr.SetNumberOfComponents(1)
Expand Down
2 changes: 0 additions & 2 deletions vedo/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1288,13 +1288,11 @@ def add_shadow(
shad.points(pts)
shad.x(point)
elif "y" == plane:
# shad = shad.project_on_plane('y')
x0, x1 = self.ybounds()
pts[:, 1] = (pts[:, 1] - (x0 + x1) / 2) / 1000 + self.GetOrigin()[1]
shad.points(pts)
shad.y(point)
elif "z" == plane:
# shad = shad.project_on_plane('z')
x0, x1 = self.zbounds()
pts[:, 2] = (pts[:, 2] - (x0 + x1) / 2) / 1000 + self.GetOrigin()[2]
shad.points(pts)
Expand Down
26 changes: 15 additions & 11 deletions vedo/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3229,7 +3229,7 @@ def add_inset(self, *actors, **options):
self.widgets.append(widget)
return widget

def clear(self, at=None, render=True):
def clear(self, at=None, render=True, deep=False):
"""Clear the scene from all meshes and volumes."""
if at is not None:
renderer = self.renderers[at]
Expand All @@ -3238,16 +3238,20 @@ def clear(self, at=None, render=True):
if not renderer:
return self

for a in set(self.get_meshes() + self.get_volumes() + self.actors + self.axes_instances):
if isinstance(a, vedo.shapes.Text2D):
continue
self.remove(a)
try:
if a.scalarbar:
self.remove(a.scalarbar)
except AttributeError:
pass
self.actors = []
if deep:
renderer.RemoveAllViewProps()
else:
for a in set(self.get_meshes() + self.get_volumes() + self.actors + self.axes_instances):
if isinstance(a, vedo.shapes.Text2D):
continue
self.remove(a)
try:
if a.scalarbar:
self.remove(a.scalarbar)
except AttributeError:
pass
self.actors = []

if render:
self.render()
return self
Expand Down
2 changes: 1 addition & 1 deletion vedo/pointcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -3875,7 +3875,7 @@ def cut_with_line(self, points, invert=False, closed=True):
clipper = vtk.vtkClipPolyData()
clipper.SetInputData(self.polydata(True)) # must be True
clipper.SetClipFunction(pplane)
clipper.SetInsideOut(not invert)
clipper.SetInsideOut(invert)
clipper.GenerateClippedOutputOff()
clipper.GenerateClipScalarsOff()
clipper.SetValue(0)
Expand Down

0 comments on commit 70a16da

Please sign in to comment.