Ejemplo n.º 1
0
        private static bool IsTargetRingNullPoint(
            [NotNull] SegmentIntersection thisLinearIntersection,
            [CanBeNull] SegmentIntersection previousLinearIntersection,
            ISegmentList targetSegments)
        {
            if (previousLinearIntersection == null)
            {
                return(false);
            }

            if (thisLinearIntersection.TargetStartIntersects &&
                targetSegments.IsFirstSegmentInPart(thisLinearIntersection.TargetIndex) &&
                targetSegments.IsLastSegmentInPart(previousLinearIntersection.TargetIndex) &&
                targetSegments.IsClosed)
            {
                return(true);
            }

            // The linear intersections can be inverted, i.e. travelling backwards along target:
            if (thisLinearIntersection.TargetStartIntersects &&             // TargetEndIntersects??
                targetSegments.IsLastSegmentInPart(thisLinearIntersection.TargetIndex) &&
                targetSegments.IsFirstSegmentInPart(previousLinearIntersection.TargetIndex) &&
                targetSegments.IsClosed)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        private static void CollectIntersection(
            [NotNull] SegmentIntersection intersection,
            [NotNull] ISegmentList source,
            [NotNull] IDictionary <int, HashSet <double> > allLinearIntersectionFactors,
            [NotNull] ICollection <SegmentIntersection> intersectionsForCurrentSourceSegment)
        {
            // Collect segments for current index in list, unless they are clearly not needed
            // (and would need to be filtered by a later linear intersection if added)

            bool isLinear = intersection.HasLinearIntersection;

            if (isLinear)
            {
                int partIndex;
                int localSegmentIndex =
                    source.GetLocalSegmentIndex(intersection.SourceIndex, out partIndex);

                double linearIntersectionStartFactor =
                    localSegmentIndex +
                    intersection.GetLinearIntersectionStartFactor(true);

                double linearIntersectionEndFactor =
                    localSegmentIndex +
                    intersection.GetLinearIntersectionEndFactor(true);

                if (intersection.IsSourceZeroLength2D &&
                    ContainsIntersection(allLinearIntersectionFactors,
                                         partIndex, linearIntersectionEndFactor))
                {
                    // avoid double linear segments if the source segment is vertical
                    return;
                }

                AddIntersectionFactor(linearIntersectionStartFactor, partIndex,
                                      allLinearIntersectionFactors, source);

                AddIntersectionFactor(linearIntersectionEndFactor, partIndex,
                                      allLinearIntersectionFactors, source);
            }

            if (!isLinear && intersection.SourceStartIntersects &&
                source.IsFirstSegmentInPart(intersection.SourceIndex) && source.IsClosed)
            {
                // will be reported again at the end
                return;
            }

            if (!isLinear && intersection.SourceEndIntersects &&
                !source.IsLastSegmentInPart(intersection.SourceIndex))
            {
                // will be reported again at next segment
                return;
            }

            intersectionsForCurrentSourceSegment.Add(intersection);
        }