Example #1
0
		/// <summary>
		/// Compute the change in depth as an edge is crossed from R to L
		/// </summary>
		/// <param name="label"></param>
		/// <returns></returns>
		private static int DepthDelta(Label label)
		{
			int lLoc = label.GetLocation(0, Position.Left);
			int rLoc = label.GetLocation(0, Position.Right);
			if (lLoc == Location.Interior && rLoc == Location.Exterior)
				return 1;
			else if (lLoc == Location.Exterior && rLoc == Location.Interior)
				return -1;
			return 0;
		}
Example #2
0
 /// <summary>
 /// Updates an IM from the label for an edge. Handles edges from both L and A geometrys.
 /// </summary>
 /// <param name="label"></param>
 /// <param name="im"></param>
 public static void UpdateIM(Label label, IntersectionMatrix im)
 {
     im.SetAtLeastIfValid( label.GetLocation( 0, Position.On ), label.GetLocation( 1, Position.On ), 1);
     if ( label.IsArea() )
     {
         im.SetAtLeastIfValid( label.GetLocation( 0, Position.Left ),  label.GetLocation( 1, Position.Left ),   2);
         im.SetAtLeastIfValid( label.GetLocation( 0, Position.Right ), label.GetLocation( 1, Position.Right ),  2);
     }
 }
Example #3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="lbl"></param>
 public void Add(Label lbl)
 {
     for (int i = 0; i < 2; i++)
     {
         for (int j = 1; j < 3; j++)
         {
             int loc = lbl.GetLocation( i, j );
             if ( loc == Location.Exterior || loc == Location.Interior )
             {
                 // initialize depth if it is null, otherwise add this location value
                 if (IsNull(i, j))
                 {
                     _depth[i,j] = DepthAtLocation(loc);
                 }
                 else
                     _depth[i,j] += DepthAtLocation(loc);
             }
         }
     } // for (int i = 0; i < 2; i++)
 }
Example #4
0
 /// <summary>
 /// To merge labels for two nodes, the merged location for each LabelElement is computed.
 /// The location for the corresponding node LabelElement is set to the result, as long as the location is non-null.
 /// </summary>
 /// <param name="label2"></param>
 public void MergeLabel( Label label2 )
 {
     for (int i = 0; i < 2; i++)
     {
         int loc = ComputeMergedLocation(label2, i);
         int thisLoc = _label.GetLocation(i);
         if ( thisLoc == Location.Null )
         {
             _label.SetLocation( i, loc );
         }
     } // for (int i = 0; i < 2; i++)
 }
Example #5
0
 protected void MergeLabel( Label deLabel )
 {
     MergeLabel( deLabel, 0 );
     MergeLabel( deLabel, 1 );
 }
Example #6
0
		/**
		 * Inserted edges are checked identical edge already exists.
		 * If so, the edge is not inserted, but its label is merged
		 * with the existing edge.
		 */
		protected void InsertEdge(Edge e)
		{
			//Debug.println(e);
			int foundIndex = _edgeList.FindEdgeIndex(e);
			// If an identical edge already exists, simply update its label
			if (foundIndex >= 0) 
			{
				Edge existingEdge = (Edge) _edgeList[foundIndex];
				Label existingLabel = existingEdge.Label;

				Label labelToMerge = e.Label;
				// check if new edge is in reverse direction to existing edge
				// if so, must flip the label before merging it
				if (! existingEdge.IsPointwiseEqual(e)) 
				{
					labelToMerge = new Label(e.Label);
					labelToMerge.Flip();
				}
				existingLabel.Merge(labelToMerge);

				// compute new depth delta of sum of edges
				int mergeDelta = DepthDelta(labelToMerge);
				int existingDelta = existingEdge.DepthDelta;
				int newDelta = existingDelta + mergeDelta;
				existingEdge.DepthDelta=newDelta;

				CheckDimensionalCollapse(labelToMerge, existingLabel);
				//Debug.print("new edge "); Debug.println(e);
				//Debug.print("existing "); Debug.println(existingEdge);

			}
			else 
			{   // no matching existing edge was found
				// add this new edge to the list of edges in this graph
				//e.setName(name + edges.size());
				_edgeList.Add(e);
				e.DepthDelta=DepthDelta(e.Label);
			}
		}
Example #7
0
 /// <summary>
 /// Converts a Label to a Line label (that is, one with no side Locations)
 /// </summary>
 /// <param name="label"></param>
 /// <returns></returns>
 public static Label ToLineLabel(Label label)
 {
     Label lineLabel = new Label( Location.Null );
     for (int i = 0; i < 2; i++)
     {
         lineLabel.SetLocation( i, label.GetLocation(i) );
     }
     return lineLabel;
 }
