Esempio n. 1
0
 /// <summary>
 /// Initializes this Edge's two DirectedEdges, and for each DirectedEdge: sets the
 /// Edge, sets the symmetric DirectedEdge, and adds this Edge to its from-Node.
 /// </summary>
 /// <param name="de0"></param>
 /// <param name="de1"></param>
 public void SetDirectedEdges(DirectedEdge de0, DirectedEdge de1)
 {
     dirEdge = new DirectedEdge[] { de0, de1, };
     de0.Edge = this;
     de1.Edge = this;
     de0.Sym = de1;
     de1.Sym = de0;
     de0.FromNode.AddOutEdge(de0);
     de1.FromNode.AddOutEdge(de1);
 }
Esempio n. 2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="de"></param>
 /// <param name="pos"></param>
 /// <param name="list"></param>
 /// <param name="expectedClosed"></param>
 /// <returns></returns>
 private LinkedListNode<DirectedEdge> AddReverseSubpath(DirectedEdge de, LinkedListNode<DirectedEdge> pos,
                                         LinkedList<DirectedEdge> list,  bool expectedClosed)
 {
     // trace an unvisited path *backwards* from this de
     Node endNode = de.ToNode;
     Node fromNode = null;
     while (true)
     {
         if (pos == null)
              pos = list.AddLast(de.Sym);
         else pos = list.AddAfter(pos, de.Sym);
         de.Edge.Visited = true;
         fromNode = de.FromNode;
         DirectedEdge unvisitedOutDE = FindUnvisitedBestOrientedDE(fromNode);
         // this must terminate, since we are continually marking edges as visited
         if (unvisitedOutDE == null)
             break;
         de = unvisitedOutDE.Sym;
     }
     if (expectedClosed)
     {
         // the path should end at the toNode of this de, otherwise we have an error
         Assert.IsTrue(fromNode == endNode, "path not contiguous");
     }
     return pos;
 }
Esempio n. 3
0
 /// <summary>
 /// Drops a member of this DirectedEdgeStar.
 /// </summary>
 /// <param name="de"></param>
 public void Remove(DirectedEdge de)
 {
     outEdges.Remove(de);
 }
Esempio n. 4
0
 /// <summary>
 /// Adds a new member to this DirectedEdgeStar.
 /// </summary>
 /// <param name="de"></param>
 public void Add(DirectedEdge de)
 {            
     outEdges.Add(de);
     sorted = false;
 }
Esempio n. 5
0
 /// <summary>
 /// Returns the DirectedEdge on the left-hand side of the given DirectedEdge (which
 /// must be a member of this DirectedEdgeStar). 
 /// </summary>
 /// <param name="dirEdge"></param>
 /// <returns></returns>
 public DirectedEdge GetNextEdge(DirectedEdge dirEdge)
 {
     int i = GetIndex(dirEdge);
     return (DirectedEdge)outEdges[GetIndex(i + 1)];
 }
Esempio n. 6
0
 /// <summary>
 /// Returns the zero-based index of the given DirectedEdge, after sorting in ascending order
 /// by angle with the positive x-axis.
 /// </summary>
 /// <param name="dirEdge"></param>
 /// <returns></returns>
 public int GetIndex(DirectedEdge dirEdge)
 {
     SortEdges();
     for (int i = 0; i < outEdges.Count; i++)
     {
         DirectedEdge de = (DirectedEdge)outEdges[i];
         if (de == dirEdge)
             return i;
     }
     return -1;
 }
Esempio n. 7
0
 /// <summary>
 /// Adds an outgoing DirectedEdge to this Node.
 /// </summary>
 /// <param name="de"></param>
 public void AddOutEdge(DirectedEdge de)
 {
     deStar.Add(de);
 }
Esempio n. 8
0
 /// <summary>
 /// Removes this directed edge from its containing graph.
 /// </summary>
 internal void Remove()
 {
     this.sym        = null;
     this.parentEdge = null;
 }
