/// <summary> /// this function might change the shape's loose polylines by inserting new points /// </summary> void FillVisibilityGraphUnderShape(Shape shape) { //going depth first var children = shape.Children; foreach (Shape child in children) FillVisibilityGraphUnderShape(child); TightLooseCouple tightLooseCouple; Polyline looseBoundary = shapesToTightLooseCouples.TryGetValue(shape, out tightLooseCouple) ? tightLooseCouple.LooseShape.BoundaryCurve as Polyline : null; Shape looseShape = tightLooseCouple != null ? tightLooseCouple.LooseShape : looseRoot; var obstacles = new Set<Polyline>(looseShape.Children.Select(c => c.BoundaryCurve as Polyline)); var portLocations = RemoveInsidePortsAndSplitBoundaryIfNeeded(looseBoundary); //this run will split the polyline enough to route later from the inner ports var tmpVisGraph = new VisibilityGraph(); var coneSpanner = new ConeSpanner(new Polyline[] {}, tmpVisGraph, coneAngle, portLocations, looseBoundary); coneSpanner.Run(); //now run the spanner again to create the correct visibility graph around the inner obstacles tmpVisGraph = new VisibilityGraph(); coneSpanner = new ConeSpanner(obstacles, tmpVisGraph, coneAngle, portLocations, looseBoundary) { Bidirectional = Bidirectional && obstacles.Count>0 }; coneSpanner.Run(); ProgressStep(); foreach (VisibilityEdge edge in tmpVisGraph.Edges) TryToCreateNewEdgeAndSetIsPassable(edge, looseShape); AddBoundaryEdgesToVisGraph(looseBoundary); // if (obstacles.Count > 0) // SplineRouter.ShowVisGraph(tmpVisGraph, obstacles, null, null); }
internal void CalculateWholeVisibilityGraphOnExistingGraph() { activePolygons = new List<Polygon>(AllPolygons()); foreach (Polyline polylineLocal in ObstacleCalculator.LooseObstacles) VisibilityGraph.AddHole(polylineLocal); AlgorithmBase visibilityGraphGenerator; if (UseSpanner) { visibilityGraphGenerator = new ConeSpanner(ObstacleCalculator.LooseObstacles, VisibilityGraph) {ConeAngle = ConeSpannerAngle}; } else { visibilityGraphGenerator = new InteractiveTangentVisibilityGraphCalculator(new List<Polygon>(), activePolygons, visibilityGraph); } visibilityGraphGenerator.Run(); }