From: adam Date: Sun, 16 Dec 2007 05:38:22 +0000 (-0800) Subject: checkpoint X-Git-Url: http://git.megacz.com/?p=anneal.git;a=commitdiff_plain;h=9c8449ec3a4e9a70399bbcb5cfeadea9dc18a646;ds=sidebyside checkpoint darcs-hash:20071216053822-5007d-5ff80415601099932b34469d250cd0b6eee1e38b.gz --- diff --git a/src/edu/berkeley/qfat/Mesh.java b/src/edu/berkeley/qfat/Mesh.java index 3208442..3da4835 100644 --- a/src/edu/berkeley/qfat/Mesh.java +++ b/src/edu/berkeley/qfat/Mesh.java @@ -80,7 +80,7 @@ public class Mesh implements Iterable { Matrix binding = Matrix.ONE; Vertex bound_to = this; - private boolean good; + private boolean illegal = false; public Point getPoint() { return p; } public float error() { return olderror; } @@ -91,7 +91,11 @@ public class Mesh implements Iterable { vertices.add(this); } - public void reinsert() { vertices.remove(this); vertices.add(this); } + public void reinsert() { + vertices.remove(this); + vertices.add(this); + for(E e = this.e; e!=null; e=e.pair.next==this.e?null:e.pair.next) e.t.reinsert(); + } public float olderror = 0; public void setError(float nerror) { @@ -135,23 +139,24 @@ public class Mesh implements Iterable { if (immutableVertices) throw new Error(); unApplyQuadricToNeighbor(); - this.p = newp; - for(E e = this.e; e!=null; e=e.pair.next==this.e?null:e.pair.next) e.t.reinsert(); reinsert(); - applyQuadricToNeighbor(); if (ignoreProblems) return true; - good = true; + illegal = false; + checkLegality(); + return !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.crossAngle()) > (Math.PI * 0.9) || Math.abs(e.next.crossAngle()) > (Math.PI * 0.9)) good = false; - if (e.t.aspect() < 0.1) good = false; + if (Math.abs(e.crossAngle()) > (Math.PI * 0.9) || Math.abs(e.next.crossAngle()) > (Math.PI * 0.9)) illegal = true; + if (e.t.aspect() < 0.1) illegal = true; e.p2.quadricStale = true; } - if (good) triangles.range(oldp, this.p, (Visitor)this); - return good; + if (illegal) triangles.range(oldp, this.p, (Visitor)this); } public void reComputeErrorAround() { @@ -166,16 +171,16 @@ public class Mesh implements Iterable { 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; + if (illegal) 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 (!t.has(e.p1) && !t.has(e.p2) && e.intersects(t)) { illegal = true; } 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 (!e.t.has(t.e1().p1) && !e.t.has(t.e1().p2) && t.e1().intersects(e.t)) { illegal = true; } + if (!e.t.has(t.e2().p1) && !e.t.has(t.e2().p2) && t.e2().intersects(e.t)) { illegal = true; } + if (!e.t.has(t.e3().p1) && !e.t.has(t.e3().p2) && t.e3().intersects(e.t)) { illegal = true; } } } - return good; + return !illegal; } public boolean move(Matrix m, boolean ignoreProblems) {