// // Determine which of the inner Shape points apply to the given connection; add them as collinear points. // private static void AcquireCollinearAndSegments(List <Segment> segments, List <Point> points, out List <Segment> trueSegments, out List <Collinear> collinear) { trueSegments = new List <Segment>(); collinear = new List <Collinear>(); // Maximal segments (containing no subsegments). List <Segment> maximal = new List <Segment>(); // // Prune subsegments away // for (int s1 = 0; s1 < segments.Count; s1++) { bool max = true; for (int s2 = 0; s2 < segments.Count; s2++) { if (s1 != s2) { if (segments[s1].HasSubSegment(segments[s2])) { max = false; break; } } } if (max) { maximal.Add(segments[s1]); } } // // Place all points on appropriate segments for collinearity. // foreach (Segment max in maximal) { max.ClearCollinear(); foreach (Point pt in points) { if (max.PointLiesOn(pt)) { max.AddCollinearPoint(pt); } } // // Convert to collinear or straight-up segments. // if (max.collinear.Count > 2) { collinear.Add(new Collinear(max.collinear)); } else { trueSegments.Add(max); } } }