[MATH-749] Change the way the line segments are computed as they can not be serialized. Use the array only as cache and create them as needed.