示例#1
0
        static void Main(string[] args)
        {
            Path3d path = new Path3d();
            path.addPoint(1, 2, 3);
            path.addPoint(2, 3, 4);
            path.addPoint(3, 4, 5);

            Console.WriteLine(path);

            Storage.WriteToFile(path.ToString(), "pathfile");
            Path3d newPath = new Path3d();
            Storage.ReadFromFile("pathfile", newPath);
            Console.WriteLine("new path is: " + newPath.ToString());
        }
示例#2
0
        public static void ReadFromFile(string fileName, Path3d path)
        {
            using (StreamReader reader = new StreamReader($"../../{fileName}.txt"))
            {
                string line = reader.ReadLine();
                Regex rgx = new Regex(@"(\d+),(\d+),(\d+)");
                MatchCollection matches = rgx.Matches(line);

                foreach (Match match in matches)
                {
                    int x = int.Parse(match.Groups[1].Value);
                    int y = int.Parse(match.Groups[2].Value);
                    int z = int.Parse(match.Groups[3].Value);
                    path.addPoint(x, y, z);

                }

            }
        }