Example #1
0
        }         // public DirectedEdge GetRightmostEdge()

        /// <summary>
        /// Compute the labelling for all dirEdges in this star, as well
        ///  as the overall labelling
        /// </summary>
        /// <param name="geom"></param>
        public override void ComputeLabelling(GeometryGraph[] geom)
        {
            //Trace.WriteLine( ToString() );
            base.ComputeLabelling(geom);

            // determine the overall labelling for this DirectedEdgeStar
            // (i.e. for the node it is based at)
            _label = new Label(Location.Null);
            foreach (object obj in Edges())
            {
                EdgeEnd ee     = (EdgeEnd)obj;
                Edge    e      = ee.Edge;
                Label   eLabel = e.Label;
                for (int i = 0; i < 2; i++)
                {
                    int eLoc = eLabel.GetLocation(i);
                    if (eLoc == Location.Interior || eLoc == Location.Boundary)
                    {
                        _label.SetLocation(i, Location.Interior);
                    }
                }
            }             // foreach ( object obj in edges )

            //Trace.WriteLine( ToString() );
        }         // public override void ComputeLabelling(GeometryGraph[] geom)
Example #2
0
        private bool CheckAreaLabelsConsistent(int geomIndex)
        {
            // Since edges are stored in CCW order around the node,
            // As we move around the ring we move from the right to the left side of the edge
            ArrayList edges = Edges();

            // if no edges, trivially consistent
            if (edges.Count <= 0)
            {
                return(true);
            }

            // initialize startLoc to location of last L side (if any)
            int   lastEdgeIndex = edges.Count - 1;
            Label startLabel    = ((EdgeEnd)edges[lastEdgeIndex]).Label;
            int   startLoc      = startLabel.GetLocation(geomIndex, Position.Left);

            if (startLoc == Location.Null)
            {
                throw new InvalidOperationException("Found an unlabelled area edge.");
            }

            int currLoc = startLoc;

            edges = Edges();
            foreach (object obj in edges)
            {
                EdgeEnd e = (EdgeEnd)obj;

                Label label = e.Label;
                // we assume that we are only checking a area
                if (!label.IsArea(geomIndex))
                {
                    throw new InvalidOperationException("Label is a non-area edge.");
                }

                int leftLoc  = label.GetLocation(geomIndex, Position.Left);
                int rightLoc = label.GetLocation(geomIndex, Position.Right);

                Trace.WriteLine(leftLoc + " " + rightLoc);
                Trace.WriteLine(ToString());

                // check that edge is really a boundary between inside and outside!
                if (leftLoc == rightLoc)
                {
                    return(false);
                }
                // check side location conflict

                if (rightLoc != currLoc)
                {
                    //Trace.WriteLine( ToString() );
                    return(false);
                }
                currLoc = leftLoc;
            }
            return(true);
        }         // private bool CheckAreaLabelsConsistent(int geomIndex)
Example #3
0
        /// <summary>
        /// Returns the coordinate for the node this star is based at.
        /// </summary>
        /// <returns>Return the coordinate for the node this star is based at.</returns>
        public Coordinate GetCoordinate()
        {
            Edges();
            if (_edgeList.Count <= 0)
            {
                return(null);
            }
            EdgeEnd e = (EdgeEnd)_edgeList[0];

            return(e.Coordinate);
        }         // public Coordinate GetCoordinate()
Example #4
0
        /// <summary>
        /// Returns the next EdgeEnd following the EdgeEnd ee.  EdgeEnds are stored in ClockWise order.
        /// </summary>
        /// <param name="ee">Returns the next EdgeEnd which follows this EdgeEnd.</param>
        /// <returns>Returns the next EdgeEnd following the EdgeEnd ee.</returns>
        public EdgeEnd GetNextCW(EdgeEnd ee)
        {
            Edges();
            int i       = _edgeList.IndexOf(ee);          // had to implement EdgeEnd.Equals for this  to work.
            int iNextCW = i - 1;

            if (i == 0)
            {
                iNextCW = _edgeList.Count - 1;
            }
            return((EdgeEnd)_edgeList[iNextCW]);
        }         // public EdgeEnd GetNextCW(EdgeEnd ee)
Example #5
0
        }         // public void LinkAllDirectedEdges()

        /// <summary>
        /// Returns the EdgeEnd which has edge e as its base edge
        /// (MD 18 Feb 2002 - this should return a pair of edges)
        /// </summary>
        /// <param name="e"></param>
        /// <returns>return the edge, if found. Null if the edge was not found</returns>
        public EdgeEnd FindEdgeEnd(Edge e)
        {
            foreach (object objectEdgeEnd in EdgeEnds)
            {
                EdgeEnd ee = (EdgeEnd)objectEdgeEnd;
                if (ee.Edge == e)
                {
                    return(ee);
                }
            }
            return(null);
        }         // public EdgeEnd FindEdgeEnd( Edge e )
