Exemple #1
0
 private void nextButton_Click(object sender, EventArgs e)
 {
     if (nextButton.Text == "Next Section")
     {
         ChangeSection(m_currentSection + 1);
     }
     else
     {
         if (MessageBox.Show("Add another section to this surface?", "Add Section", MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             AVL_File.Surface.Section newsec  = new AVL_File.Surface.Section(m_surf);
             AVL_File.Surface.Section lastsec = m_surf.Sections[m_surf.Sections.Count - 1];
             newsec.Chord           = lastsec.Chord;
             newsec.AirfoilFile     = lastsec.AirfoilFile;
             newsec.NACA            = lastsec.NACA;
             newsec.Angle_Incidence = lastsec.Angle_Incidence;
             newsec.X_LeadingEdge   = lastsec.X_LeadingEdge;
             newsec.Y_LeadingEdge   = lastsec.Y_LeadingEdge + 10;
             newsec.Z_LeadingEdge   = lastsec.Z_LeadingEdge;
             m_surf.Sections.Add(newsec);
             ChangeSection(m_surf.Sections.Count - 2);
             RecalculateStats();
         }
     }
 }
Exemple #2
0
        private void addSurfButton_Click(object sender, EventArgs e)
        {
            InputBox ib = new InputBox("Create a new surface for this aircraft", "Enter name for the new lifting surface:");

            if (ib.ShowDialog() == DialogResult.OK)
            {
                if (ib.InputText != string.Empty)
                {
                    AVL_File.Surface         surf = new AVL_File.Surface(ib.InputText, m_ap.Initial_AVL_File);
                    AVL_File.Surface.Section sec1 = new AVL_File.Surface.Section(surf);
                    sec1.Chord = 10;
                    AVL_File.Surface.Section sec2 = new AVL_File.Surface.Section(surf);
                    sec2.Chord         = 10;
                    sec2.Y_LeadingEdge = 10;

                    surf.Sections.Add(sec1);
                    surf.Sections.Add(sec2);

                    m_ap.Initial_AVL_File.Surfaces.Add(surf);

                    SurfaceUC suc = new SurfaceUC(surf);
                    this.flowLayoutPanel1.Controls.Add(suc);
                }
            }
        }
Exemple #3
0
        private void newFileButton_Click(object sender, EventArgs e)
        {
            //here we create a new default airplane
            InputBox ib = new InputBox("Create a new aircraft design", "Name of new design:");

            if (ib.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (ib.InputText == string.Empty)
                {
                    return;
                }

                Aircraft ac = new Aircraft();
                ac.Initial_AVL_File.Title = ib.InputText;

                //make wing surface
                AVL_File.Surface         wingSurf = new AVL_File.Surface("Wing", ac.Initial_AVL_File);
                AVL_File.Surface.Section startSec = new AVL_File.Surface.Section(wingSurf);
                startSec.Chord = 12;
                wingSurf.Sections.Add(startSec);
                AVL_File.Surface.Section endsec = new AVL_File.Surface.Section(wingSurf);
                endsec.Chord         = 12;
                endsec.Y_LeadingEdge = 20;
                wingSurf.Sections.Add(endsec);

                ac.Initial_AVL_File.Surfaces.Add(wingSurf);

                //make hstab surface
                AVL_File.Surface         hSurf     = new AVL_File.Surface("HTail", ac.Initial_AVL_File);
                AVL_File.Surface.Section startHSec = new AVL_File.Surface.Section(hSurf);
                startHSec.Chord         = 7;
                startHSec.X_LeadingEdge = 30;
                hSurf.Sections.Add(startHSec);
                AVL_File.Surface.Section endHsec = new AVL_File.Surface.Section(hSurf);
                endHsec.Chord         = 7;
                endHsec.X_LeadingEdge = 30;
                endHsec.Y_LeadingEdge = 9;
                hSurf.Sections.Add(endHsec);

                ac.Initial_AVL_File.Surfaces.Add(hSurf);

                ac.Initial_AVL_File.Sref = 480;
                ac.Initial_AVL_File.Bref = 40;
                ac.Initial_AVL_File.Cref = 12;
                ac.Initial_AVL_File.Xref = 3;

                this.designs.Add(ac);

                InstanceUC iuc = new InstanceUC(ac);
                this.flowLayoutPanel1.Controls.Add(iuc);
                iuc.Click += new EventHandler(iuc_Click);

                System.Threading.Thread.Sleep(75);
                ConstraintsUC cuc = new ConstraintsUC(ac);
                cuc.Height = flowLayoutPanel2.Height - 25;
                this.flowLayoutPanel2.Controls.Add(cuc);
            }
        }
Exemple #4
0
        private void addSurfButton_Click(object sender, EventArgs e)
        {
            InputBox ib = new InputBox("Create a new surface for this aircraft", "Enter name for the new lifting surface:");
            if (ib.ShowDialog() == DialogResult.OK)
            {
                if (ib.InputText != string.Empty)
                {
                    AVL_File.Surface surf = new AVL_File.Surface(ib.InputText, m_ap.Initial_AVL_File);
                    AVL_File.Surface.Section sec1 = new AVL_File.Surface.Section(surf);
                    sec1.Chord = 10;
                    AVL_File.Surface.Section sec2 = new AVL_File.Surface.Section(surf);
                    sec2.Chord = 10;
                    sec2.Y_LeadingEdge = 10;

                    surf.Sections.Add(sec1);
                    surf.Sections.Add(sec2);

                    m_ap.Initial_AVL_File.Surfaces.Add(surf);

                    SurfaceUC suc = new SurfaceUC(surf);
                    this.flowLayoutPanel1.Controls.Add(suc);
                }
            }
        }
Exemple #5
0
        private void newFileButton_Click(object sender, EventArgs e)
        {
            //here we create a new default airplane
            InputBox ib = new InputBox("Create a new aircraft design", "Name of new design:");
            if(ib.ShowDialog()== System.Windows.Forms.DialogResult.OK)
            {
                if (ib.InputText == string.Empty)
                    return;

                Aircraft ac = new Aircraft();
                ac.Initial_AVL_File.Title = ib.InputText;

                //make wing surface
                AVL_File.Surface wingSurf = new AVL_File.Surface("Wing", ac.Initial_AVL_File);
                AVL_File.Surface.Section startSec = new AVL_File.Surface.Section(wingSurf);
                startSec.Chord = 12;
                wingSurf.Sections.Add(startSec);
                AVL_File.Surface.Section endsec = new AVL_File.Surface.Section(wingSurf);
                endsec.Chord = 12;
                endsec.Y_LeadingEdge = 20;
                wingSurf.Sections.Add(endsec);

                ac.Initial_AVL_File.Surfaces.Add(wingSurf);

                //make hstab surface
                AVL_File.Surface hSurf = new AVL_File.Surface("HTail", ac.Initial_AVL_File);
                AVL_File.Surface.Section startHSec = new AVL_File.Surface.Section(hSurf);
                startHSec.Chord = 7;
                startHSec.X_LeadingEdge = 30;
                hSurf.Sections.Add(startHSec);
                AVL_File.Surface.Section endHsec = new AVL_File.Surface.Section(hSurf);
                endHsec.Chord = 7;
                endHsec.X_LeadingEdge = 30;
                endHsec.Y_LeadingEdge = 9;
                hSurf.Sections.Add(endHsec);

                ac.Initial_AVL_File.Surfaces.Add(hSurf);

                ac.Initial_AVL_File.Sref = 480;
                ac.Initial_AVL_File.Bref = 40;
                ac.Initial_AVL_File.Cref = 12;
                ac.Initial_AVL_File.Xref = 3;

                this.designs.Add(ac);

                InstanceUC iuc = new InstanceUC(ac);
                this.flowLayoutPanel1.Controls.Add(iuc);
                iuc.Click += new EventHandler(iuc_Click);

                System.Threading.Thread.Sleep(75);
                ConstraintsUC cuc = new ConstraintsUC(ac);
                cuc.Height = flowLayoutPanel2.Height - 25;
                this.flowLayoutPanel2.Controls.Add(cuc);
            }
        }
        private static List <Line3D> DrawSection(AVL_File.Surface.Section sec1, AVL_File.Surface.Section sec2, int Nchord, int Cspace, int Nspan, int Sspace, double ydup, bool highlight)
        {
            //these could be defined for the entire surface, or by the section, so check
            if (Nspan == 0)
            {
                Nspan = sec1.Nspanwise;
            }
            if (Sspace == 0)
            {
                Sspace = sec1.Sspace;
            }

            Point3D LE_Sec1 = new Point3D(sec1.X_LeadingEdge, sec1.Y_LeadingEdge, sec1.Z_LeadingEdge);
            Point3D LE_Sec2 = new Point3D(sec2.X_LeadingEdge, sec2.Y_LeadingEdge, sec2.Z_LeadingEdge);

            Point3D TE_Sec1 = new Point3D(sec1.X_LeadingEdge + sec1.Chord, sec1.Y_LeadingEdge, sec1.Z_LeadingEdge);
            Point3D TE_Sec2 = new Point3D(sec2.X_LeadingEdge + sec2.Chord, sec2.Y_LeadingEdge, sec2.Z_LeadingEdge);

            List <Line3D> lines = new List <Line3D>();

            //chord-length lines stepping along the span, has to be Nspan-1 since for loop starts at 0, otherwise there will be one extra line
            Point3D d_le = (LE_Sec2 - LE_Sec1) / Nspan;
            Point3D d_te = (TE_Sec2 - TE_Sec1) / Nspan;

            for (int i = 0; i < Nspan; i++)
            {
                double space_mod = i;
                if (Sspace == 1 || Sspace == -1)//cosine distribution of lines
                {
                    space_mod = (double)Nspan / 2 * (1 - Math.Cos(Math.PI * i / (Nspan - 1)));
                }
                else if (Sspace == -2)//negative sine distribution of lines
                {
                    space_mod = (double)Nspan * Math.Sin((Math.PI / 2) * i / (Nspan - 1));
                }
                else if (Sspace == 2)//positive sine distribution of lines
                {
                    space_mod = (double)Nspan + ((double)Nspan * Math.Sin((-Math.PI / 2) * i / (Nspan - 1)));
                }

                Point3D le_point = LE_Sec1 + (d_le * space_mod);
                Point3D te_point = TE_Sec1 + (d_te * space_mod);

                lines.Add(new Line3D(new Point3D[] { le_point, te_point }, highlight ? SelectedColor : LatticeColor));
                if (!double.IsNaN(ydup))
                {
                    lines.Add(new Line3D(new Point3D[] { le_point.InvertY(ydup), te_point.InvertY(ydup) }, highlight ? SelectedColor : LatticeColor));
                }
            }

            //span-length lines stepping down the chord
            double dx_root = sec1.Chord / (Nchord - 1);
            double dx_tip  = sec2.Chord / (Nchord - 1);

            for (int i = 0; i < Nchord; i++)
            {
                double space_mod = i;
                if (Cspace == 1 || Cspace == -1)//cosine distribution of lines
                {
                    space_mod = Nchord / 2 * (1 - Math.Cos(Math.PI * i / Nchord));
                }
                else if (Cspace == -2)//negative sine distribution of lines
                {
                    space_mod = Nchord * Math.Sin((Math.PI / 2) * i / Nchord);
                }
                else if (Cspace == 2)//positive sine distribution of lines
                {
                    space_mod = Nchord + (Nchord * Math.Sin((-Math.PI / 2) * i / Nchord));
                }
                Point3D root_point = new Point3D(LE_Sec1.X + dx_root * i, LE_Sec1.Y, LE_Sec1.Z);
                Point3D tip_point  = new Point3D(LE_Sec2.X + dx_tip * i, LE_Sec2.Y, LE_Sec2.Z);

                double controlFractionRoot = 1;
                double controlFractionTip  = 1;
                foreach (AVL_File.Surface.Section.Control csurfroot in sec1.control_surfaces)
                {
                    foreach (AVL_File.Surface.Section.Control csurftip in sec2.control_surfaces)
                    {
                        if (csurfroot.Name == csurftip.Name)
                        {
                            if (csurfroot.Xhinge < controlFractionRoot)
                            {
                                controlFractionRoot = csurfroot.Xhinge;
                            }
                            if (csurftip.Xhinge < controlFractionTip)
                            {
                                controlFractionTip = csurftip.Xhinge;
                            }
                        }
                    }
                }

                Color c = LatticeColor;
                if (controlFractionTip < 1 && (root_point.X - sec1.X_LeadingEdge) / sec1.Chord > controlFractionRoot)
                {
                    c = ControlSurfColor;
                }
                if (controlFractionRoot < 1 && (tip_point.X - sec2.X_LeadingEdge) / sec2.Chord > controlFractionTip)
                {
                    c = ControlSurfColor;
                }
                if (highlight)
                {
                    c = SelectedColor;
                }

                lines.Add(new Line3D(new Point3D[] { root_point, tip_point }, c));//highlight ? SelectedColor : LatticeColor));
                if (!double.IsNaN(ydup))
                {
                    lines.Add(new Line3D(new Point3D[] { root_point.InvertY(ydup), tip_point.InvertY(ydup) }, c));//highlight ? SelectedColor : LatticeColor));
                }
            }

            return(lines);
        }