Exemple #1
0
        static void Main(string[] args)
        {
            Point3D p1 = new Point3D(45, -5, 23);
            Point3D p2 = new Point3D(-25, 78, 115);
            Point3D p3 = new Point3D(2, 56, -8);

            List <Point3D> points1 = new List <Point3D> {
                p1, p2, p3
            };
            List <Point3D> points2 = new List <Point3D> {
                p2, p3
            };
            List <Point3D> points3 = new List <Point3D> {
                p1, p3
            };

            Path3D path1 = new Path3D(points1);
            Path3D path2 = new Path3D(points2);
            Path3D path3 = new Path3D(points3);

            Storage.SavePath("../../path3D.txt", path1, path2, path3);
            Path3D newPath = Storage.LoadPath("../../path3D");

            Storage.SavePath("../../path3D.txt", newPath);

            Console.WriteLine(newPath);
        }
Exemple #2
0
        public static Path3D LoadPath(string fileName)
        {
            List <Point3D> points = new List <Point3D>();
            Path3D         path;

            try
            {
                StreamReader sr = new StreamReader(fileName);
                using (sr)
                {
                    String line = sr.ReadLine();
                    while (line != null)
                    {
                        double[] coordinates = PointExtractor(line);
                        Point3D  p           = new Point3D(coordinates[0], coordinates[1], coordinates[2]);
                        points.Add(p);
                        line = sr.ReadLine();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }

            path = new Path3D(points);
            return(path);
        }