Example #6
0
        }         // void PropagateSideLabels( int geomIndex )

        /// <summary>
        /// Searchs the Edges list for the supplied EdgeEnd and returns the index into the list if found.  If not found,
        /// returns -1.
        /// </summary>
        /// <param name="eSearch">The EdgeEnd to find in the Edges list.</param>
        /// <returns>Returns the index for the supplied EdgeEnd or -1 if not found.</returns>
        public int FindIndex(EdgeEnd eSearch)
        {
            Edges();
            for (int i = 0; i < _edgeList.Count; i++)
            {
                EdgeEnd e = (EdgeEnd)_edgeList[i];
                if (e == eSearch)
                {
                    return(i);
                }
            }     // for( int i = 0; i < Edges().Count; i++ )
            return(-1);
        }         // public int FindIndex(EdgeEnd eSearch)
		/// <summary>
		/// Insert an EdgeEnd in order in the list.  If there is an existing EdgeStubBundle which is parallel,
		/// the EdgeEnd is added to the bundle.  Otherwise, a new EdgeEndBundle is created to contain the EdgeEnd.
		/// </summary>
		/// <param name="e"></param>
		public override void Insert( EdgeEnd e )
		{
			EdgeEndBundle eb = (EdgeEndBundle) _edgeMap[ e ];
			if (eb == null) 
			{
				eb = new EdgeEndBundle( e );
				InsertEdgeEnd( e, eb );
			}
			else 
			{
				eb.Insert( e );
			}
		} // public override void Insert( EdgeEnd e )
Example #8
0
        }         // public int FindIndex(EdgeEnd eSearch)

        /// <summary>
        /// Returns the string representation for this object.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("EdgeEndStar:   " + GetCoordinate());
            ArrayList edges = Edges();

            foreach (object edgeend in edges)
            {
                EdgeEnd e = edgeend as EdgeEnd;
                if (e != null)
                {
                    sb.Append(e.ToString());
                }
            }     // foreach( object edgeend in edges )
            return(sb.ToString());
        }         // public override string ToString()
Example #9
0
 /// <summary>
 ///  Implements the total order relation.
 /// </summary>
 /// <remarks>
 /// <para>Implements the total order relation: a has a greater angle with the positive x-axis than b.</para>
 /// <para>
 /// Using the obvious algorithm of simply computing the angle is not robust,
 /// since the angle calculation is obviously susceptible to roundoff.
 /// A robust algorithm is: - first compare the quadrant.  If the quadrants
 /// are different, it it trivial to determine which vector is "greater".
 /// - if the vectors lie in the same quadrant, the computeOrientation function
 ///  can be used to decide the relative orientation of the vectors.
 ///
 /// </para>
 ///
 ///
 /// </remarks>
 /// <param name="e"></param>
 /// <returns></returns>
 public int CompareDirection(EdgeEnd e)
 {
     if (_dx == e.Dx && _dy == e.Dy)
     {
         return(0);
     }
     // if the rays are in different quadrants, determining the ordering is trivial
     if (_quadrant > e.QuadrantLocation)
     {
         return(1);
     }
     if (_quadrant < e.QuadrantLocation)
     {
         return(-1);
     }
     // vectors are in the same quadrant - check relative orientation of direction vectors
     // this is > e if it is CCW of e
     return(_cga.ComputeOrientation(e.Coordinate, e.DirectedCoordinate, _p1));
 }
Example #10
0
 /// <summary>
 ///  Insert a directed edge in the list.
 /// </summary>
 /// <param name="ee">The EdgeEnd to be inserted into the list.  Must be of type DirectedEdge.</param>
 public override void Insert(EdgeEnd ee)
 {
     DirectedEdge de = (DirectedEdge) ee;
     InsertEdgeEnd( de, de );
 }
Example #11
0
        /// <summary>
        ///  Insert a directed edge in the list.
        /// </summary>
        /// <param name="ee">The EdgeEnd to be inserted into the list.  Must be of type DirectedEdge.</param>
        public override void Insert(EdgeEnd ee)
        {
            DirectedEdge de = (DirectedEdge)ee;

            InsertEdgeEnd(de, de);
        }
