public void Populate(List <List <Point3d> > P, List <List <double> > pressure) { Mesh_Vis = false; Section_Vis = false; if (pressure.Count > 0) { PC = new PointCloud(); for (int j = 0; j < P.Count; j++) { for (int i = 0; i < P[j].Count; i++) { PC.Add(P[j][i], P_Color(20 * System.Math.Log(pressure[j][i] / 2E-5)));//0.0000000004 } } } else { for (int j = 0; j < P.Count; j++) { PC = new PointCloud(P[j]); } } this.Enabled = true; }
public void Populate(List<List<Point3d>> P, List<List<double>> pressure) { Mesh_Vis = false; Section_Vis = false; if (pressure.Count > 0) { PC = new PointCloud(); for (int j = 0; j < P.Count; j++) { for (int i = 0; i < P[j].Count; i++) { PC.Add(P[j][i], P_Color(20 * System.Math.Log(pressure[j][i] / 2E-5)));//0.0000000004 } } } else { for (int j = 0; j < P.Count; j++) { PC = new PointCloud(P[j]); } } this.Enabled = true; }
/// <summary> /// Adds particle points to this class for display based on the distance traveled from the source. /// </summary> /// <param name="Dist"></param> public void Populate(double Dist, bool Nearest_Neighbor) { Mesh_Vis = false; Section_Vis = false; PC = new PointCloud(); this.Enabled = false; double[] e = new double[PR.Length * PR[0].Count()]; Point3d[] pts = new Point3d[PR.Length * PR[0].Count()]; int[][] voxel = new int[e.Length][]; double emin = System.Math.Pow(10, V_Bounds[0] / 10) * 1e-12; for (int s = 0; s < PR.Length; s++) { for (int q = 0; q < PR[s].Count(); q++) { double energy; Point3d N, PT; if (!PR[s].RayPt(q, Dist, 4, out energy, out N, out PT)) { continue; } Vector3d loc = PT - min; int x = (int)System.Math.Floor(loc.X / dx); int y = (int)System.Math.Floor(loc.Y / dy); int z = (int)System.Math.Floor(loc.Z / dz); int id = q + s * PR[s].Count(); ptgrid[x, y, z].Add(id); voxel[id] = new int[3] { x, y, z }; pts[id] = PT; e[id] = energy; } } //foreach(int[] i in voxel) //{ // if (i == null) // { // Rhino.RhinoApp.WriteLine("oops..."); // } //} System.Threading.Semaphore S = new System.Threading.Semaphore(1, 1); if (Nearest_Neighbor) { System.Threading.Tasks.Parallel.For(0, pts.Length, s => //for (int s = 0; s < pts.Length; s++) { if (e[s] > emin) { if (voxel[s] != null) { double energy = e[s]; foreach (int[] sp in SearchPattern) { int x = voxel[s][0] + sp[0]; int y = voxel[s][1] + sp[1]; int z = voxel[s][2] + sp[2]; if (x < 0 || x > nx - 1 || y < 0 || y > ny - 1 || z < 0 || z > nz - 1) { continue; } foreach (int t in ptgrid[x, y, z]) { if (s == t) { continue; } Vector3d pt = pts[s] - pts[t]; double d2 = pt.X * pt.X + pt.Y * pt.Y + pt.Z * pt.Z; if (d2 < 1) { energy += e[t] * (1 - d2); } } } S.WaitOne(); PC.Add(pts[s], P_Color(Utilities.AcousticalMath.SPL_Intensity(energy))); S.Release(); } } }); foreach (List <int> p in ptgrid) { p.Clear(); } } else { for (int s = 0; s < pts.Length; s++) { PC.Add(pts[s], P_Color(Utilities.AcousticalMath.SPL_Intensity(e[s]))); } } this.Enabled = true; }
/// <summary> /// Adds particle points to this class for display based on the distance traveled from the source. /// </summary> /// <param name="Dist"></param> public void Populate(double Dist, bool Nearest_Neighbor) { Mesh_Vis = false; Section_Vis = false; PC = new PointCloud(); this.Enabled = false; double[] e = new double[PR.Length * PR[0].Count()]; Point3d[] pts = new Point3d[PR.Length * PR[0].Count()]; int[][] voxel = new int[e.Length][]; for (int s = 0; s < PR.Length; s++) { for (int q = 0; q < PR[s].Count(); q++) { double energy; Point3d N, PT; if (!PR[s].RayPt(q, Dist, 4, out energy, out N, out PT)) continue; Vector3d loc = PT - min; int x = (int)System.Math.Floor(loc.X / dx); int y = (int)System.Math.Floor(loc.Y / dy); int z = (int)System.Math.Floor(loc.Z / dz); int id = q + s * PR[s].Count(); ptgrid[x,y,z].Add(id); voxel[id] = new int[3] { x, y, z }; pts[id] = PT; e[id] = energy; } } //foreach(int[] i in voxel) //{ // if (i == null) // { // Rhino.RhinoApp.WriteLine("oops..."); // } //} System.Threading.Semaphore S = new System.Threading.Semaphore(1, 1); if (Nearest_Neighbor) { System.Threading.Tasks.Parallel.For(0, pts.Length, s => //for (int s = 0; s < pts.Length; s++) { if (voxel[s] != null) { double energy = e[s]; foreach (int[] sp in SearchPattern) { int x = voxel[s][0] + sp[0]; int y = voxel[s][1] + sp[1]; int z = voxel[s][2] + sp[2]; if (x < 0 || x > nx - 1 || y < 0 || y > ny - 1 || z < 0 || z > nz - 1) continue; foreach (int t in ptgrid[x, y, z]) { if (s == t) continue; Vector3d pt = pts[s] - pts[t]; double d2 = pt.X * pt.X + pt.Y * pt.Y + pt.Z * pt.Z; if (d2 < 1) { energy += e[t] * (1 - d2); } } } S.WaitOne(); PC.Add(pts[s], P_Color(Utilities.AcousticalMath.SPL_Intensity(energy))); S.Release(); } }); foreach (List<int> p in ptgrid) { p.Clear(); } } else { for (int s = 0; s < pts.Length; s++) { PC.Add(pts[s], P_Color(Utilities.AcousticalMath.SPL_Intensity(e[s]))); } } this.Enabled = true; }