Пример #1
0
            public void AdaptAssymetry(
                Dictionary <FeaturePoint, List <NeighboredSegmentsSubpart> > splittedParts)
            {
                foreach (KeyValuePair <FeaturePoint, List <NeighboredSegmentsSubpart> > pair in
                         splittedParts)
                {
                    var              cap          = new RoundCap();
                    FeaturePoint     p            = pair.Key;
                    SideRowsDistance rowsDistance =
                        _nearProvider.GetRowsDistance(p.Feature, p.TableIndex);
                    List <NeighboredSegmentsSubpart> splitted = pair.Value;
                    foreach (NeighboredSegmentsSubpart part in splitted)
                    {
                        foreach (SegmentParts segmentParts in part.SegmentNeighbors.Values)
                        {
                            foreach (SegmentPart segmentPart in segmentParts)
                            {
                                SegmentHull hull = CreateSegmentHull(
                                    (SegmentProxy)Assert.NotNull(
                                        segmentPart.SegmentProxy, "segmentproxy is null"),
                                    rowsDistance, cap, cap);

                                var segNbPart = (SegmentPartWithNeighbor)segmentPart;
                                AdaptAssymetry(rowsDistance, hull, segNbPart, cap);
                            }
                        }
                    }
                }

                Drop0LengthParts(EnumSegmentParts(splittedParts.Values));
            }
Пример #2
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);
            }
Пример #3
0
            private void AdaptAssymetry([NotNull] SideRowsDistance rowsDistance,
                                        [NotNull] SegmentHull hull,
                                        [NotNull] SegmentPartWithNeighbor part,
                                        [NotNull] RoundCap cap)
            {
                SegmentHull nbHull = CreateNeighborSegmentHull(
                    (SegmentProxy)part.NeighborProxy, rowsDistance,
                    part.NeighborFeature,
                    part.NeighborTableIndex, cap, cap);

                if (hull.LeftOffset == nbHull.RightOffset &&
                    nbHull.LeftOffset == nbHull.RightOffset)
                {
                    return;
                }

                RecalcPart(part, hull, nbHull);
            }
Пример #4
0
        public void CanCutRoundRound()
        {
            var cap = new RoundCap();

            SegmentProxy segment0 = CreateSegment(0, 0, 0, 10);
            var          hull     = new SegmentHull(segment0, 1, cap, cap);

            SegmentProxy segment1 = CreateSegment(-5, 5, 5, 5);
            var          neighbor = new SegmentHull(segment1, 1, cap, cap);

            var pair = new SegmentPair2D(hull, neighbor);

            IList <double[]> limits;
            NearSegment      startNear;
            NearSegment      endNear;
            bool             coincident;
            bool             intersects = pair.CutCurveHull(0, out limits, out startNear, out endNear,
                                                            out coincident);

            Assert.IsTrue(intersects);
        }
Пример #5
0
            private SegmentPair RecalcFlatEnd(
                [NotNull] FeaturePoint end,
                [NotNull] SegmentPartWithNeighbor segWithNb,
                [NotNull] Dictionary <FeaturePoint, SegmentInfo> flatEnds,
                out bool neighborIsFlatEnd)
            {
                IFeatureRowsDistance rowsDistance =
                    NearDistanceProvider.GetRowsDistance(end.Feature, end.TableIndex);

                SegmentInfo segmentInfo;

                Find(end, segWithNb.SegmentIndex, flatEnds, out segmentInfo);

                SegmentCap startCap = segmentInfo.FlatStart
                                                              ? (SegmentCap) new RectCap(0)
                                                              : new RoundCap();

                SegmentCap endCap = segmentInfo.FlatEnd
                                                            ? (SegmentCap) new RectCap(0)
                                                            : new RoundCap();

                SegmentHull hull = CreateSegmentHull(
                    (SegmentProxy)Assert.NotNull(segWithNb.SegmentProxy, "segmentproxy is null"),
                    rowsDistance, startCap, endCap);

                var neighborKey = new FeaturePoint(segWithNb.NeighborFeature,
                                                   segWithNb.NeighborTableIndex,
                                                   segWithNb.PartIndex, 0);

                neighborIsFlatEnd = false;

                SegmentInfo neighborInfo;

                SegmentCap nbStartCap;
                SegmentCap nbEndCap;

                if (Find(neighborKey, segWithNb.NeighborProxy.SegmentIndex, flatEnds,
                         out neighborInfo))
                {
                    neighborIsFlatEnd = true;

                    nbStartCap = neighborInfo.FlatStart
                                                             ? (SegmentCap) new RectCap(0)
                                                             : new RoundCap();
                    nbEndCap = neighborInfo.FlatEnd
                                                           ? (SegmentCap) new RectCap(0)
                                                           : new RoundCap();
                }
                else
                {
                    nbStartCap = new RoundCap();
                    nbEndCap   = new RoundCap();
                }

                SegmentHull neighborhull = CreateNeighborSegmentHull(
                    (SegmentProxy)segWithNb.NeighborProxy, rowsDistance, segWithNb.NeighborFeature,
                    segWithNb.NeighborTableIndex, nbStartCap, nbEndCap);

                SegmentPair segPair = RecalcPart(segWithNb, hull, neighborhull);

                return(segPair);
            }