Example #8
0
		} // private void InsertUniqueEdges( ArrayList edges )

		/// <summary>
		/// Insert an edge from one of the noded input graphs.
		/// Checks edges that are inserted to see if an
		/// identical edge already exists.
		/// If so, the edge is not inserted, but its label is merged
		/// with the existing edge.
		/// </summary>
		/// <param name="e"></param>
		protected void InsertUniqueEdge( Edge e )
		{
			// Trace.WriteLine( e.ToString() );
			int foundIndex = _edgeList.FindEdgeIndex( e );
			// If an identical edge already exists, simply update its label
			if ( foundIndex >= 0 ) 
			{
				Edge existingEdge = (Edge) _edgeList[foundIndex];
				Label existingLabel = existingEdge.Label;

				Label labelToMerge = e.Label;
				// check if new edge is in reverse direction to existing edge
				// if so, must flip the label before merging it
				if ( !existingEdge.IsPointwiseEqual( e ) ) 
				{
					labelToMerge = new Label( e.Label );
					labelToMerge.Flip();
				}

				Depth depth = existingEdge.Depth;
				// if this is the first duplicate found for this edge, initialize the depths
				//
				if ( depth.IsNull() ) 
				{
					depth.Add( existingLabel );
				}
				//
				depth.Add( labelToMerge );
				existingLabel.Merge( labelToMerge );
				//Trace.WriteLine("inserted edge: ");
				//Trace.WriteLine( e.ToString() );
				//Trace.WriteLine("existing edge: ");
				//Trace.WriteLine( existingEdge.ToString() );

			} // if ( foundIndex >= 0 )
			else 
			{  
				// no matching existing edge was found
				// add this new edge to the list of edges in this graph
				//e.setName(name + edges.size());
				//e.getDepth().add(e.getLabel());
				_edgeList.Add( e );
			} // else
		} // protected void InsertUniqueEdge( Edge e )
Example #9
0
 public EdgeEnd(Edge edge, Coordinate p0, Coordinate p1, Label label)
     : this(edge)
 {
     Initialize(p0, p1);
     _label = label;
 }
Example #10
0
 /// <summary>
 /// Construct a Label with the same values as the argument Label.
 /// </summary>
 /// <param name="lbl"></param>
 public Label( Label lbl )
 {
     _elt[0] = new TopologyLocation(lbl.LabelElements[0]);
     _elt[1] = new TopologyLocation(lbl.LabelElements[1]);
 }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the Node class.
 /// </summary>
 public Node(Coordinate coord, EdgeEndStar edges)
 {
     _coord = coord;
     _edges = edges;
     _label = new Label( 0, Location.Null );
 }
Example #12
0
 /// <summary>
 /// The location for a given eltIndex for a node will be one
 /// of { null, INTERIOR, BOUNDARY }.
 /// A node may be on both the boundary and the interior of a geometry;
 /// in this case, the rule is that the node is considered to be in the boundary.
 /// The merged location is the maximum of the two input values.
 /// </summary>
 /// <param name="label2"></param>
 /// <param name="eltIndex"></param>
 /// <returns></returns>
 int ComputeMergedLocation(Label label2, int eltIndex)
 {
     int loc = Location.Null;
     loc = _label.GetLocation( eltIndex );
     if ( !label2.IsNull( eltIndex ) )
     {
         int nLoc = label2.GetLocation( eltIndex );
         if (loc != Location.Boundary)
         {
             loc = nLoc;
         }
     }
     return loc;
 }
Example #13
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="argIndex"></param>
 /// <param name="onLocation"></param>
 public void SetLabel( int argIndex, int onLocation )
 {
     if ( _label == null )
     {
         _label = new Label( argIndex, onLocation );
     }
     else
     {
         _label.SetLocation( argIndex, onLocation );
     }
 }
Example #14
0
 /// <summary>
 /// Constructs a new edge using the coordinates collection and supplied label object.
 /// </summary>
 /// <param name="pts"></param>
 /// <param name="label"></param>
 public Edge(Coordinates pts, Label label)
 {
     _eiList = new EdgeIntersectionList( this );
     _pts = pts;
     _label = label;		// inherited member variable.
 }
Example #15
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="lbl"></param>
 /// <param name="side"></param>
 /// <returns></returns>
 public bool IsEqualOnSide(Label lbl, int side)
 {
     return _elt[0].IsEqualOnSide( lbl.LabelElements[0], side )
            &&  _elt[1].IsEqualOnSide( lbl.LabelElements[1], side );
 }
