private static Point?EscapeProcessI(CoverSet coverSet, Point Z, ConnectorSegment escapeLine, Orientation orientation, Size margin) { List <DistanceFromPoint> extremitiesList = new List <DistanceFromPoint>(4); ConnectorSegment cover = coverSet.GetCover(Z, (orientation == Orientation.Horizontal) ? DesignerEdges.Left : DesignerEdges.Bottom); if (cover != null) { AddBoundPoint(ref extremitiesList, cover.A, cover, Z); AddBoundPoint(ref extremitiesList, cover.B, cover, Z); } ConnectorSegment segment = coverSet.GetCover(Z, (orientation == Orientation.Horizontal) ? DesignerEdges.Right : DesignerEdges.Top); if (segment != null) { AddBoundPoint(ref extremitiesList, segment.A, segment, Z); AddBoundPoint(ref extremitiesList, segment.B, segment, Z); } if (extremitiesList.Count != 0) { DistanceSorter.Sort(ref extremitiesList); for (int i = 0; i < extremitiesList.Count; i++) { DesignerEdges edges; Point point3; Point p = extremitiesList[i].P; int x = Math.Sign((int)(p.X - Z.X)); Point point2 = new Point(x, Math.Sign((int)(p.Y - Z.Y))); if (((orientation == Orientation.Vertical) ? point2.X : point2.Y) == 0) { p = extremitiesList[i].ConnectorSegment.ExtendPointOutwards(p); int introduced13 = Math.Sign((int)(p.X - Z.X)); point2 = new Point(introduced13, Math.Sign((int)(p.Y - Z.Y))); p = extremitiesList[i].P; } if (orientation == Orientation.Vertical) { edges = (point2.Y < 0) ? DesignerEdges.Bottom : DesignerEdges.Top; } else { edges = (point2.X < 0) ? DesignerEdges.Left : DesignerEdges.Right; } if (orientation == Orientation.Vertical) { point3 = new Point(p.X + (point2.X * margin.Width), Z.Y); } else { point3 = new Point(Z.X, p.Y + (point2.Y * margin.Height)); } ConnectorSegment segment4 = new ConnectorSegment(Z, point3); if (((!coverSet.EscapeLineHasBeenUsed(segment4, point3) && escapeLine.IsPointOnSegment(point3)) && ((escapeLine.A != point3) && (escapeLine.B != point3))) && coverSet.IsEscapePoint(Z, point3, edges)) { coverSet.AddUsedEscapeLine(segment4); return(new Point?(point3)); } } } return(null); }
private static void SecondRefinementAlgorithm(CoverSet coverSet, ref List <Point> refinedPath, Size margin) { int num; List <Point> list = new List <Point>(); for (num = 0; num < (refinedPath.Count - 1); num++) { Point a = refinedPath[num]; Point b = refinedPath[num + 1]; ConnectorSegment segment = ConnectorSegment.ConstructBoundSegment(coverSet, a, b); int num2 = num + 2; while (num2 < (refinedPath.Count - 1)) { Point point3 = refinedPath[num2]; Point point4 = refinedPath[num2 + 1]; ConnectorSegment segment2 = ConnectorSegment.ConstructBoundSegment(coverSet, point3, point4); Point? nullable = segment.Intersect(segment2); if (nullable.HasValue) { list.Clear(); for (int i = 0; i <= num; i++) { list.Add(refinedPath[i]); } list.Add(nullable.Value); for (int j = num2 + 1; j < refinedPath.Count; j++) { list.Add(refinedPath[j]); } List <Point> list2 = refinedPath; refinedPath = list; list = list2; list.Clear(); num2 = num + 2; } else { num2++; } } } num = 0; while (num < (refinedPath.Count - 1)) { Point point5 = refinedPath[num]; Point point6 = refinedPath[num + 1]; bool flag = false; ConnectorSegment segment3 = ConnectorSegment.ConstructBoundSegment(coverSet, point5, point6); if (segment3 != null) { Point point7 = new Point(point6.X - point5.X, point6.Y - point5.Y); int introduced30 = Math.Abs((int)(point7.X / margin.Width)); int num5 = Math.Max(introduced30, Math.Abs((int)(point7.Y / margin.Height))); point7.X = Math.Sign(point7.X); point7.Y = Math.Sign(point7.Y); for (int k = 1; k <= num5; k++) { Point point8 = new Point(point5.X + ((k * margin.Width) * point7.X), point5.Y + ((k * margin.Height) * point7.Y)); if (point8 == point6) { break; } ConnectorSegment segment4 = ConnectorSegment.ConstructBoundSegment(coverSet, point8, (segment3.Orientation == Orientation.Horizontal) ? Orientation.Vertical : Orientation.Horizontal); for (int m = num + 2; (m < (refinedPath.Count - 1)) && !flag; m++) { Point point9 = refinedPath[m]; Point point10 = refinedPath[m + 1]; ConnectorSegment segment5 = new ConnectorSegment(point9, point10); Point? nullable2 = segment4.Intersect(segment5); if (nullable2.HasValue && segment5.IsPointOnSegment(nullable2.Value)) { flag = true; list.Clear(); for (int n = 0; n <= num; n++) { list.Add(refinedPath[n]); } list.Add(point8); list.Add(nullable2.Value); for (int num9 = m + 1; num9 < refinedPath.Count; num9++) { list.Add(refinedPath[num9]); } List <Point> list3 = refinedPath; refinedPath = list; list3.Clear(); break; } } if (flag) { break; } } } if (!flag) { num++; } } }