Example #12
0
		} // public void ComputeEdgeEnds( Edge edge, ArrayList l )

		/// <summary>
		/// Create a EdgeStub for the edge before the intersection eiCurr.
		///	The previous intersection is provided
		///	in case it is the endpoint for the stub edge.
		///	Otherwise, the previous point from the parent edge will be the endpoint.
		/// eiCurr will always be an EdgeIntersection, but eiPrev may be null.
		/// </summary>
		/// <param name="edge"></param>
		/// <param name="list"></param>
		/// <param name="eiCurr"></param>
		/// <param name="eiPrev"></param>
		void CreateEdgeEndForPrev(
			Edge edge,
			ArrayList list,
			EdgeIntersection eiCurr,
			EdgeIntersection eiPrev)
		{
			int iPrev = eiCurr.SegmentIndex;
			if ( eiCurr.Distance == 0.0 ) 
			{
				// if at the start of the edge there is no previous edge
				if ( iPrev == 0 ) return;
				iPrev--;
			}

			Coordinate pPrev = edge.GetCoordinate( iPrev );

			// if prev intersection is past the previous vertex, use it instead
			if ( eiPrev != null && eiPrev.SegmentIndex >= iPrev )
			{
				pPrev = eiPrev.Coordinate;
			}

			Label label = new Label( edge.Label );
			// since edgeStub is oriented opposite to it's parent edge, have to flip sides for edge label
			label.Flip();
			EdgeEnd e = new EdgeEnd( edge, eiCurr.Coordinate, pPrev, label );
			//Trace.WriteLine( e.ToString() );
			list.Add( e );	
		}  //void CreateEdgeEndForPrev(...
Example #13
0
		}  //void CreateEdgeEndForPrev(...

		/// <summary>
		/// Create a StubEdge for the edge after the intersection eiCurr.
		/// The next intersection is provided in case it is the endpoint for the stub edge.
		/// Otherwise, the next point from the parent edge will be the endpoint.
		/// eiCurr will always be an EdgeIntersection, but eiNext may be null.
		/// </summary>
		/// <param name="edge"></param>
		/// <param name="list"></param>
		/// <param name="eiCurr"></param>
		/// <param name="eiNext"></param>
		void CreateEdgeEndForNext(
			Edge edge,
			ArrayList list,
			EdgeIntersection eiCurr,
			EdgeIntersection eiNext)
		{
			int iNext = eiCurr.SegmentIndex + 1;

			// if there is no next edge there is nothing to do
			if ( iNext >= edge.NumPoints && eiNext == null ) return;

			Coordinate pNext = edge.GetCoordinate( iNext );

			// if the next intersection is in the same segment as the current, use it as the endpoint
			if ( eiNext != null && eiNext.SegmentIndex == eiCurr.SegmentIndex )
			{
				pNext = eiNext.Coordinate;
			}

			EdgeEnd e = new EdgeEnd( edge, eiCurr.Coordinate, pNext, new Label( edge.Label ) );
			//Trace.WriteLine( e.ToString() );
			list.Add( e );
		} // void CreateEdgeEndForNext(...
Example #14
0
 /// <summary>
 /// Add the edge to the list of edges at this node.
 /// </summary>
 /// <param name="e"></param>
 public void Add( EdgeEnd e )
 {
     // Assert: start pt of e is equal to node point
     _edges.Insert( e );
     e.Node = this;
 }
Example #15
0
 /// <summary>
 /// Insert a EdgeEnd into this EdgeEndStar.
 /// </summary>
 /// <param name="e">The edge to be inserted.</param>
 public abstract void Insert(EdgeEnd e);
Example #16
0
		/// <summary>
		/// Insert an EdgeEnd into the map, and clear the edgeList cache,
		/// since the list of edges has now changed
		/// </summary>
		/// <param name="e"></param>
		/// <param name="obj"></param>
		protected void InsertEdgeEnd(EdgeEnd e, Object obj)  // what's object?
		{
									// uses IComparable interface to maintain sorted order.
			_edgeMap[e]= obj;	// first element is the key, second is values.  automatically entered in sorted.
			_edgeList = null;		// edge list has changed - clear the cache
		}
Example #17
0
		} // void PropagateSideLabels( int geomIndex )


		/// <summary>
		/// Searchs the Edges list for the supplied EdgeEnd and returns the index into the list if found.  If not found,
		/// returns -1.
		/// </summary>
		/// <param name="eSearch">The EdgeEnd to find in the Edges list.</param>
		/// <returns>Returns the index for the supplied EdgeEnd or -1 if not found.</returns>
		public int FindIndex(EdgeEnd eSearch)
		{
			Edges();
			for( int i = 0; i < _edgeList.Count; i++ ) 
			{
				EdgeEnd e = (EdgeEnd)_edgeList[i];
				if ( e == eSearch  ) 
				{
					return i;
				}
			} // for( int i = 0; i < Edges().Count; i++ )
			return -1;
		} // public int FindIndex(EdgeEnd eSearch)
Example #18
0
 /// <summary>
 /// Add the edge to the list of edges at this node.
 /// </summary>
 /// <param name="e"></param>
 public void Add(EdgeEnd e)
 {
     // Assert: start pt of e is equal to node point
     _edges.Insert(e);
     e.Node = this;
 }         // public void Add(EdgeEnd e)
