/** * Defines a comparison operation on DepthSegments * which orders them left to right * * <pre> * DS1 < DS2 if DS1.seg is left of DS2.seg * DS1 > DS2 if DS1.seg is right of DS2.seg * </pre> * * @param obj * @return the comparison value */ public int compareTo(Object obj) { DepthSegment other = (DepthSegment) obj; if (! envelopesOverlap(upwardSeg, other.upwardSeg)) return upwardSeg.compareTo(other.upwardSeg); // check orientations int orientIndex = upwardSeg.orientationIndex(other.upwardSeg); if (orientIndex != 0) return orientIndex; orientIndex = - other.upwardSeg.orientationIndex(upwardSeg); if (orientIndex != 0) return orientIndex; // segments cross or are collinear. Use segment ordering return upwardSeg.compareTo(other.upwardSeg); }
return upwardSeg.compareTo(other.upwardSeg);