Example #1
0
        private static List <LineSegment2D> SubdivideAll(IEnumerable <LineSegment2D> segments, LineSegment2D divider)
        {
            var subdivisions = new List <LineSegment2D>();

            foreach (var segment in segments)
            {
                if (divider.CheckForIntersectionOfExtension(segment, out var intersection) && intersection != null &&
                    intersection != segment.StartPoint && intersection != segment.EndPoint)
                {
                    subdivisions.Add(new LineSegment2D(segment.StartPoint, intersection.Value));
                    subdivisions.Add(new LineSegment2D(intersection.Value, segment.EndPoint));
                }
                else
                {
                    subdivisions.Add(segment);
                }
            }

            return(subdivisions);
        }