예제 #1
0
            private void RecalcFlatEnds(
                [NotNull] Dictionary <FeaturePoint, SegmentInfo> flatEnds,
                [NotNull] Dictionary <FeaturePoint, List <NeighboredSegmentsSubpart> > splittedParts)
            {
                foreach (KeyValuePair <FeaturePoint, SegmentInfo> pair in flatEnds)
                {
                    SegmentInfo segmentInfo = pair.Value;
                    foreach (SegmentPart segmentPart in segmentInfo.SegmentParts)
                    {
                        var segWithNb = (SegmentPartWithNeighbor)segmentPart;

                        bool        neighborIsFlatEnd;
                        SegmentPair hulls = RecalcFlatEnd(pair.Key, segWithNb, flatEnds,
                                                          out neighborIsFlatEnd);

                        if (!neighborIsFlatEnd)
                        {
                            SegmentPartWithNeighbor nbSegmentPart = FindNeighbor(
                                splittedParts, pair.Key,
                                segWithNb);
                            if (nbSegmentPart != null)
                            {
                                RecalcNeighbor(nbSegmentPart, segWithNb, hulls);
                            }
                        }
                    }
                }
            }
예제 #2
0
            private static void FindCoincident(
                [NotNull] Dictionary <SegmentPartWithNeighbor, List <SegmentPartWithNeighbor> >
                coincidents,
                [NotNull] SegmentPartWithNeighbor segmentNeighbor, int segmentIndex,
                [NotNull] Dictionary <SegmentPartWithNeighbor, List <SegmentPartWithNeighbor> >
                remaining)
            {
                foreach (KeyValuePair <SegmentPartWithNeighbor,
                                       List <SegmentPartWithNeighbor> > pair in coincidents)
                {
                    SegmentPartWithNeighbor startCoincident = pair.Key;

                    if (startCoincident.NeighborTableIndex == segmentNeighbor.NeighborTableIndex &&
                        startCoincident.NeighborFeature.OID ==
                        segmentNeighbor.NeighborFeature.OID &&
                        startCoincident.NeighborProxy.PartIndex ==
                        segmentNeighbor.NeighborProxy.PartIndex &&
                        Math.Abs(startCoincident.NeighborProxy.SegmentIndex -
                                 segmentNeighbor.NeighborProxy.SegmentIndex) == segmentIndex)
                    {
                        pair.Value.Add(segmentNeighbor);
                        // TODO "key already exists" when testing across multiple tiles
                        remaining.Add(startCoincident, pair.Value);
                        break;
                    }
                }
            }
예제 #3
0
            private SegmentPartWithNeighbor FindNeighbor(
                [NotNull] Dictionary <FeaturePoint, List <NeighboredSegmentsSubpart> > splittedParts,
                [NotNull] FeaturePoint segmentFeature,
                [NotNull] SegmentPartWithNeighbor segWithNb)
            {
                var neighborKey = new FeaturePoint(segWithNb.NeighborFeature,
                                                   segWithNb.NeighborTableIndex,
                                                   segWithNb.PartIndex, 0);

                List <NeighboredSegmentsSubpart> subparts;

                if (!splittedParts.TryGetValue(neighborKey, out subparts))
                {
                    return(null);
                }

                foreach (NeighboredSegmentsSubpart subpart in subparts)
                {
                    if (subpart.FullMinFraction > segWithNb.NeighborProxy.SegmentIndex ||
                        subpart.FullMaxFraction < segWithNb.NeighborProxy.SegmentIndex)
                    {
                        continue;
                    }

                    foreach (SegmentParts segmentParts in subpart.SegmentNeighbors.Values)
                    {
                        foreach (SegmentPart segmentPart in segmentParts)
                        {
                            if (segmentPart.SegmentIndex != segWithNb.NeighborProxy.SegmentIndex)
                            {
                                continue;
                            }

                            var partWithNeighbor = (SegmentPartWithNeighbor)segmentPart;
                            if (partWithNeighbor.NeighborFeature == segmentFeature.Feature &&
                                partWithNeighbor.NeighborTableIndex == segmentFeature.TableIndex &&
                                partWithNeighbor.NeighborProxy.PartIndex == segWithNb.PartIndex &&
                                partWithNeighbor.NeighborProxy.SegmentIndex ==
                                segWithNb.SegmentIndex)
                            {
                                return(partWithNeighbor);
                            }
                        }
                    }
                }

                return(null);
            }
예제 #4
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);
            }
예제 #5
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);
            }
예제 #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);
            }