private void RecurseRestrictRayWithObstacles(RectangleNode <Obstacle, Point> rectNode)
        {
            // A lineSeg that moves along the boundary of an obstacle is not blocked by it.
            if (!StaticGraphUtility.RectangleInteriorsIntersect(currentRestrictedRay.BoundingBox, (Rectangle)rectNode.Rectangle))
            {
                return;
            }

            Obstacle obstacle = rectNode.UserData;

            if (null != obstacle)
            {
                // Leaf node. Get the interior intersections.  Use the full-length original segment for the intersection calculation.
                IList <IntersectionInfo> intersections = Curve.GetAllIntersections(restrictedIntersectionTestSegment, obstacle.VisibilityPolyline, true /*liftIntersections*/);

                if (!obstacle.IsGroup || stopAtGroups)
                {
                    LookForCloserNonGroupIntersectionToRestrictRay(intersections);
                    return;
                }

                if (wantGroupCrossings)
                {
                    AddGroupIntersectionsToRestrictedRay(obstacle, intersections);
                }

                Debug.Assert(rectNode.IsLeaf, "RectNode with UserData is not a Leaf");
                return;
            }

            // Not a leaf; recurse into children.
            RecurseRestrictRayWithObstacles(rectNode.Left);
            RecurseRestrictRayWithObstacles(rectNode.Right);
        }
Пример #2
0
        private bool InteriorEdgeCrossesObstacle(Rectangle rect, Func <Obstacle, Polyline> whichPolylineToUse, IEnumerable <Obstacle> candidates)
        {
            LineSegment lineSeg = null;

            foreach (var blocker in candidates)
            {
                var blockerPolyline = whichPolylineToUse(blocker);
                if (!StaticGraphUtility.RectangleInteriorsIntersect(rect, blockerPolyline.BoundingBox))
                {
                    continue;
                }

                lineSeg = lineSeg ?? new LineSegment(this.UnpaddedBorderIntersect, this.VisibilityBorderIntersect);
                var xx = Curve.CurveCurveIntersectionOne(lineSeg, blockerPolyline, liftIntersection: false);
                if (xx != null)
                {
                    return(true);
                }

                if (PointLocation.Outside != Curve.PointRelativeToCurveLocation(this.UnpaddedBorderIntersect, blockerPolyline))
                {
                    return(true);
                }
            }
            return(false);
        }