Example #19
0
 /// <summary>
 /// Insert a EdgeEnd into this EdgeEndStar.
 /// </summary>
 /// <param name="e">The edge to be inserted.</param>
 abstract public void Insert(EdgeEnd e);
Example #20
0
 /// <summary>
 ///  Implements the total order relation.
 /// </summary>
 /// <remarks>
 /// <para>Implements the total order relation: a has a greater angle with the positive x-axis than b.</para>
 /// <para>
 /// Using the obvious algorithm of simply computing the angle is not robust,
 /// since the angle calculation is obviously susceptible to roundoff.
 /// A robust algorithm is: - first compare the quadrant.  If the quadrants
 /// are different, it it trivial to determine which vector is "greater".
 /// - if the vectors lie in the same quadrant, the computeOrientation function
 ///  can be used to decide the relative orientation of the vectors.
 /// 
 /// </para> 
 /// 
 /// 
 /// </remarks>
 /// <param name="e"></param>
 /// <returns></returns>
 public int CompareDirection(EdgeEnd e)
 {
     if ( _dx == e.Dx && _dy == e.Dy)
     {
         return 0;
     }
     // if the rays are in different quadrants, determining the ordering is trivial
     if (_quadrant > e.QuadrantLocation) return 1;
     if (_quadrant < e.QuadrantLocation) return -1;
     // vectors are in the same quadrant - check relative orientation of direction vectors
     // this is > e if it is CCW of e
     return _cga.ComputeOrientation( e.Coordinate, e.DirectedCoordinate, _p1);
 }
Example #21
0
 /// <summary>
 /// Adds and EdgeEnd into the EdgeEndList.
 /// </summary>
 /// <param name="e"></param>
 public void Add(EdgeEnd e)
 {
     _nodes.Add(e);
     _edgeEndList.Add(e);
 }
Example #22
0
 /// <summary>
 /// Insert an EdgeEnd into the map, and clear the edgeList cache,
 /// since the list of edges has now changed
 /// </summary>
 /// <param name="e"></param>
 /// <param name="obj"></param>
 protected void InsertEdgeEnd(EdgeEnd e, Object obj)          // what's object?
 {
     // uses IComparable interface to maintain sorted order.
     _edgeMap[e] = obj;                  // first element is the key, second is values.  automatically entered in sorted.
     _edgeList   = null;                 // edge list has changed - clear the cache
 }
Example #23
0
		/// <summary>
		/// Initializes a new instance of the EdgeEndBundle class.
		/// </summary>
		public EdgeEndBundle( EdgeEnd e ) : base( e.Edge, e.Coordinate, e.DirectedCoordinate, new Label( e.Label ) )
		{
			Insert( e );
		}
Example #24
0
		/// <summary>
		/// Returns the next EdgeEnd following the EdgeEnd ee.  EdgeEnds are stored in ClockWise order.
		/// </summary>
		/// <param name="ee">Returns the next EdgeEnd which follows this EdgeEnd.</param>
		/// <returns>Returns the next EdgeEnd following the EdgeEnd ee.</returns>
		public EdgeEnd GetNextCW(EdgeEnd ee)
		{
			Edges();
			int i = _edgeList.IndexOf( ee );  // had to implement EdgeEnd.Equals for this  to work.
			int iNextCW = i - 1;
			if (i == 0)
			{
				iNextCW = _edgeList.Count - 1;
			}
			return (EdgeEnd) _edgeList[iNextCW];
		} // public EdgeEnd GetNextCW(EdgeEnd ee)
Example #25
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="e"></param>
		public void Insert( EdgeEnd e )
		{
			// Assert: start point is the same
			// Assert: direction is the same
			_edgeEnds.Add( e );
		} // public void Insert( EdgeEnd e )
Example #26
0
		/// <summary>
		/// Insert a EdgeEnd into this EdgeEndStar.
		/// </summary>
		/// <param name="e">The edge to be inserted.</param>
		abstract public void Insert(EdgeEnd e);
Example #27
0
 /// <summary>
 /// Adds a node for the start point of this EdgeEnd (if one does not already exist in this map).
 /// Adds the EdgeEnd to the (possibly new) node.
 /// </summary>
 /// <param name="e"></param>
 public void Add(EdgeEnd e)
 {
     Coordinate p = e.Coordinate;
     Node n = AddNode( p );
     n.Add( e );
 }
Example #28
0
 /// <summary>
 /// Adds and EdgeEnd into the EdgeEndList.
 /// </summary>
 /// <param name="e"></param>
 public void Add( EdgeEnd e )
 {
     _nodes.Add( e );
     _edgeEndList.Add( e );
 }
Example #29
0
        public int CompareTo(object obj)
        {
            EdgeEnd e = (EdgeEnd)obj;

            return(CompareDirection(e));
        }