示例#1
0
            protected override bool VerifyContinue(SegmentProxy seg0, SegmentProxy seg1,
                                                   SegmentNeighbors processed1,
                                                   SegmentParts partsOfSeg0, bool coincident)
            {
                TryAssignComplete(seg1, processed1, partsOfSeg0);

                SegmentParts coincidentPartsOfSeg0;
                var          key = new SegmentPart(seg0, 0, 1, true);

                if (!_coincidentParts.TryGetValue(key, out coincidentPartsOfSeg0))
                {
                    coincidentPartsOfSeg0 = new SegmentParts();
                    _coincidentParts.Add(key, coincidentPartsOfSeg0);
                }

                if (coincident)
                {
                    partsOfSeg0.IsComplete = true;
                    coincidentPartsOfSeg0.Add(key);
                    return(false);
                }
                //return true;

                IBox seg0Box = seg0.Extent;

                seg0Box = new Box(Pnt.Create(seg0Box.Min), Pnt.Create(seg0Box.Max));
                if (_coincidenceTolerance > 0)
                {
                    seg0Box.Min.X -= _coincidenceTolerance;
                    seg0Box.Min.Y -= _coincidenceTolerance;
                    seg0Box.Max.X += _coincidenceTolerance;
                    seg0Box.Max.Y += _coincidenceTolerance;
                }

                if (!seg0Box.Intersects(seg1.Extent))
                {
                    return(true);
                }

                var              cap = new RoundCap();
                NearSegment      hullStart;
                NearSegment      hullEnd;
                bool             isCoincident;
                IList <double[]> limits =
                    FindNeighborhood(
                        new SegmentHull(seg0, 0, cap, cap),
                        new SegmentHull(seg1, _coincidenceTolerance, cap, cap),
                        _is3D, 0,
                        out hullStart, out hullEnd, out isCoincident);
                IList <SegmentPart> addParts = GetSegmentParts(seg0, seg1, limits, isCoincident);

                coincidentPartsOfSeg0.AddRange(addParts);

                bool isComplete = SegmentPart.VerifyComplete(coincidentPartsOfSeg0);

                partsOfSeg0.IsComplete = isComplete;

                return(!isComplete);
            }
            protected override bool VerifyContinue(SegmentProxy seg0, SegmentProxy seg1,
                                                   SegmentNeighbors processed1,
                                                   SegmentParts partsOfSeg0, bool coincident)
            {
                bool isComplete = SegmentPart.VerifyComplete(partsOfSeg0);

                TryAssignComplete(seg1, processed1, partsOfSeg0);
                return(!isComplete);
            }
示例#3
0
            private void DropCoincidentParts(
                [NotNull] NeighboredSegmentsSubpart featurePart,
                [NotNull] Dictionary <SegmentPartWithNeighbor, List <SegmentPartWithNeighbor> >
                coincidents,
                [NotNull] HashSet <FeaturePoint> dropParts,
                [NotNull] List <NeighboredSegmentsSubpart> nonCoincidentParts)
            {
                foreach (List <SegmentPartWithNeighbor> coincidentParts in coincidents.Values)
                {
                    foreach (SegmentPartWithNeighbor coincidentPart in coincidentParts)
                    {
                        dropParts.Add(coincidentPart.CreateNeighborFeaturePoint());
                    }
                }

                // TODO? : transfer SegmentParts of coincident neighbor (due to differing offsets)

                var dropNeighbors =
                    new Dictionary <SegmentPartWithNeighbor, SegmentPartWithNeighbor>();

                foreach (List <SegmentPartWithNeighbor> coincidentParts in
                         coincidents.Values)
                {
                    foreach (
                        SegmentPartWithNeighbor coincidentPart in
                        coincidentParts)
                    {
                        dropNeighbors.Add(coincidentPart, coincidentPart);
                    }
                }

                foreach (
                    SegmentParts segmentParts in
                    featurePart.SegmentNeighbors.Values)
                {
                    List <SegmentPart> remaining = new SegmentParts();
                    foreach (SegmentPart segmentPart in segmentParts)
                    {
                        var part = (SegmentPartWithNeighbor)segmentPart;
                        if (!dropNeighbors.ContainsKey(part))
                        {
                            remaining.Add(part);
                        }
                    }

                    segmentParts.Clear();
                    segmentParts.AddRange(remaining);
                }

                nonCoincidentParts.Add(featurePart);
            }
示例#4
0
            private static void DropParts(
                [NotNull] Dictionary <FeaturePoint, List <NeighboredSegmentsSubpart> > splittedParts,
                [NotNull] HashSet <FeaturePoint> dropParts)
            {
                // TODO? : transfer SegmentParts of coincident neighbor (due to differing offsets), (Add needed Info to dropParts values)

                foreach (List <NeighboredSegmentsSubpart> featureParts in splittedParts.Values)
                {
                    foreach (NeighboredSegmentsSubpart featurePart in featureParts)
                    {
                        foreach (KeyValuePair <SegmentPart, SegmentParts> pair
                                 in featurePart.SegmentNeighbors)
                        {
                            SegmentPart  segmentKey      = pair.Key;
                            SegmentParts neighboredParts = pair.Value;
                            if (dropParts.Contains(featurePart.CreateFeaturePoint(segmentKey)))
                            {
                                neighboredParts.Clear();
                                continue;
                            }

                            var remaining = new List <SegmentPart>(neighboredParts.Count);

                            foreach (SegmentPart segmentPart in neighboredParts)
                            {
                                var part = (SegmentPartWithNeighbor)segmentPart;
                                if (!dropParts.Contains(part.CreateNeighborFeaturePoint()))
                                {
                                    remaining.Add(part);
                                }
                            }

                            if (remaining.Count < neighboredParts.Count)
                            {
                                neighboredParts.Clear();
                                neighboredParts.AddRange(remaining);
                            }
                        }
                    }
                }
            }
