add helper newT() method which does not require a colorclass
[anneal.git] / src / edu / berkeley / qfat / Mesh.java
index 31e0590..032457b 100644 (file)
@@ -85,6 +85,7 @@ public class Mesh implements Iterable<Mesh.T> {
     public float error() { return (float)error; }
 
     public int size() { return vertices.size(); }
+    public int numTriangles() { return triangles.size(); }
     public Iterable<Vertex> vertices() { return vertices; }
     public Iterator<T> iterator() { return triangles.iterator(); }
 
@@ -898,6 +899,7 @@ public class Mesh implements Iterable<Mesh.T> {
         public E(Point v1, Point v2) {
             if (vertices.get(v1) != null) throw new Error();
             if (vertices.get(v2) != null) throw new Error();
+            if (v1.equals(v2)) throw new Error("attempt to create a zero-length edge!");
             this.v1 = new Vertex(v1);
             this.v2 = new Vertex(v2);
             this.prev = this.next = this.pair = new E(this, this, this);
@@ -967,6 +969,7 @@ public class Mesh implements Iterable<Mesh.T> {
     public T newT(HasPoint v1, HasPoint v2, HasPoint v3) {
         return newT(v1.getPoint(), v2.getPoint(), v3.getPoint(), null, 0);
     }
+    public T newT(Point v1, Point v2, Point v3, Vec norm) { return newT(v1, v2, v3, norm, 1); }
     public T newT(Point v1, Point v2, Point v3, Vec norm, int colorclass) {
         if (coalesce) {