private void Partition(Source Src_Pt, bool ProcessMesh) { int processorCt = UI.PachydermAc_PlugIn.Instance.ProcessorSpec(); if (ProcessMesh) { Hare.Geometry.Point p; if (Z_Displacement) { Hare.Geometry.Point V = new Hare.Geometry.Point(0, 0, increment * .5); if (Rec_Vertex) { for (int i = 0; i < Map_Mesh.Vertices.Count; i++) { p = new Hare.Geometry.Point(Map_Mesh.Vertices[i].X, Map_Mesh.Vertices[i].Y, Map_Mesh.Vertices[i].Z) + V; Rec_List[i] = new Map_Receiver(increment, i, p, Src_Pt, _Sc.Sound_speed(p), _Sc.Rho(p), _Sc.Attenuation(p), 1000, CutOffTime, processorCt, Time1Pt, Directional); } } else { for (int i = 0; i < Map_Mesh.Faces.Count; i++) { Point3f center = new Point3f(); center.X = Map_Mesh.Vertices[Map_Mesh.Faces[i].A].X+ Map_Mesh.Vertices[Map_Mesh.Faces[i].B].X + Map_Mesh.Vertices[Map_Mesh.Faces[i].C].X; center.Y = Map_Mesh.Vertices[Map_Mesh.Faces[i].A].Y+ Map_Mesh.Vertices[Map_Mesh.Faces[i].B].Y + Map_Mesh.Vertices[Map_Mesh.Faces[i].C].Y; center.Z = Map_Mesh.Vertices[Map_Mesh.Faces[i].A].Z+ Map_Mesh.Vertices[Map_Mesh.Faces[i].B].Z + Map_Mesh.Vertices[Map_Mesh.Faces[i].C].Z; if (Map_Mesh.Faces[i].IsQuad) { center.X += Map_Mesh.Vertices[Map_Mesh.Faces[i].D].X; center.Y += Map_Mesh.Vertices[Map_Mesh.Faces[i].D].Y; center.Z += Map_Mesh.Vertices[Map_Mesh.Faces[i].D].Z; center.X /= 4; center.Y /= 4;center.Z /= 4; } else { center.X /= 3; center.Y /= 3;center.Z /= 3; } p = new Hare.Geometry.Point(center.X, center.Y, center.Z) + V; Rec_List[i] = new Map_Receiver(increment, i, p, Src_Pt, _Sc.Sound_speed(p), _Sc.Rho(p), _Sc.Attenuation(p), 1000, CutOffTime, processorCt, Time1Pt, Directional); } } if (Mesh_Offset) for (int i = 0; i < Map_Mesh.Vertices.Count; i++) { Map_Mesh.Vertices[i] = new Point3f(Map_Mesh.Vertices[i].X + (float)V.x, Map_Mesh.Vertices[i].Y + (float)V.y, Map_Mesh.Vertices[i].Z + (float)V.z); } } else { if (Rec_Vertex) { for (int i = 0; i < Map_Mesh.Vertices.Count; i++) { Vector3f V = new Vector3f((float)(Map_Mesh.Normals[i].X * increment * .5), (float)(Map_Mesh.Normals[i].Y * increment * .5), (float)(Map_Mesh.Normals[i].Z * increment * .5)); p = new Hare.Geometry.Point(Map_Mesh.Vertices[i].X+ V.X, Map_Mesh.Vertices[i].Y + V.Y, Map_Mesh.Vertices[i].Z+ V.Z); Rec_List[i] = new Map_Receiver(increment, i, p, Src_Pt, _Sc.Sound_speed(p), _Sc.Rho(p), _Sc.Attenuation(p), 1000, CutOffTime, processorCt, Time1Pt, Directional); } } else { for (int i = 0; i < Map_Mesh.Faces.Count; i++) { Point3f center = new Point3f(); center.X = Map_Mesh.Vertices[Map_Mesh.Faces[i].A].X + Map_Mesh.Vertices[Map_Mesh.Faces[i].B].X + Map_Mesh.Vertices[Map_Mesh.Faces[i].C].X; center.Y = Map_Mesh.Vertices[Map_Mesh.Faces[i].A].Y + Map_Mesh.Vertices[Map_Mesh.Faces[i].B].Y + Map_Mesh.Vertices[Map_Mesh.Faces[i].C].Y; center.Z = Map_Mesh.Vertices[Map_Mesh.Faces[i].A].Z + Map_Mesh.Vertices[Map_Mesh.Faces[i].B].Z + Map_Mesh.Vertices[Map_Mesh.Faces[i].C].Z; if (Map_Mesh.Faces[i].IsQuad) { center.X += Map_Mesh.Vertices[Map_Mesh.Faces[i].D].X; center.Y += Map_Mesh.Vertices[Map_Mesh.Faces[i].D].Y; center.Z += Map_Mesh.Vertices[Map_Mesh.Faces[i].D].Z; center.X /= 4; center.Y /= 4; center.Z /= 4; } else { center.X /= 3; center.Y /= 3; center.Z /= 3; } Vector3f V = new Vector3f((float)(Map_Mesh.FaceNormals[i].X * increment * .5), (float)(Map_Mesh.FaceNormals[i].Y * increment * .5), (float)(Map_Mesh.FaceNormals[i].Z * increment * .5)); p = new Hare.Geometry.Point(center.X + V.X, center.Y + V.Y, center.Z + V.Z); Rec_List[i] = new Map_Receiver(increment, i, p, Src_Pt, _Sc.Sound_speed(p),_Sc.Rho(p), _Sc.Attenuation(p), 1000, CutOffTime, processorCt, Time1Pt, Directional); } } if (Mesh_Offset) for (int i = 0; i < Map_Mesh.Vertices.Count; i++) { Vector3f V = Map_Mesh.Normals[i]; Map_Mesh.Vertices[i] = new Point3f(Map_Mesh.Vertices[i].X + (float)V.X, Map_Mesh.Vertices[i].Y + (float)V.Y, Map_Mesh.Vertices[i].Z + (float)V.Z); } } } else { for (int i = 0; i < Map_Mesh.Vertices.Count; i++) { Hare.Geometry.Point V = new Hare.Geometry.Point(0, 0, increment * .5); Hare.Geometry.Point p = new Hare.Geometry.Point(Map_Mesh.Vertices[i].X, Map_Mesh.Vertices[i].Y, Map_Mesh.Vertices[i].Z); Rec_List[i] = new Map_Receiver(increment, i, p, Src_Pt, _Sc.Rho(p), _Sc.Sound_speed(p), _Sc.Attenuation(p), 1000, CutOffTime, processorCt, Time1Pt, Directional); } } foreach (Spherical_Receiver R in Rec_List) { //Find max and min bounds of all spheres... if ((R.H_Origin.x + (increment * .5)) > Max.x) Max.x = R.H_Origin.x + (increment * .5); if ((R.H_Origin.y + (increment * .5)) > Max.y) Max.y = R.H_Origin.y + (increment * .5); if ((R.H_Origin.z + (increment * .5)) > Max.z) Max.z = R.H_Origin.z + (increment * .5); if ((R.H_Origin.x - (increment * .5)) < Min.x) Min.x = R.H_Origin.x - (increment * .5); if ((R.H_Origin.y - (increment * .5)) < Min.y) Min.y = R.H_Origin.y - (increment * .5); if ((R.H_Origin.z - (increment * .5)) < Min.z) Min.z = R.H_Origin.z - (increment * .5); } OBox = new AABB(Min, Max); //Divide the Min and Max into separate sub-voxels... VoxelCtX = (int)Math.Ceiling((OBox.Max_PT.x - OBox.Min_PT.x) / (increment * 4)); VoxelCtY = (int)Math.Ceiling((OBox.Max_PT.y - OBox.Min_PT.y) / (increment * 4)); VoxelCtZ = (int)Math.Ceiling((OBox.Max_PT.z - OBox.Min_PT.z) / (increment * 2.5)); Voxels = new AABB[VoxelCtX, VoxelCtY, VoxelCtZ]; Voxel_Inv = new List<int>[VoxelCtX, VoxelCtY, VoxelCtZ]; BoxDims = (Max - Min); VoxelDims = new Hare.Geometry.Point(BoxDims.x / VoxelCtX, BoxDims.y / VoxelCtY, BoxDims.z / VoxelCtZ); VoxelDims_Inv = new Hare.Geometry.Point(1 / VoxelDims.x, 1 / VoxelDims.y, 1 / VoxelDims.z); BoxDims_Inv = new Hare.Geometry.Point(1 / BoxDims.x, 1 / BoxDims.y, 1 / BoxDims.z); for (int x = 0; x < VoxelCtX; x++) { for (int y = 0; y < VoxelCtY; y++) { for (int z = 0; z < VoxelCtZ; z++) { Voxel_Inv[x, y, z] = new List<int>(); Hare.Geometry.Point voxelmin = new Hare.Geometry.Point(x * VoxelDims.x, y * VoxelDims.y, z * VoxelDims.z); Hare.Geometry.Point voxelmax = new Hare.Geometry.Point((x + 1) * VoxelDims.x, (y + 1) * VoxelDims.y, (z + 1) * VoxelDims.z); AABB Box = new AABB(voxelmin + OBox.Min_PT, voxelmax + OBox.Min_PT); Voxels[x, y, z] = Box; for (int i = 0; i < Rec_List.Length; i++) { //Check for intersection between voxel x,y,z with Receiver i... Hare.Geometry.Point PT = Box.ClosestPt(Rec_List[i].H_Origin); PT -= Rec_List[i].H_Origin; if ((PT.x * PT.x + PT.y * PT.y + PT.z * PT.z) < Rec_List[i].Radius2) { Voxel_Inv[x, y, z].Add(i); } } } } } }