Exemplo n.º 1
0
 //In my text files there are more than just one path, because I decided that different paths could be added in txt files with the same names.
 public static void LoadPath(string pathName)
 {
     try
     {
         var reader = new StreamReader(String.Format("{0}.txt", pathName));
         using (reader)
         {
             string buffer = reader.ReadLine();
             do
             {
                 double[] coordinates = buffer
                     .Split(',')
                     .Select(double.Parse)
                     .ToArray();
                 Path currentPath = new Path();
                 for (int i = 0; i < coordinates.Length; i += 3)
                 {
                     Point3D currentPoint = new Point3D(coordinates[i], coordinates[i + 1], coordinates[i + 2]);
                     currentPath.Sequence.Add(currentPoint);
                 }
                 pathes.Add(currentPath);
                 buffer = reader.ReadLine();
             }
             while (buffer != null);
         }
     }
     catch (FileNotFoundException)
     {
         Console.WriteLine("The file could not be found!");
     }
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var pointOne = new Point3D(0, 2, 3);
            var pointTwo = new Point3D(3, 2, 3);

            //Console.WriteLine(pointOne);
            //Console.WriteLine(Calculations.FindDistance(pointOne,pointTwo));

            Path randomPath = new Path();
            randomPath.Sequence.Add(pointOne);
            randomPath.Sequence.Add(pointTwo);
            PathStorage.SavePath(randomPath,"randomPath");
            PathStorage.SavePath(randomPath, "randomPath");
            Console.WriteLine(String.Join("\nThe Points in the current path are:\n", PathStorage.Pathes));

            PathStorage.LoadPath("rasndomPath");
            Console.Write("The Points in the current path are:\n");
            Console.WriteLine(String.Join("\nThe Points in the current path are:\n", PathStorage.Pathes));
        }
Exemplo n.º 3
0
 static Point3D()
 {
     pointO=new Point3D(0,0,0);
 }