static void Main() { Path testPath = new Path(); //creates a Path class instance testPath = PathStorage.LoadPath(@"..\..\InputPath.txt"); //test method loading a path of points from specified file Console.WriteLine(testPath.ToString()); //test method Path.ToString() testPath.Add(Point3D.PointZero); //test constant PointZero (0,0,0) Console.WriteLine(testPath.ToString()); testPath.RemoveAt(0); //test remove the first point from the path Console.WriteLine(testPath.ToString()); PathStorage.SavePath(testPath, @"..\..\OutputPath.txt"); //test save the path to file Console.WriteLine("The distance between {0} and {1} is: {2}", new Point3D(3.2, 3.5, 3.0), Point3D.PointZero, Distance3D.CalcDistance3D(new Point3D(3.2, 3.5, 3.0), Point3D.PointZero)); //tests the calculation of the distance between two 3D points }
public static Path LoadPath(string fileName) { Path currPath = new Path(); using (StreamReader reader = new StreamReader(fileName)) { for (string input = reader.ReadLine(); input != "end"; input = reader.ReadLine()) { string[] coord = input.Split(','); Point3D currPoint = new Point3D(double.Parse(coord[0]), double.Parse(coord[1]), double.Parse(coord[2])); currPath.Add(currPoint); } } return currPath; }