public static Hare.Geometry.Topology Rhino_to_HareMesh(Mesh M)
            {
                Hare.Geometry.Point[][] polys = new Hare.Geometry.Point[M.Faces.Count][];

                for (int i = 0; i < M.Faces.Count; i++)
                {
                    Hare.Geometry.Point[] pts;
                    if (M.Faces[i].IsTriangle)
                    {
                        pts    = new Hare.Geometry.Point[3];
                        pts[0] = RPttoHPt(M.Vertices[M.Faces[i].A]);
                        pts[1] = RPttoHPt(M.Vertices[M.Faces[i].B]);
                        pts[2] = RPttoHPt(M.Vertices[M.Faces[i].C]);
                    }
                    else
                    {
                        pts    = new Hare.Geometry.Point[4];
                        pts[0] = RPttoHPt(M.Vertices[M.Faces[i].A]);
                        pts[1] = RPttoHPt(M.Vertices[M.Faces[i].B]);
                        pts[2] = RPttoHPt(M.Vertices[M.Faces[i].C]);
                        pts[3] = RPttoHPt(M.Vertices[M.Faces[i].D]);
                    }
                    polys[i] = pts;
                }

                Hare.Geometry.Topology HM = new Hare.Geometry.Topology(polys);
                HM.Finish_Topology(new List <Hare.Geometry.Point>());
                return(HM);
            }
