Ejemplo n.º 1
0
        static void Main()
        {
            Point3D[] PointArr =
            {
                new Point3D(1, 2, 3),
                new Point3D(4, 5, 6),
                new Point3D(7, 8, 9)
            };

            //Some weird thing happening here.
            Path3D SamplePath = new Path3D(PointArr);

            SamplePath.PointStorage = PointArr;

            Storage.SavePaths(SamplePath);

            string[] paths = Storage.LoadPaths().Split(';');

            foreach (string path in paths)
            {
                if (path != "")
                {
                    Console.WriteLine(String.Format("Point: {0}", path));
                }
            }
        }
Ejemplo n.º 2
0
        static void Main()
        {
            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("../../paths.txt", path1, path2, path3);
            Path3D newPath = Storage.LoadPath("../../pathToLoad.txt");

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

            Console.WriteLine(newPath);
        }
Ejemplo n.º 3
0
        public static Path3D LoadPaths()
        {
            List<Point3D> points = new List<Point3D>();

            Path3D path;

            try
            {
                StreamReader sr = new StreamReader("../../PathsFile.txt");
                using (sr)
                {
                    String line = sr.ReadLine();

                    while (line != null)
                    {
                        points.Add(Get3DPoints(line));
                        line = sr.ReadLine();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }

            path = new Path3D(points);
            return path;
        }
Ejemplo n.º 4
0
        static public void Save(Path3D path, string filePath)
        {
            string spoints = "";

            for (int i = 0; i < path.Points.Count; i++)
            {
                spoints += path.Points[i].X + "," + path.Points[i].Y + "," + path.Points[i].Z + "/";
            }
            spoints = spoints.Substring(0, spoints.Length - 1);
            string filePathPlusName = filePath + "filePath" + savedPathsCounter + ".txt";

            if (!File.Exists(filePathPlusName))
            {
                using (StreamWriter sw = File.CreateText(filePathPlusName))
                {
                    sw.WriteLine(spoints);
                    Storage.savedPathsCounter++;
                    sw.Close();
                }
            }
            else
            {
                StreamWriter sw = new StreamWriter(filePathPlusName);
                sw.WriteLine(spoints);
                Storage.savedPathsCounter++;
                sw.Close();
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            Point3D        p1   = new Point3D(1, 2, 3);
            Point3D        p2   = new Point3D(2, 2, 3);
            List <Point3D> list = new List <Point3D> {
                p1, p2
            };
            Path3D path = new Path3D(list);

            Storage.Save(path, @"C:\Users\Vak\Desktop\New folder\_02_hw\_03_Paths\");
            Path3D loadedPath = new Path3D(Storage.Load(@"C:\Users\Vak\Desktop\New folder\_02_hw\_03_Paths\filePath0.txt"));

            Console.WriteLine("Loaded points from the file: " + loadedPath.ToString());
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            Point3D p1 = new Point3D(1, 10, 5);
            Point3D p2 = new Point3D(5, 10, 20);
            Point3D p3 = new Point3D(20, 45, 80);

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

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

            Storage.SavePaths(path1, path2);

            Path3D newPath = Storage.LoadPaths();

            Console.WriteLine(newPath);
        }