checkpoint
[anneal.git] / src / edu / berkeley / qfat / geom / HasQuadric.java
index 889eaee..8addfc2 100644 (file)
@@ -37,12 +37,29 @@ public abstract class HasQuadric extends HasPoint {
             applyQuadricToNeighbor();
         }
     public abstract void _recomputeFundamentalQuadric();
-    public abstract void applyQuadricToNeighbor();
     public abstract void reComputeErrorAround();
     public abstract void reComputeError();
     public abstract void unComputeError();
     public abstract void computeError();
     public abstract HasQuadric nearest();
+        public void applyQuadricToNeighbor() {
+            HasQuadric new_nearest = nearest();
+            if (nearest_in_other_mesh != null && new_nearest == nearest_in_other_mesh) return;
+
+            if (nearest_in_other_mesh != null) unApplyQuadricToNeighbor();
+            if (nearest_in_other_mesh != null) throw new Error();
+
+            nearest_in_other_mesh = new_nearest;
+
+            if (nearest_in_other_mesh!=null) {
+                nearest_in_other_mesh.unComputeError();
+                nearest_in_other_mesh.quadric = nearest_in_other_mesh.quadric.plus(fundamentalQuadric());
+                nearest_in_other_mesh.quadric_count++;
+                nearest_in_other_mesh.computeError();
+            }
+
+            reComputeError();
+        }
         public Matrix fundamentalQuadric() {
             if (fundamentalQuadric == null) recomputeFundamentalQuadric();
             return fundamentalQuadric;