示例#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);
            }
示例#2
0
            private void FindDropParts(NeighboredSegmentsSubpart featurePart,
                                       HashSet <FeaturePoint> dropParts,
                                       List <NeighboredSegmentsSubpart> nonCoincidentParts,
                                       out int errorCount)
            {
                Dictionary <SegmentPartWithNeighbor, List <SegmentPartWithNeighbor> >
                coincidents = null;
                SegmentNeighbors segmentsNeighbors = featurePart.SegmentNeighbors;

                var first = true;

                NearDistanceProvider.GetRowsDistance(featurePart.BaseFeature,
                                                     featurePart.TableIndex);

                for (int i = featurePart.FullMinFraction; i < featurePart.FullMaxFraction; i++)
                {
                    if (!first && coincidents == null)
                    {
                        break;
                    }

                    var          key = new SegmentPart(featurePart.PartIndex, i, 0, 1, true);
                    SegmentParts segmentNeighbors;
                    if (!segmentsNeighbors.TryGetValue(key, out segmentNeighbors))
                    {
                        coincidents = null;
                        break;
                    }

                    var remaining =
                        new Dictionary <SegmentPartWithNeighbor, List <SegmentPartWithNeighbor> >();

                    foreach (SegmentPart segmentPart in segmentNeighbors)
                    {
                        var segmentNeighbor = (SegmentPartWithNeighbor)segmentPart;
                        if (segmentNeighbor.NeighborIsCoincident)
                        {
                            if (first)
                            {
                                remaining.Add(
                                    segmentNeighbor,
                                    new List <SegmentPartWithNeighbor> {
                                    segmentNeighbor
                                });
                            }
                            else
                            {
                                int segmentIndex = i - featurePart.FullMinFraction;
                                FindCoincident(coincidents, segmentNeighbor, segmentIndex,
                                               remaining);
                            }
                        }
                    }

                    coincidents = remaining;
                    if (coincidents.Count == 0)
                    {
                        coincidents = null;
                    }

                    first = false;
                }

                if (coincidents == null)
                {
                    nonCoincidentParts.Add(featurePart);
                    errorCount = 0;
                    return;
                }

                // Check if is lowest part
                bool keepPart = CheckKeepPart(featurePart, coincidents, out errorCount);

                if (keepPart)
                {
                    DropCoincidentParts(featurePart, coincidents, dropParts, nonCoincidentParts);
                }
            }