static void Main() { Point3D p1 = new Point3D(1, 2, 3); Point3D p2 = new Point3D(2, 3, 4); Point3D p3 = new Point3D(3, 4, 5); Paths3D myPath = new Paths3D(); myPath.AddPoint(p1); myPath.AddPoint(p2); myPath.AddPoint(p3); }
public static Paths3D LoadPathFromFile(string fileName) { Paths3D path = new Paths3D(); using (StreamReader reader = new StreamReader(fileName)) { string input = input = reader.ReadToEnd(); string pattern = "{([\\d,.]+), ([\\d,.]+), ([\\d,.]+)}"; Regex regex = new Regex(pattern); var matchs = regex.Matches(input); foreach (Match match in matchs) { double x = double.Parse(match.Groups[1].Value); double y = double.Parse(match.Groups[2].Value); double z = double.Parse(match.Groups[3].Value); Point3D point = new Point3D(x, y, z); path.AddPoint(point); } return(path); } }