private void Update_Graphs() { if (Chart_Contents.SelectedIndex == 0) { Alpha_Normal.ChartAreas[0].AxisY.Title = "Alpha (0 to 1)"; if (Fin_Sample.Checked && Zr == null) { return; } List <ABS_Layer> Layers = Material_Layers(); if (Layers.Count == 0) { return; } if (Inf_Sample.Checked) { sm = new Environment.Smart_Material(Air_Term.Checked, Layers, 16000, 1.2, 343, Averaging.SelectedIndex); } else { sm = new Environment.Smart_Material(Air_Term.Checked, Layers, 16000, 1.2, 343, Zr, 0.1, Averaging.SelectedIndex, Zf_Incorp_Method.SelectedIndex); } //Polar Graph double[] AnglesDeg = new double[sm.Angles.Length]; for (int i = 0; i < sm.Angles.Length; i++) { AnglesDeg[i] = sm.Angles[i].Real; } RI_Absorption = new double[8]; Polar_Absorption.ChartAreas[0].AxisY.Minimum = 0; Polar_Absorption.ChartAreas[0].AxisY.Maximum = 1; for (int oct = 0; oct < 8; oct++) { Polar_Absorption.Series[oct].Points.DataBindXY(AnglesDeg, sm.Ang_Coef_Oct[oct]); for (int a = 0; a < sm.Ang_Coef_Oct[oct].Length; a++) { if (Polar_Absorption.ChartAreas[0].AxisY.Maximum < sm.Ang_Coef_Oct[oct][a]) { Polar_Absorption.ChartAreas[0].AxisY.Maximum = Math.Ceiling(sm.Ang_Coef_Oct[oct][a] * 10) / 10; } } } //Z Graph double[] real = new double[sm.Z[18].Length]; double[] imag = new double[sm.Z[18].Length]; for (int i = 0; i < sm.Z[18].Length; i++) { real[i] = sm.Z[18][i].Real; imag[i] = sm.Z[18][i].Imaginary; } Impedance_Graph.Series[0].Points.DataBindXY(sm.frequency, real); Impedance_Graph.Series[1].Points.DataBindXY(sm.frequency, imag); Impedance_Graph.ChartAreas[0].AxisY.Maximum = 4000; Impedance_Graph.ChartAreas[0].AxisY.Minimum = -6000; //Alpha Normal graph Alpha_Normal.Series[0].Points.Clear(); Alpha_Normal.Series[1].Points.Clear(); RI_Absorption = sm.RI_Coef; Alpha_Normal.ChartAreas[0].AxisY.Maximum = 1; if (Fin_Sample.Checked) { foreach (double a in RI_Absorption) { if (Alpha_Normal.ChartAreas[0].AxisY.Maximum < a) { Alpha_Normal.ChartAreas[0].AxisY.Maximum = Math.Ceiling(a * 10) / 10; } } } foreach (double a in sm.NI_Coef) { if (Alpha_Normal.ChartAreas[0].AxisY.Maximum < a) { Alpha_Normal.ChartAreas[0].AxisY.Maximum = Math.Ceiling(a * 10) / 10; } } if (Direction_choice.SelectedIndex == 0) { for (int i = 0; i < sm.frequency.Length; i++) { Alpha_Normal.Series[0].Points.AddXY(sm.frequency[i], sm.NI_Coef[i]); } } else { double[][] acoef = AbsorptionModels.Operations.Absorption_Coef(sm.Reflection_Coefficient); //(sm.Z, sm.frequency); for (int i = 0; i < sm.frequency.Length; i++) { Alpha_Normal.Series[0].Points.AddXY(sm.frequency[i], acoef[Direction_choice.SelectedIndex + 17][i]); //sm.NI_Coef[i]); } } for (int oct = 0; oct < 8; oct++) { Alpha_Normal.Series[1].Points.AddXY(62.5 * Math.Pow(2, oct), RI_Absorption[oct]); } } else { if (Rigid_Term.Checked) { return; } Alpha_Normal.ChartAreas[0].AxisY.Title = "Transmission Loss (dB)"; if (Fin_Sample.Checked && Zr == null) { return; } List <ABS_Layer> Layers = Material_Layers(); if (Layers.Count == 0) { return; } if (Inf_Sample.Checked) { sm = new Environment.Smart_Material(Air_Term.Checked, Layers, 16000, 1.2, 343, Averaging.SelectedIndex); } else { sm = new Environment.Smart_Material(Air_Term.Checked, Layers, 16000, 1.2, 343, Zr, 0.1, Averaging.SelectedIndex, Zf_Incorp_Method.SelectedIndex); } double[] AnglesDeg = new double[sm.Angles.Length]; for (int i = 0; i < sm.Angles.Length; i++) { AnglesDeg[i] = sm.Angles[i].Real; } //Z graph... RI_Absorption = new double[8]; double[] real = new double[sm.Z[18].Length]; double[] imag = new double[sm.Z[18].Length]; for (int i = 0; i < sm.Z[18].Length; i++) { real[i] = sm.Z[18][i].Real; imag[i] = sm.Z[18][i].Imaginary; } Impedance_Graph.Series[0].Points.DataBindXY(sm.frequency, real); Impedance_Graph.Series[1].Points.DataBindXY(sm.frequency, imag); Impedance_Graph.ChartAreas[0].AxisY.Maximum = 40000; Impedance_Graph.ChartAreas[0].AxisY.Minimum = -60000; //T graph... Alpha_Normal.Series[0].Points.Clear(); Alpha_Normal.Series[1].Points.Clear(); double[] TL = new double[sm.frequency.Length]; double[] aTL = new double[sm.frequency.Length]; double max = double.NegativeInfinity; for (int i = 0; i < sm.frequency.Length; i++) { //Complex tau = 0; //for (int a = 0; a < sm.Angles.Length; a++) //{ // tau += sm.Trans_Coefficient[a][i] * Math.Cos(a * sm.Angles.Length / 180) * Math.Sin(a * sm.Angles.Length / 180); //TL[i] = 10 * Math.Log10((sm.Trans_Loss[19][i].Real * sm.Trans_Loss[19][i].Real)); //} //aTL[i] = -10 * Complex.Log10(tau).Real; TL[i] = -10 * Complex.Log10(sm.Trans_Coefficient[Direction_choice.SelectedIndex + 17][i]).Real; //TL[i] = 10 * Math.Log10((sm.Trans_Loss[19][i].Real * sm.Trans_Loss[19][i].Real)); max = Math.Max(TL[i], max); } double maxTL = 0; double minTL = double.PositiveInfinity; Polar_Absorption.ChartAreas[0].AxisY.Minimum = 0; Polar_Absorption.ChartAreas[0].AxisY.Maximum = 1; for (int oct = 0; oct < 8; oct++) { double[] TL_ang = new double[sm.Ang_tau_Oct[oct].Length]; for (int a = 0; a < sm.Ang_tau_Oct[oct].Length; a++) { //if (Polar_Absorption.ChartAreas[0].AxisY.Maximum < sm.Ang_Coef_Oct[oct][a]) //{ double TLnow = sm.Ang_tau_Oct[oct][a];// - 10 * Math.Log10(sm.Ang_tau_Oct[oct][a]); maxTL = Math.Max(TLnow, maxTL); minTL = Math.Min(TLnow, minTL); TL_ang[a] = TLnow; //Polar_Absorption.ChartAreas[0].AxisY.Maximum = sm.Ang_tau_Oct[oct][a] * 10; //} } Polar_Absorption.Series[oct].Points.DataBindXY(AnglesDeg, TL_ang); } Polar_Absorption.ChartAreas[0].AxisY.Maximum = 1; //Math.Min(1, maxTL);// maxTL; if (Chart_Contents.SelectedIndex == 0) { PolarTitle.Text = "Absorption Coefficient by Angle of Incidence"; } else { PolarTitle.Text = "Transmission Coefficient by Angle of Incidence"; } for (int i = 0; i < sm.frequency.Length; i++) { Alpha_Normal.Series[0].Points.AddXY(sm.frequency[i], TL[i]); } for (int oct = 0; oct < 8; oct++) { double TLnow = -10 * Math.Log10(sm.TI_Coef[oct]); Alpha_Normal.Series[1].Points.AddXY(62.5 * Math.Pow(2, oct), TLnow); } Alpha_Normal.ChartAreas[0].AxisY.Maximum = -10 * Math.Log10(minTL); if (Chart_Contents.SelectedIndex == 0) { Alpha_Normal.Titles[0].Text = "Absorption Coefficient"; } else { Alpha_Normal.Titles[0].Text = "Transmission Loss (dB)"; } } //Estimate_IIR(); }
private void Update_Graphs() { if (Fin_Sample.Checked && Zr == null) return; List<ABS_Layer> Layers = Material_Layers(); if (Layers.Count == 0) return; if (Inf_Sample.Checked) sm = new Environment.Smart_Material(Layers, 16000, 1.2, 343, Averaging.SelectedIndex); else sm = new Environment.Smart_Material(Layers, 16000, 1.2, 343, Zr, 0.1, Averaging.SelectedIndex, Zf_Incorp_Method.SelectedIndex); double[] AnglesDeg = new double[sm.Angles.Length]; for (int i = 0; i < sm.Angles.Length; i++) AnglesDeg[i] = sm.Angles[i].Real; RI_Absorption = new double[8]; double root2 = Math.Sqrt(2); Polar_Absorption.ChartAreas[0].AxisY.Minimum = 0; Polar_Absorption.ChartAreas[0].AxisY.Maximum = 1; for (int oct = 0; oct < 8; oct++) { Polar_Absorption.Series[oct].Points.DataBindXY(AnglesDeg, sm.Ang_Coef_Oct[oct]); for (int a = 0; a < sm.Ang_Coef_Oct[oct].Length; a++) { if (Polar_Absorption.ChartAreas[0].AxisY.Maximum < sm.Ang_Coef_Oct[oct][a]) Polar_Absorption.ChartAreas[0].AxisY.Maximum = Math.Ceiling(sm.Ang_Coef_Oct[oct][a] * 10) / 10; } } double[] real = new double[sm.Z[18].Length]; double[] imag = new double[sm.Z[18].Length]; for (int i = 0; i < sm.Z[18].Length; i++) { real[i] = sm.Z[18][i].Real; imag[i] = sm.Z[18][i].Imaginary; } Impedance_Graph.Series[0].Points.DataBindXY(sm.frequency, real); Impedance_Graph.Series[1].Points.DataBindXY(sm.frequency, imag); Impedance_Graph.ChartAreas[0].AxisY.Maximum = 4000; Impedance_Graph.ChartAreas[0].AxisY.Minimum = -6000; Alpha_Normal.Series[0].Points.Clear(); Alpha_Normal.Series[1].Points.Clear(); RI_Absorption = sm.RI_Coef; Alpha_Normal.ChartAreas[0].AxisY.Maximum = 1; if (Fin_Sample.Checked) { foreach (double a in RI_Absorption) if (Alpha_Normal.ChartAreas[0].AxisY.Maximum < a) Alpha_Normal.ChartAreas[0].AxisY.Maximum = Math.Ceiling(a * 10)/10; } foreach (double a in sm.NI_Coef) if (Alpha_Normal.ChartAreas[0].AxisY.Maximum < a) Alpha_Normal.ChartAreas[0].AxisY.Maximum = Math.Ceiling(a * 10) / 10; if (Fin_Sample.Checked) for (int i = 0; i < sm.frequency.Length; i++) Alpha_Normal.Series[0].Points.AddXY(sm.frequency[i], sm.NI_Coef[i]); else for (int i = 0; i < sm.frequency.Length; i++) Alpha_Normal.Series[0].Points.AddXY(sm.frequency[i], sm.NI_Coef[i]); for (int oct = 0; oct < 8; oct++) Alpha_Normal.Series[1].Points.AddXY(62.5 * Math.Pow(2, oct), RI_Absorption[oct]); //Estimate_IIR(); }
private void Update_Graphs() { if (Fin_Sample.Checked && Zr == null) { return; } List <ABS_Layer> Layers = Material_Layers(); if (Layers.Count == 0) { return; } if (Inf_Sample.Checked) { sm = new Environment.Smart_Material(Layers, 16000, 1.2, 343, Averaging.SelectedIndex); } else { sm = new Environment.Smart_Material(Layers, 16000, 1.2, 343, Zr, 0.1, Averaging.SelectedIndex, Zf_Incorp_Method.SelectedIndex); } double[] AnglesDeg = new double[sm.Angles.Length]; for (int i = 0; i < sm.Angles.Length; i++) { AnglesDeg[i] = sm.Angles[i].Real; } RI_Absorption = new double[8]; double root2 = Math.Sqrt(2); Polar_Absorption.ChartAreas[0].AxisY.Minimum = 0; Polar_Absorption.ChartAreas[0].AxisY.Maximum = 1; for (int oct = 0; oct < 8; oct++) { Polar_Absorption.Series[oct].Points.DataBindXY(AnglesDeg, sm.Ang_Coef_Oct[oct]); for (int a = 0; a < sm.Ang_Coef_Oct[oct].Length; a++) { if (Polar_Absorption.ChartAreas[0].AxisY.Maximum < sm.Ang_Coef_Oct[oct][a]) { Polar_Absorption.ChartAreas[0].AxisY.Maximum = Math.Ceiling(sm.Ang_Coef_Oct[oct][a] * 10) / 10; } } } double[] real = new double[sm.Z[18].Length]; double[] imag = new double[sm.Z[18].Length]; for (int i = 0; i < sm.Z[18].Length; i++) { real[i] = sm.Z[18][i].Real; imag[i] = sm.Z[18][i].Imaginary; } Impedance_Graph.Series[0].Points.DataBindXY(sm.frequency, real); Impedance_Graph.Series[1].Points.DataBindXY(sm.frequency, imag); Impedance_Graph.ChartAreas[0].AxisY.Maximum = 4000; Impedance_Graph.ChartAreas[0].AxisY.Minimum = -6000; Alpha_Normal.Series[0].Points.Clear(); Alpha_Normal.Series[1].Points.Clear(); RI_Absorption = sm.RI_Coef; Alpha_Normal.ChartAreas[0].AxisY.Maximum = 1; if (Fin_Sample.Checked) { foreach (double a in RI_Absorption) { if (Alpha_Normal.ChartAreas[0].AxisY.Maximum < a) { Alpha_Normal.ChartAreas[0].AxisY.Maximum = Math.Ceiling(a * 10) / 10; } } } foreach (double a in sm.NI_Coef) { if (Alpha_Normal.ChartAreas[0].AxisY.Maximum < a) { Alpha_Normal.ChartAreas[0].AxisY.Maximum = Math.Ceiling(a * 10) / 10; } } if (Fin_Sample.Checked) { for (int i = 0; i < sm.frequency.Length; i++) { Alpha_Normal.Series[0].Points.AddXY(sm.frequency[i], sm.NI_Coef[i]); } } else { for (int i = 0; i < sm.frequency.Length; i++) { Alpha_Normal.Series[0].Points.AddXY(sm.frequency[i], sm.NI_Coef[i]); } } for (int oct = 0; oct < 8; oct++) { Alpha_Normal.Series[1].Points.AddXY(62.5 * Math.Pow(2, oct), RI_Absorption[oct]); } //Estimate_IIR(); }
private void Construct(List<Rhino.DocObjects.RhinoObject> ObjectList) { BoundingBox Box = ObjectList[0].Geometry.GetBoundingBox(true); for (int i = 1; i < ObjectList.Count; i++) Box.Union(ObjectList[i].Geometry.GetBoundingBox(true)); List<GeometryBase> BList = new List<GeometryBase>(); Brep_ids = new List<int>(); List<Material> Mat_Layer = new List<Material>(); List<Scattering> Scat_Layer = new List<Scattering>(); List<Material> Mat_Obj = new List<Material>(); List<Scattering> Scat_Obj = new List<Scattering>(); List<double[]> Trans_Layer = new List<double[]>(); List<double[]> Trans_Obj = new List<double[]>(); List<bool> Finite_Layers = new List<bool>(); List<bool> Finite_Obj = new List<bool>(); //Organize the geometry into Breps //Get materials for each layer: for (int l = 0; l < Rhino.RhinoDoc.ActiveDoc.Layers.Count; l++) { Rhino.DocObjects.Layer Layer = Rhino.RhinoDoc.ActiveDoc.Layers[l]; string abstype = Layer.GetUserString("ABSType"); if (abstype == "Buildup") { Finite_Layers.Add(false); string BU = Layer.GetUserString("BuildUp"); string[] BU_split = BU.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); List<AbsorptionModels.ABS_Layer> Buildup = new List<AbsorptionModels.ABS_Layer>(); foreach (string swatch in BU_split) Buildup.Add(AbsorptionModels.ABS_Layer.LayerFromCode(swatch)); Mat_Layer.Add(new Environment.Smart_Material(Buildup, 44100, Env_Prop.Rho(0), Env_Prop.Sound_Speed(0), 2)); double[] Abs = new double[8], Scat = new double[8], Trans = new double[8]; Pachyderm_Acoustic.UI.PachydermAc_PlugIn.DecodeAcoustics(Layer.GetUserString("Acoustics"), ref Abs, ref Scat, ref Trans); ///Other properties are still coefficient based... Scat_Layer.Add(new Environment.Lambert_Scattering(Scat, SplitRatio)); Trans_Layer.Add(Trans); } else if (abstype == "Buildup_Finite") { Finite_Layers.Add(true); string BU = Layer.GetUserString("BuildUp"); string[] BU_split = BU.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); List<AbsorptionModels.ABS_Layer> Buildup = new List<AbsorptionModels.ABS_Layer>(); foreach (string swatch in BU_split) Buildup.Add(AbsorptionModels.ABS_Layer.LayerFromCode(swatch)); Environment.Smart_Material sm = new Environment.Smart_Material(Buildup, 44100, Env_Prop.Rho(0), Env_Prop.Sound_Speed(0), 2); Mat_Layer.Add(sm); double[] Abs = new double[8], Scat = new double[8], Trans = new double[8]; Pachyderm_Acoustic.UI.PachydermAc_PlugIn.DecodeAcoustics(Layer.GetUserString("Acoustics"), ref Abs, ref Scat, ref Trans); ///Other properties are still coefficient based... Scat_Layer.Add(new Environment.Lambert_Scattering(Scat, SplitRatio)); Trans_Layer.Add(Trans); } else { Finite_Layers.Add(false); string spec = Layer.GetUserString("Acoustics"); if (spec == "") { ///Layer is not used. As long as there is no geometry for pachyderm on this layer without object set properties, this is ok. Mat_Layer.Add(null); Scat_Layer.Add(null); Trans_Layer.Add(null); continue; } double[] Abs = new double[8], Scat = new double[8], Trans = new double[8]; Pachyderm_Acoustic.UI.PachydermAc_PlugIn.DecodeAcoustics(spec, ref Abs, ref Scat, ref Trans); Mat_Layer.Add(new Environment.Basic_Material(Abs, new double[8] { 0, 0, 0, 0, 0, 0, 0, 0 })); Scat_Layer.Add(new Environment.Lambert_Scattering(Scat, SplitRatio)); Trans_Layer.Add(Trans); } } for (int q = 0; q <= ObjectList.Count - 1; q++) { List<Brep> B = new List<Brep>(); if (ObjectList[q].ObjectType == Rhino.DocObjects.ObjectType.Brep) { Rhino.DocObjects.BrepObject BObj = ((Rhino.DocObjects.BrepObject)ObjectList[q]); B.Add(BObj.BrepGeometry.DuplicateBrep()); //string m = ObjectList[q].Geometry.GetUserString("Acoustics_User"); if (ObjectList[q].Geometry.GetUserString("Acoustics_User") == "yes") { double[] ABS = new double[8], SCAT = new double[8], TRANS = new double[8]; Pachyderm_Acoustic.UI.PachydermAc_PlugIn.DecodeAcoustics(ObjectList[q].Geometry.GetUserString("Acoustics"), ref ABS, ref SCAT, ref TRANS); Mat_Obj.Add(new Basic_Material(ABS, new double[] { 0, 0, 0, 0, 0, 0, 0, 0 })); Finite_Obj.Add(false); Scat_Obj.Add(new Lambert_Scattering(SCAT, SplitRatio)); Trans_Obj.Add(TRANS); } else { //Rhino.DocObjects.Layer Layer = Rhino.RhinoDoc.ActiveDoc.Layers[ObjectList[q].Attributes.LayerIndex]; //AcousticsData.Add(Layer.GetUserString("Acoustics")); Mat_Obj.Add(Mat_Layer[ObjectList[q].Attributes.LayerIndex]); Scat_Obj.Add(Scat_Layer[ObjectList[q].Attributes.LayerIndex]); Trans_Obj.Add(Trans_Layer[ObjectList[q].Attributes.LayerIndex]); Finite_Obj.Add(Finite_Layers[ObjectList[q].Attributes.LayerIndex]); } } else if (ObjectList[q].ObjectType == Rhino.DocObjects.ObjectType.Extrusion) { Rhino.Geometry.Brep BObj = ((Rhino.DocObjects.ExtrusionObject)ObjectList[q]).ExtrusionGeometry.ToBrep(); for (int i = 0; i < BObj.Faces.Count; i++) { if (ObjectList[q].Geometry.GetUserString("Acoustics_User") == "yes") { //AcousticsData.Add(ObjectList[q].Geometry.GetUserString("Acoustics")); double[] ABS = new double[8], SCAT = new double[8], TRANS = new double[8]; Pachyderm_Acoustic.UI.PachydermAc_PlugIn.DecodeAcoustics(ObjectList[q].Geometry.GetUserString("Acoustics"), ref ABS, ref SCAT, ref TRANS); Mat_Obj.Add(new Basic_Material(ABS, new double[] { 0, 0, 0, 0, 0, 0, 0, 0 })); Scat_Obj.Add(new Lambert_Scattering(SCAT, SplitRatio)); Trans_Obj.Add(TRANS); Finite_Obj.Add(false); } else { //Rhino.DocObjects.Layer Layer = Rhino.RhinoDoc.ActiveDoc.Layers[ObjectList[q].Attributes.LayerIndex]; //AcousticsData.Add(Layer.GetUserString("Acoustics")); //Rhino.DocObjects.Layer Layer = Rhino.RhinoDoc.ActiveDoc.Layers[ObjectList[q].Attributes.LayerIndex]; //AcousticsData.Add(Layer.GetUserString("Acoustics")); Mat_Obj.Add(Mat_Layer[ObjectList[q].Attributes.LayerIndex]); Scat_Obj.Add(Scat_Layer[ObjectList[q].Attributes.LayerIndex]); Trans_Obj.Add(Trans_Layer[ObjectList[q].Attributes.LayerIndex]); Finite_Obj.Add(Finite_Layers[ObjectList[q].Attributes.LayerIndex]); } //B.Add(BObj.Faces[0].ToBrep()); //for (int i = 1; i < BObj.Faces.Count; i++) //{ // if (ObjectList[q].Geometry.GetUserString("Acoustics_User") == "yes") // { // AcousticsData.Add(ObjectList[q].Geometry.GetUserString("Acoustics")); // } // else // { // Rhino.DocObjects.Layer Layer = Rhino.RhinoDoc.ActiveDoc.Layers[ObjectList[q].Attributes.LayerIndex]; // AcousticsData.Add(Layer.GetUserString("Acoustics")); // } B.Add(BObj.Faces[i].ToBrep()); } } else { continue; } BList.AddRange(B); } //////////////////////////////////////// Topo = new Hare.Geometry.Topology[1]; Topo[0] = new Topology(Utilities.PachTools.RPttoHPt(Box.Min), Utilities.PachTools.RPttoHPt(Box.Max)); //////////////////////////////////////// for (int q = 0; q < BList.Count; q++) { for (int r = 0; r < ((Brep)BList[q]).Faces.Count; r++) { BrepList.Add(((Brep)BList[q]).Faces[r].DuplicateFace(false)); //Material Abs = null ; //Scattering Scat = null; //double[] Transparency = new double[8]; double[] Transmission = new double[8]; //double[] Scat = new double[8]; //if (!string.IsNullOrEmpty(AcousticsData[q])) //if (Mat_Obj[q] != null) //{ // //double[] Absorption = new double[8]; // //double[] phase = new double[8]; // //double[] Scattering = new double[8]; // ////double[,] Scattering = new double[8, 3]; // //double[] Reflection = new double[8]; // //UI.PachydermAc_PlugIn.DecodeAcoustics(AcousticsData[q], ref Absorption, ref Scattering, ref Transparency); // Abs = Mat_Obj[q]; // Scat = Scat_Obj[q]; // Transmission = Trans_Obj[q]; //} //else if ((Mat_Obj[q] == null) || (Scat_Obj[q] == null) || (Trans_Obj[q] == null)) { if (!Custom_Method) { Status = System.Windows.Forms.MessageBox.Show("A material is not specified correctly. Please assign absorption and scattering to all layers in the model.", "Materials Error", System.Windows.Forms.MessageBoxButtons.OK); Complete = false; return; } ///Materials do not need to be specified, as it will not be used for an acoustical simulation... (hopefully...) } //for (int i = 0; i < 8; i++) //{ // Reflection[i] = (1 - Absorption[i]); // Transmission[i] = Transparency[i]; // Scattering[i, 1] = Scat[i]; // double Mod = ((Scattering[i, 1] < (1 - Scattering[i, 1])) ? (Scattering[i, 1] * SplitRatio / 2) : ((1 - Scattering[i, 1]) * SplitRatio / 2)); // Scattering[i, 0] = Scattering[i, 1] - Mod; // Scattering[i, 2] = Scattering[i, 1] + Mod; // phase[i] = 0; //} Mesh[] meshes; MeshingParameters mp = new MeshingParameters(); if (Finite_Obj[q]) { mp.MinimumEdgeLength = 0.1; mp.SimplePlanes = false; } else { mp.MinimumEdgeLength = 0.1; mp.SimplePlanes = true; } meshes = Rhino.Geometry.Mesh.CreateFromBrep((Brep)BrepList[BrepList.Count - 1], mp); if (meshes == null) throw new Exception("Problem with meshes"); for (int t = 0; t < meshes.Length; t++) { if (meshes[t].Faces.Count < 1) { Status = System.Windows.Forms.MessageBox.Show("A surface in the model does not generate a rendermesh. This surface will not be represented in the simulation. It is recommended that you cancel this simulation and repair the affected surface. It can be located in shaded view by finding the surface which generates boundary and isoparm lines, but does not generate a fill. It can sometimes be repaired by running the command 'ShrinkTrimmedSurface'. If this does not work, it will have to be replaced by some means which would generate a proper surface.", "Surface without Rendermesh", System.Windows.Forms.MessageBoxButtons.OKCancel); if (Status == System.Windows.Forms.DialogResult.Cancel) { Complete = false; return; } continue; } for (int u = 0; u < meshes[t].Faces.Count; u++) { Hare.Geometry.Point[] P; if (meshes[t].Faces[u].IsQuad) { P = new Hare.Geometry.Point[4]; Point3f FP = meshes[t].Vertices[meshes[t].Faces[u][0]]; P[0] = new Hare.Geometry.Point(FP.X, FP.Y, FP.Z); FP = meshes[t].Vertices[meshes[t].Faces[u][1]]; P[1] = new Hare.Geometry.Point(FP.X, FP.Y, FP.Z); FP = meshes[t].Vertices[meshes[t].Faces[u][2]]; P[2] = new Hare.Geometry.Point(FP.X, FP.Y, FP.Z); FP = meshes[t].Vertices[meshes[t].Faces[u][3]]; P[3] = new Hare.Geometry.Point(FP.X, FP.Y, FP.Z); } else { P = new Hare.Geometry.Point[3]; Point3f FP = meshes[t].Vertices[meshes[t].Faces[u][0]]; P[0] = new Hare.Geometry.Point(FP.X, FP.Y, FP.Z); FP = meshes[t].Vertices[meshes[t].Faces[u][1]]; P[1] = new Hare.Geometry.Point(FP.X, FP.Y, FP.Z); FP = meshes[t].Vertices[meshes[t].Faces[u][2]]; P[2] = new Hare.Geometry.Point(FP.X, FP.Y, FP.Z); } if (Finite_Obj[q]) { if (!(Mat_Obj[q] is Smart_Material)) throw new Exception("Finite Material must have a Smart_Material..."); Smart_Material mat = Mat_Obj[q] as Smart_Material; AbsorptionData.Add(new Finite_Material(mat, BrepList[q], meshes[t], u, Env_Prop)); } else AbsorptionData.Add(Mat_Obj[q]); ScatteringData.Add(Scat_Obj[q]); TransmissionData.Add(Trans_Obj[q]); bool Trans = false; for (int t_oct = 0; t_oct < 8; t_oct++) { if (Transmission[t_oct] > 0) { Trans = true; break; } } Transmissive.Add(Trans); if (BrepList[BrepList.Count - 1].Faces[t].IsPlanar()) { Topo[0].Add_Polygon(P); Brep_ids.Add(BrepList.Count - 1); } else { Topo[0].Add_Polygon(new Hare.Geometry.Point[3] { P[0], P[1], P[2] }); Brep_ids.Add(BrepList.Count - 1); if (P.Length > 3) { //break this quad into two polygons in order to avoid warping... if (Finite_Obj[q]) { if (!(Mat_Obj[q] is Smart_Material)) throw new Exception("Finite Material must have a Smart_Material..."); Smart_Material mat = Mat_Obj[q] as Smart_Material; AbsorptionData.Add(new Finite_Material(mat, BrepList[q], meshes[t], u, Env_Prop)); } else AbsorptionData.Add(Mat_Obj[q]); ScatteringData.Add(Scat_Obj[q]); TransmissionData.Add(Trans_Obj[q]); Transmissive.Add(Trans); Topo[0].Add_Polygon(new Hare.Geometry.Point[3] { P[0], P[2], P[3] }); Brep_ids.Add(BrepList.Count - 1); } } } } } } //Set up a system to find random points on planes.// Plane_Area = new double[Topo[0].Plane_Members.Length]; PolyPlaneFract = new double[Topo[0].Plane_Members.Length][]; for (int q = 0; q < Topo[0].Plane_Members.Length; q++) { foreach (int t in Topo[0].Plane_Members[q]) { Plane_Area[q] += Topo[0].Polygon_Area(t); } } ////////////////////////// for (int i = 0; i < Topo[0].planeList.Count; i++) for (int j = 0; j < Topo[0].Plane_Members[i].Count; j++) { Point3d pt = Utilities.PachTools.HPttoRPt(Topo[0].Polygon_Centroid(Topo[0].Plane_Members[i][j])); string n = Topo[0].Polys[Topo[0].Plane_Members[i][j]].Plane_ID.ToString(); } ////////////////////////// for (int q = 0; q < Topo[0].Plane_Members.Length; q++) { PolyPlaneFract[q] = new double[Topo[0].Plane_Members[q].Count]; PolyPlaneFract[q][0] = Topo[0].Polygon_Area(Topo[0].Plane_Members[q][0]) / Plane_Area[q]; for (int t = 1; t < Topo[0].Plane_Members[q].Count; t++) { PolyPlaneFract[q][t] += PolyPlaneFract[q][t - 1] + Topo[0].Polygon_Area(Topo[0].Plane_Members[q][t]) / Plane_Area[q]; } } Valid = true; //Utilities.PachTools.Plot_Hare_Topology(Topo[0]); }