public Particle(ParticleID pid, Real3 coordinate, float radius, string species) { this.pid = pid; this.coordinate = coordinate; this.radius = radius; this.species = species; }
private List <Particle> ReadCSV(string filepath) { FileInfo fi = new FileInfo(filepath); List <Particle> snapshot = new List <Particle>(); using (StreamReader sr = new StreamReader(fi.OpenRead(), Encoding.UTF8)) { sr.ReadLine(); // Skip The Header Line while (!sr.EndOfStream) { var line = sr.ReadLine(); var values = line.Split(','); ParticleID pid = new ParticleID( System.Convert.ToInt32(values[5]), System.Convert.ToInt32(values[6])); Real3 coordinate = new Real3( System.Convert.ToSingle(values[0]), System.Convert.ToSingle(values[1]), System.Convert.ToSingle(values[2])); snapshot.Add(new Particle( pid, coordinate, /* radius = */ System.Convert.ToSingle(values[3]), /* species = */ values[4])); } } return(snapshot); }
Vector3 Real2Vector(Real3 real3) { return(new Vector3(real3.x * scale, real3.y * scale, real3.z * scale)); }