From: adam Date: Sun, 16 Dec 2007 03:24:11 +0000 (-0800) Subject: checkpoint X-Git-Url: http://git.megacz.com/?p=anneal.git;a=commitdiff_plain;h=0333b4f07d3e3cacb5975fe7ac3c8c3933150e37 checkpoint darcs-hash:20071216032411-5007d-bf239e57410a69f3c57e55a0b7c9eed83dd6b0cb.gz --- diff --git a/src/edu/berkeley/qfat/Mesh.java b/src/edu/berkeley/qfat/Mesh.java index c563563..42f03d2 100644 --- a/src/edu/berkeley/qfat/Mesh.java +++ b/src/edu/berkeley/qfat/Mesh.java @@ -109,25 +109,6 @@ public class Mesh implements Iterable { fundamentalQuadric = m.times(1/(float)count); } - public void applyQuadricToNeighbor() { - if (score_against == null) return; - - Vertex new_nearest = (Vertex)nearest(); - if (nearest_in_other_mesh != null && new_nearest == nearest_in_other_mesh) return; - - if (nearest_in_other_mesh != null) unApplyQuadricToNeighbor(); - if (nearest_in_other_mesh != null) throw new Error(); - - nearest_in_other_mesh = new_nearest; - - nearest_in_other_mesh.unComputeError(); - nearest_in_other_mesh.quadric = nearest_in_other_mesh.quadric.plus(fundamentalQuadric()); - nearest_in_other_mesh.quadric_count++; - nearest_in_other_mesh.computeError(); - - reComputeError(); - } - public void reComputeErrorAround() { reComputeError(); if (nearest_in_other_mesh != null) nearest_in_other_mesh.reComputeError(); @@ -142,7 +123,10 @@ public class Mesh implements Iterable { score -= oldscore; oldscore = 0; } - public HasQuadric nearest() { return score_against.vertices.nearest(p, this); } + public HasQuadric nearest() { + if (score_against==null) return null; + return score_against.vertices.nearest(p, this); + } public void computeError() { oldscore = quadric_count != 0 diff --git a/src/edu/berkeley/qfat/geom/HasQuadric.java b/src/edu/berkeley/qfat/geom/HasQuadric.java index 889eaee..8addfc2 100644 --- a/src/edu/berkeley/qfat/geom/HasQuadric.java +++ b/src/edu/berkeley/qfat/geom/HasQuadric.java @@ -37,12 +37,29 @@ public abstract class HasQuadric extends HasPoint { applyQuadricToNeighbor(); } public abstract void _recomputeFundamentalQuadric(); - public abstract void applyQuadricToNeighbor(); public abstract void reComputeErrorAround(); public abstract void reComputeError(); public abstract void unComputeError(); public abstract void computeError(); public abstract HasQuadric nearest(); + public void applyQuadricToNeighbor() { + HasQuadric new_nearest = nearest(); + if (nearest_in_other_mesh != null && new_nearest == nearest_in_other_mesh) return; + + if (nearest_in_other_mesh != null) unApplyQuadricToNeighbor(); + if (nearest_in_other_mesh != null) throw new Error(); + + nearest_in_other_mesh = new_nearest; + + if (nearest_in_other_mesh!=null) { + nearest_in_other_mesh.unComputeError(); + nearest_in_other_mesh.quadric = nearest_in_other_mesh.quadric.plus(fundamentalQuadric()); + nearest_in_other_mesh.quadric_count++; + nearest_in_other_mesh.computeError(); + } + + reComputeError(); + } public Matrix fundamentalQuadric() { if (fundamentalQuadric == null) recomputeFundamentalQuadric(); return fundamentalQuadric;