private void Calculate_Click(object sender, System.EventArgs e)
            {
                Pach_GetModel_Command Model = new Pach_GetModel_Command();

                Source[] Source;


                if (PachydermAc_PlugIn.Instance.Source(out Source) && !object.ReferenceEquals(FileLocation.SelectedPath, ""))
                {
                    Rhino.RhinoApp.WriteLine("Model geometry not specified... Exiting calculation...");
                }
                ParticleRays[] RTParticles = new ParticleRays[Source.Length];

                Calculate.Enabled = false;
                PachydermAc_PlugIn plugin = PachydermAc_PlugIn.Instance;
                Scene Sc;

                if (PachydermAc_PlugIn.Instance.Geometry_Spec() == 0)
                {
                    Sc = PachTools.Get_NURBS_Scene(0, (double)Air_Temp.Value, 0, 0, false);
                }
                else
                {
                    Sc = PachTools.Get_Poly_Scene(0, (double)Air_Temp.Value, 0, 0, false);
                }

                for (int i = 0; i < Source.Length; i++)
                {
                    if (Source != null)
                    {
                        List <Point3d> L = new List <Point3d>();
                        List <Rhino.Geometry.Point3d> L_RC = new List <Rhino.Geometry.Point3d>();
                        for (int j = 0; j < Source.Length; j++)
                        {
                            L.Add(Source[j].Origin());
                            L_RC.Add(new Rhino.Geometry.Point3d(Source[j].Origin().X, Source[j].Origin().Y, Source[j].Origin().Z));
                        }

                        if (plugin.Geometry_Spec() == 0)
                        {
                            Sc.partition(L_RC, 15);
                            RTParticles[i] = new ParticleRays(Source[i], Sc, (int)RT_Count.Value, CutOffLength());
                        }
                        else if (plugin.Geometry_Spec() == 1)
                        {
                            Sc.partition(L, 15);
                            RTParticles[i] = new ParticleRays(Source[i], Sc, (int)RT_Count.Value, CutOffLength());
                        }
                        RTParticles[i].Begin();
                    }
                    else
                    {
                        Rhino.RhinoApp.WriteLine("Model geometry not specified... Exiting calculation...");
                    }

                    Pachyderm_Acoustic.Visualization.Phonon P;
                    if (ParticleChoice.SelectedIndex == 0)
                    {
                        P = new Tetrahedron();
                    }
                    else if (ParticleChoice.SelectedIndex == 1)
                    {
                        P = new Icosahedron();
                    }
                    else
                    {
                        P = new Geodesic_sphere();
                    }
                    RenderParticles(RTParticles, (double)(Frame_Rate.Value * Seconds.Value), P);
                    Rhino.RhinoDoc.ActiveDoc.Views.Redraw();
                }
                Calculate.Enabled = true;
            }
            private void Calculate_Click(object sender, System.EventArgs e)
            {
                Pach_GetModel_Command Model = new Pach_GetModel_Command();
                Source[] Source;


                if (PachydermAc_PlugIn.Instance.Source(out Source) && !object.ReferenceEquals(FileLocation.SelectedPath, "")) Rhino.RhinoApp.WriteLine("Model geometry not specified... Exiting calculation...");
                ParticleRays[] RTParticles = new ParticleRays[Source.Length];

                Calculate.Enabled = false;
                PachydermAc_PlugIn plugin = PachydermAc_PlugIn.Instance;
                Scene Sc;
                if (PachydermAc_PlugIn.Instance.Geometry_Spec() == 0) Sc = PachTools.Get_NURBS_Scene(0, (double)Air_Temp.Value, 0, 0, false);
                else Sc = PachTools.Get_Poly_Scene(0, (double)Air_Temp.Value, 0, 0, false);
                
                for (int i = 0; i < Source.Length; i++)
                {
                    if (Source != null)
                    {
                        List<Point3d> L = new List<Point3d>();
                        List<Rhino.Geometry.Point3d> L_RC = new List<Rhino.Geometry.Point3d>();
                        for (int j = 0; j < Source.Length; j++)
                        {
                            L.Add(Source[j].Origin());
                            L_RC.Add(new Rhino.Geometry.Point3d(Source[j].Origin().X, Source[j].Origin().Y, Source[j].Origin().Z));
                        }

                        if (plugin.Geometry_Spec() == 0)
                        {
                            Sc.partition(L_RC, 15);
                            RTParticles[i] = new ParticleRays(Source[i], Sc, (int)RT_Count.Value, CutOffLength());
                        }
                        else if (plugin.Geometry_Spec() == 1)
                        {
                            Sc.partition(L, 15);
                            RTParticles[i] = new ParticleRays(Source[i], Sc, (int)RT_Count.Value, CutOffLength());
                        }
                        RTParticles[i].Begin();
                    }
                    else
                    {
                        Rhino.RhinoApp.WriteLine("Model geometry not specified... Exiting calculation...");
                    }

                    Pachyderm_Acoustic.Visualization.Phonon P;
                    if (ParticleChoice.SelectedIndex == 0)
                    { P = new Tetrahedron(); }
                    else if (ParticleChoice.SelectedIndex == 1)
                    {
                        P = new Icosahedron();
                    }
                    else { P = new Geodesic_sphere(); }
                    RenderParticles(RTParticles, (double)(Frame_Rate.Value * Seconds.Value), P);
                    Rhino.RhinoDoc.ActiveDoc.Views.Redraw();
                }
                Calculate.Enabled = true;
            }