public static List<Paths3D> LoadPaths(string fullFilename) { try { List<Paths3D> paths = new List<Paths3D>(); using (StreamReader sr = new StreamReader(fullFilename, Encoding.GetEncoding("UTF-8"))) { string line = sr.ReadLine(); while (line != null) { Paths3D points = new Paths3D(); var lines = line.Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries); foreach (var l in lines) { points.Add(Point3D.DeSerialize(l)); } line = sr.ReadLine(); paths.Add(points); } } return paths; } catch (Exception ex) { Console.WriteLine(ex.Message); throw ex.InnerException; } }
public static List <Paths3D> LoadPaths(string fullFilename) { try { List <Paths3D> paths = new List <Paths3D>(); using (StreamReader sr = new StreamReader(fullFilename, Encoding.GetEncoding("UTF-8"))) { string line = sr.ReadLine(); while (line != null) { Paths3D points = new Paths3D(); var lines = line.Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries); foreach (var l in lines) { points.Add(Point3D.DeSerialize(l)); } line = sr.ReadLine(); paths.Add(points); } } return(paths); } catch (Exception ex) { Console.WriteLine(ex.Message); throw ex.InnerException; } }
public static void SavePath(string fullFilename, bool append, Paths3D path) { try { using (StreamWriter sw = new StreamWriter(fullFilename, append, Encoding.GetEncoding("UTF-8"))) { sw.WriteLine(path.ToString()); } } catch (Exception ex) { Console.WriteLine(ex.Message); throw ex.InnerException; } }
static void Main(string[] args) { Console.WriteLine(Point3D.StartingPoint.ToString()); Point3D a = new Point3D( 1, 3, 5.6); Point3D b = new Point3D( -1, 3, 5.6); Point3D c = new Point3D( 1, -3, 5.6); Point3D d = new Point3D( 1, 3, -5.6); Paths3D path = new Paths3D(a, b, c, d); Console.WriteLine(path.ToString()); Console.WriteLine(DistanceCalc.CalculateDistance(a, d)); //Storage tests Storage.SavePath(@"../../SavedPaths.txt", false, path); Storage.SavePath(@"../../SavedPaths.txt", true, path); var loadedList = Storage.LoadPaths(@"../..SavedPaths.txt"); loadedList.ForEach(p => Console.WriteLine(p.ToString())); }
static void Main(string[] args) { Console.WriteLine(Point3D.StartingPoint.ToString()); Point3D a = new Point3D(1, 3, 5.6); Point3D b = new Point3D(-1, 3, 5.6); Point3D c = new Point3D(1, -3, 5.6); Point3D d = new Point3D(1, 3, -5.6); Paths3D path = new Paths3D(a, b, c, d); Console.WriteLine(path.ToString()); Console.WriteLine(DistanceCalc.CalculateDistance(a, d)); //Storage tests Storage.SavePath(@"../../SavedPaths.txt", false, path); Storage.SavePath(@"../../SavedPaths.txt", true, path); var loadedList = Storage.LoadPaths(@"../..SavedPaths.txt"); loadedList.ForEach(p => Console.WriteLine(p.ToString())); }