checkpoint
[anneal.git] / src / edu / berkeley / qfat / Mesh.java
index 6fd53d3..5c913c4 100644 (file)
@@ -129,7 +129,7 @@ public class Mesh implements Iterable<Mesh.T> {
         }
 
         /** does NOT update bound pairs! */
-        public boolean transform(Point newp, boolean ignoreProblems) {
+        private boolean transform(Point newp, boolean ignoreProblems) {
             this.oldp = this.p;
             if (immutableVertices) throw new Error();
 
@@ -169,31 +169,25 @@ public class Mesh implements Iterable<Mesh.T> {
         }
 
         public boolean visit(Object o) {
-            if (o instanceof T) {
-                T t = (T)o;
-                if (!good) return false;
-                for(E e = Vertex.this.e; e!=null; e=e.pair.next==Vertex.this.e?null:e.pair.next) {
-                    if (!t.has(e.p1) && !t.has(e.p2) && e.intersects(t)) { good = false; }
-                    if (e.t != null) {
-                        if (!e.t.has(t.e1().p1) && !e.t.has(t.e1().p2) && t.e1().intersects(e.t)) { good = false; }
-                        if (!e.t.has(t.e2().p1) && !e.t.has(t.e2().p2) && t.e2().intersects(e.t)) { good = false; }
-                        if (!e.t.has(t.e3().p1) && !e.t.has(t.e3().p2) && t.e3().intersects(e.t)) { good = false; }
-                    }
+            if (o instanceof Vertex)
+                return ((Vertex)o).e != null && ((Vertex)o).norm().dot(Vertex.this.norm()) >= 0;
+            T t = (T)o;
+            if (!good) return false;
+            for(E e = Vertex.this.e; e!=null; e=e.pair.next==Vertex.this.e?null:e.pair.next) {
+                if (!t.has(e.p1) && !t.has(e.p2) && e.intersects(t)) { good = false; }
+                if (e.t != null) {
+                    if (!e.t.has(t.e1().p1) && !e.t.has(t.e1().p2) && t.e1().intersects(e.t)) { good = false; }
+                    if (!e.t.has(t.e2().p1) && !e.t.has(t.e2().p2) && t.e2().intersects(e.t)) { good = false; }
+                    if (!e.t.has(t.e3().p1) && !e.t.has(t.e3().p2) && t.e3().intersects(e.t)) { good = false; }
                 }
-                return good;
-            } else {
-                Vertex v = (Vertex)o;
-                if (v.e==null || v.norm().dot(Vertex.this.norm()) < 0)
-                    return false;
-                return true;
             }
+            return good;
         }
 
-        public boolean move(Vec v) {
-            Matrix m = Matrix.translate(v);
+        public boolean move(Matrix m, boolean ignoreProblems) {
             boolean good = true;
             for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to)
-                good &= p.transform(m.times(p.p), false);
+                good &= p.transform(m.times(p.p), ignoreProblems);
             for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to)
                 if (good)  p.reComputeErrorAround();
                 else       p.transform(p.oldp, true);