private bool CreateConvexHulls() { var found = false; var graph = new BasicGraph <IntPair>(this.overlapPairs); var connectedComponents = ConnectedComponentCalculator <IntPair> .GetComponents(graph); foreach (var component in connectedComponents) { // GetComponents returns at least one self-entry for each index - including the < FirstNonSentinelOrdinal ones. if (component.Count() == 1) { continue; } found = true; var obstacles = component.Select(this.OrdinalToObstacle); var points = obstacles.SelectMany(obs => obs.VisibilityPolyline); var och = new OverlapConvexHull(ConvexHull.CreateConvexHullAsClosedPolyline(points), obstacles); foreach (var obstacle in obstacles) { obstacle.SetConvexHull(och); } } return(found); }
} // Note there is no !IsGroup check internal void SetConvexHull(OverlapConvexHull hull) { // This obstacle may have been in a rectangular obstacle or clump that was now found to overlap with a non-rectangular obstacle. this.Clump = null; this.IsRectangle = false; this.ConvexHull = hull; this.looseVisibilityPolyline = null; }
private bool CreateConvexHulls() { var found = false; var graph = new BasicGraph<IntPair>(this.overlapPairs); var connectedComponents = ConnectedComponentCalculator<IntPair>.GetComponents(graph); foreach (var component in connectedComponents) { // GetComponents returns at least one self-entry for each index - including the < FirstNonSentinelOrdinal ones. if (component.Count() == 1) { continue; } found = true; var obstacles = component.Select(this.OrdinalToObstacle); var points = obstacles.SelectMany(obs => obs.VisibilityPolyline); var och = new OverlapConvexHull(ConvexHull.CreateConvexHullAsClosedPolyline(points), obstacles); foreach (var obstacle in obstacles) { obstacle.SetConvexHull(och); } } return found; }
internal bool IsInConvexHull { get { return this.ConvexHull != null; } } // Note there is no !IsGroup check internal void SetConvexHull(OverlapConvexHull hull) { // This obstacle may have been in a rectangular obstacle or clump that was now found to overlap with a non-rectangular obstacle. this.Clump = null; this.IsRectangle = false; this.ConvexHull = hull; this.looseVisibilityPolyline = null; }