예제 #1
0
 public static void Save3DPointsPath(Path3D listOfPoints, string path)
 {
     using (StreamWriter file = new StreamWriter(path))
     {
         for (int i = 0; i < listOfPoints.Count; i++)
         {
             file.WriteLine(listOfPoints[i]);
         }
     }
 }
예제 #2
0
        public static void Main()
        {
            Path3D testPath = new Path3D();
            testPath.AddPoint(0, 3.78, 5);
            testPath.AddPoint(7, 3, 1);
            testPath.AddPoint(9, 4, 1);

            Storage.Save3DPointsPath(testPath, "SavedPoint.txt");
            Path3D newPath = Storage.Load3DPointsPath("SavedPoint.txt");
            Console.WriteLine(newPath[0]);
        }
예제 #3
0
        public static Path3D Load3DPointsPath(string path)
        {
            Path3D listofpoints = new Path3D();
            using (StreamReader reader = new StreamReader(path))
            {
                string line;
                Regex regex = new Regex(@"(\d+|\d+\.\d+)\,\s*(\d+|\d+\.\d+)\,\s*(\d+|\d+\.\d+)");
                while ((line = reader.ReadLine()) != null)
                {
                    var v = regex.Match(line);
                    double x = double.Parse(v.Groups[1].Value);
                    double y = double.Parse(v.Groups[2].Value);
                    double z = double.Parse(v.Groups[3].Value);
                    listofpoints.AddPoint(x, y, z); // Add to list.
                    Console.WriteLine(line); // Write to console.
                }
            }

            return listofpoints;
        }