Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pts"></param>
        /// <param name="label"></param>
        public Edge(IList<Coordinate> pts, Label label)
        {
            _eiList = new EdgeIntersectionList(this);

            _pts = pts;
            base.Label = label;
        }
        /// <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(LocationType.Null);
            IEnumerator it = GetEnumerator();
            while (it.MoveNext())
            {
                EdgeEnd ee = (EdgeEnd)it.Current;
                Edge e = ee.Edge;
                Label eLabel = e.Label;
                for (int i = 0; i < 2; i++)
                {
                    LocationType eLoc = eLabel.GetLocation(i);
                    if (eLoc == LocationType.Interior || eLoc == LocationType.Boundary)
                        _label.SetLocation(i, LocationType.Interior);
                }
            }
        }
Exemple #3
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 virtual LocationType ComputeMergedLocation(Label label2, int eltIndex)
 {
     LocationType loc = Label.GetLocation(eltIndex);
     if (!label2.IsNull(eltIndex))
     {
         LocationType nLoc = label2.GetLocation(eltIndex);
         if (loc != LocationType.Boundary)
             loc = nLoc;
     }
     return loc;
 }
Exemple #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="argIndex"></param>
 /// <param name="onLocation"></param>
 public virtual void SetLabel(int argIndex, LocationType onLocation)
 {
     if (Label == null)
         Label = new Label(argIndex, onLocation);
     else Label.SetLocation(argIndex, onLocation);
 }
Exemple #5
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 virtual void MergeLabel(Label label2)
 {
     for (int i = 0; i < 2; i++)
     {
         LocationType loc = ComputeMergedLocation(label2, i);
         LocationType thisLoc = Label.GetLocation(i);
         if (thisLoc == LocationType.Null)
             Label.SetLocation(i, loc);
     }
 }
Exemple #6
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"></param>
        protected virtual void InsertUniqueEdge(Edge e)
        {
            int foundIndex = _edgeList.FindEdgeIndex(e);
            // If an identical edge already exists, simply update its label
            if (foundIndex >= 0)
            {
                Edge existingEdge = _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);
            }
            else
            {
                // no matching existing edge was found
                // add this new edge to the list of edges in this graph
                _edgeList.Add(e);
            }
        }
Exemple #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="lbl"></param>
 /// <param name="side"></param>
 /// <returns></returns>
 public virtual bool IsEqualOnSide(Label lbl, int side)
 {
     return _elt[0].IsEqualOnSide(lbl._elt[0], side)
         && _elt[1].IsEqualOnSide(lbl._elt[1], side);
 }
Exemple #8
0
 /// <summary>
 /// Converts a Label to a Line label (that is, one with no side Locations).
 /// </summary>
 /// <param name="label">Label to convert.</param>
 /// <returns>Label as Line label.</returns>
 public static Label ToLineLabel(Label label)
 {
     Label lineLabel = new Label(LocationType.Null);
     for (int i = 0; i < 2; i++)
         lineLabel.SetLocation(i, label.GetLocation(i));
     return lineLabel;
 }
        /// <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 virtual void CreateEdgeEndForPrev(Edge edge, IList 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);
        }
 /// <summary>
 /// Compute the label in the appropriate orientation for this DirEdge.
 /// </summary>
 private void ComputeDirectedLabel()
 {
     Label = new Label(Edge.Label);
     if (!_isForward)
         Label.Flip();
 }
Exemple #11
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 virtual void MergeLabel(Label deLabel, int geomIndex)
 {
     LocationType loc = deLabel.GetLocation(geomIndex, PositionType.Right);
     // no information to be had from this label
     if (loc == LocationType.Null)
         return;
     // if there is no current RHS value, set it
     if (_label.GetLocation(geomIndex) == LocationType.Null)
     {
         _label.SetLocation(geomIndex, loc);
         return;
     }
 }
Exemple #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="deLabel"></param>
 protected virtual void MergeLabel(Label deLabel)
 {
     MergeLabel(deLabel, 0);
     MergeLabel(deLabel, 1);
 }
        /// <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>
        /// <param name="e"></param>
        protected void InsertEdge(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);
            }
        }
 /// <summary>
 /// Compute the change in depth as an edge is crossed from R to L.
 /// </summary>
 /// <param name="label"></param>
 private static int DepthDelta(Label label)
 {
     LocationType lLoc = label.GetLocation(0, PositionType.Left);
     LocationType rLoc = label.GetLocation(0, PositionType.Right);
     if (lLoc == LocationType.Interior && rLoc == LocationType.Exterior)
         return 1;
     if (lLoc == LocationType.Exterior && rLoc == LocationType.Interior)
         return -1;
     return 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>
        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;
            for (IEnumerator it = GetEnumerator(); it.MoveNext(); )
            {
                EdgeEnd e = (EdgeEnd)it.Current;
                if (e.Label.IsArea())
                    isArea = true;
            }
            if (isArea)
            {
                Label = new Label(LocationType.Null, LocationType.Null, LocationType.Null);
            }
            else
            {
                Label = new Label(LocationType.Null);
            }

            // compute the On label, and the side labels if present
            for (int i = 0; i < 2; i++)
            {
                ComputeLabelOn(i);
                if (isArea)
                    ComputeLabelSides(i);
            }
        }
 /// <summary>
 /// Update incomplete dirEdge labels from the labelling for the node.
 /// </summary>
 /// <param name="nodeLabel"></param>
 public virtual void UpdateLabelling(Label nodeLabel)
 {
     for (IEnumerator it = GetEnumerator(); it.MoveNext(); )
     {
         DirectedEdge de = (DirectedEdge)it.Current;
         Label label = de.Label;
         label.SetAllLocationsIfNull(0, nodeLabel.GetLocation(0));
         label.SetAllLocationsIfNull(1, nodeLabel.GetLocation(1));
     }
 }
Exemple #17
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]);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="inLabel"></param>
 protected GraphComponent(Label inLabel)
 {
     _label = inLabel;
 }
Exemple #19
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 virtual 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]);
     }
 }
Exemple #20
0
 /// <summary>
 /// Updates an IM from the label for an edge.
 /// Handles edges from both L and A geometries.
 /// </summary>
 /// <param name="label"></param>
 /// <param name="im"></param>
 public static void UpdateIm(Label label, IntersectionMatrix im)
 {
     im.SetAtLeastIfValid(label.GetLocation(0, PositionType.On), label.GetLocation(1, PositionType.On), DimensionType.Curve);
     if (!label.IsArea()) return;
     im.SetAtLeastIfValid(label.GetLocation(0, PositionType.Left), label.GetLocation(1, PositionType.Left), DimensionType.Surface);
     im.SetAtLeastIfValid(label.GetLocation(0, PositionType.Right), label.GetLocation(1, PositionType.Right), DimensionType.Surface);
 }
Exemple #21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="edge"></param>
 /// <param name="p0"></param>
 /// <param name="p1"></param>
 /// <param name="inLabel"></param>
 public EdgeEnd(Edge edge, Coordinate p0, Coordinate p1, Label inLabel)
     : this(edge)
 {
     DoInit(p0, p1);
     _label = inLabel;
 }
Exemple #22
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="label"></param>
 /// <param name="opCode"></param>
 /// <returns></returns>
 public static bool IsResultOfOp(Label label, SpatialFunction opCode)
 {
     LocationType loc0 = label.GetLocation(0);
     LocationType loc1 = label.GetLocation(1);
     return IsResultOfOp(loc0, loc1, opCode);
 }