Ejemplo n.º 1
0
        static void Main()
        {
            ThreeDPoint firstPoint = new ThreeDPoint(1.3, 3.0, 2.7);
            ThreeDPoint secondPoint = new ThreeDPoint(3.2, 2.5, 1.0);

            Console.WriteLine("First point coordinates: {0}", firstPoint);
            Console.WriteLine("Second point coordinates: {0}", secondPoint);

            Console.WriteLine("Distance between first and second point: {0:F2}", CalculateDistance.CalcDistance(firstPoint, secondPoint));

            Path listOfPaths = new Path();
            listOfPaths.AddPoint(firstPoint);
            listOfPaths.AddPoint(secondPoint);

            PathStorage.SavePathToFile(@"../../PathStorageTest.txt",listOfPaths);
            PathStorage.LoadPathFromFile(@"../../PathStorageTest.txt");

            Console.WriteLine("List of paths stored in text file:");
            foreach (ThreeDPoint point in listOfPaths.Points)
            {
                Console.WriteLine(point);
            }
        }
Ejemplo n.º 2
0
        public static Path LoadPath(string fullFileName)
        {
            Path points = new Path();

            using (StreamReader fileReader = new StreamReader(fullFileName))
            {
                string line;
                while ((line = fileReader.ReadLine()) != null)
                {
                    string[] coordinates = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    int x, y, z;

                    x = int.Parse(coordinates[0]);
                    y = int.Parse(coordinates[1]);
                    z = int.Parse(coordinates[2]);

                    Point3D point = new Point3D(x, y, z);
                    points.AddPoint(point);
                }
                return points;
            }
        }