/** * Implements the Comparable interface. The triangles will be sorted according the middle of their * bounding box. As we work on a triangulation where triangles' intersection can only be an edge, * a point or void, the Bounding boxes are unique. * * <p>BE CAREFUL : this method is not consistent with equals ! We are making a comparison on the * bounding box of two triangles, they could be equal even if the triangle are different !!! * * @param t * @return -1, 0 or 1, using the point comparison on the center of the bounding boxes */ @Override public final int compareTo(DTriangle t) { try { DPoint midT = getBoundingBox().getMiddle(); DPoint midO = t.getBoundingBox().getMiddle(); int c = midT.compareTo(midO); if (c == 0) { try { c = getBarycenter().compareTo(t.getBarycenter()); } catch (DelaunayError ex) { Logger.getLogger(DTriangle.class.getName()).log(Level.WARNING, null, ex); } } return c; } catch (DelaunayError e) { throw new IllegalArgumentException(e.getLocalizedMessage(), e); } }
/** * Get the leftmost point of this triangle. * * @return the leftmost point of this triangle. */ public final DPoint getLeftMost() { DPoint p1 = edges[0].getPointLeft(); DPoint p2 = edges[1].getPointLeft(); return p1.compareTo(p2) < 1 ? p1 : p2; }