From 01a13b911f7eea04e21d64e524cb7f06fced723f Mon Sep 17 00:00:00 2001 From: Joshua Steer <joshua.w.steer@gmail.com> Date: Wed, 29 Aug 2018 23:18:53 +0100 Subject: [PATCH] Added scaling into registration code --- AmpScan/pca.py | 4 ++-- AmpScan/registration.py | 10 +++++++++- GUIs/AmpScanGUI.py | 3 +-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/AmpScan/pca.py b/AmpScan/pca.py index 73cdb30..3ee7d5f 100644 --- a/AmpScan/pca.py +++ b/AmpScan/pca.py @@ -35,11 +35,11 @@ class pca(object): for s in self.shapes: s.planarTrim(height) - def register(self): + def register(self, scale=None): r""" Function to register all the shapes to a baseline """ - self.registered = [registration(self.baseline, t) for t in self.shapes] + self.registered = [registration(self.baseline, t, fixBrim=True, steps=10).reg for t in self.shapes] self.X = np.array([r.vert.flatten() for r in self.registered]).T def pca(self): diff --git a/AmpScan/registration.py b/AmpScan/registration.py index 7646626..b89fc6a 100644 --- a/AmpScan/registration.py +++ b/AmpScan/registration.py @@ -47,7 +47,8 @@ class registration(object): getattr(self, method)(*args, **kwargs) - def point2plane(self, steps = 1, neigh = 10, inside = True, subset = None, smooth=1, fixBrim=False): + def point2plane(self, steps = 1, neigh = 10, inside = True, subset = None, + scale=False, smooth=1, fixBrim=False): r""" Point to Plane method for registration between the two meshes @@ -80,6 +81,13 @@ class registration(object): [self.b.vert, self.b.faces, self.b.values])) regData = copy.deepcopy(bData) self.reg = AmpObject(regData, stype='reg') + if scale is not None: + tmin = self.t.vert.min(axis=0)[2] + rmin = self.reg.vert.min(axis=0)[2] + SF = 1 - ((tmin-scale)/(rmin-scale)) + logic = self.reg.vert[:, 2] < scale + d = (self.reg.vert[logic, 2] - scale) * SF + self.reg.vert[logic, 2] += d normals = np.cross(self.t.vert[self.t.faces[:,1]] - self.t.vert[self.t.faces[:,0]], self.t.vert[self.t.faces[:,2]] - diff --git a/GUIs/AmpScanGUI.py b/GUIs/AmpScanGUI.py index 2ed1233..4ff33f6 100644 --- a/GUIs/AmpScanGUI.py +++ b/GUIs/AmpScanGUI.py @@ -143,7 +143,6 @@ class AmpScanGUI(QMainWindow): ang = float(button.text()) idx = [0, 0, 1] self.files[moving].rotateAng([ang*i for i in idx], 'deg') - print(self.files[moving].actor.GetOrigin()) self.files[moving].tform.RotateZ(ang) self.renWin.Render() @@ -188,8 +187,8 @@ class AmpScanGUI(QMainWindow): maxiter=10, method='linPoint2Plane').m al.tform = vtk.vtkTransform() al.tform.PostMultiply() - al.actor.SetUserTransform(al.tform) al.addActor() + al.actor.SetUserTransform(al.tform) alName = moving + '_al' self.files[alName] = al self.filesDrop.append(alName) -- GitLab