From 70a16da358f301632d5a751f8f07e11b74657075 Mon Sep 17 00:00:00 2001 From: marcomusy Date: Thu, 15 Dec 2022 18:16:01 +0100 Subject: [PATCH] clear(deep=...) --- vedo/base.py | 2 +- vedo/mesh.py | 2 -- vedo/plotter.py | 26 +++++++++++++++----------- vedo/pointcloud.py | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/vedo/base.py b/vedo/base.py index 47d415e5..1d5cde03 100644 --- a/vedo/base.py +++ b/vedo/base.py @@ -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) diff --git a/vedo/mesh.py b/vedo/mesh.py index 28c55924..17252fbe 100644 --- a/vedo/mesh.py +++ b/vedo/mesh.py @@ -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) diff --git a/vedo/plotter.py b/vedo/plotter.py index 1db9470d..bf240861 100644 --- a/vedo/plotter.py +++ b/vedo/plotter.py @@ -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] @@ -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 diff --git a/vedo/pointcloud.py b/vedo/pointcloud.py index e8659746..f241a26c 100644 --- a/vedo/pointcloud.py +++ b/vedo/pointcloud.py @@ -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)