internal double RadiusCost(Station node, Point newPosition) { double idealR; if (ApproximateComparer.Close(node.Position, newPosition)) { idealR = node.cachedIdealRadius; } else { idealR = HubRadiiCalculator.CalculateIdealHubRadiusWithNeighbors(metroGraphData, bundlingSettings, node, newPosition); } List <Tuple <Polyline, Point> > touchedObstacles; if (!metroGraphData.looseIntersections.HubAvoidsObstacles(node, newPosition, idealR, out touchedObstacles)) { return(Inf); } double cost = 0; foreach (var d in touchedObstacles) { double dist = (d.Item2 - newPosition).Length; cost += RError(idealR, dist, bundlingSettings); } return(cost); }
internal void UpdateCostCache(Station node) { RectangleNode <CdtTriangle> cdtTree = cdt.GetCdtTree(); node.CdtTriangle = cdtTree.FirstHitNode(node.Position, Test).UserData; node.cachedIdealRadius = HubRadiiCalculator.CalculateIdealHubRadiusWithNeighbors(metroGraphData, bundlingSettings, node); node.cachedRadiusCost = costCalculator.RadiusCost(node, node.Position); node.cachedBundleCost = 0; foreach (var adj in node.Neighbors) { if (!adj.IsRealNode) { adj.cachedIdealRadius = HubRadiiCalculator.CalculateIdealHubRadiusWithNeighbors(metroGraphData, bundlingSettings, adj); adj.cachedRadiusCost = costCalculator.RadiusCost(adj, adj.Position); } StationEdgeInfo edgeInfo = metroGraphData.GetIjInfo(node, adj); adj.cachedBundleCost -= edgeInfo.cachedBundleCost; edgeInfo.cachedBundleCost = costCalculator.BundleCost(node, adj, node.Position); node.cachedBundleCost += edgeInfo.cachedBundleCost; adj.cachedBundleCost += edgeInfo.cachedBundleCost; } }
double GetCurrentHubRadius(Station node) { if (node.IsRealNode) { return(node.BoundaryCurve.BoundingBox.Diagonal / 2); } else { double idealR = node.cachedIdealRadius = HubRadiiCalculator.CalculateIdealHubRadiusWithNeighbors(this.metroGraphData, this.bundlingSettings, node); double r = metroGraphData.looseIntersections.GetMinimalDistanceToObstacles(node, node.Position, idealR); Debug.Assert(r <= idealR); foreach (var adj in node.Neighbors) { r = Math.Min(r, (node.Position - adj.Position).Length); } return(r); } }
internal void InitializeCostCache() { foreach (var v in metroGraphData.VirtualNodes()) { v.cachedIdealRadius = HubRadiiCalculator.CalculateIdealHubRadiusWithNeighbors(metroGraphData, bundlingSettings, v); v.cachedRadiusCost = costCalculator.RadiusCost(v, v.Position); v.cachedBundleCost = 0; } foreach (var edge in metroGraphData.VirtualEdges()) { var v = edge.Item1; var u = edge.Item2; StationEdgeInfo edgeInfo = metroGraphData.GetIjInfo(v, u); edgeInfo.cachedBundleCost = costCalculator.BundleCost(v, u, v.Position); v.cachedBundleCost += edgeInfo.cachedBundleCost; u.cachedBundleCost += edgeInfo.cachedBundleCost; } }
IEnumerable <DebugCurve> IdealHubsWithNeighbors() { return(mgd.VirtualNodes().Select(station => new DebugCurve(200, 1, "black", CurveFactory.CreateCircle(HubRadiiCalculator.CalculateIdealHubRadiusWithNeighbors(mgd, bundlingSettings, station), station.Position)))); }