Beispiel #1
0
        public static void Main()
        {
            // set and print test Point3D
            Point3D testPoint = new Point3D(1, 2, 3);

            System.Console.WriteLine(testPoint);

            // set test Path
            Path testPath = new Path();

            testPath.AddPionts(new Point3D(1, 1, 1), new Point3D(2, 2, 2), new Point3D(3, 3, 3), new Point3D(4, 4, 4));

            // print test Path
            Console.WriteLine();
            Console.WriteLine(testPath);

            // saves the test Path to "..\..\testPath.txt"
            PathStorage.SavePath(testPath, "testPath");

            // load currently saved test Path from "..\..\testPath.txt"
            Path loadedPath = PathStorage.LoadPath("testPath");

            // print loaded Path
            Console.WriteLine();
            Console.WriteLine(loadedPath);
        }
Beispiel #2
0
        public static Path LoadPath(string nameOfPath)
        {
            Path   path         = new Path();
            string pathLocation = string.Format(@"..\..\{0}.txt", nameOfPath.Trim());

            using (StreamReader reader = new StreamReader(pathLocation))
            {
                string[] points = reader
                                  .ReadToEnd()
                                  .Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);

                foreach (var point in points)
                {
                    double[] c = point
                                 .Split(new char[] { '(', ')', ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)
                                 .Select(double.Parse)
                                 .ToArray();

                    path.AddPionts(new Point3D(c[0], c[1], c[2]));
                }
            }

            return(path);
        }