X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2FMain.java;h=bb5dd1136801efb0db91efd80826b082868b3146;hb=2f48eabf8a07e99905e1eae0b64b5a2abecb01fe;hp=0246692022dbb42ad6c479dbf69b7e720aeed264;hpb=0f91cadcd5a273c8c312c1d054fe9de1a82ebf8e;p=anneal.git diff --git a/src/edu/berkeley/qfat/Main.java b/src/edu/berkeley/qfat/Main.java index 0246692..bb5dd11 100644 --- a/src/edu/berkeley/qfat/Main.java +++ b/src/edu/berkeley/qfat/Main.java @@ -12,6 +12,8 @@ import edu.berkeley.qfat.geom.Point; public class Main extends MeshViewer { + public static int verts = 0; + public static final Random random = new Random(); /** magnification factor */ @@ -127,23 +129,23 @@ public class Main extends MeshViewer { if ((t1.v1().p.times(m).minus(t2.v1().p).mag() < Mesh.EPSILON) && (t1.v2().p.times(m).minus(t2.v3().p).mag() < Mesh.EPSILON) && (t1.v3().p.times(m).minus(t2.v2().p).mag() < Mesh.EPSILON)) { - t1.e1().bind(t2.e3().pair); - t1.e2().bind(t2.e2().pair); - t1.e3().bind(t2.e1().pair); + t1.e1().bindEdge(t2.e3()); + t1.e2().bindEdge(t2.e2()); + t1.e3().bindEdge(t2.e1()); } if ((t1.v2().p.times(m).minus(t2.v1().p).mag() < Mesh.EPSILON) && (t1.v3().p.times(m).minus(t2.v3().p).mag() < Mesh.EPSILON) && (t1.v1().p.times(m).minus(t2.v2().p).mag() < Mesh.EPSILON)) { - t1.e2().bind(t2.e3().pair); - t1.e3().bind(t2.e2().pair); - t1.e1().bind(t2.e1().pair); + t1.e2().bindEdge(t2.e3()); + t1.e3().bindEdge(t2.e2()); + t1.e1().bindEdge(t2.e1()); } if ((t1.v3().p.times(m).minus(t2.v1().p).mag() < Mesh.EPSILON) && (t1.v1().p.times(m).minus(t2.v3().p).mag() < Mesh.EPSILON) && (t1.v2().p.times(m).minus(t2.v2().p).mag() < Mesh.EPSILON)) { - t1.e3().bind(t2.e3().pair); - t1.e1().bind(t2.e2().pair); - t1.e2().bind(t2.e1().pair); + t1.e3().bindEdge(t2.e3()); + t1.e1().bindEdge(t2.e2()); + t1.e2().bindEdge(t2.e1()); } } } @@ -162,7 +164,7 @@ public class Main extends MeshViewer { //tx.e3.shatter(); - tile.bind(); + tile.rebindPoints(); //mid.move(new Vec((float)0,0,(float)-0.05)); //ltn.move(new Vec((float)0,0,(float)-0.05)); @@ -178,23 +180,22 @@ public class Main extends MeshViewer { } public synchronized void breakit() { - if (verts > 200) return; + if (verts > 300) return; PriorityQueue es = new PriorityQueue(); for(Mesh.E e : tile.edges()) es.add(e); for(int i=0; i<10; i++) { Mesh.E e = es.poll(); verts++; - System.out.println("shatter " + e); + //System.out.println("shatter " + e); e.shatter(); - tile.unbind(); - tile.bind(); + tile.rebindPoints(); } } public synchronized void rand(double temperature, Mesh.Vert p) { double tile_score = tile.score(); double goal_score = goal.score(); - p.rescore(); + p.reComputeError(); Vec v = new Vec((random.nextFloat() - (float)0.5) / 1000, (random.nextFloat() - (float)0.5) / 1000, @@ -221,25 +222,23 @@ public class Main extends MeshViewer { } } - public static int verts = 0; - public void anneal() throws Exception { int verts = 0; while(true) { - for(int i=0; i<1; i++) { + HashSet hs = new HashSet(); + for(Mesh.Vert p : tile.vertices()) hs.add(p); + for(int i=0; i<10; i++) { repaint(); - for(Mesh.T t : tile) - for(Mesh.Vert p : new Mesh.Vert[] { t.v1(), t.v2(), t.v3() }) { - rand(10,p); - } - goal.unscore(); - tile.unscore(); - goal.fundamental(); - tile.fundamental(); - goal.rescore(); - tile.rescore(); + for(Mesh.Vert v : hs) rand(10,v); } + tile.rebuildPointSet(); breakit(); + repaint(); + goal.unApplyQuadricToNeighborAll(); + repaint(); + tile.recomputeAllFundamentalQuadrics(); + repaint(); + goal.applyQuadricToNeighborAll(); } } @@ -250,4 +249,5 @@ public class Main extends MeshViewer { Main main = new Main(stlf, f); main.anneal(); } + } \ No newline at end of file