From: adam Date: Wed, 5 Dec 2007 08:06:22 +0000 (-0800) Subject: checkpoint X-Git-Url: http://git.megacz.com/?p=anneal.git;a=commitdiff_plain;h=96343836d53ebbd1ada9d7daafdbdb1326fc0349 checkpoint darcs-hash:20071205080622-5007d-5df9b5b5aab92f6ed8ef5a01b6fca62e68528035.gz --- diff --git a/src/edu/berkeley/qfat/Main.java b/src/edu/berkeley/qfat/Main.java index f067158..55eefd9 100644 --- a/src/edu/berkeley/qfat/Main.java +++ b/src/edu/berkeley/qfat/Main.java @@ -193,7 +193,7 @@ public class Main extends MeshViewer { public synchronized void rand(double temperature, Mesh.Vert p) { double tile_score = tile.score(); double goal_score = goal.score(); - p.rescore(); + p.applyQuadricToNeighbor(); Vec v = new Vec((random.nextFloat() - (float)0.5) / 1000, (random.nextFloat() - (float)0.5) / 1000, @@ -233,11 +233,11 @@ public class Main extends MeshViewer { } breakit(); repaint(); - goal.unscoreAll(); + goal.unApplyQuadricToNeighborAll(); repaint(); tile.recomputeAllFundamentalQuadrics(); repaint(); - goal.rescoreAll(); + goal.applyQuadricToNeighborAll(); } } diff --git a/src/edu/berkeley/qfat/Mesh.java b/src/edu/berkeley/qfat/Mesh.java index 774efa3..55052b9 100644 --- a/src/edu/berkeley/qfat/Mesh.java +++ b/src/edu/berkeley/qfat/Mesh.java @@ -65,13 +65,13 @@ public class Mesh implements Iterable { } } - public void unscoreAll() { + public void unApplyQuadricToNeighborAll() { HashSet done = new HashSet(); for(T t : this) for(Vert p : new Vert[] { t.v1(), t.v2(), t.v3() }) { if (done.contains(p)) continue; done.add(p); - p.unscore(); + p.unApplyQuadricToNeighbor(); } } public void recomputeAllFundamentalQuadrics() { @@ -83,7 +83,7 @@ public class Mesh implements Iterable { p.recomputeFundamentalQuadric(); } } - public float rescoreAll() { + public float applyQuadricToNeighborAll() { int num = 0; double dist = 0; HashSet done = new HashSet(); @@ -91,7 +91,7 @@ public class Mesh implements Iterable { for(Vert p : new Vert[] { t.v1(), t.v2(), t.v3() }) { if (done.contains(p)) continue; done.add(p); - p.rescore(); + p.applyQuadricToNeighbor(); } return (float)(dist/num); @@ -171,7 +171,7 @@ public class Mesh implements Iterable { } public void recomputeFundamentalQuadric() { - unscore(); + unApplyQuadricToNeighbor(); Matrix m = Matrix.ZERO; E e = this.e; do { @@ -180,10 +180,10 @@ public class Mesh implements Iterable { e = e.pair.next; } while(e != this.e); fundamentalQuadric = m; - rescore(); + applyQuadricToNeighbor(); } - public void unscore() { + public void unApplyQuadricToNeighbor() { if (nearest_in_other_mesh == null) return; if (fundamentalQuadric == null) return; nearest_in_other_mesh.unsc(); @@ -199,12 +199,10 @@ public class Mesh implements Iterable { score -= oldscore; oldscore = 0; } - public void rescore() { + public void applyQuadricToNeighbor() { if (score_against == null) return; - unsc(); - - if (nearest_in_other_mesh != null) unscore(); + if (nearest_in_other_mesh != null) unApplyQuadricToNeighbor(); if (nearest_in_other_mesh == null) { nearest_in_other_mesh = score_against.nearest(p); @@ -218,7 +216,7 @@ public class Mesh implements Iterable { nearest_in_other_mesh.resc(); } } - + unsc(); resc(); } public void resc() { @@ -228,7 +226,7 @@ public class Mesh implements Iterable { /** does NOT update bound pairs! */ public boolean transform(Matrix m) { - unscore(); + unApplyQuadricToNeighbor(); try { if (pointset.get(this.p)==null) throw new Error(); pointset.remove(this); @@ -240,7 +238,7 @@ public class Mesh implements Iterable { } catch (Exception e) { throw new RuntimeException(e); } - rescore(); + applyQuadricToNeighbor(); // should recompute fundamental quadrics of all vertices sharing a face, but we defer... // FIXME: intersection test needed?