checkpoint
[anneal.git] / src / edu / berkeley / qfat / Mesh.java
index 34a8de2..57eda26 100644 (file)
@@ -90,6 +90,7 @@ public class Mesh implements Iterable<Mesh.T> {
         private Vertex(Point p) {
             this.p = p;
             this.goodp = p;
+            this.oldp = p;
             if (vertices.get(p) != null) throw new Error();
             vertices.add(this);
         }
@@ -154,7 +155,7 @@ public class Mesh implements Iterable<Mesh.T> {
                 if (ang > Math.PI) throw new Error();
                 if (ang < -Math.PI) throw new Error();
                 //float minangle = (float)(Math.PI * 0.8);
-                nerror += ((ang / Math.PI)*(ang/Math.PI)) * e.length() * 0.01;
+                nerror += ((ang / Math.PI)*(ang/Math.PI)) * e.length() * 0.05;
                 //System.out.println(((ang / Math.PI)*(ang/Math.PI)) * 0.000001);
                 //if (ang > minangle) nerror += (ang - minangle);
                 /*
@@ -184,7 +185,7 @@ public class Mesh implements Iterable<Mesh.T> {
             if (bindingGroup != null) {
                 Matrix m2 = null;
                 for(int i=0; i<20 && !m.equals(m2); i++) {
-                    m2 = m.times(bindingGroup.krank);
+                    m2 = m.times(getConstraint());
                     //System.out.println(m.minus(m2));
                 }
                 if (!m.equals(m2)) return true;
@@ -222,6 +223,7 @@ public class Mesh implements Iterable<Mesh.T> {
             unApplyQuadricToNeighbor();
 
 
+            boolean illegalbefore = illegal;
             illegal = false;
             /*
             if (this.p.minus(newp).mag() > 0.1 && !ignoreProblems) {
@@ -243,17 +245,17 @@ public class Mesh implements Iterable<Mesh.T> {
             }
             for(E e = this.e; e!=null; e=e.pair.next==this.e?null:e.pair.next)
                 e.p2.quadricStale = true;
-            return !illegal;
+            return !illegal || (illegalbefore && illegal);
         } 
 
         public void checkLegality() {
-
+            /*
             for(E e = this.e; e!=null; e=e.pair.next==this.e?null:e.pair.next) {
                 if (Math.abs(e.dihedralAngle()) > (Math.PI * 0.9) ||
                     Math.abs(e.next.dihedralAngle()) > (Math.PI * 0.9)) illegal = true;
                 if (e.t.aspect() < 0.2) illegal = true;
             }
-
+            */
             if (!illegal) triangles.range(oldp, this.p, (Visitor<T>)this);
         }
 
@@ -452,10 +454,10 @@ public class Mesh implements Iterable<Mesh.T> {
                 e.p2.getE(mid).pair.     bindTo(e.getBindingMatrix(firste), firstq);
                 e.p2.getE(mid).pair.pair.bindTo(e.getBindingMatrix(firste), firstq.pair);
             }
-            if (firste.bindingGroup != null)
-                firste.bindingGroup.setKrank(bindingGroup.krank);
-            if (firstq.bindingGroup != null)
-                firstq.bindingGroup.setKrank(bindingGroup.krank);
+            /*
+            first.setConstraint(firste.getConstraint());
+            firstq.setConstraint(firste.getConstraint());
+            */
             return null;
         }