public Speaker_Balloon(string[] Ballooncode_in, string SWL_in, int Type_in, Hare.Geometry.Point Center)//int sym_in,
        {
            code = Ballooncode_in;
            Type = Type_in;
            if (SWL_in != "" || SWL_in != null)
            {
                SWL = SWL_in;
            }
            else
            {
                SWL_in = "120; 120; 120; 120; 120; 120; 120; 120";
            }
            string[] swl        = SWL.Split(';');
            double[] swl_values = new double[8];

            Vector upper = new Vector(0, 1, 0);

            int umax, vmax;

            switch (Type)
            {
            case 0:
                umax = 19;
                vmax = 36;
                break;

            case 1:
                umax = 37;
                vmax = 72;
                break;

            default:
                throw new Exception();
            }

            m_HareMesh = new Topology[8];
            for (int oct = 1; oct < 9; oct++)
            {
                string[] values;
                swl_values[oct - 1] = double.Parse(swl[oct - 1]);
                if (code[oct - 1] != "")
                {
                    values = code[oct - 1].Split(';');
                }
                else
                {
                    values = new string[umax * vmax];
                    for (int i = 0; i < values.Length; i++)
                    {
                        values[i] = "0";
                    }
                }

                Vector[,] Magnitude = new Vector[umax, vmax];
                double Theta, Phi;
                int    idx = 0;

                for (int v = 0; v < vmax; v++)
                {
                    for (int u = 0; u < umax; u++)
                    {
                        if (double.IsInfinity(swl_values[oct - 1]) || double.IsNaN(swl_values[oct - 1]))
                        {
                            Magnitude[u, v] = new Vector();
                        }
                        else
                        {
                            Theta           = u * System.Math.PI / (umax - 1);
                            Phi             = 2 * v * System.Math.PI / (vmax) + System.Math.PI / 2;
                            Magnitude[u, v] = new Vector(Math.Sin(Theta) * Math.Cos(Phi), Math.Cos(Theta), Math.Sin(Theta) * Math.Sin(Phi));
                            Magnitude[u, v].Normalize();
                            double swlmag = (double.Parse(values[idx]) + 60);
                            if (swlmag < 0)
                            {
                                swlmag = 0;
                            }
                            Magnitude[u, v] *= swlmag;
                        }
                        idx++;
                    }
                }

                //Create a mesh of the points...
                List <Hare.Geometry.Point[]> list = new List <Hare.Geometry.Point[]>();
                double Minx = double.MaxValue, Miny = double.MaxValue, Minz = double.MaxValue, Maxx = double.MinValue, Maxy = double.MinValue, Maxz = double.MinValue;

                for (int u = 0; u < umax - 1; u++)
                {
                    for (int v = 0; v < vmax; v++)
                    {
                        Hare.Geometry.Point[] Poly = new Hare.Geometry.Point[4];
                        Poly[0] = Magnitude[u, v];
                        Poly[1] = Magnitude[u, (v + 1) % vmax];
                        Poly[2] = Magnitude[u + 1, (v + 1) % vmax];
                        Poly[3] = Magnitude[u + 1, v];
                        list.Add(Poly);

                        foreach (Hare.Geometry.Point p in Poly)
                        {
                            if (p.x < Minx)
                            {
                                Minx = p.x;
                            }
                            if (p.y < Miny)
                            {
                                Miny = p.y;
                            }
                            if (p.z < Minz)
                            {
                                Minz = p.z;
                            }
                            if (p.x > Maxx)
                            {
                                Maxx = p.x;
                            }
                            if (p.y > Maxy)
                            {
                                Maxy = p.y;
                            }
                            if (p.z > Maxz)
                            {
                                Maxz = p.z;
                            }
                        }
                    }
                }

                m_HareMesh[oct - 1] = new Topology(new Hare.Geometry.Point(Minx, Miny, Minz), new Hare.Geometry.Point(Maxx, Maxy, Maxz));
                foreach (Hare.Geometry.Point[] Poly in list)
                {
                    m_HareMesh[oct - 1].Add_Polygon(Poly);
                }
                if (oct == 4)
                {
                    m_DisplayMesh = new Topology(new Hare.Geometry.Point(Minx, Miny, Minz), new Hare.Geometry.Point(Maxx, Maxy, Maxz));
                    foreach (Hare.Geometry.Point[] Poly in list)
                    {
                        m_DisplayMesh.Add_Polygon(Poly);
                    }
                }
            }
            Update_Position(Center);
        }
        public Balloon(string[] ballooncodes, Hare.Geometry.Point Center) //, double[] SWL
        {
            string[][][] balloons = new string[8][][];
            Code = ballooncodes;

            int minstable = 8;

            for (int oct = 0; oct < 8; oct++)
            {
                if (ballooncodes[oct] == null)
                {
                    continue;
                }
                minstable = Math.Min(minstable, oct);
                string[] lines = ballooncodes[oct].Split(new char[1] {
                    ';'
                }, StringSplitOptions.RemoveEmptyEntries);
                balloons[oct] = new string[lines.Length][];
                for (int i = 0; i < lines.Length; i++)
                {
                    balloons[oct][i] = lines[i].Split(new char[1] {
                        ' '
                    }, StringSplitOptions.RemoveEmptyEntries);
                }
            }

            int umax, vmax;

            if (balloons[minstable][0].Length == 19) //[36].Count == 36 || balloons[4].Count == 19 || balloons[4].Count == 10)
            {
                Type = 0;
                umax = 19;
                vmax = 36;
            }
            else if (balloons[minstable][0].Length == 37)//[72].Count == 72 || balloons[4].Count == 37 || balloons[4].Count == 19)
            {
                Type = 1;
                umax = 37;
                vmax = 72;
            }
            else
            {
                throw new Exception("Balloon Resolution - the number of samples in the balloon is non-standard. This is not supported in Pachyderm at this time...");
            }

            for (int oct = 0; oct < 8; oct++)
            {
                if (balloons[oct] == null)
                {
                    balloons[oct] = new string[vmax][];
                    for (int v = 0; v < vmax; v++)
                    {
                        balloons[oct][v] = new string[umax];
                        for (int u = 0; u < umax; u++)
                        {
                            balloons[oct][v][u] = "40";
                        }
                    }
                }
            }

            m_HareMesh = new Topology[8];
            for (int oct = 0; oct < 8; oct++)
            {
                Vector[,] Magnitude = new Vector[umax, vmax];
                double[,] mag       = new double[umax, vmax];
                double Theta, Phi;
                //int idx = 0;

                for (int v = 0; v < balloons[oct].Length; v++)
                {
                    for (int u = 0; u < balloons[oct][v].Length; u++)
                    {
                        Theta           = u * System.Math.PI / (umax - 1);
                        Phi             = 2 * v * System.Math.PI / (vmax) + System.Math.PI / 2;
                        Magnitude[u, v] = new Vector(Math.Sin(Theta) * Math.Cos(Phi), Math.Cos(Theta), Math.Sin(Theta) * Math.Sin(Phi));
                        Magnitude[u, v].Normalize();

                        double swlmag = (-double.Parse(balloons[oct][v][u]) + 60);
                        if (swlmag < 0)
                        {
                            swlmag = 0;
                        }
                        Magnitude[u, v] *= swlmag;
                        mag[u, v]        = swlmag;

                        if (balloons[oct].Length == vmax / 4 + 1)    //Quarter data
                        {
                            int v_2 = vmax / 2 + 1;
                            Magnitude[(vmax - u) % vmax, v] = Magnitude[u, v];
                            Magnitude[v_2 - u, v]           = Magnitude[u, v];
                            Magnitude[v_2 + u, v]           = Magnitude[u, v];
                            mag[(vmax - u) % 36, v]         = mag[u, v];
                            mag[v_2 - u, v] = mag[u, v];
                            mag[v_2 + u, v] = mag[u, v];
                        }
                        if (balloons[oct].Length == vmax / 2 + 1)    //Half data
                        {
                            Magnitude[(vmax - u) % vmax, v] = Magnitude[u, v];
                            mag[(vmax - u) % vmax, v]       = mag[u, v];
                        }
                    }
                }

                if (Code[oct] == null)
                {
                    Code[oct] = "";
                    for (int v = 0; v < balloons[oct].Length; v++)
                    {
                        for (int u = 0; u < balloons[oct][v].Length; u++)
                        {
                            Code[oct] += "0.0 ";
                        }
                        Code[oct] += ';';
                    }
                }
                //Create a mesh of the points...
                List <Hare.Geometry.Point[]> list = new List <Hare.Geometry.Point[]>();
                double Minx = double.MaxValue, Miny = double.MaxValue, Minz = double.MaxValue, Maxx = double.MinValue, Maxy = double.MinValue, Maxz = double.MinValue;

                for (int u = 0; u < umax - 1; u++)
                {
                    for (int v = 0; v < vmax; v++)
                    {
                        Hare.Geometry.Point[] Poly = new Hare.Geometry.Point[4];
                        Poly[0] = new Hare.Geometry.Point(Magnitude[u, v].x, Magnitude[u, v].y, Magnitude[u, v].z);
                        Poly[1] = new Hare.Geometry.Point(Magnitude[u, (v + 1) % vmax].x, Magnitude[u, (v + 1) % vmax].y, Magnitude[u, (v + 1) % vmax].z);
                        Poly[2] = new Hare.Geometry.Point(Magnitude[u + 1, (v + 1) % vmax].x, Magnitude[u + 1, (v + 1) % vmax].y, Magnitude[u + 1, (v + 1) % vmax].z);
                        Poly[3] = new Hare.Geometry.Point(Magnitude[u + 1, v].x, Magnitude[u + 1, v].y, Magnitude[u + 1, v].z);
                        list.Add(Poly);

                        foreach (Hare.Geometry.Point p in Poly)
                        {
                            if (p.x < Minx)
                            {
                                Minx = p.x;
                            }
                            if (p.y < Miny)
                            {
                                Miny = p.y;
                            }
                            if (p.z < Minz)
                            {
                                Minz = p.z;
                            }
                            if (p.x > Maxx)
                            {
                                Maxx = p.x;
                            }
                            if (p.y > Maxy)
                            {
                                Maxy = p.y;
                            }
                            if (p.z > Maxz)
                            {
                                Maxz = p.z;
                            }
                        }
                    }
                }

                m_HareMesh[oct] = new Topology(new Hare.Geometry.Point(Minx, Miny, Minz), new Hare.Geometry.Point(Maxx, Maxy, Maxz));
                foreach (Hare.Geometry.Point[] Poly in list)
                {
                    m_HareMesh[oct].Add_Polygon(Poly);
                }
                if (oct == 4)
                {
                    m_DisplayMesh = new Topology(new Hare.Geometry.Point(Minx, Miny, Minz), new Hare.Geometry.Point(Maxx, Maxy, Maxz));
                    foreach (Hare.Geometry.Point[] Poly in list)
                    {
                        m_DisplayMesh.Add_Polygon(Poly);
                    }
                    for (int i = 0; i < m_DisplayMesh.Vertex_Count; i++)
                    {
                        m_DisplayMesh.Set_Vertex(i, m_DisplayMesh[i] / 90);
                    }
                }
            }
            Update_Position(Center);
        }