}
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 (v1.equals(v2)
+ || v2.equals(v3)
+ || v3.equals(v1))
+ throw new Error("attempt to make a triangle with a length-zero side");
if (coalesce) {
-
for(Vertex v : vertices) { if (v1.distance(v.p) < EPSILON) { v1 = v.p; break; } }
for(Vertex v : vertices) { if (v2.distance(v.p) < EPSILON) { v2 = v.p; break; } }
for(Vertex v : vertices) { if (v3.distance(v.p) < EPSILON) { v3 = v.p; break; } }
v2 = new Point(round(v2.x), round(v2.y), round(v2.z));
v3 = new Point(round(v3.x), round(v3.y), round(v3.z));
*/
+ /*
+ // triangle's vertices got merged
+ if (v1.equals(v2) || v2.equals(v3) || v3.equals(v1))
+ return null;
+ */
}
if (norm != null) {
Vec norm2 = v3.minus(v1).cross(v2.minus(v1));
E e12 = makeE(v1, v2);
E e23 = makeE(v2, v3);
E e31 = makeE(v3, v1);
+ if (e12==e23 || e23==e31 || e12==e31) throw new Error();
while(e12.next != e23 || e23.next != e31 || e31.next != e12) {
e12.makeAdjacent(e23);
e23.makeAdjacent(e31);