Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting point:");
            Console.WriteLine(Point3D.StartPoint.ToString());
            Console.WriteLine();

            Point3D a = new Point3D("A", 1, 2, 1.5);
            Point3D b = new Point3D("B", -1, 2, 1.5);
            Point3D c = new Point3D("C", 1, -2, 1.5);
            Point3D d = new Point3D("D", 1, 2, -1.5);

            Path3D path = new Path3D(a, b, c, d);
            Console.WriteLine("The points of the path:");
            Console.WriteLine(path.ToString());
            Console.WriteLine();

            Console.WriteLine("The distance between point A and point C:");
            Console.WriteLine(DistanceCalculator.CalculateDistance3D(a,c));
            Console.WriteLine();

            Storage.MakePath("../../user_files/Paths.txt", false, path);
            Storage.MakePath("../../user_files.Paths.txt", true, path);

            var loaded = Storage.LoadPath(@"../../user_files/Paths.txt");
            loaded.ForEach(p => Console.WriteLine(p.ToString()));
        }
Ejemplo n.º 2
0
 public static List<Path3D> LoadPath(string fileName)
 {
     try
     {
         var paths = new List<Path3D>();
         using (var reader = new StreamReader(fileName, Encoding.GetEncoding("UTF-8")))
         {
             string line = reader.ReadLine();
             while (line != null)
             {
                 Path3D points = new Path3D();
                 var lines = line.Split(new[] {", "}, StringSplitOptions.RemoveEmptyEntries);
                 foreach (var item in lines)
                 {
                     points.Add(Point3D.Regular(item));
                 }
                 line = reader.ReadLine();
                 paths.Add(points);
             }
         }
         return paths;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         throw ex.InnerException;
     }
 }