Example #1
0
        public static void WriteData(Path3D paths)
        {
            StreamWriter sw = new StreamWriter("../../output.txt");

            try
            {
                using (sw)
                {
                    List<Point3D> pathToWrite = paths.GetPoints();

                    foreach (Point3D point in pathToWrite)
                    {
                        sw.WriteLine(point.ToString());
                    }
                }
            }

            catch (FileLoadException fle)
            {
                Console.WriteLine("Problem opening OutputPath.txt " + fle.Message);
            }

            finally
            {
                sw.Close();
            }
        }
Example #2
0
        public static void WriteData(Path3D paths)
        {
            StreamWriter sw = new StreamWriter("../../output.txt");

            try
            {
                using (sw)
                {
                    List <Point3D> pathToWrite = paths.GetPoints();

                    foreach (Point3D point in pathToWrite)
                    {
                        sw.WriteLine(point.ToString());
                    }
                }
            }

            catch (FileLoadException fle)
            {
                Console.WriteLine("Problem opening OutputPath.txt " + fle.Message);
            }

            finally
            {
                sw.Close();
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            Path3D path = Storage.ReadData();

            List <Point3D> pathToPrint = path.GetPoints();

            foreach (var point in pathToPrint)
            {
                Console.WriteLine(point.ToString());
            }

            Storage.WriteData(path);
        }
Example #4
0
        public static Path3D ReadData()
        {
            Path3D paths = new Path3D();
            string line;
            StreamReader sr = new StreamReader("../../input.txt");

            try
            {
                string pattern = "(\\d+[\\.{1}\\d+]*).[^\\.\\d]*(\\d+[\\.{1}\\d+]*).[^\\.\\d]*(\\d+[\\.{1}\\d+]*)";
                line = sr.ReadLine();

                using (sr)
                {
                    while (line != null)
                    {
                        double pointX;
                        double pointY;
                        double pointZ;

                        MatchCollection matches = Regex.Matches(line, pattern);
                        foreach (Match match in matches)
                        {
                            pointX = double.Parse(match.Groups[1].Value);
                            pointY = double.Parse(match.Groups[2].Value);
                            pointZ = double.Parse(match.Groups[3].Value);

                            Point3D point = new Point3D(pointX, pointY, pointZ);
                            paths.AddPoint(point);
                        }
                        line = sr.ReadLine();
                    }
                }
            }

            catch (FileNotFoundException fnf)
            {
                Console.WriteLine("Input.txt not found!" + fnf.Message);
            }
            catch (FileLoadException fle)
            {
                Console.WriteLine("Problem loading Input.txt " + fle.Message);
            }

            finally
            {
                sr.Close();
            }

            return paths;
        }
Example #5
0
        public static Path3D ReadData()
        {
            Path3D       paths = new Path3D();
            string       line;
            StreamReader sr = new StreamReader("../../input.txt");

            try
            {
                string pattern = "(\\d+[\\.{1}\\d+]*).[^\\.\\d]*(\\d+[\\.{1}\\d+]*).[^\\.\\d]*(\\d+[\\.{1}\\d+]*)";
                line = sr.ReadLine();

                using (sr)
                {
                    while (line != null)
                    {
                        double pointX;
                        double pointY;
                        double pointZ;

                        MatchCollection matches = Regex.Matches(line, pattern);
                        foreach (Match match in matches)
                        {
                            pointX = double.Parse(match.Groups[1].Value);
                            pointY = double.Parse(match.Groups[2].Value);
                            pointZ = double.Parse(match.Groups[3].Value);

                            Point3D point = new Point3D(pointX, pointY, pointZ);
                            paths.AddPoint(point);
                        }
                        line = sr.ReadLine();
                    }
                }
            }

            catch (FileNotFoundException fnf)
            {
                Console.WriteLine("Input.txt not found!" + fnf.Message);
            }
            catch (FileLoadException fle)
            {
                Console.WriteLine("Problem loading Input.txt " + fle.Message);
            }

            finally
            {
                sr.Close();
            }

            return(paths);
        }