internal void CreatePortEntrance(Point unpaddedBorderIntersect, Directions outDir, ObstacleTree obstacleTree) { var entrance = new ObstaclePortEntrance(this, unpaddedBorderIntersect, outDir, obstacleTree); PortEntrances.Add(entrance); this.VisibilityRectangle.Add(entrance.MaxVisibilitySegment.End); #if SHARPKIT //https://code.google.com/p/sharpkit/issues/detail?id=370 this.HasCollinearEntrances = this.HasCollinearEntrances | entrance.IsCollinearWithPort; #else this.HasCollinearEntrances |= entrance.IsCollinearWithPort; #endif }
private void AddObstaclePortEntranceToGraph(ObstaclePortEntrance entrance) { // Note: As discussed in ObstaclePortEntrance.AddToGraph, oport.VisibilityBorderIntersect may be // on a border shared with another obstacle, in which case we'll extend into that obstacle. This // should be fine if we're consistent about "touching means overlapped", so that a path that comes // through the other obstacle on the shared border is OK. VisibilityVertex borderVertex = VisGraph.FindVertex(entrance.VisibilityBorderIntersect); if (null != borderVertex) { entrance.ExtendFromBorderVertex(TransUtil, borderVertex, this.portSpliceLimitRectangle, RouteToCenterOfObstacles); return; } // There may be no scansegment to splice to before we hit an adjacent obstacle, so if the edge // is null there is nothing to do. VisibilityVertex targetVertex; double weight = entrance.IsOverlapped ? ScanSegment.OverlappedWeight : ScanSegment.NormalWeight; VisibilityEdge edge = this.FindorCreateNearestPerpEdge(entrance.MaxVisibilitySegment.End, entrance.VisibilityBorderIntersect, entrance.OutwardDirection, weight /*checkForObstacle*/, out targetVertex); if (null != edge) { entrance.AddToAdjacentVertex(TransUtil, targetVertex, this.portSpliceLimitRectangle, RouteToCenterOfObstacles); } }
private static Point[] GetPathPointsFromIntersectingVisibility(ObstaclePortEntrance sourceEntrance, ObstaclePortEntrance targetEntrance) { Point intersect; if (!StaticGraphUtility.SegmentsIntersect(sourceEntrance.MaxVisibilitySegment, targetEntrance.MaxVisibilitySegment, out intersect)) { return null; } if (sourceEntrance.HasGroupCrossingBeforePoint(intersect) || targetEntrance.HasGroupCrossingBeforePoint(intersect)) { return null; } return new[] { sourceEntrance.UnpaddedBorderIntersect, intersect, targetEntrance.UnpaddedBorderIntersect }; }
private static Point[] GetPathPointsFromOverlappingCollinearVisibility(ObstaclePortEntrance sourceEntrance, ObstaclePortEntrance targetEntrance) { // If the segments are the same they'll be in reverse. Note: check for IntervalsOverlap also, if we support FreePoints here. if (!StaticGraphUtility.IntervalsAreSame(sourceEntrance.MaxVisibilitySegment.Start, sourceEntrance.MaxVisibilitySegment.End, targetEntrance.MaxVisibilitySegment.End, targetEntrance.MaxVisibilitySegment.Start)) { return null; } if (sourceEntrance.HasGroupCrossings || targetEntrance.HasGroupCrossings) { return null; } if (PointComparer.Equal(sourceEntrance.UnpaddedBorderIntersect, targetEntrance.UnpaddedBorderIntersect)) { // Probably one obstacle contained within another; we handle that elsewhere. return null; } return new[] { sourceEntrance.UnpaddedBorderIntersect, targetEntrance.UnpaddedBorderIntersect }; }