Skip to content

Commit

Permalink
Fix a bug when the user wants to reuse the visualization component
Browse files Browse the repository at this point in the history
  • Loading branch information
Onur R. Bingol committed Jan 9, 2018
1 parent a006a92 commit 107c9b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions geomdl/BSpline.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def render(self, cpcolor="blue", curvecolor="black"):
self.evaluate()

# Run the visualization component
self._vis_component.clear()
self._vis_component.add(self.ctrlpts, "Control Points", cpcolor)
self._vis_component.add(self.curvepts, "Curve", curvecolor)
self._vis_component.render()
Expand Down Expand Up @@ -1067,6 +1068,7 @@ def render(self, cpcolor="blue", surfcolor="green"):
ctrlpts = utils.make_quad(self.ctrlpts, self._control_points_size_v, self._control_points_size_u)

# Run the visualization component
self._vis_component.clear()
self._vis_component.add(ctrlpts, "Control Points", cpcolor)
self._vis_component.add(self.surfpts, "Surface", surfcolor)
self._vis_component.render()
Expand Down
6 changes: 6 additions & 0 deletions geomdl/visualization/VisBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def __init__(self):
self._colors = []
self._names = []

def clear(self):
if self._points:
self._points[:] = []
self._colors[:] = []
self._names[:] = []

def add(self, ptsarr=(), name=None, color=None):
if not ptsarr or not color or not name:
return
Expand Down

0 comments on commit 107c9b5

Please sign in to comment.