From 557fda2443948e1cb334f40290cfae7c73b9eb60 Mon Sep 17 00:00:00 2001 From: Joshua Steer <Joshua.Steer@soton.ac.uk> Date: Fri, 10 Aug 2018 12:52:56 +0100 Subject: [PATCH] Added registration tools to GUI --- AmpScan/core.py | 3 ++- AmpScan/registration.py | 2 +- GUIs/AmpScanGUI.py | 28 +++++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/AmpScan/core.py b/AmpScan/core.py index cfc74cd..754b80c 100644 --- a/AmpScan/core.py +++ b/AmpScan/core.py @@ -114,13 +114,14 @@ 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() # Call function to calculate the edges array if struc is True: self.calcStruct() + self.values = np.zeros([len(self.vert)]) def calcStruct(self, norm=True, edges=True, edgeFaces=True, faceEdges=True, vNorm=False): diff --git a/AmpScan/registration.py b/AmpScan/registration.py index 686e714..895f397 100644 --- a/AmpScan/registration.py +++ b/AmpScan/registration.py @@ -111,7 +111,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 diff --git a/GUIs/AmpScanGUI.py b/GUIs/AmpScanGUI.py index 751f456..96ab7b7 100644 --- a/GUIs/AmpScanGUI.py +++ b/GUIs/AmpScanGUI.py @@ -118,13 +118,32 @@ class AmpScanGUI(QMainWindow): # self.socket.actor.setOpacity(0.5) def runICP(self): + static = str(self.alCont.static.currentText()) moving = str(self.alCont.moving.currentText()) + self.fileManager.setTable(static, [1,0,0], 0.5, 2) + self.fileManager.setTable(moving, [0,0,1], 0.5, 2) print('Run the ICP code between %s and %s' % (static, moving)) def runRegistration(self): + c1 = [31.0, 73.0, 125.0] + c3 = [170.0, 75.0, 65.0] + c2 = [212.0, 221.0, 225.0] + CMap1 = np.c_[[np.linspace(st, en) for (st, en) in zip(c1, c2)]] + CMap2 = np.c_[[np.linspace(st, en) for (st, en) in zip(c2, c3)]] + CMap = np.c_[CMap1[:, :-1], CMap2] + self.CMapN2P = np.transpose(CMap)/255.0 + self.CMap02P = np.flip(np.transpose(CMap1)/255.0, axis=0) baseline = str(self.regCont.baseline.currentText()) target = str(self.regCont.target.currentText()) + self.fileManager.setTable(baseline, [1,0,0], 0.5, 0) + self.fileManager.setTable(target, [0,0,1], 0.5, 0) + reg = registration(self.files[baseline], self.files[target]) + reg.addActor(CMap = self.CMapN2P) + regName = target + '_reg' + self.files[regName] = reg + self.fileManager.addRow(regName, self.files[regName]) + print('Run the Registration code between %s and %s' % (baseline, target)) def register(self): @@ -277,7 +296,14 @@ class fileManager(QMainWindow): for r in range(self.table.columnCount() - 1): row.append(self.table.item(i, r).text()) row.append(self.table.item(i, r+1).checkState()) - return row + return row + + def setTable(self, name, color = [1.0, 1.0, 1.0], opacity=1.0, display=2): + for i in range(self.n): + if self.table.item(i, 0).text() == name: + self.table.item(i, 2).setText(str(color)) + self.table.item(i, 3).setText(str(opacity)) + self.table.item(i, 4).setCheckState(display) class AlignControls(QMainWindow): """ -- GitLab