void CreateTightObstacles() { var tightObstacles = new Set <Polyline>(MainShape.Children.Select(InitialTightPolyline)); int initialNumberOfTightObstacles = tightObstacles.Count; tightHierarchy = InteractiveObstacleCalculator.RemovePossibleOverlapsInTightPolylinesAndCalculateHierarchy(tightObstacles); OverlapsDetected = initialNumberOfTightObstacles > tightObstacles.Count; }
void CreateTigthLooseCouples() { var couples = new List <TightLooseCouple>(); foreach (var tightPolyline in tightHierarchy.GetAllLeaves()) { var distance = InteractiveObstacleCalculator.FindMaxPaddingForTightPolyline(tightHierarchy, tightPolyline, LoosePadding); var loosePoly = InteractiveObstacleCalculator.LoosePolylineWithFewCorners(tightPolyline, distance); couples.Add(new TightLooseCouple(tightPolyline, new Shape(loosePoly), distance)); } coupleHierarchy = RectangleNode <TightLooseCouple> . CreateRectangleNodeOnEnumeration(couples.Select(c => new RectangleNode <TightLooseCouple>(c, c.TightPolyline.BoundingBox))); }
Polyline InitialTightPolyline(Shape shape) { var poly = InteractiveObstacleCalculator.PaddedPolylineBoundaryOfNode(shape.BoundaryCurve, TightPadding); var stickingPointsArray = LoosePolylinesUnderShape(shape).SelectMany(l => l).Where( p => Curve.PointRelativeToCurveLocation(p, poly) == PointLocation.Outside).ToArray(); if (stickingPointsArray.Length <= 0) { return(poly); } return(new Polyline( ConvexHull.CalculateConvexHull(poly.Concat(stickingPointsArray))) { Closed = true }); }