static void Main(string[] args)
        {
            // Set the curent culture to invariante to use "." instate of ","
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            // Test creation of points, point zero and path of points
            Points3DPath.PointsPath path = new Points3DPath.PointsPath();
            path.AddPoint(new Point3D(3.4f, 4.3f, 2.3f));
            path.AddPoint(Point3D.PointZero);
            path.AddPoint(new Point3D(23.4f, 42.3f, 32.3f));
            Console.WriteLine("Curent path:");
            Console.WriteLine(path);

            // Test calculation of distance
            Console.WriteLine();
            Console.WriteLine("Distance between:");
            Console.WriteLine("{0} and", path.Path[0]);
            Console.WriteLine(path.Path[2]);
            Console.WriteLine("Distance = {0}", Points3DCalculations.DistanceCalculations.CalcDistance(path.Path[0], path.Path[2]));

            // Test save and load of points
            Console.WriteLine();
            Console.Write("Saving a path to PathFile.3dp file    ");
            FunLoading();
            Points3DPath.Points3DPathStorage.WritePoints3DPath(path, "PathFile.3dp");
            Console.Write("Clearing the path object    ");
            FunLoading();
            path = new Points3DPath.PointsPath();
            Console.Write("Loading a path from PathFile.3dp file    ");
            FunLoading();
            path = Points3DPath.Points3DPathStorage.ReadPoints3DPath("PathFile.3dp");
            Console.WriteLine();
            Console.WriteLine("Curent path:");
            Console.WriteLine(path);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            // Set the curent culture to invariante to use "." instate of ","
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            // Test creation of points, point zero and path of points
            Points3DPath.PointsPath path = new Points3DPath.PointsPath();
            path.AddPoint(new Point3D(3.4f, 4.3f, 2.3f));
            path.AddPoint(Point3D.PointZero);
            path.AddPoint(new Point3D(23.4f, 42.3f, 32.3f));
            Console.WriteLine("Curent path:");
            Console.WriteLine(path);

            // Test calculation of distance
            Console.WriteLine();
            Console.WriteLine("Distance between:");
            Console.WriteLine("{0} and", path.Path[0]);
            Console.WriteLine(path.Path[2]);
            Console.WriteLine("Distance = {0}", Points3DCalculations.DistanceCalculations.CalcDistance(path.Path[0], path.Path[2]));

            // Test save and load of points
            Console.WriteLine();
            Console.Write("Saving a path to PathFile.3dp file    ");
            FunLoading();
            Points3DPath.Points3DPathStorage.WritePoints3DPath(path, "PathFile.3dp");
            Console.Write("Clearing the path object    ");
            FunLoading();
            path = new Points3DPath.PointsPath();
            Console.Write("Loading a path from PathFile.3dp file    ");
            FunLoading();
            path = Points3DPath.Points3DPathStorage.ReadPoints3DPath("PathFile.3dp");
            Console.WriteLine();
            Console.WriteLine("Curent path:");
            Console.WriteLine(path);
        }
 // Write PointsPath to file
 public static void WritePoints3DPath(PointsPath path, string fileStr)
 {
     try
     {
         // Open file for rewrite and store the path point by point
         using (FileStream fs = new FileStream(fileStr, FileMode.Create))
         using (StreamWriter sw = new StreamWriter(fs))
         {
             foreach (var point in path.Path)
             {
                 sw.WriteLine("{0} {1} {2}", point.X, point.Y, point.Z);
             }
         }
     }
     catch (Exception)
     {
         // Throw exception if have a problem to write data
         throw new IOException("File writing problem!");
     }
 }
 // Write PointsPath to file
 public static void WritePoints3DPath(PointsPath path, string fileStr)
 {
     try
     {
         // Open file for rewrite and store the path point by point
         using (FileStream fs = new FileStream(fileStr, FileMode.Create))
             using (StreamWriter sw = new StreamWriter(fs))
             {
                 foreach (var point in path.Path)
                 {
                     sw.WriteLine("{0} {1} {2}", point.X, point.Y, point.Z);
                 }
             }
     }
     catch (Exception)
     {
         // Throw exception if have a problem to write data
         throw new IOException("File writing problem!");
     }
 }