Exemplo n.º 1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="de"></param>
 public void ComputeDepths(DirectedEdge de)
 {
     int edgeIndex = FindIndex(de);
     int startDepth = de.GetDepth(Positions.Left);
     int targetLastDepth = de.GetDepth(Positions.Right);
     // compute the depths from this edge up to the end of the edge array
     int nextDepth = ComputeDepths(edgeIndex + 1, edgeList.Count, startDepth);
     // compute the depths for the initial part of the array
     int lastDepth = ComputeDepths(0, edgeIndex, nextDepth);
     if (lastDepth != targetLastDepth)
         throw new TopologyException("depth mismatch at " + de.Coordinate);
 }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="de"></param>
        public void ComputeDepths(DirectedEdge de)
        {
            int edgeIndex       = FindIndex(de);
            int startDepth      = de.GetDepth(Positions.Left);
            int targetLastDepth = de.GetDepth(Positions.Right);
            // compute the depths from this edge up to the end of the edge array
            int nextDepth = ComputeDepths(edgeIndex + 1, edgeList.Count, startDepth);
            // compute the depths for the initial part of the array
            int lastDepth = ComputeDepths(0, edgeIndex, nextDepth);

            if (lastDepth != targetLastDepth)
            {
                throw new TopologyException("depth mismatch at " + de.Coordinate);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Compute the DirectedEdge depths for a subsequence of the edge array.
        /// </summary>
        /// <returns>The last depth assigned (from the R side of the last edge visited).</returns>
        private int ComputeDepths(int startIndex, int endIndex, int startDepth)
        {
            int currDepth = startDepth;

            for (int i = startIndex; i < endIndex; i++)
            {
                DirectedEdge nextDe = (DirectedEdge)edgeList[i];
                nextDe.SetEdgeDepths(Positions.Right, currDepth);
                currDepth = nextDe.GetDepth(Positions.Left);
            }
            return(currDepth);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Finds all non-horizontal segments intersecting the stabbing line
        /// in the input dirEdge.
        /// The stabbing line is the ray to the right of stabbingRayLeftPt.
        /// </summary>
        /// <param name="stabbingRayLeftPt">The left-hand origin of the stabbing line.</param>
        /// <param name="dirEdge"></param>
        /// <param name="stabbedSegments">The current list of DepthSegments intersecting the stabbing line.</param>
        private void FindStabbedSegments(ICoordinate stabbingRayLeftPt, DirectedEdge dirEdge, IList stabbedSegments)
        {
            ICoordinate[] pts = dirEdge.Edge.Coordinates;
            for (int i = 0; i < pts.Length - 1; i++)
            {
                seg.P0 = pts[i];
                seg.P1 = pts[i + 1];
                // ensure segment always points upwards
                if (seg.P0.Y > seg.P1.Y)
                    seg.Reverse();

                // skip segment if it is left of the stabbing line
                double maxx = Math.Max(seg.P0.X, seg.P1.X);
                if (maxx < stabbingRayLeftPt.X) continue;

                // skip horizontal segments (there will be a non-horizontal one carrying the same depth info
                if (seg.IsHorizontal) continue;

                // skip if segment is above or below stabbing line
                if (stabbingRayLeftPt.Y < seg.P0.Y || stabbingRayLeftPt.Y > seg.P1.Y) continue;

                // skip if stabbing ray is right of the segment
                if (CGAlgorithms.ComputeOrientation(seg.P0, seg.P1, stabbingRayLeftPt) == CGAlgorithms.Right) continue;

                // stabbing line cuts this segment, so record it
                int depth = dirEdge.GetDepth(Positions.Left);
                // if segment direction was flipped, use RHS depth instead
                if (! seg.P0.Equals(pts[i]))
                    depth = dirEdge.GetDepth(Positions.Right);
                DepthSegment ds = new DepthSegment(seg, depth);
                stabbedSegments.Add(ds);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="de"></param>
 private void CopySymDepths(DirectedEdge de)
 {
     DirectedEdge sym = de.Sym;
     sym.SetDepth(Positions.Left, de.GetDepth(Positions.Right));
     sym.SetDepth(Positions.Right, de.GetDepth(Positions.Left));
 }