Example #16
0
		} // public void Insert( EdgeEnd e )

		/// <summary>
		/// This computes the overall edge label for the set of edges in this EdgeStubBundle.
		/// It essentially merges the ON and side labels for each edge. These labels must be compatible.
		/// </summary>
		public override void ComputeLabel()
		{
			// create the label.  If any of the edges belong to areas,
			// the label must be an area label
			bool isArea = false;
			foreach ( object obj in _edgeEnds ) 
			{
				EdgeEnd e = (EdgeEnd)obj;
				if ( e.Label.IsArea() )
				{
					isArea = true;
				}
			}
			if ( isArea )
			{
				_label = new Label( Location.Null, Location.Null, Location.Null );
			}
			else
			{
				_label = new Label( Location.Null );
			}

			// compute the On label, and the side labels if present
			for ( int i = 0; i < 2; i++ ) 
			{
				ComputeLabelOn( i );
				if ( isArea )
				{
					ComputeLabelSides(i);
				}
			} // for ( int i = 0; i < 2; i++ )

		} // public override void ComputeLabel()
Example #17
0
 /// <summary>
 /// Merge this label with another one. Merging updates any null attributes of this label
 /// with the attributes from label.
 /// </summary>
 /// <param name="lbl"></param>
 public void Merge( Label lbl )
 {
     for (int i = 0; i < 2; i++)
     {
         if (_elt[i] == null && lbl.LabelElements[i] != null)
         {
             _elt[i] = new TopologyLocation( lbl.LabelElements[i] );
         }
         else
         {
             _elt[i].Merge( lbl.LabelElements[i] );
         }
     }
 }
Example #18
0
		} // public static Geometry Overlay( Geometry geom0, Geometry geom1, int opCode )

		/// <summary>
		/// 
		/// </summary>
		/// <param name="label"></param>
		/// <param name="opCode"></param>
		/// <returns></returns>
		public static bool IsResultOfOp( Label label, int opCode )
		{
			int loc0 = label.GetLocation( 0 );
			int loc1 = label.GetLocation( 1 );
			return IsResultOfOp( loc0, loc1, opCode );
		} // public static bool IsResultOfOp( Label label, int opCode )		
Example #19
0
 /// <summary>
 /// Update incomplete dirEdge labels from the labelling for the node.
 /// </summary>
 /// <param name="nodeLabel"></param>
 public void UpdateLabelling(Label nodeLabel)
 {
     foreach ( DirectedEdge de in Edges() )
     {
         Label label = de.Label;
         label.SetAllLocationsIfNull( 0, nodeLabel.GetLocation( 0 ) );
         label.SetAllLocationsIfNull( 1, nodeLabel.GetLocation( 1 ) );
     }
 }
Example #20
0
        /// <summary>
        /// Merge the RHS label from a DirectedEdge into the label for this EdgeRing.
        /// from a node which is NOT an intersection node between the Geometries
        /// (e.g. the end node of a LinearRing).  In this case the DirectedEdge label
        /// does not contribute any information to the overall labelling, and is simply skipped.
        /// </summary>
        /// <param name="deLabel"></param>
        /// <param name="geomIndex"></param>
        protected void MergeLabel( Label deLabel, int geomIndex )
        {
            int loc = deLabel.GetLocation( geomIndex, Position.Right );	// get the location for this label.

            // no information to be had from this label
            if ( loc == Location.Null ) return;

            // if there is no current RHS value, set it
            if ( _label.GetLocation( geomIndex ) == Location.Null )
            {
                _label.SetLocation( geomIndex, loc );
                return;
            }
        }
Example #21
0
        /// <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() );
        }
Example #22
0
		/**
		 * If either of the GeometryLocations for the existing label is
		 * exactly opposite to the one in the labelToMerge,
		 * this indicates a dimensional collapse has happened.
		 * In this case, convert the label for that Geometry to a Line label
		 */
		private void CheckDimensionalCollapse(Label labelToMerge, Label existingLabel)
		{
			if (existingLabel.IsArea() && labelToMerge.IsArea()) 
			{
				for (int i = 0; i < 2; i++) 
				{
					if (! labelToMerge.IsNull(i)
						&&  labelToMerge.GetLocation(i, Position.Left)  == existingLabel.GetLocation(i, Position.Right)
						&&  labelToMerge.GetLocation(i, Position.Right) == existingLabel.GetLocation(i, Position.Left) )
					{
						existingLabel.ToLine(i);
					}
				}
			}
		}
Example #23
0
 /// <summary>
 /// Compute the label in the appropriate orientation for this DirEdge.
 /// </summary>
 private void ComputeDirectedLabel()
 {
     _label = new Label( _edge.Label );
     if (!IsForward )
     {
         _label.Flip();
     }
 }
Example #24
0
 public GraphComponent(Label label)
 {
     _label = label;
 }
Example #25
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(...