예제 #1
0
 public static void WritePathToFile(string file, Path3D points)
 {
     using (StreamWriter writer = new StreamWriter(file, false, Encoding.UTF8))
     {
         foreach (var point in points.Path)
         {
             writer.WriteLine("{0} {1} {2}", point.x, point.y, point.z);
         }
     }
 }
        public static void SavePath(Path3D path, string filePathName = SAVE_FILE)
        {
            StringBuilder sb = new StringBuilder();

            foreach (Point3D p in path.PointList)
            {
                sb.Append(JsonConvert.SerializeObject(p));
                sb.Append("\n");
            }

            using (StreamWriter sWriter = new StreamWriter(filePathName, false, ENCODING))
            {
                sWriter.Write(sb.ToString());
            }
        }
예제 #3
0
        static void Main()
        {
            Path3D path = new Path3D(12, -50, 50);

            Console.WriteLine("Generated path:");
            Console.WriteLine(path.ToString());

            Storage.SavePath(path);

            Path3D loadedPath = Storage.LoadPath();

            Console.WriteLine("Loaded path:");
            Console.WriteLine(loadedPath.ToString());

            Console.ReadKey();
        }
예제 #4
0
        static void Main(string[] args)
        {
            List <Point3D> list = new List <Point3D>()
            {
                new Point3D(0, 0, 0),
                new Point3D(1, 1, 1),
                new Point3D(2, 2, 2),
                new Point3D(3, 2, 1),
                new Point3D(5, 3, 4)
            };

            Storage.WritePathToFile("blabal.txt", new Path3D(list));


            Path3D test = Storage.ReadPathFromFile("blabal.txt");

            foreach (var point in test.Path)
            {
                Console.WriteLine(point);
            }
        }
예제 #5
0
        static void Main(string[] args)
        {

            List<Point3D> listOfPoints = new List<Point3D>();
            listOfPoints.Add(Point3D.StartingPoint);

            listOfPoints.Add(new Point3D(0,1,2));
            listOfPoints.Add(new Point3D(1.5,-3.4));
            listOfPoints.Add(new Point3D(-3.1,0,4));

            Path3D path = new Path3D(listOfPoints);
            path.AddPointToPath(new Point3D(0,-1,1.111111));
            Console.WriteLine(path);


            string fileLocation = "Path3D.txt";
            Storage.SavePathToFile(fileLocation,path);

            Path3D pathFromFile = Storage.LoadPathFromFile(fileLocation);
            Console.WriteLine(pathFromFile);

        }