Пример #1
0
        // ctor

        internal void Update(Point start, Point end)
        {
            Debug.Assert(PointComparer.Equal(start, end) ||
                         StaticGraphUtility.IsAscending(PointComparer.GetPureDirection(start, end))
                         , "non-ascending segment");
            startPoint = start;
            endPoint   = end;
        }
Пример #2
0
        private void SpliceGroupBoundaryCrossings(PointAndCrossingsList crossingList, VisibilityVertex startVertex, LineSegment maxSegment)
        {
            if ((null == crossingList) || (0 == crossingList.Count))
            {
                return;
            }

            crossingList.Reset();
            var start = maxSegment.Start;
            var end   = maxSegment.End;
            var dir   = PointComparer.GetPureDirection(start, end);

            // Make sure we are going in the ascending direction.
            if (!StaticGraphUtility.IsAscending(dir))
            {
                start = maxSegment.End;
                end   = maxSegment.Start;
                dir   = CompassVector.OppositeDir(dir);
            }

            // We need to back up to handle group crossings that are between a VisibilityBorderIntersect on a sloped border and the
            // incoming startVertex (which is on the first ScanSegment in Perpendicular(dir) that is outside that padded border).
            startVertex = TraverseToFirstVertexAtOrAbove(startVertex, start, CompassVector.OppositeDir(dir));

            // Splice into the Vertices between and including the start/end points.
            for (var currentVertex = startVertex; null != currentVertex; currentVertex = StaticGraphUtility.FindNextVertex(currentVertex, dir))
            {
                bool isFinalVertex = (PointComparer.Compare(currentVertex.Point, end) >= 0);
                while (crossingList.CurrentIsBeforeOrAt(currentVertex.Point))
                {
                    PointAndCrossings pac = crossingList.Pop();

                    // If it's past the start and at or before the end, splice in the crossings in the descending direction.
                    if (PointComparer.Compare(pac.Location, startVertex.Point) > 0)
                    {
                        if (PointComparer.Compare(pac.Location, end) <= 0)
                        {
                            SpliceGroupBoundaryCrossing(currentVertex, pac, CompassVector.OppositeDir(dir));
                        }
                    }

                    // If it's at or past the start and before the end, splice in the crossings in the descending direction.
                    if (PointComparer.Compare(pac.Location, startVertex.Point) >= 0)
                    {
                        if (PointComparer.Compare(pac.Location, end) < 0)
                        {
                            SpliceGroupBoundaryCrossing(currentVertex, pac, dir);
                        }
                    }
                }

                if (isFinalVertex)
                {
                    break;
                }
            }
        }
 // Use the internal static xxxInstance properties to get an instance.
 private ScanDirection(Directions directionAlongScanLine)
 {
     System.Diagnostics.Debug.Assert(StaticGraphUtility.IsAscending(directionAlongScanLine),
                                     "directionAlongScanLine must be ascending");
     Direction            = directionAlongScanLine;
     DirectionAsPoint     = CompassVector.ToPoint(Direction);
     PerpDirection        = (Directions.North == directionAlongScanLine) ? Directions.East : Directions.North;
     PerpDirectionAsPoint = CompassVector.ToPoint(PerpDirection);
     OppositeDirection    = CompassVector.OppositeDir(directionAlongScanLine);
 }
Пример #4
0
        internal bool HasGroupCrossingBeforePoint(Point point)
        {
            if (!this.HasGroupCrossings)
            {
                return(false);
            }
            var pac = StaticGraphUtility.IsAscending(this.OutwardDirection) ? this.pointAndCrossingsList.First : this.pointAndCrossingsList.Last;

            return(PointComparer.GetDirections(this.MaxVisibilitySegment.Start, pac.Location) == PointComparer.GetDirections(pac.Location, point));
        }
Пример #5
0
 internal void SetSides(Directions dir, RBNode <BasicObstacleSide> neighborNode, RBNode <BasicObstacleSide> overlapEndNode,
                        BasicObstacleSide interveningGroupSide)
 {
     if (StaticGraphUtility.IsAscending(dir))
     {
         HighNeighbor   = neighborNode;
         HighOverlapEnd = overlapEndNode;
         this.GroupSideInterveningBeforeHighNeighbor = interveningGroupSide;
         return;
     }
     LowNeighbor   = neighborNode;
     LowOverlapEnd = overlapEndNode;
     this.GroupSideInterveningBeforeLowNeighbor = interveningGroupSide;
 }
Пример #6
0
        internal RBNode <BasicObstacleSide> Next(Directions dir, RBNode <BasicObstacleSide> sideNode)
        {
            var succ = (StaticGraphUtility.IsAscending(dir)) ? SideTree.Next(sideNode) : SideTree.Previous(sideNode);

            return(succ);
        }