/// <summary> /// </summary> /// <param name="obj"></param> /// <returns> /// -1 this SegmentNode is located before the argument location;<br/> /// 0 this SegmentNode is at the argument location;<br/> /// 1 this SegmentNode is located after the argument location. /// </returns> public int CompareTo(object obj) { var other = (SegmentNode)obj; if (SegmentIndex < other.SegmentIndex) { return(-1); } if (SegmentIndex > other.SegmentIndex) { return(1); } if (Coord.Equals2D(other.Coord)) { return(0); } // an exterior node is the segment start point, so always sorts first // this guards against a robustness problem where the octants are not reliable if (!IsInterior) { return(-1); } if (!other.IsInterior) { return(1); } return(SegmentPointComparator.Compare(_segmentOctant, Coord, other.Coord)); }
/// <summary> /// </summary> /// <param name="obj"></param> /// <returns> /// -1 this SegmentNode is located before the argument location;<br/> /// 0 this SegmentNode is at the argument location;<br/> /// 1 this SegmentNode is located after the argument location. /// </returns> public int CompareTo(object obj) { var other = (SegmentNode)obj; if (SegmentIndex < other.SegmentIndex) { return(-1); } if (SegmentIndex > other.SegmentIndex) { return(1); } if (Coord.Equals2D(other.Coord)) { return(0); } return(SegmentPointComparator.Compare(_segmentOctant, Coord, other.Coord)); }