Exemplo n.º 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));
            }
Exemplo n.º 2
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);
            }
Exemplo n.º 3
0
            private void RecalcNeighbor([NotNull] SegmentPartWithNeighbor neighbor,
                                        [NotNull] SegmentPartWithNeighbor part,
                                        [NotNull] SegmentPair hulls)
            {
                IFeatureRowsDistance rowsDistance =
                    NearDistanceProvider.GetRowsDistance(part.NeighborFeature,
                                                         part.NeighborTableIndex);

                SegmentHull neighborhull = CreateSegmentHull(
                    (SegmentProxy)part.NeighborProxy, rowsDistance,
                    hulls.Neighbor.StartCap, hulls.Neighbor.EndCap);

                SegmentHull hull = CreateNeighborSegmentHull(
                    (SegmentProxy)Assert.NotNull(part.SegmentProxy, "segmentproxy is null"),
                    rowsDistance, neighbor.NeighborFeature,          // == part.Feature
                    neighbor.NeighborTableIndex,                     // == part.TableIndex
                    hulls.Hull.StartCap, hulls.Hull.EndCap);

                RecalcPart(neighbor, neighborhull, hull);
            }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
        public void CutCurveHullTest()
        {
            //seg0 = CreateSegment(GeometryFactory.CreatePoint(0, 0, 0), GeometryFactory.CreatePoint(100, 200, 10));
            //seg1 = CreateSegment(GeometryFactory.CreatePoint(0, 0, 0), GeometryFactory.CreatePoint(100, 200, 10));
            //SegmentUtils.CutCurveHull(seg0, seg1, 0, 0, true,
            //    out limits, out hullStartNear, out hullEndNear, out coincident);

            const double r  = 0.0001;
            const double x0 = 600000;
            const double y0 = 200000;

            SegmentProxy seg0 = CreateSegment(
                GeometryFactory.CreatePoint(x0 + 100, y0 + 200, 10),
                GeometryFactory.CreatePoint(x0, y0, 500));
            SegmentProxy seg1 = CreateSegment(
                GeometryFactory.CreatePoint(x0, y0, 500 + 2 * r),
                GeometryFactory.CreatePoint(x0 - 200 - r, y0, 20));

            IList <double[]> limits;
            NearSegment      hullStartNear;
            NearSegment      hullEndNear;
            bool             coincident;

            SegmentHull hull0  = seg0.CreateHull(0);
            SegmentHull hull1  = seg1.CreateHull(0);
            var         pair2D = new SegmentPair2D(hull0, hull1);

            pair2D.CutCurveHull(0,
                                out limits, out hullStartNear, out hullEndNear, out coincident);
            Assert.AreEqual(1, limits.Count);

            var pair3D = new SegmentPair3D(hull0, hull1);

            pair3D.CutCurveHull(0,
                                out limits, out hullStartNear, out hullEndNear, out coincident);
            Assert.AreEqual(0, limits.Count);
        }
Exemplo n.º 6
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);
            }