X-Git-Url: http://git.megacz.com/?p=anneal.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2FMesh.java;h=50df8dd8d40bec3536646f2f2549066b4ca078d3;hp=1a1b9a30924c6047afa2cf8b34e11ad9d02f4b90;hb=c05b2e9cafc557d3f1e0a91323efe095d072efb4;hpb=161d356850a765c2f6b83b42275095b777d7b2aa diff --git a/src/edu/berkeley/qfat/Mesh.java b/src/edu/berkeley/qfat/Mesh.java index 1a1b9a3..50df8dd 100644 --- a/src/edu/berkeley/qfat/Mesh.java +++ b/src/edu/berkeley/qfat/Mesh.java @@ -17,8 +17,8 @@ public class Mesh implements Iterable { public static Random random = new Random(); private HashMap ps = new HashMap(); - public HashSet es = new HashSet(); - public ArrayList ts = new ArrayList(); + public HashSet es = new HashSet(); + public ArrayList ts = new ArrayList(); public Iterator iterator() { return ts.iterator(); } @@ -28,15 +28,17 @@ public class Mesh implements Iterable { public double score = 0; public float score() { return (float)score; } - public void unbind() { + public int numedges = 0; + public float avgedge = 0; + public void unbind() { for(Mesh.T t : this) { t.p1().unbind(); t.p2().unbind(); t.p3().unbind(); } - } + public void bind() { for(Mesh.T t : this) { t.e1().dobind(); @@ -44,8 +46,6 @@ public class Mesh implements Iterable { t.e3().dobind(); } } - public int numedges = 0; - public float avgedge = 0; public float rescore() { int num = 0; @@ -111,14 +111,6 @@ public class Mesh implements Iterable { (float)(max_z + min_z)/2); } - public T newT(Vert p12, Vert p23, Vert p31, Vec norm) { - Vec norm2 = p31.p.minus(p12.p).cross(p23.p.minus(p12.p)); - float dot = norm.dot(norm2); - //if (Math.abs(dot) < EPointSILON) throw new Error("dot products within epsilon of each other: "+norm+" "+norm2); - if (dot < 0) { Vert p = p12; p12=p23; p23 = p; } - return newT(p12, p23, p31); - } - public float volume() { double total = 0; for(T t : ts) { @@ -137,7 +129,13 @@ public class Mesh implements Iterable { return (Vert)results[0]; } - public T newT(Vert p1, Vert p2, Vert p3) { + public T newT(Vert p1, Vert p2, Vert p3, Vec norm) { + if (norm != null) { + Vec norm2 = p3.p.minus(p1.p).cross(p2.p.minus(p1.p)); + float dot = norm.dot(norm2); + //if (Math.abs(dot) < EPointSILON) throw new Error("dot products within epsilon of each other: "+norm+" "+norm2); + if (dot < 0) { Vert p = p1; p1=p2; p2 = p; } + } E e12 = p1.makeE(p2); E e23 = p2.makeE(p3); E e31 = p3.makeE(p1); @@ -238,7 +236,6 @@ public class Mesh implements Iterable { score += oldscore; } - /** does NOT update bound pairs! */ public boolean transform(Matrix m) { // FIXME: screws up kdtree @@ -478,8 +475,8 @@ public class Mesh implements Iterable { pair.shatter(); destroy(); - newT(r, p1, mid); - newT(r, mid, p2); + newT(r, p1, mid, null); + newT(r, mid, p2, null); bg1.add(p1.getE(mid)); bg2.add(mid.getE(p2)); return mid;