示例#5
0
 protected override bool VerifyContinue(SegmentProxy seg0, SegmentProxy seg1,
                                        SegmentNeighbors processed1,
                                        SegmentParts partsOfSeg0, bool coincident)
 {
     return(true);
 }
示例#6
0
 public SegmentInfo([NotNull] SegmentParts segmentParts)
 {
     SegmentParts = segmentParts;
 }
            public IEnumerable <ConnectedLinesEx> CleanupNotReportedPairs(
                ConnectedLinesEx errorCandidate)
            {
                if (_notReportedCondition == null)
                {
                    yield return(errorCandidate);

                    yield break;
                }

                AllNotReportedPairConditions notReportedCondition = _notReportedCondition;

                ConnectedLines      subConnected       = null;
                SegmentNeighbors    subNeighbors       = null;
                SegmentPairRelation subRelevantSegment = null;
                int minRelationIndex = SegmentRelationsToCheck.Count;

                foreach (
                    ConnectedSegmentsSubpart allParts in errorCandidate.Line.BaseSegments)
                {
                    IEnumerable <SegmentPartWithNeighbor> neighbors;
                    double limit;
                    Func <SegmentPartWithNeighbor, double, bool>   checkLimit;
                    Func <SegmentPartWithNeighbor, double, double> getLimit;
                    Func <double, bool> checkEndLimit;
                    if (allParts.FullStartFraction > allParts.FullEndFraction)
                    {
                        var sorted =
                            new List <SegmentPartWithNeighbor>(GetNeighbors(allParts));
                        sorted.Sort((x, y) => - x.FullMax.CompareTo(y.FullMax));
                        neighbors = sorted;

                        limit         = allParts.FullMaxFraction;
                        checkLimit    = (x, l) => x.FullMax < l;
                        getLimit      = (x, l) => Math.Min(l, x.FullMin);
                        checkEndLimit = l => l > allParts.FullMinFraction;
                    }
                    else
                    {
                        neighbors     = GetNeighbors(allParts);
                        limit         = allParts.FullMinFraction;
                        checkLimit    = (x, l) => x.FullMin > l;
                        getLimit      = (x, l) => Math.Max(l, x.FullMax);
                        checkEndLimit = l => l < allParts.FullMaxFraction;
                    }

                    ConnectedSegmentsSubpart subSubparts = null;
                    foreach (SegmentPartWithNeighbor segmentPart in neighbors)
                    {
                        if (notReportedCondition.IsFulfilled(
                                allParts.BaseFeature, allParts.TableIndex,
                                segmentPart.NeighborFeature,
                                segmentPart.NeighborTableIndex))
                        {
                            continue;
                        }

                        if (checkLimit(segmentPart, limit) && subConnected != null)
                        {
                            subConnected.RelevantSegment =
                                errorCandidate.Line.RelevantSegment;
                            yield return(GetClean(subConnected, errorCandidate));

                            subConnected = null;
                        }

                        if (subConnected == null)
                        {
                            subConnected =
                                new ConnectedLines(new List <ConnectedSegmentsSubpart>());
                            subRelevantSegment = null;
                            subSubparts        = null;
                        }

                        if (subRelevantSegment == null ||
                            segmentPart.MinRelationIndex <
                            subRelevantSegment.Segment.MinRelationIndex)
                        {
                            subRelevantSegment = new SegmentPairRelation(
                                segmentPart,
                                SegmentRelationsToCheck[segmentPart.MinRelationIndex]);
                        }

                        if (subSubparts == null)
                        {
                            subNeighbors = new SegmentNeighbors(new SegmentPartComparer());

                            var subCurve = new SubClosedCurve(allParts.ConnectedCurve.BaseGeometry,
                                                              allParts.ConnectedCurve.PartIndex,
                                                              segmentPart.FullMin,
                                                              segmentPart.FullMax);

                            subSubparts = new ConnectedSegmentsSubpart(
                                allParts, subNeighbors, subCurve);

                            subConnected.BaseSegments.Add(subSubparts);
                        }

                        SegmentParts parts;
                        var          key = new SegmentPart(
                            Assert.NotNull(segmentPart.SegmentProxy), 0, 1, true);
                        if (!subNeighbors.TryGetValue(key, out parts))
                        {
                            parts = new SegmentParts();
                            subNeighbors.Add(key, parts);
                        }

                        parts.Add(segmentPart);

                        int relationIndex = segmentPart.MinRelationIndex;
                        if (relationIndex < minRelationIndex)
                        {
                            minRelationIndex = relationIndex;
                        }

                        limit = getLimit(segmentPart, limit);
                    }

                    if (checkEndLimit(limit) && subConnected != null)
                    {
                        subConnected.RelevantSegment = errorCandidate.Line.RelevantSegment;
                        yield return(GetClean(subConnected, errorCandidate));

                        subConnected = null;
                    }
                }

                if (subConnected != null)
                {
                    subConnected.RelevantSegment = errorCandidate.Line.RelevantSegment;
                    yield return(GetClean(subConnected, errorCandidate));
                }
            }