protected void Initialize(Coordinate p0, Coordinate p1) { _p0 = p0; _p1 = p1; _dx = p1.X - p0.X; _dy = p1.Y - p0.Y; _quadrant = Quadrant.QuadrantLocation(_dx, _dy); if (_dx == 0 && _dy == 0) { throw new InvalidOperationException("EdgeEnd with identical endpoints found."); } }
} // public Edge FindEdgeInSameDirection( Coordinate p0, Coordinate p1 ) /// <summary> /// The coordinate pairs match if they define line segments lying in the same direction. /// </summary> /// <remarks> /// E.g. the segments are parallel and in the same quadrant (as opposed to parallel and opposite!). /// </remarks> /// <param name="p0"></param> /// <param name="p1"></param> /// <param name="ep0"></param> /// <param name="ep1"></param> /// <returns></returns> private bool MatchInSameDirection(Coordinate p0, Coordinate p1, Coordinate ep0, Coordinate ep1) { if (!p0.Equals(ep0)) { return(false); } if (_cga.ComputeOrientation(p0, p1, ep1) == CGAlgorithms.COLLINEAR && Quadrant.QuadrantLocation(p0, p1) == Quadrant.QuadrantLocation(ep0, ep1)) { return(true); } return(false); } // private bool MatchInSameDirection( Coordinate p0, Coordinate p1, Coordinate ep0, Coordinate ep1 )
} // public int GetOutgoingDegree( EdgeRing er ) /// <summary> /// /// </summary> /// <returns></returns> public DirectedEdge GetRightmostEdge() { ArrayList edges = Edges(); int size = edges.Count; if (size < 1) { return(null); } DirectedEdge de0 = (DirectedEdge)edges[0]; if (size == 1) { return(de0); } DirectedEdge deLast = (DirectedEdge)edges[size - 1]; int quad0 = de0.QuadrantLocation; int quad1 = deLast.QuadrantLocation; if (Quadrant.IsNorthern(quad0) && Quadrant.IsNorthern(quad1)) { return(de0); } else if (!Quadrant.IsNorthern(quad0) && !Quadrant.IsNorthern(quad1)) { return(deLast); } else { // edges are in different hemispheres - make sure we return one that is non-horizontal //Assert.isTrue(de0.getDy() != 0, "should never return horizontal edge!"); if (de0.Dy != 0) { return(de0); } else if (deLast.Dy != 0) { return(deLast); } } throw new InvalidOperationException("found two horizontal edges incident on node"); } // public DirectedEdge GetRightmostEdge()