Index: src/Common/NetTopologySuite/Triangulate/QuadEdge/QuadEdge.cs =================================================================== diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a --- src/Common/NetTopologySuite/Triangulate/QuadEdge/QuadEdge.cs (.../QuadEdge.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9) +++ src/Common/NetTopologySuite/Triangulate/QuadEdge/QuadEdge.cs (.../QuadEdge.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -26,7 +26,95 @@ /// Martin Davis public class QuadEdge { + // the dual of this edge, directed from right to left +// private int visitedKey = 0; + /// + /// Quadedges must be made using {@link makeEdge}, + /// to ensure proper construction. + /// + private QuadEdge() {} + + /// + /// Gets or sets the external data value for this edge. + /// + /// + /// an object containing external data + /// + public object Data { set; get; } + + /// + /// Tests whether this edge has been deleted. + /// + /// true if this edge has not been deleted. + public bool IsLive + { + get + { + return Rot != null; + } + } + + /*********************************************************************************************** + * Data Access + **********************************************************************************************/ + /* + /// + /// Sets the vertex for this edge's origin + /// + /// the origin vertex + internal void SetOrig(Vertex o) + { + _vertex = o; + } + */ + + /* + /// + /// Sets the vertex for this edge's destination + /// + /// the destination vertex + internal void SetDest(Vertex d) + { + Sym.Orig = d; + } + */ + + /// + /// Gets or sets the vertex for the edge's origin + /// + /// Gets the origin vertex + public Vertex Orig { get; internal set; } + + /// + /// Gets or sets the vertex for the edge's destination + /// + /// Gets the destination vertex + public Vertex Dest + { + get + { + return Sym.Orig; + } + internal set + { + Sym.Orig = value; + } + } + + /// + /// Gets the length of the geometry of this quadedge. + /// + /// Gets the length of the quadedge + public double Length + { + get + { + return Orig.Coordinate.Distance(Dest.Coordinate); + } + } + + /// /// Creates a new QuadEdge quartet from o to d. /// /// the origin Vertex @@ -113,21 +201,7 @@ e.Dest = b.Dest; } - // the dual of this edge, directed from right to left - private Vertex _vertex; // The vertex that this edge represents - private QuadEdge _next; // A reference to a connected edge -// private int visitedKey = 0; - /// - /// Quadedges must be made using {@link makeEdge}, - /// to ensure proper construction. - /// - private QuadEdge() - { - - } - - /// /// Gets the primary edge of this quadedge and its sym. /// The primary edge is the one for which the origin /// and destination coordinates are ordered @@ -137,19 +211,13 @@ public QuadEdge GetPrimary() { if (Orig.Coordinate.CompareTo(Dest.Coordinate) <= 0) + { return this; + } return Sym; } /// - /// Gets or sets the external data value for this edge. - /// - /// - /// an object containing external data - /// - public object Data { set; get; } - - /// /// Marks this quadedge as being deleted. /// This does not free the memory used by /// this quadedge quartet, but indicates @@ -162,23 +230,71 @@ } /// - /// Tests whether this edge has been deleted. + /// Sets the connected edge /// - /// true if this edge has not been deleted. - public bool IsLive + /// edge + public void SetNext(QuadEdge next) { - get { return Rot != null; } + ONext = next; } /// - /// Sets the connected edge + /// Tests if this quadedge and another have the same line segment geometry, + /// regardless of orientation. /// - /// edge - public void SetNext(QuadEdge next) + /// a quadege + /// true if the quadedges are based on the same line segment regardless of orientation + public bool EqualsNonOriented(QuadEdge qe) { - _next = next; + if (EqualsOriented(qe)) + { + return true; + } + if (EqualsOriented(qe.Sym)) + { + return true; + } + return false; } + /// + /// Tests if this quadedge and another have the same line segment geometry + /// with the same orientation. + /// + /// a quadege + /// true if the quadedges are based on the same line segment + public bool EqualsOriented(QuadEdge qe) + { + if (Orig.Coordinate.Equals2D(qe.Orig.Coordinate) + && Dest.Coordinate.Equals2D(qe.Dest.Coordinate)) + { + return true; + } + return false; + } + + /// + /// Creates a representing the + /// geometry of this edge. + /// + /// a LineSegment + public LineSegment ToLineSegment() + { + return new LineSegment(Orig.Coordinate, Dest.Coordinate); + } + + /// + /// Converts this edge to a WKT two-point LINESTRING indicating + /// the geometry of this edge. + /// + /// a String representing this edge's geometry + public override String ToString() + { + var p0 = Orig.Coordinate; + var p1 = Dest.Coordinate; + return WKTWriter.ToLineString(p0, p1); + } + /*************************************************************************** * QuadEdge Algebra *************************************************************************** @@ -191,18 +307,6 @@ internal QuadEdge Rot { get; set; } /// - /// Gets the dual of this edge, directed from its left to its right. - /// - /// Gets the inverse rotated edge. - private QuadEdge InvRot - { - get - { - return Rot.Sym; - } - } - - /// /// Gets the edge from the destination to the origin of this edge. /// /// Gets the sym of the edge. @@ -213,18 +317,12 @@ return Rot.Rot; } } - + /// /// Gets the next CCW edge around the origin of this edge. /// /// Gets the next linked edge. - internal QuadEdge ONext - { - get - { - return _next; - } - } + internal QuadEdge ONext { get; private set; } /// /// Gets the next CW edge around (from) the origin of this edge. @@ -234,23 +332,11 @@ { get { - return Rot._next.Rot; + return Rot.ONext.Rot; } } /// - /// Gets the next CCW edge around (into) the destination of this edge. - /// - /// Get the next destination edge. - private QuadEdge DNext - { - get - { - return Sym.ONext.Sym; - } - } - - /// /// Gets the next CW edge around (into) the destination of this edge. /// /// Get the previous destination edge. @@ -270,7 +356,7 @@ { get { - return this.InvRot.ONext.Rot; + return InvRot.ONext.Rot; } } @@ -282,146 +368,56 @@ { get { - return _next.Sym; + return ONext.Sym; } } /// - /// Gets the edge around the right face ccw following this edge. + /// Gets the dual of this edge, directed from its left to its right. /// - /// Gets the next right face edge. - private QuadEdge RNext + /// Gets the inverse rotated edge. + private QuadEdge InvRot { get { - return Rot._next.InvRot; + return Rot.Sym; } } /// - /// Gets the edge around the right face ccw before this edge. + /// Gets the next CCW edge around (into) the destination of this edge. /// - /// Gets the previous right face edge. - private QuadEdge RPrev + /// Get the next destination edge. + private QuadEdge DNext { get { - return this.Sym.ONext; + return Sym.ONext.Sym; } } - /*********************************************************************************************** - * Data Access - **********************************************************************************************/ - /* /// - /// Sets the vertex for this edge's origin + /// Gets the edge around the right face ccw following this edge. /// - /// the origin vertex - internal void SetOrig(Vertex o) + /// Gets the next right face edge. + private QuadEdge RNext { - _vertex = o; - } - */ - - /* - /// - /// Sets the vertex for this edge's destination - /// - /// the destination vertex - internal void SetDest(Vertex d) - { - Sym.Orig = d; - } - */ - - /// - /// Gets or sets the vertex for the edge's origin - /// - /// Gets the origin vertex - public Vertex Orig - { - get { return _vertex; } - internal set + get { - _vertex = value; + return Rot.ONext.InvRot; } } /// - /// Gets or sets the vertex for the edge's destination + /// Gets the edge around the right face ccw before this edge. /// - /// Gets the destination vertex - public Vertex Dest + /// Gets the previous right face edge. + private QuadEdge RPrev { - get { return Sym.Orig; } - internal set - { - Sym.Orig = value; - } - } - - /// - /// Gets the length of the geometry of this quadedge. - /// - /// Gets the length of the quadedge - public double Length - { get { - return Orig.Coordinate.Distance(Dest.Coordinate); + return Sym.ONext; } } - - /// - /// Tests if this quadedge and another have the same line segment geometry, - /// regardless of orientation. - /// - /// a quadege - /// true if the quadedges are based on the same line segment regardless of orientation - public bool EqualsNonOriented(QuadEdge qe) - { - if (EqualsOriented(qe)) - return true; - if (EqualsOriented(qe.Sym)) - return true; - return false; - } - - /// - /// Tests if this quadedge and another have the same line segment geometry - /// with the same orientation. - /// - /// a quadege - /// true if the quadedges are based on the same line segment - public bool EqualsOriented(QuadEdge qe) - { - if (Orig.Coordinate.Equals2D(qe.Orig.Coordinate) - && Dest.Coordinate.Equals2D(qe.Dest.Coordinate)) - return true; - return false; - } - - /// - /// Creates a representing the - /// geometry of this edge. - /// - /// a LineSegment - public LineSegment ToLineSegment() - { - return new LineSegment(_vertex.Coordinate, Dest.Coordinate); - } - - /// - /// Converts this edge to a WKT two-point LINESTRING indicating - /// the geometry of this edge. - /// - /// a String representing this edge's geometry - public override String ToString() - { - var p0 = _vertex.Coordinate; - var p1 = Dest.Coordinate; - return WKTWriter.ToLineString(p0, p1); - } } } \ No newline at end of file