Exemplo n.º 1
0
 /// <summary>
 /// Converts a Label to a Line label (that is, one with no side Location).
 /// </summary>
 /// <param name="label">Label to convert.</param>
 /// <returns>Label as Line label.</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;
 }
Exemplo n.º 2
0
        private int _depthDelta;   // the change in area depth from the R to Curve side of this edge

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pts"></param>
        /// <param name="label"></param>
        public Edge(Coordinate[] pts, Label label)
        {
            _eiList = new EdgeIntersectionList(this);

            _pts = pts;
            Label = label;
        }
Exemplo n.º 3
0
 /// <summary> 
 /// Updates an IM from the label for an edge.
 /// Handles edges from both L and A geometries.
 /// </summary>
 /// <param name="im"></param>
 /// <param name="label"></param>
 public static void UpdateIM(Label label, IntersectionMatrix im)
 {
     im.SetAtLeastIfValid(label.GetLocation(0, Positions.On), label.GetLocation(1, Positions.On), Dimension.Curve);
     if (label.IsArea())
     {
         im.SetAtLeastIfValid(label.GetLocation(0, Positions.Left), label.GetLocation(1, Positions.Left), Dimension.Surface);
         im.SetAtLeastIfValid(label.GetLocation(0, Positions.Right), label.GetLocation(1, Positions.Right), Dimension.Surface);
     }
 }
Exemplo n.º 4
0
 ///<summary>Compute the change in depth as an edge is crossed from R to L</summary>
 private static int DepthDelta(Label label)
 {
     var lLoc = label.GetLocation(0, Positions.Left);
     var rLoc = label.GetLocation(0, Positions.Right);
     if (lLoc == Location.Interior && rLoc == Location.Exterior)
         return 1;
     if (lLoc == Location.Exterior && rLoc == Location.Interior)
         return -1;
     return 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)
        {
            base.ComputeLabelling(geom);

            // determine the overall labelling for this DirectedEdgeStar
            // (i.e. for the node it is based at)
            _label = new Label(Location.Null);
            IEnumerator<EdgeEnd> it = GetEnumerator();
            while(it.MoveNext())
            {
                EdgeEnd ee = it.Current;
                Edge e = ee.Edge;
                Label eLabel = e.Label;
                for (int i = 0; i < 2; i++)
                {
                    Location eLoc = eLabel.GetLocation(i);
                    if (eLoc == Location.Interior || eLoc == Location.Boundary)
                        _label.SetLocation(i, Location.Interior);
                }
            }
        }
Exemplo n.º 6
0
        /// <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>
        /// <param name="boundaryNodeRule"></param>
        public override void ComputeLabel(IBoundaryNodeRule boundaryNodeRule)
        {
            // create the label.  If any of the edges belong to areas,
            // the label must be an area label
            bool isArea = false;
            foreach (EdgeEnd e in _edgeEnds)
            {
                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, boundaryNodeRule);
                if (isArea)
                    ComputeLabelSides(i);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Tests whether a point with a given topological <see cref="Label"/>
 /// relative to two geometries is contained in 
 /// the result of overlaying the geometries using
 /// a given overlay operation.
 /// <para/>
 /// The method handles arguments of <see cref="Location.Null"/> correctly
 /// </summary>
 /// <param name="label">The topological label of the point</param>
 /// <param name="overlayOpCode">The code for the overlay operation to test</param>
 /// <returns><c>true</c> if the label locations correspond to the overlayOpCode</returns>
 public static bool IsResultOfOp(Label label, SpatialFunction overlayOpCode)
 {
     var loc0 = label.GetLocation(0);
     var loc1 = label.GetLocation(1);
     return IsResultOfOp(loc0, loc1, overlayOpCode);
 }
Exemplo n.º 8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="coord"></param>
 /// <param name="edges"></param>
 public Node(Coordinate coord, EdgeEndStar edges)
 {
     _coord = coord;
     _edges = edges;
     Label = new Label(0, Location.Null);
 }
Exemplo n.º 9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="argIndex"></param>
 /// <param name="onLocation"></param>
 public void SetLabel(int argIndex, Location onLocation)
 {
     if (Label == null)
          Label = new Label(argIndex, onLocation);
     else Label.SetLocation(argIndex, onLocation);
 }
Exemplo n.º 10
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++)
     {
         Location loc = ComputeMergedLocation(label2, i);
         Location thisLoc = Label.GetLocation(i);
         if (thisLoc == Location.Null)
             Label.SetLocation(i, loc);
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Inserted edges are checked 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>
        protected void InsertUniqueEdge(Edge e)
        {
            //<FIX> MD 8 Oct 03  speed up identical edge lookup
            // fast lookup
            Edge existingEdge = _edgeList.FindEqualEdge(e);

            // If an identical edge already exists, simply update its label
            if (existingEdge != null)
            {
                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;
            }
            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);
            }
        }
