From c05b2e9cafc557d3f1e0a91323efe095d072efb4 Mon Sep 17 00:00:00 2001 From: adam Date: Tue, 4 Dec 2007 20:27:18 -0800 Subject: [PATCH] checkpoint darcs-hash:20071205042718-5007d-82852fbaef52ef7f81706ce64f9708b909021ff2.gz --- src/edu/berkeley/qfat/Main.java | 40 +++++++++++++++++++-------------------- src/edu/berkeley/qfat/Mesh.java | 33 +++++++++++++++----------------- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/src/edu/berkeley/qfat/Main.java b/src/edu/berkeley/qfat/Main.java index 7f99039..9ba230d 100644 --- a/src/edu/berkeley/qfat/Main.java +++ b/src/edu/berkeley/qfat/Main.java @@ -148,36 +148,36 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener // top - tile.newT(ltf, mtf, mtn); - tile.newT(mtn, ltn, ltf); - tile.newT(mtf, rtf, rtn); - tile.newT(rtn, mtn, mtf); + tile.newT(ltf, mtf, mtn, null); + tile.newT(mtn, ltn, ltf, null); + tile.newT(mtf, rtf, rtn, null); + tile.newT(rtn, mtn, mtf, null); // bottom (swap normals) - tile.newT(mbf, lbf, mbn); - tile.newT(lbn, mbn, lbf); - tile.newT(rbf, mbf, rbn); - tile.newT(mbn, rbn, mbf); + tile.newT(mbf, lbf, mbn, null); + tile.newT(lbn, mbn, lbf, null); + tile.newT(rbf, mbf, rbn, null); + tile.newT(mbn, rbn, mbf, null); // left - tile.newT(ltf, ltn, lbn); - tile.newT(lbn, lbf, ltf); + tile.newT(ltf, ltn, lbn, null); + tile.newT(lbn, lbf, ltf, null); // right (swap normals) - tile.newT(rtn, rtf, rbn); - tile.newT(rbf, rbn, rtf); + tile.newT(rtn, rtf, rbn, null); + tile.newT(rbf, rbn, rtf, null); // front - tile.newT(ltn, mtn, mbn); - tile.newT(ltn, mbn, lbn); - tile.newT(mtn, rtn, rbn); - tile.newT(mtn, rbn, mbn); + tile.newT(ltn, mtn, mbn, null); + tile.newT(ltn, mbn, lbn, null); + tile.newT(mtn, rtn, rbn, null); + tile.newT(mtn, rbn, mbn, null); // back - tile.newT(mtf, ltf, mbf); - tile.newT(mbf, ltf, lbf); - tile.newT(rtf, mtf, rbf); - tile.newT(rbf, mtf, mbf); + tile.newT(mtf, ltf, mbf, null); + tile.newT(mbf, ltf, lbf, null); + tile.newT(rtf, mtf, rbf, null); + tile.newT(rbf, mtf, mbf, null); for(Matrix m : translations) { for(Mesh.T t1 : tile) { 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; -- 1.7.10.4