X-Git-Url: http://git.megacz.com/?p=anneal.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2FMain.java;fp=src%2Fedu%2Fberkeley%2Fqfat%2FMain.java;h=b7df3d4a848e231fa1ac7f04f7ffa9543faecfdb;hp=237266b343a7e3c37788cc0953027ae87e58e517;hb=8cb2aceb7c2b140b70b9955f1a0a6f2524f2314e;hpb=4d37197f8e2572a3c5510d77c0f09a19e9d9f748 diff --git a/src/edu/berkeley/qfat/Main.java b/src/edu/berkeley/qfat/Main.java index 237266b..b7df3d4 100644 --- a/src/edu/berkeley/qfat/Main.java +++ b/src/edu/berkeley/qfat/Main.java @@ -14,13 +14,6 @@ import edu.berkeley.qfat.geom.Polygon; // TO DO: // -// - Implement "real" constraints (plane, line, point) -// -// - Constrained surface subdivision -// - Edge.flip() gets us the triforce subdivision -// - Edge.delete() gets us the catmull-clark subdivision -// - Catmull-Clark: just don't move points if we can't. Need to average the influence of the points on a binding group. -// // - Ability to snap three views to orthgonal // - SLIDE UI // - left button -> crystal ball @@ -32,28 +25,11 @@ import edu.berkeley.qfat.geom.Polygon; // Editing: // - fracture edge, face // - change aspect ratio +// - translate, rotate goal mesh // - ability to select a point, rotate the model, then move the point // - when moving a vertex in one window, show that window's axes in all other windows // - -// TO DO: -// - real anneal -// - solve self-intersection problem -// - get a better test model? -// - symmetry constraints withing the tile -// - rotation matrices -// - overbinding results in forced equational constraints on the leader -// - shatter in invertd-triforce pattern brian mentioned -// - aspect ratio? non-uniform deformation? -// - rotational alignment - -// - movie-style user interface like -// http://www.coleran.com/markcoleranreell.html ? - -// - consider recasting the Shewchuk predicates in Java? -// http://www.cs.cmu.edu/afs/cs/project/quake/public/code/predicates.c - /* blender keys - middle mouse = option+click @@ -66,20 +42,39 @@ import edu.berkeley.qfat.geom.Polygon; wheel: zoom home: home view: take current angle, zoom to whole scnee 5 = ortho vs non-ortho - */ /* +Meshlab Notes: +Log console + - blend-shaded overlay? slick. +face/vertex count +rendering FPS +ability to not draw edges between faces - */ +three circumcircles showing crystal ball -- these don't get scaled +axes? -// FIXME: re-orient goal (how?) +drawing modes: + - bounding box + - vertices + - edges + - visible-edges + - flat with or without edges + - shaded with or without edges + * contrasting-faces -public class Main extends InteractiveMeshViewer { +quadric decimation? +show normals +show bounding box +show axes (big+fat) + */ + +public class Main extends InteractiveMeshViewer { public static int verts = 1; @@ -229,162 +224,6 @@ public class Main extends InteractiveMeshViewer { fixupGoal(); } - public void breakit() { - int oldverts = verts; - if (verts > 2000 && !force) return; - force = false; - System.out.println("doubling vertices."); - PriorityQueue es = new PriorityQueue(); - for(Mesh.T t : tile) { - es.add(t.e1()); - es.add(t.e2()); - es.add(t.e3()); - Thread.yield(); - repaint(); - } - for(int i=0; i 0) { - while (breaks>0) { - breaks--; - breakit(); - } - seek_upward = true; - continue; - } else if (acceptance > 0.96) gamma = 0.1f; - else if (acceptance > 0.9) gamma = 0.2f; - else if (acceptance > 0.8) gamma = 0.3f; - else if (acceptance > 0.6) gamma = 0.4f; - else if (acceptance > 0.3) gamma = 0.8f; - else if (acceptance > 0.15) gamma = 0.94f; - else if (acceptance > 0.10) gamma = 0.98f; - - else if (acceptance < 0.01) breaks++; - - if (seek_upward) { - if (acceptance > 0.25) seek_upward = false; - else gamma = 2-gamma; - } - - if (anneal) - temp = temp * gamma; - - - HashSet hs = new HashSet(); - for(Mesh.Vertex p : tile.vertices()) hs.add(p); - Mesh.Vertex[] pts = (Mesh.Vertex[])hs.toArray(new Mesh.Vertex[0]); - - int count = 0; - long then = System.currentTimeMillis(); - for(int i=0; i<300; i++) { - if (anneal) { - Mesh.Vertex v = pts[Math.abs(random.nextInt()) % pts.length]; - if (breaks>0) break; - if (!rand(temp,v)) { i--; continue; } - v.recomputeFundamentalQuadricIfStale(); - v.recomputeFundamentalQuadricIfNeighborChanged(); - count++; - } - Thread.yield(); - repaint(); - } - - System.out.println("temp="+temp + " ratio="+(Math.ceil(acceptance*100)) + " " + - "points_per_second=" + - (count*1000)/((double)(System.currentTimeMillis()-then))); - for(Mesh.Vertex p : goal.vertices()) { - p.quadricStale = true; - p.recomputeFundamentalQuadricIfNeighborChanged(); - } - } - } - } - - - public static void main(String[] s) throws Exception { - JFrame f = new JFrame(); - f.setLayout(new BorderLayout()); - Main main = new Main(f); - f.add(main, BorderLayout.CENTER); - f.setJMenuBar(main.new MyMenuBar()); - f.pack(); - f.show(); - f.setSize(900, 900); - f.doLayout(); - main.anneal(); - } public class MyMenuItem extends JMenuItem implements ActionListener { public MyMenuItem(String s) { @@ -1013,4 +852,163 @@ public class Main extends InteractiveMeshViewer { mthis.m, mthis.n, mthis.o, 1); } +////////////////////////////////////////////////////////////////////////////// + public void breakit() { + int oldverts = verts; + if (verts > 2000 && !force) return; + force = false; + System.out.println("doubling vertices."); + PriorityQueue es = new PriorityQueue(); + for(Mesh.T t : tile) { + es.add(t.e1()); + es.add(t.e2()); + es.add(t.e3()); + Thread.yield(); + repaint(); + } + for(int i=0; i 0) { + while (breaks>0) { + breaks--; + breakit(); + } + seek_upward = true; + continue; + } else if (acceptance > 0.96) gamma = 0.1f; + else if (acceptance > 0.9) gamma = 0.2f; + else if (acceptance > 0.8) gamma = 0.3f; + else if (acceptance > 0.6) gamma = 0.4f; + else if (acceptance > 0.3) gamma = 0.8f; + else if (acceptance > 0.15) gamma = 0.94f; + else if (acceptance > 0.10) gamma = 0.98f; + + else if (acceptance < 0.01) breaks++; + + if (seek_upward) { + if (acceptance > 0.25) seek_upward = false; + else gamma = 2-gamma; + } + + if (anneal) + temp = temp * gamma; + + + HashSet hs = new HashSet(); + for(Mesh.Vertex p : tile.vertices()) hs.add(p); + Mesh.Vertex[] pts = (Mesh.Vertex[])hs.toArray(new Mesh.Vertex[0]); + + int count = 0; + long then = System.currentTimeMillis(); + for(int i=0; i<300; i++) { + if (anneal) { + Mesh.Vertex v = pts[Math.abs(random.nextInt()) % pts.length]; + if (breaks>0) break; + if (!rand(temp,v)) { i--; continue; } + v.recomputeFundamentalQuadricIfStale(); + v.recomputeFundamentalQuadricIfNeighborChanged(); + count++; + } + Thread.yield(); + repaint(); + } + + System.out.println("temp="+temp + " ratio="+(Math.ceil(acceptance*100)) + " " + + "points_per_second=" + + (count*1000)/((double)(System.currentTimeMillis()-then))); + for(Mesh.Vertex p : goal.vertices()) { + p.quadricStale = true; + p.recomputeFundamentalQuadricIfNeighborChanged(); + } + } + } + } + + + public static void main(String[] s) throws Exception { + JFrame f = new JFrame(); + f.setLayout(new BorderLayout()); + Main main = new Main(f); + f.add(main, BorderLayout.CENTER); + f.setJMenuBar(main.new MyMenuBar()); + f.pack(); + f.show(); + f.setSize(900, 900); + f.doLayout(); + main.anneal(); + } + + } \ No newline at end of file