コード例 #2
0
 public Hare.Geometry.Topology Output(IEnumerable <double> magnitude, double Min, double Max, double Diameter)
 {
     if (magnitude.Count() != Vertices.Length)
     {
         throw new Exception("Invalid data input to spherical plot...");
     }
     Hare.Geometry.Point[] points = new Hare.Geometry.Point[Vertices.Length];
     for (int i = 0; i < magnitude.Count(); i++)
     {
         double mag = (magnitude.ElementAt(i));
         if (double.IsInfinity(mag))
         {
             mag = 0;
         }
         mag       = Math.Max(mag, Min);
         mag       = Math.Min(mag, Max);
         mag      -= Min;
         mag      /= (Max - Min) * Diameter;
         points[i] = mag * Vertices[i];
     }
     Hare.Geometry.Topology T = new Hare.Geometry.Topology();
     T.Set_Topology(points, Faces.ToArray());
     T.Finish_Topology();
     return(T);
 }
            public static void Plot_Hare_Topology(Hare.Geometry.Topology T)
            {
                Mesh m_RhinoMesh = Hare_to_RhinoMesh(T, true);

                m_RhinoMesh.FaceNormals.ComputeFaceNormals();
                m_RhinoMesh.Normals.ComputeNormals();
                Rhino.RhinoDoc.ActiveDoc.Objects.Add(m_RhinoMesh);
            }
            public static Mesh Hare_to_RhinoMesh(Hare.Geometry.Topology T, bool welded)
            {
                Mesh m_RhinoMesh = new Mesh();
                int  ct          = 0;

                if (welded)
                {
                    for (int j = 0; j < T.Vertex_Count; j++)
                    {
                        m_RhinoMesh.Vertices.Add(Utilities.RC_PachTools.HPttoRPt(T[j]));
                    }
                    for (int j = 0; j < T.Polygon_Count; j++)
                    {
                        if (T.Polys[j].Points.Count() == 3)
                        {
                            m_RhinoMesh.Faces.AddFace(T.Polys[j].Points[0].index, T.Polys[j].Points[1].index, T.Polys[j].Points[2].index);
                        }
                        else if (T.Polys[j].Points.Count() == 4)
                        {
                            m_RhinoMesh.Faces.AddFace(T.Polys[j].Points[0].index, T.Polys[j].Points[1].index, T.Polys[j].Points[2].index, T.Polys[j].Points[3].index);
                        }
                        else
                        {
                            throw new Exception("Faces of more than 4 vertices not supported...");
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < T.Polygon_Count; i++)
                    {
                        Hare.Geometry.Point[] Pt = T.Polygon_Vertices(i);
                        int[] F = new int[T.Polys[i].VertextCT];
                        for (int j = 0; j < T.Polys[i].VertextCT; j++)
                        {
                            m_RhinoMesh.Vertices.Add(new Point3d(Pt[j].x, Pt[j].y, Pt[j].z));
                            F[j] = ct;
                            ct++;
                        }
                        if (F.Length == 3)
                        {
                            m_RhinoMesh.Faces.AddFace(F[2], F[1], F[0]);
                        }
                        else
                        {
                            m_RhinoMesh.Faces.AddFace(F[2], F[1], F[0], F[3]);
                        }
                    }
                }
                m_RhinoMesh.Normals.ComputeNormals();

                return(m_RhinoMesh);
            }
コード例 #5
0
            /// <summary>
            /// reads a file and populates the map receiver instance.
            /// </summary>
            /// <returns></returns>
            public static bool Read_pachm(string path, ref PachMapReceiver[] Map)
            {
                System.IO.BinaryReader sr = new System.IO.BinaryReader(System.IO.File.Open(path, System.IO.FileMode.Open));
                //1. Write calculation type. (string)
                string CalcType = sr.ReadString();

                if (CalcType != "Type;Map_Data" && CalcType != "Type;Map_Data_NoDir")
                {
                    throw new Exception("Map Data File Expected");
                }
                bool Directional = (CalcType == "Type;Map_Data");

                //2. Write the number of samples in each histogram. (int)
                int SampleCT = (int)sr.ReadUInt32();
                //3. Write the sample rate. (int)
                int SampleRate = (int)sr.ReadUInt32();
                //4. Write the number of Receivers (int)
                int Rec_CT = (int)sr.ReadUInt32();
                //4.5 Write the version number
                double version = 1.1;
                double rev     = 0;
                //5. Announce that the following data pertains to the form of the analysis mesh. (string)
                int s_ct = 1;

                Hare.Geometry.Topology Map_Mesh = new Hare.Geometry.Topology();
                Map    = new PachMapReceiver[1];
                Map[0] = new PachMapReceiver();
                //double[] Rho_C = null;

                double[] delay;

                do
                {
                    switch (sr.ReadString())
                    {
                    case "Version":
                        //Pach1.7 = Versioning functionality added.
                        string v = sr.ReadString();
                        version = double.Parse(v.Substring(0, 3));
                        rev     = int.Parse(v.Split(new char[1] {
                            '.'
                        })[3]);
                        break;

                    case "Mesh Information":
                        //6. Announce Mesh Vertices (string)
                        //Write the number of vertices & faces (int) (int)
                        if (sr.ReadString() != "Mesh Vertices")
                        {
                            throw new Exception("Mesh Vertices Expected");
                        }

                        int VC = (int)sr.ReadUInt32();
                        int FC = (int)sr.ReadUInt32();

                        Hare.Geometry.Point[] Vertices = new Hare.Geometry.Point[VC];

                        for (int i = 0; i < VC; i++)
                        {
                            //Write Vertex: (double) (double) (double)
                            //Map_Mesh.Vertices.Add(new Rhino.Geometry.Point3d(sr.ReadSingle(), sr.ReadSingle(), sr.ReadSingle()));
                            Vertices[i] = new Hare.Geometry.Point(sr.ReadDouble(), sr.ReadDouble(), sr.ReadDouble());
                        }

                        //7. Announce Mesh Faces (string)
                        if (sr.ReadString() != "Mesh Faces")
                        {
                            throw new Exception("Mesh Faces Expected");
                        }

                        Hare.Geometry.Point[][] Polys = new Hare.Geometry.Point[FC][];
                        for (int i = 0; i < FC; i++)
                        {
                            // Write mesh vertex indices: (int) (int) (int) (int)
                            int F0 = (int)sr.ReadUInt32(), F1 = (int)sr.ReadUInt32(), F2 = (int)sr.ReadUInt32(), F3 = (int)sr.ReadUInt32();

                            if (F2 == F3)
                            {
                                Polys[i] = new Hare.Geometry.Point[3] {
                                    Vertices[F0], Vertices[F1], Vertices[F2]
                                }
                            }
                            ;                                                                                                  // Map_Mesh.Faces.AddFace(F0, F1, f2);
                            else
                            {
                                Polys[i] = new Hare.Geometry.Point[4] {
                                    Vertices[F0], Vertices[F1], Vertices[F2], Vertices[F3]
                                }
                            };                                                                                                        //Map_Mesh.Faces.AddFace(F0, F1, f2, F3);
                        }

                        Map_Mesh = new Hare.Geometry.Topology(Polys);
                        break;

                    case "Sources":
                        //7.5: Announce the number of sources.
                        s_ct  = sr.ReadInt32();
                        delay = new double[s_ct];
                        Map   = new PachMapReceiver[s_ct];
                        //7.5a Announce the type of source.

                        for (int s = 0; s < s_ct; s++)
                        {
                            Map[s]            = new PachMapReceiver();
                            Map[s].CutOffTime = (double)SampleCT / (double)SampleRate;
                            Map[s].SampleCT   = SampleCT;
                            Map[s].SampleRate = SampleRate;
                            Map[s].Map_Mesh   = Map_Mesh;
                            Map[s].Rec_List   = new PachMapReceiver.Map_Receiver[Rec_CT];
                            Map[s].SrcType    = sr.ReadString();
                            //4.4 Source delay (ms)
                            if (version > 2.0 || (version == 2.0 && rev >= 1))
                            {
                                delay[s] = sr.ReadDouble();
                            }
                        }
                        break;

                    case "SourceswLoc":
                        //7.5: Announce the number of sources.
                        s_ct  = sr.ReadInt32();
                        delay = new double[s_ct];
                        Map   = new PachMapReceiver[s_ct];
                        //7.5a Announce the type of source.

                        for (int s = 0; s < s_ct; s++)
                        {
                            Map[s]            = new PachMapReceiver();
                            Map[s].CutOffTime = (double)SampleCT / (double)SampleRate * 1000;
                            Map[s].SampleCT   = SampleCT;
                            Map[s].SampleRate = SampleRate;
                            Map[s].Map_Mesh   = Map_Mesh;
                            Map[s].Rec_List   = new PachMapReceiver.Map_Receiver[Rec_CT];
                            Map[s].Src        = new Hare.Geometry.Point(sr.ReadDouble(), sr.ReadDouble(), sr.ReadDouble());
                            Map[s].SrcType    = sr.ReadString();
                            //4.4 Source delay (ms)
                            if (version > 2.0 || (version == 2.0 && rev >= 1))
                            {
                                delay[s] = sr.ReadDouble();
                            }
                        }
                        break;

                    case "Receiver Hit Data":
                        if (Map[0] == null)
                        {
                            Map               = new PachMapReceiver[1];
                            Map[0]            = new PachMapReceiver();
                            Map[0].CutOffTime = (double)SampleCT / (double)SampleRate;
                            Map[0].SampleRate = SampleRate;
                            Map[0].SampleCT   = SampleCT;
                            Map[0].Map_Mesh   = Map_Mesh;
                            Map[0].Rec_List   = new PachMapReceiver.Map_Receiver[Rec_CT];
                            Map[0].SrcType    = "Geodesic";
                        }

                        //8. Announce that the following data pertains to the receiver histograms (string)
                        //8a. Announce whether or not data is linked to vertices rather than faces (bool)
                        bool vert_Receiver = sr.ReadBoolean();
                        for (int s = 0; s < s_ct; s++)
                        {
                            Map[s].Rec_Vertex = vert_Receiver;
                            for (int i = 0; i < Map[s].Rec_List.Length; i++)
                            {
                                //for version 1.7 and up, write direct sound arrival time.
                                //Write Receiver Index (int)
                                int j = (int)sr.ReadUInt32();
                                //Write Direct Sound Arrival Time.
                                double Direct_Time;
                                if (version >= 1.7)
                                {
                                    Direct_Time = sr.ReadDouble();
                                }
                                else
                                {
                                    Direct_Time = (Map[s].Src - Map[s].Rec_List[i].Origin).Length() / 343f;
                                }
                                //Write Impedance of Air
                                double Rho_C = version >= 2.0 ? sr.ReadDouble() : 400;

                                if (vert_Receiver)
                                {
                                    Map[s].Rec_List[i] = new PachMapReceiver.Map_Receiver(Map_Mesh[i], Map[s].Src, Direct_Time, Rho_C, i, SampleRate, SampleCT, Directional);
                                }
                                else
                                {
                                    Hare.Geometry.Point RecLoc = Map_Mesh.Polys[i].Points[0] + Map_Mesh.Polys[i].Points[1] + Map_Mesh.Polys[i].Points[2];
                                    if (Map_Mesh.Polys[i].VertextCT > 3)
                                    {
                                        RecLoc += Map_Mesh.Polys[i].Points[3];
                                        RecLoc /= 4;
                                    }
                                    else
                                    {
                                        RecLoc /= 3;
                                    }
                                    Map[s].Rec_List[i] = new PachMapReceiver.Map_Receiver(RecLoc, Map[s].Src, Direct_Time, Rho_C, i, SampleRate, SampleCT, Directional);
                                }

                                for (int Octave = 0; Octave < 8; Octave++)
                                {
                                    //Write Octave (int)
                                    int Oct_out = (int)sr.ReadUInt32();
                                    if (Oct_out != Octave)
                                    {
                                        throw new Exception(string.Format("Octave {0} Expected", Octave));
                                    }
                                    double[] Hist = Map[s].Rec_List[i].GetEnergyHistogram(Octave);
                                    if (Directional)
                                    {
                                        if (version < 1.7)
                                        {
                                            for (int e = 0; e < SampleCT; e++)
                                            {
                                                Map[s].Rec_List[i].Combine_Sample(e, sr.ReadDouble(), new Hare.Geometry.Vector(sr.ReadSingle(), sr.ReadSingle(), sr.ReadSingle()), new Hare.Geometry.Vector(sr.ReadSingle(), sr.ReadSingle(), sr.ReadSingle()), Octave);
                                            }
                                        }
                                        else
                                        {
                                            for (int e = 0; e < SampleCT; e++)
                                            {
                                                Map[s].Rec_List[i].Combine_Sample(e, sr.ReadDouble(), new Hare.Geometry.Vector(sr.ReadSingle(), sr.ReadSingle(), sr.ReadSingle()), new Hare.Geometry.Vector(sr.ReadSingle(), sr.ReadSingle(), sr.ReadSingle()), Octave);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (version < 1.7)
                                        {
                                            for (int e = 0; e < SampleCT; e++)
                                            {
                                                Map[s].Rec_List[i].Combine_Sample(e, sr.ReadDouble(), new Hare.Geometry.Vector(0, 0, 0), new Hare.Geometry.Vector(0, 0, 0), Octave);
                                            }
                                        }
                                        else
                                        {
                                            for (int e = 0; e < SampleCT; e++)
                                            {
                                                Map[s].Rec_List[i].Combine_Sample(e, sr.ReadDouble(), new Hare.Geometry.Vector(0, 0, 0), new Hare.Geometry.Vector(0, 0, 0), Octave);
                                            }
                                        }
                                    }
                                }
                                if (sr.ReadString() != "End_Receiver_Hits")
                                {
                                    throw new Exception("End of Receiver Hits Expected");
                                }
                            }
                        }
                        break;

                    case "End_of_File":
                        sr.Close();
                        return(true);
                    }
                } while (true);
                throw new Exception("Unsuccessful Read");
            }
コード例 #6
0
            private void Construct(List<GeometryBase> Breps, List<int> LayerIds)
            {
                BoundingBox Box = Breps[0].GetBoundingBox(true);
                for (int i = 1; i < Breps.Count; i++) Box.Union(Breps[i].GetBoundingBox(true));

                List<Brep> BList = new List<Brep>();
                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[]>();
                //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")
                    {
                        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
                    {
                        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 <= Breps.Count - 1; q++)
                {
                    List<Brep> B = new List<Brep>();
                    if (Breps[q].ObjectType == Rhino.DocObjects.ObjectType.Brep || Breps[q].ObjectType == Rhino.DocObjects.ObjectType.Surface)
                    {
                        //string m = ObjectList[q].Geometry.GetUserString("Acoustics_User");

                        if (Breps[q].ObjectType == Rhino.DocObjects.ObjectType.Surface) B.Add((Breps[q] as Surface).ToBrep());
                        else B.Add(((Rhino.Geometry.Brep)Breps[q]).DuplicateBrep());

                        if (Breps[q].GetUserString("Acoustics_User") == "yes")
                        {
                            double[] ABS = new double[8], SCAT = new double[8], TRANS = new double[8];
                            Pachyderm_Acoustic.UI.PachydermAc_PlugIn.DecodeAcoustics(Breps[q].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);
                        }
                        else
                        {
                            //Rhino.DocObjects.Layer Layer = Rhino.RhinoDoc.ActiveDoc.Layers[ObjectList[q].Attributes.LayerIndex];
                            //AcousticsData.Add(Layer.GetUserString("Acoustics"));
                            if (Mat_Layer[LayerIds[q]] == null) hasnulllayers = true;

                            Mat_Obj.Add(Mat_Layer[LayerIds[q]]);
                            Scat_Obj.Add(Scat_Layer[LayerIds[q]]);
                            Trans_Obj.Add(Trans_Layer[LayerIds[q]]);
                        }
                    }
                    else if (Breps[q].ObjectType == Rhino.DocObjects.ObjectType.Extrusion)
                    {
                        Rhino.Geometry.Brep BObj = ((Rhino.Geometry.Extrusion)Breps[q]).ToBrep();
                        for (int i = 0; i < BObj.Faces.Count; i++)
                        {
                            if (Breps[q].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(Breps[q].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);
                            }
                            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"));
                                if (Mat_Layer[LayerIds[q]] == null) hasnulllayers = true;

                                Mat_Obj.Add(Mat_Layer[LayerIds[q]]);
                                Scat_Obj.Add(Scat_Layer[LayerIds[q]]);
                                Trans_Obj.Add(Trans_Layer[LayerIds[q]]);
                            }

                            //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 Hare.Geometry.Topology(Utilities.PachTools.RPttoHPt(Box.Min), Utilities.PachTools.RPttoHPt(Box.Max));
                ////////////////////////////////////////
                for (int q = 0; q < BList.Count; q++)
                {
                    BrepList.Add(BList[q]);

                    //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();
                    mp.MinimumEdgeLength = 0.1;
                    mp.MaximumEdgeLength = 1;
                    //mp.SimplePlanes = true;
                    meshes = Rhino.Geometry.Mesh.CreateFromBrep(BList[q], MeshingParameters.Smooth);
                    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);
                            }

                            //ReflectionData.Add(Reflection);
                            AbsorptionData.Add(Mat_Obj[q]);
                            ScatteringData.Add(Scat_Obj[q]);
                            TransmissionData.Add(Trans_Obj[q]);
                            //PhaseData.Add(phase);

                            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[q].Faces[t].IsPlanar())
                            {
                                Topo[0].Add_Polygon(P);
                                Brep_ids.Add(q);
                            }
                            else
                            {
                                Topo[0].Add_Polygon(new Hare.Geometry.Point[3] { P[0], P[1], P[2] });
                                Brep_ids.Add(q);
                                if (P.Length > 3)
                                {//ReflectionData.Add(Reflection);
                                    AbsorptionData.Add(Mat_Obj[q]);
                                    ScatteringData.Add(Scat_Obj[q]);
                                    TransmissionData.Add(Trans_Obj[q]);
                                    Transmissive.Add(Trans);
                                    //PhaseData.Add(phase);
                                    Topo[0].Add_Polygon(new Hare.Geometry.Point[3] { P[0], P[2], P[3] });
                                    Brep_ids.Add(q);
                                }
                            }
                        }
                    }
                }

                //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];
                    }
                }
                ////////////////////////////////////////////////////
                //Determine whether or not the room is a closed volume...
                IsContained = Utilities.AcousticalMath.RoomVolume(BrepList, ref Volume, out Area);
                ////////////////////////////////////////////////////
                Valid = true;
                Rhino.RhinoDoc.ActiveDoc.Objects.Add(Utilities.PachTools.Hare_to_RhinoMesh(Topo[0]));
            }