Exemplo n.º 12
0
 /// <summary> 
 /// Merge this label with another one.
 /// Merging updates any null attributes of this label with the attributes from lbl.
 /// </summary>
 /// <param name="lbl"></param>
 public  void Merge(Label lbl)
 {
     for (int i = 0; i < 2; i++) 
     {
         if (elt[i] == null && lbl.elt[i] != null) 
              elt[i] = new TopologyLocation(lbl.elt[i]);            
         else elt[i].Merge(lbl.elt[i]);            
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="deLabel"></param>
 protected void MergeLabel(Label deLabel)
 {
     MergeLabel(deLabel, 0);
     MergeLabel(deLabel, 1);
 }
Exemplo n.º 14
0
        /// <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">The edge to insert</param>
        protected void InsertUniqueEdge(Edge e)
        {
            var existingEdge = _edgeList.FindEqualEdge(e);
            // If an identical edge already exists, simply update its label
            if (existingEdge != null)
            {
                var existingLabel = existingEdge.Label;

                var 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();
                }
                var 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);
            }
            else
            {
                // no matching existing edge was found
                // add this new edge to the list of edges in this graph
                _edgeList.Add(e);
            }
        }
Exemplo n.º 15
0
        /// <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="l"></param>
        /// <param name="eiCurr"></param>
        /// <param name="eiPrev"></param>
        public void CreateEdgeEndForPrev(Edge edge, IList<EdgeEnd> l, 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);
            l.Add(e);
        }
Exemplo n.º 16
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++)
         {
             Location loc = lbl.GetLocation(i, (Positions)j);
             if (loc == Location.Exterior || loc == Location.Interior)
             {
                 // initialize depth if it is null, otherwise add this location value
                 if (IsNull(i, (Positions)j))
                      depth[i,j]  = DepthAtLocation(loc);
                 else depth[i,j] += DepthAtLocation(loc);
             }
         }
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="label"></param>
 protected GraphComponent(Label label)
 {
     _label = label;
 }
Exemplo n.º 18
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();
 }
Exemplo n.º 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));
     }
 }
Exemplo n.º 20
0
 /// <summary> 
 /// Merge the RHS label from a DirectedEdge into the label for this EdgeRing.
 /// The DirectedEdge label may be null.  This is acceptable - it results
 /// 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)
 {
     Location loc = deLabel.GetLocation(geomIndex, Positions.Right);
     // 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;
     }
 }
Exemplo n.º 21
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.elt[0]);
     elt[1] = new TopologyLocation(lbl.elt[1]);
 }
Exemplo n.º 22
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="lbl"></param>
 /// <param name="side"></param>
 /// <returns></returns>
 public  bool IsEqualOnSide(Label lbl, int side)
 {
     return  this.elt[0].IsEqualOnSide(lbl.elt[0], side)
         &&  this.elt[1].IsEqualOnSide(lbl.elt[1], side);
 }
Exemplo n.º 23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="lbl"></param>
 /// <param name="side"></param>
 /// <returns></returns>
 public bool IsEqualOnSide(Label lbl, int side)
 {
     return(this.elt[0].IsEqualOnSide(lbl.elt[0], side) &&
            this.elt[1].IsEqualOnSide(lbl.elt[1], side));
 }
Exemplo n.º 24
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.elt[0]);
     elt[1] = new TopologyLocation(lbl.elt[1]);
 }
Exemplo n.º 25
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 point;
 /// 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>
 public Location ComputeMergedLocation(Label label2, int eltIndex)
 {
     /*Location loc = Location.Null*/
     Location loc = Label.GetLocation(eltIndex);
     if (!label2.IsNull(eltIndex))
     {
         Location nLoc = label2.GetLocation(eltIndex);
         if (loc != Location.Boundary)
             loc = nLoc;
     }
     return loc;
 }