Exemple #1
0
 /**
  * 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);
   }
 }