Пример #1
0
        private static void AddPointsBetweenForward(
            List <Point2> results,
            Ring2 ring,
            PolygonBoundaryLocation from,
            PolygonBoundaryLocation to
            )
        {
            Contract.Requires(results != null);
            Contract.Requires(ring != null);
            Contract.Requires(from != null);
            Contract.Requires(to != null);
            Contract.Ensures(results.Count >= Contract.OldValue(results).Count);

            if (from.SegmentIndex == to.SegmentIndex && from.SegmentRatio <= to.SegmentRatio)
            {
                return; // no points will result from this
            }
            var segmentCount        = ring.SegmentCount;
            var currentSegmentIndex = IterationUtils.AdvanceLoopingIndex(from.SegmentIndex, segmentCount);

            do
            {
                if (to.SegmentIndex == currentSegmentIndex)
                {
                    if (to.SegmentRatio > 0)
                    {
                        results.Add(ring[currentSegmentIndex]);
                    }
                    return;
                }
                results.Add(ring[currentSegmentIndex]);
                currentSegmentIndex = IterationUtils.AdvanceLoopingIndex(currentSegmentIndex, segmentCount);
            } while (true);
        }
Пример #2
0
 /// <summary>
 /// Creates a new polygon crossing defined by a point on the respective location on each polygon boundary.
 /// </summary>
 /// <param name="p">The calculated point of intersection.</param>
 /// <param name="locationA">The location on the first polygon boundary.</param>
 /// <param name="locationB">The location on the second polygon boundary.</param>
 public PolygonCrossing(Point2 p, PolygonBoundaryLocation locationA, PolygonBoundaryLocation locationB)
 {
     if (null == locationA)
     {
         throw new ArgumentNullException("locationA");
     }
     if (null == locationB)
     {
         throw new ArgumentNullException("locationB");
     }
     Contract.EndContractBlock();
     Point     = p;
     LocationA = locationA;
     LocationB = locationB;
 }