- int count = 0;
- long then = System.currentTimeMillis();
- for(int i=0; i<100; i++) {
- if (anneal) {
- count++;
- Mesh.Vert v = pts[Math.abs(random.nextInt()) % pts.length];
- rand(temp,v);
+ HashSet<Mesh.Vertex> hs = new HashSet<Mesh.Vertex>();
+ 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<40; i++) {
+ if (anneal) {
+ count++;
+ Mesh.Vertex v = pts[Math.abs(random.nextInt()) % pts.length];
+ rand(temp,v);
+ v.recomputeFundamentalQuadricIfStale();
+ v.recomputeFundamentalQuadricIfNeighborChanged();
+ }
+ Thread.yield();
+ repaint();
+ }
+ PriorityQueue<Mesh.E> es = new PriorityQueue<Mesh.E>();
+ for(Mesh.T t : tile) {
+ float max = 5;
+ for(Mesh.E e : new Mesh.E[] { t.e1(), t.e2(), t.e3() }) {
+ if (e==null) continue;
+ if (e.stretchRatio() > max) es.add(e);
+ if (t.aspect() < 0.1 && e.length()>e.next.length() && e.length()>e.prev.length()) es.add(e);
+ }
+ }
+
+ for(int i=0; i<5; i++) {
+ Mesh.E e = es.poll();
+ if (e==null) break;
+ e.shatter();
+ }
+ tile.rebindPoints();
+
+ 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.recomputeFundamentalQuadricIfNeighborChanged();
+
+ synchronized(safeTriangles) {
+ safeTriangles.clear();
+ for(Mesh.T t : tile)
+ if (t.shouldBeDrawn())
+ safeTriangles.add(t);