Ejemplo n.º 1
0
        public static Path LoadPath()
        {
            Path loaded = new Path();
            try
            {
                StreamReader reader = new StreamReader("../../LoadPath.txt");

                using (reader)
                {
                    string line = reader.ReadLine();

                    if (line != null)
                    {
                        while (line != null)
                        {
                            int position = line.IndexOf(':');
                            string needed = line.Substring(position + 1);
                            double[] points = needed.Split(new [] {' '}, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray();
                            loaded.AddPoint(new Point3D(points[0], points[1], points[2]));

                            line = reader.ReadLine();
                        }
                    }
                }
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("LoadPath.txt is missing from program's directory.");
            }

            return loaded;  
        }
Ejemplo n.º 2
0
        static void Main()
        {
            //Console.WriteLine(Point3D.O);
            
            //Console.WriteLine(myPoint);
            //double distance = Distance.CalculateDistance(Point3D.O, myPoint);
            //Console.WriteLine(distance);

            var myPoint = new Point3D(3, 5, 7);
            
            Path points = new Path();
            points.AddPoint(new Point3D(2, 5, 7.56789));
            points.AddPoint(myPoint);
            points.AddPoint(Point3D.O);
            PathStorage.StorePath(points, "load.txt");
         
            
            
          
        }
Ejemplo n.º 3
0
        public static Path LoadPath(string filePath)
        {
            Path path = new Path();

            using (StreamReader sr = new StreamReader(filePath))
            {
                while (sr.EndOfStream == false)
                {
                    string  nextPointTxt = sr.ReadLine();
                    Point3D nextPoint    = Point3D.Parse(nextPointTxt);
                    path.AddPoint(nextPoint);
                }
            }
            return(path);
        }
Ejemplo n.º 4
0
        public static Path LoadPath(string filePath)
        {
            var path = new Path();

            using (var sr = new StreamReader(filePath))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    Point3D point = Point3D.Parse(line);
                    path.AddPoint(point);
                }
            }
            return(path);
        }
Ejemplo n.º 5
0
        public static Path LoadPath(string filePath)
        {
            Path path = new Path();

            using (StreamReader sr = new StreamReader(filePath))
            {
                while (sr.EndOfStream == false)
                {
                    string nextPointTxt = sr.ReadLine();
                    Point3D nextPoint = Point3D.Parse(nextPointTxt);
                    path.AddPoint(nextPoint);
                }
            }
            return path;
        }
Ejemplo n.º 6
0
        public static Path Load()
        {
            Path pathToLoad = new Path();

            string[] pointsRead;

            using (StreamReader reader = new StreamReader(@"..\..\Paths.txt"))
            {
                pointsRead = reader.ReadToEnd().Split();
            }

            foreach (string point in pointsRead)
            {
                double[] points = point.Split(',').Select(double.Parse).ToArray();

                pathToLoad.AddPoint(new Point3D(points[0], points[1], points[2]));
            }

            return(pathToLoad);
        }
Ejemplo n.º 7
0
 public static Path LoadPath(string filename)
 {
     StreamReader reader = new StreamReader(filename);
     Path result = new Path();
     using (reader)
     {
         string line = "default";
        
         while (line != null)
         {
            line = reader.ReadLine();
            var pointsAsString = line.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < pointsAsString.Length; i++)
            {
                var pointValues = pointsAsString[i].Split("|".ToCharArray()).Select(float.Parse).ToList();
                var currentPoint = new Point3D(pointValues[0], pointValues[1], pointValues[2]);
                result.AddPoint(currentPoint);
            }
         }
     }
     return result;
 }