Exemplo n.º 1
0
        public static List<Path> LoadPathFromFile()
        {
            Path loadingPath = new Path();
            List<Path> pathsLoaded = new List<Path>();
            try
            {
                Path loadPath = new Path();
                List<Path> pathsLoad = new List<Path>();
                using (StreamReader reader = new StreamReader(@"../../savedPath.txt"))
                {
                    string line = reader.ReadLine();
                    while (line != null)
                    {
                        if (line != "-")
                        {
                            Point3D point = new Point3D();
                            string[] points = line.Split(new char[] { '[', ',', ']' }, StringSplitOptions.RemoveEmptyEntries);
                            point.PointX = int.Parse(points[0]);
                            point.PointY = int.Parse(points[1]);
                            point.PointZ = int.Parse(points[2]);
                            loadPath.AddPoint(point);
                        }
                        else
                        {
                            pathsLoaded.Add(loadPath);
                            loadPath = new Path();
                        }

                        line = reader.ReadLine();
                    }
                }
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("File not found!!!");
            }
            catch (IOException io)
            {
                Console.WriteLine(io.Message);
            }
            finally { }
            return pathsLoaded;
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Point3D firstPoint = new Point3D(1, 2, 3);
            Point3D secondPoint = new Point3D(-1, 2, -8);
            Point3D thirdPoint = new Point3D(9, 7, 8);

            Console.WriteLine(firstPoint.ToString());
            Console.WriteLine(secondPoint.ToString());
            Console.WriteLine(thirdPoint.ToString());

            Console.WriteLine(CalcDistance.CalculateDistance(firstPoint,secondPoint));

            Path p = new Path();
            p.AddPoint(new Point3D(1, 1, 1));
            p.AddPoint(new Point3D(2, 2, 2));
            p.AddPoint(new Point3D(5, 7, 9));

            PathStorage.SavePathFromFile(p);
            PathStorage.LoadPathFromFile();
        }
Exemplo n.º 3
0
 public void RemovePoint(Point3D point)
 {
     this.PathOfPoint.Remove(point);
 }
Exemplo n.º 4
0
 public void AddPoint(Point3D point)
 {
     this.PathOfPoint.Add(point);
 }
Exemplo n.º 5
0
 public static double CalculateDistance(Point3D pointOne, Point3D pointTwo)
 {
     double result = Math.Sqrt((pointOne.PointX - pointTwo.PointX) * (pointOne.PointX - pointTwo.PointX) +
     (pointOne.PointY - pointTwo.PointY) * (pointOne.PointY - pointTwo.PointY) + (pointOne.PointZ - pointTwo.PointZ) * (pointOne.PointZ - pointTwo.PointZ));
     return result;
 }