Esempio n. 9
0
 /// <summary>
 /// Drops a member of this DirectedEdgeStar.
 /// </summary>
 /// <param name="de"></param>
 public void Remove(DirectedEdge de)
 {
     outEdges.Remove(de);
 }
Esempio n. 10
0
 /// <summary>
 /// Adds a new member to this DirectedEdgeStar.
 /// </summary>
 /// <param name="de"></param>
 public void Add(DirectedEdge de)
 {
     outEdges.Add(de);
     sorted = false;
 }
Esempio n. 11
0
        /// <summary>
        /// Returns the DirectedEdge on the left-hand side of the given DirectedEdge (which
        /// must be a member of this DirectedEdgeStar).
        /// </summary>
        /// <param name="dirEdge"></param>
        /// <returns></returns>
        public DirectedEdge GetNextEdge(DirectedEdge dirEdge)
        {
            int i = GetIndex(dirEdge);

            return((DirectedEdge)outEdges[GetIndex(i + 1)]);
        }
Esempio n. 12
0
 /// <summary>
 /// Constructs an Edge initialized with the given DirectedEdges, and for each
 /// DirectedEdge: sets the Edge, sets the symmetric DirectedEdge, and adds
 /// this Edge to its from-Node.
 /// </summary>
 /// <param name="de0"></param>
 /// <param name="de1"></param>
 public Edge(DirectedEdge de0, DirectedEdge de1)
 {
     SetDirectedEdges(de0, de1);
 }
Esempio n. 13
0
 /// <summary>
 /// Adds the Edge to this PlanarGraph; only subclasses can add DirectedEdges,
 /// to ensure the edges added are of the right class.
 /// </summary>
 /// <param name="dirEdge"></param>
 protected void Add(DirectedEdge dirEdge)
 {
     dirEdges.Add(dirEdge);
 }
Esempio n. 14
0
 /// <summary>
 /// Adds an outgoing DirectedEdge to this Node.
 /// </summary>
 /// <param name="de"></param>
 public void AddOutEdge(DirectedEdge de)
 {
     deStar.Add(de);
 }
Esempio n. 15
0
 /// <summary> 
 /// Removes DirectedEdge from its from-Node and from this PlanarGraph. Note:
 /// This method does not remove the Nodes associated with the DirectedEdge,
 /// even if the removal of the DirectedEdge reduces the degree of a Node to
 /// zero.
 /// </summary>
 /// <param name="de"></param>
 public void Remove(DirectedEdge de)
 {
     DirectedEdge sym = de.Sym;
     if (sym != null) 
         sym.Sym = null;
     de.FromNode.OutEdges.Remove(de);
     de.Remove();
     dirEdges.Remove(de);
 }
Esempio n. 16
0
 /// <summary>
 /// Adds a DirectedEdge which is known to form part of this ring.
 /// </summary>
 /// <param name="de">The DirectedEdge to add.</param>
 public void Add(DirectedEdge de)
 {
     deList.Add(de);
 }
Esempio n. 17
0
 /// <summary>
 /// Adds the Edge to this PlanarGraph; only subclasses can add DirectedEdges,
 /// to ensure the edges added are of the right class.
 /// </summary>
 /// <param name="dirEdge"></param>
 protected void Add(DirectedEdge dirEdge)
 {
     dirEdges.Add(dirEdge);
 }
Esempio n. 18
0
        /// <summary>
        /// Returns 1 if this DirectedEdge has a greater angle with the
        /// positive x-axis than b", 0 if the DirectedEdges are collinear, and -1 otherwise.
        /// Using the obvious algorithm of simply computing the angle is not robust,
        /// since the angle calculation is susceptible to roundoff. A robust algorithm
        /// is:
        /// first compare the quadrants. If the quadrants are different, it it
        /// trivial to determine which vector is "greater".
        /// if the vectors lie in the same quadrant, the robust
        /// <c>RobustCGAlgorithms.ComputeOrientation(Coordinate, Coordinate, Coordinate)</c>
        /// function can be used to decide the relative orientation of the vectors.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CompareTo(Object obj)
        {
            DirectedEdge de = (DirectedEdge)obj;

            return(CompareDirection(de));
        }