From 16c38a314abff8afcc69619e1e2cd8bce93aa7c6 Mon Sep 17 00:00:00 2001
From: Joshua Steer <joshua.w.steer@gmail.com>
Date: Sat, 5 May 2018 23:17:01 +0100
Subject: [PATCH] Use Modified function on the vtk points so the vtk renderer
 updates

---
 AmpScan/AmpScanGUI.py   | 5 +++--
 AmpScan/ampVis.py       | 3 ++-
 AmpScan/core.py         | 2 +-
 AmpScan/registration.py | 2 +-
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/AmpScan/AmpScanGUI.py b/AmpScan/AmpScanGUI.py
index 3035f07..f7bc0dc 100644
--- a/AmpScan/AmpScanGUI.py
+++ b/AmpScan/AmpScanGUI.py
@@ -81,8 +81,9 @@ class AmpScanGUI(QMainWindow):
     
     def analyse(self):
         #self.RegObj.plot_slices()
-        self.AmpObj.rotate([50, 50, 10], ang='deg')
-        self.vtkWidget.render()
+        self.AmpObj.vert[:, 0] *= 2
+        self.AmpObj.actor.points.Modified()
+        #self.renWin.renderActors([self.AmpObj.actor,])
         #self.AmpObj.vert[0,0] = 1
         #self.AmpObj._v = numpy_support.numpy_to_vtk(self.AmpObj.vert)
 
diff --git a/AmpScan/ampVis.py b/AmpScan/ampVis.py
index 8879efd..9568134 100644
--- a/AmpScan/ampVis.py
+++ b/AmpScan/ampVis.py
@@ -237,7 +237,8 @@ class visMixin(object):
         self.actor.setVert(self.vert)
         self.actor.setFaces(self.faces)
         #self.actor.setNorm()
-        if self.values is not None:
+        # Test if values array is non-zero
+        if self.values.any():
             self.actor.setValues(self.values)
             self.actor.setCMap(CMap, bands)
             self.actor.setScalarRange(sRange)
diff --git a/AmpScan/core.py b/AmpScan/core.py
index 517a9c5..78c62b4 100644
--- a/AmpScan/core.py
+++ b/AmpScan/core.py
@@ -46,7 +46,6 @@ class AmpObject(trimMixin, smoothMixin, analyseMixin,
 
     def __init__(self, data=None, stype='limb'):
         self.stype = stype
-        self.values = None
         self.createCMap()
         if isinstance(data, str):    
             if stype is 'FE':
@@ -109,6 +108,7 @@ class AmpObject(trimMixin, smoothMixin, analyseMixin,
         self.faces = faces
         self.vert = vert
         self.norm = norm
+        self.values = np.zeros([len(self.vert)])
         # Call function to unify vertices of the array
         if unify is True:
             self.unifyVert()
diff --git a/AmpScan/registration.py b/AmpScan/registration.py
index c5db75e..aa804b0 100644
--- a/AmpScan/registration.py
+++ b/AmpScan/registration.py
@@ -106,7 +106,7 @@ def registration(baseline, target, method='default', steps=5, direct=True):
             values = np.linalg.norm(regObj.vert - baseline.vert, axis=1)
             return values
 
-    regObj.values = calcError(baseline, regObj, False)
+    regObj.values[:] = calcError(baseline, regObj, False)
     return regObj
 
         
-- 
GitLab