Пример #1
0
        /// <summary>
        /// Updates the label of a node to BOUNDARY,
        /// obeying the mod-2 boundaryDetermination rule.
        /// </summary>
        /// <param name="argIndex"></param>
        public void SetLabelBoundary(int argIndex)
        {
            if (Label == null)
            {
                return;
            }

            // determine the current location for the point (if any)
            Location loc = Location.Null;

            if (Label != null)
            {
                loc = Label.GetLocation(argIndex);
            }
            // flip the loc
            Location newLoc;

            switch (loc)
            {
            case Location.Boundary:
                newLoc = Location.Interior;
                break;

            case Location.Interior:
                newLoc = Location.Boundary;
                break;

            default:
                newLoc = Location.Boundary;
                break;
            }
            Label.SetLocation(argIndex, newLoc);
        }
Пример #2
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);
        }
Пример #3
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);
     }
 }
Пример #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++)
     {
         Location loc     = ComputeMergedLocation(label2, i);
         Location thisLoc = Label.GetLocation(i);
         if (thisLoc == Location.Null)
         {
             Label.SetLocation(i, loc);
         }
     }
 }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="argIndex"></param>
        /// <param name="coord"></param>
        /// <param name="onLocation"></param>
        private void InsertPoint(int argIndex, Coordinate coord, Location onLocation)
        {
            Node  n   = NodeMap.AddNode(coord);
            Label lbl = n.Label;

            if (lbl == null)
            {
                n.Label = new Label(argIndex, onLocation);
            }
            else
            {
                lbl.SetLocation(argIndex, onLocation);
            }
        }
Пример #6
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;
            }
        }
Пример #7
0
        /// <summary>
        /// Adds candidate boundary points using the current <see cref="IBoundaryNodeRule"/>.
        /// This is used to add the boundary
        /// points of dim-1 geometries (Curves/MultiCurves).
        /// </summary>
        /// <param name="argIndex"></param>
        /// <param name="coord"></param>
        private void InsertBoundaryPoint(int argIndex, Coordinate coord)
        {
            var n = NodeMap.AddNode(coord);
            // nodes always have labels
            Label lbl = n.Label;
            // the new point to insert is on a boundary
            int boundaryCount = 1;
            // determine the current location for the point (if any)
            //Location loc = Location.Null;
            var loc = lbl.GetLocation(argIndex, Positions.On);

            if (loc == Location.Boundary)
            {
                boundaryCount++;
            }

            // determine the boundary status of the point according to the Boundary Determination Rule
            Location newLoc = DetermineBoundary(_boundaryNodeRule, boundaryCount);

            lbl.SetLocation(argIndex, newLoc);
        }
Пример #8
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);
                    }
                }
            }
        }
Пример #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="geomIndex"></param>
        public void PropagateSideLabels(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
            Location startLoc = Location.Null;

            // initialize loc to location of last Curve side (if any)
            foreach (EdgeEnd e in Edges)
            {
                Label label = e.Label;
                if (label.IsArea(geomIndex) && label.GetLocation(geomIndex, Positions.Left) != Location.Null)
                {
                    startLoc = label.GetLocation(geomIndex, Positions.Left);
                }
            }
            // no labelled sides found, so no labels to propagate
            if (startLoc == Location.Null)
            {
                return;
            }

            Location currLoc = startLoc;

            foreach (EdgeEnd e in Edges)
            {
                Label label = e.Label;
                // set null On values to be in current location
                if (label.GetLocation(geomIndex, Positions.On) == Location.Null)
                {
                    label.SetLocation(geomIndex, Positions.On, currLoc);
                }
                // set side labels (if any)
                if (label.IsArea(geomIndex))
                {
                    Location leftLoc  = label.GetLocation(geomIndex, Positions.Left);
                    Location rightLoc = label.GetLocation(geomIndex, Positions.Right);
                    // if there is a right location, that is the next location to propagate
                    if (rightLoc != Location.Null)
                    {
                        if (rightLoc != currLoc)
                        {
                            throw new TopologyException("side location conflict", e.Coordinate);
                        }
                        if (leftLoc == Location.Null)
                        {
                            Assert.ShouldNeverReachHere("found single null side (at " + e.Coordinate + ")");
                        }
                        currLoc = leftLoc;
                    }
                    else
                    {
                        /* RHS is null - LHS must be null too.
                         *  This must be an edge from the other point, which has no location
                         *  labelling for this point.  This edge must lie wholly inside or outside
                         *  the other point (which is determined by the current location).
                         *  Assign both sides to be the current location.
                         */
                        Assert.IsTrue(label.GetLocation(geomIndex, Positions.Left) == Location.Null, "found single null side");
                        label.SetLocation(geomIndex, Positions.Right, currLoc);
                        label.SetLocation(geomIndex, Positions.Left, currLoc);
                    }
                }
            }
        }