Esempio n. 1
0
        static void Main(string[] args)
        {
            Point3D A = new Point3D(3, 4, 5);

            Console.WriteLine(A);
            Console.WriteLine(Point3D.StartingPoint);
            Console.WriteLine("Distance = " + Math.Round(DistanceCalc.CalcDistancs(A, Point3D.StartingPoint), 4));
            Console.WriteLine(new String('-', 40));

            Point3D        C      = new Point3D(-3, 14, -5);
            Point3D        D      = new Point3D(-3.1, 4.4, 115);
            List <Point3D> points = new List <Point3D>()
            {
                A,
                Point3D.StartingPoint,
                C
            };

            Path3D path = new Path3D(points);

            Console.WriteLine(path);
            Console.WriteLine(new String('-', 40));
            path.AddPoint(D);
            Console.WriteLine(path);

            Storage.Save(path);
            Path3D loadedPath = Storage.Load("path.txt");

            Console.WriteLine(new String('-', 40));
            Console.WriteLine("PATH FROM LOADED FILE: ");
            Console.WriteLine(loadedPath);
        }
Esempio n. 2
0
        public static void Save(Path3D path)
        {
            string fileName = "path.txt";

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileName))
            {
                foreach (var point in path.Path)
                {
                    file.Write(String.Format("({0},{1},{2});", point.X, point.Y, point.Z));
                }
            }
        }
Esempio n. 3
0
        public static Path3D Load(String fileName)
        {
            Path3D path  = new Path3D();
            string text  = System.IO.File.ReadAllText(fileName);
            Regex  rgx   = new Regex(@"\((.+?),(.+?),(.+?)\)");
            Match  match = rgx.Match(text);

            while (match.Success)
            {
                Point3D cPoint = new Point3D(Double.Parse(match.Groups[1].Value), Double.Parse(match.Groups[2].Value), Double.Parse(match.Groups[3].Value));
                match = match.NextMatch();
                path.AddPoint(cPoint);
            }

            return(path);
        }