//==== Insert Wing Sect ====// void WingGeom::SplitWingSect( int index ) { WingSect* ws = GetWingSect( index ); if ( ws ) { double span = ws->m_Span(); double rc = ws->m_RootChord(); double ac = ws->m_AvgChord(); double tc = ws->m_TipChord(); double twist = 0.5*ws->m_Twist(); int curve_type = ws->GetXSecCurve()->GetType(); string ins_id = m_XSecSurf.InsertXSec( curve_type, index ); ws->ForceSpanRcTc( span*0.5, rc, ac ); ws->m_Twist = twist; ws->Update(); XSec* xs = m_XSecSurf.FindXSec( ins_id ); if ( xs ) { WingSect* ins_ws = dynamic_cast< WingSect* >(xs); ins_ws->CopyFrom( ws ); ins_ws->ForceSpanRcTc( span*0.5, ac, tc ); ins_ws->m_Twist = twist; ins_ws->Update(); } } }
//==== Update Wing And Cross Section Placement ====// void WingGeom::UpdateSurf() { //==== Check If Total Span/Chord/Area Has Changed ====// bool total_change_flag = false; if ( UpdatedParm( m_TotalSpan.GetID() ) ) { UpdateTotalSpan(); total_change_flag = true; } if ( UpdatedParm( m_TotalProjSpan.GetID() ) ) { UpdateTotalProjSpan(); total_change_flag = true; } if ( UpdatedParm( m_TotalChord.GetID() ) ) { UpdateTotalChord(); total_change_flag = true; } if ( UpdatedParm( m_TotalArea.GetID() ) ) { UpdateTotalArea(); total_change_flag = true; } int active_sect = GetActiveXSecIndex(); // Save Active Section //==== Set Temp Active XSec Based On Updated Parms ====// if ( total_change_flag ) SetActiveXSecIndex(1); else SetTempActiveXSec(); //==== Make Sure Chord Match For Adjacent Wing Sections ====// MatchWingSections(); SetActiveXSecIndex(active_sect); // Restore Active Section // clear the u tessellation vector m_TessUVec.clear(); vector< VspCurve > crv_vec( m_XSecSurf.NumXSec() ); //==== Compute Parameters For Each Section ====// double total_span = 0.0; double total_sweep_offset = 0.0; double total_dihed_offset = 0.0; double total_twist = 0.0; //==== Load End Points for Each Section ====// for ( int i = 0 ; i < m_XSecSurf.NumXSec() ; i++ ) { WingSect* ws = ( WingSect* ) m_XSecSurf.FindXSec( i ); if ( ws ) { //==== Reset Group Names ====// ws->SetGroupDisplaySuffix( i ); double rad = ws->m_Span(); double ty = rad*cos(GetSumDihedral(i)*DEG_2_RAD); double tz = rad*sin(GetSumDihedral(i)*DEG_2_RAD); double tan_le = ws->GetTanSweepAt( ws->m_Sweep(), 0.0 ); double toff = tan_le*rad; // Tip X Offset if ( i == 0 ) { ty = 0; tz = 0; toff = 0; } total_dihed_offset += tz; total_span += ty; total_sweep_offset += toff; if ( m_RelativeTwistFlag() ) total_twist += ws->m_Twist(); else total_twist = ws->m_Twist(); ws->SetProjectedSpan( ty ); //==== Find Width Parm ====// string width_id = ws->GetXSecCurve()->GetWidthParmID(); Parm* width_parm = ParmMgr.FindParm( width_id ); if ( width_parm ) { width_parm->Deactivate(); width_parm->Set( ws->m_TipChord() ); } double dihead_rot = 0.0; if ( m_RotateAirfoilMatchDiedralFlag() ) { if ( i == 0 ) { dihead_rot = GetSumDihedral( i+1 ); } else if ( i == m_XSecSurf.NumXSec()-1 ) { dihead_rot = GetSumDihedral( i ); } else { dihead_rot = 0.5*( GetSumDihedral( i ) + GetSumDihedral( i+1 ) ); } } //==== Load Transformations =====// ws->m_YDelta = total_span; ws->m_XDelta = total_sweep_offset; ws->m_ZDelta = total_dihed_offset; ws->m_YRotate = total_twist; ws->m_XRotate = dihead_rot; ws->m_XCenterRot = ws->m_XDelta + ws->m_TwistLoc()*ws->m_TipChord(); ws->m_YCenterRot = ws->m_YDelta; ws->m_ZCenterRot = ws->m_ZDelta; crv_vec[i] = ws->GetCurve(); if ( i > 0 ) { m_TessUVec.push_back( ws->m_SectTessU() ); } } } m_MainSurfVec[0].SkinC0( crv_vec, false ); if ( m_XSecSurf.GetFlipUD() ) { m_MainSurfVec[0].FlipNormal(); } m_MainSurfVec[0].SetSurfType( vsp::WING_SURF ); //==== Load Totals ====// m_TotalSpan = ComputeTotalSpan(); m_TotalProjSpan = ComputeTotalProjSpan(); m_TotalChord = ComputeTotalChord(); m_TotalArea = ComputeTotalArea(); }
//==== Update Wing Screen ====// bool WingScreen::Update() { assert( m_ScreenMgr ); char str[256]; Geom* geom_ptr = m_ScreenMgr->GetCurrGeom(); if ( !geom_ptr || geom_ptr->GetType().m_Type != MS_WING_GEOM_TYPE ) { Hide(); return false; } GeomScreen::Update(); m_NumUSlider.Deactivate(); WingGeom* wing_ptr = dynamic_cast< WingGeom* >( geom_ptr ); assert( wing_ptr ); //==== Plan Parms ===// m_PlanSpanSlider.Update( wing_ptr->m_TotalSpan.GetID() ); m_PlanProjSpanSlider.Update( wing_ptr->m_TotalProjSpan.GetID() ); m_PlanChordSlider.Update( wing_ptr->m_TotalChord.GetID() ); m_PlanAreaSlider.Update( wing_ptr->m_TotalArea.GetID() ); m_LEClusterSlider.Update( wing_ptr->m_LECluster.GetID() ); m_TEClusterSlider.Update( wing_ptr->m_TECluster.GetID() ); sprintf( str, "%6.4f", wing_ptr->m_TotalProjSpan() * wing_ptr->m_TotalProjSpan() / wing_ptr->m_TotalArea() ); m_PlanAROutput.Update( str ); m_RootCapTypeChoice.Update( wing_ptr->m_CapUMinOption.GetID() ); m_TipCapTypeChoice.Update( wing_ptr->m_CapUMaxOption.GetID() ); if ( wing_ptr->m_CapUMinOption() == VspSurf::NO_END_CAP && wing_ptr->m_CapUMaxOption() == VspSurf::NO_END_CAP ) { m_CapTessSlider.Deactivate(); } else { m_CapTessSlider.Update( wing_ptr->m_CapUMinTess.GetID() ); } WingSect* root_sect = dynamic_cast<WingSect*>(wing_ptr->GetXSec( 0 )); if ( root_sect ) { m_IncidenceSlider.Update( root_sect->m_Twist.GetID() ); m_IncidenceLocSlider.Update( root_sect->m_TwistLoc.GetID() ); } sprintf( str, " %d", wing_ptr->NumXSec()-1 ); m_NumSectOutput.Update( str ); ////==== Wing Section Index Display ====// int ws_index = wing_ptr->GetActiveXSecIndex(); m_SectIndexSelector.SetIndex( ws_index ); WingSect* wing_sect = dynamic_cast<WingSect*>(wing_ptr->GetXSec( ws_index )); if ( wing_sect ) { m_SectUTessSlider.Update( wing_sect->m_SectTessU.GetID() ); m_RootClusterSlider.Update( wing_sect->m_RootCluster.GetID() ); m_TipClusterSlider.Update( wing_sect->m_TipCluster.GetID() ); m_WingDriverGroupBank.SetDriverGroup( &wing_sect->m_DriverGroup ); vector< string > parm_ids = wing_sect->GetDriverParms(); wing_sect->m_DriverGroup.UpdateGroup( parm_ids ); m_WingDriverGroupBank.Update( parm_ids ); m_SweepSlider.Update( wing_sect->m_Sweep.GetID() ); m_SweepLocSlider.Update( wing_sect->m_SweepLoc.GetID() ); m_SecSweepLocSlider.Update( wing_sect->m_SecSweepLoc.GetID() ); m_TwistSlider.Update( wing_sect->m_Twist.GetID() ); m_TwistLocSlider.Update( wing_sect->m_TwistLoc.GetID() ); m_DihedralSlider.Update( wing_sect->m_Dihedral.GetID() ); m_DihedralAbsRelToggle.Update( wing_ptr->m_RelativeDihedralFlag.GetID() ); m_TwistAbsRelToggle.Update( wing_ptr->m_RelativeTwistFlag.GetID() ); m_RotateFoilMatchDihedral.Update( wing_ptr->m_RotateAirfoilMatchDiedralFlag.GetID() ); sprintf( str, " %6.4f", wing_sect->GetProjectedSpan() ); m_SectProjSpanOutput.Update( str ); } //==== XSec Index Display ===// int xsid = wing_ptr->GetActiveAirfoilIndex(); m_AfIndexSelector.SetIndex( xsid ); m_AfModIndexSelector.SetIndex( xsid ); WingSect* ws = ( WingSect* ) wing_ptr->GetXSec( xsid ); if ( ws ) { XSecCurve* xsc = ws->GetXSecCurve(); if ( xsc ) { m_AfTypeChoice.SetVal( xsc->GetType() ); if ( xsc->GetType() == XS_POINT ) { DisplayGroup( NULL ); } else if ( xsc->GetType() == XS_SUPER_ELLIPSE ) { DisplayGroup( &m_SuperGroup ); SuperXSec* super_xs = dynamic_cast< SuperXSec* >( xsc ); assert( super_xs ); m_SuperHeightSlider.Update( super_xs->m_Height.GetID() ); m_SuperWidthSlider.Update( super_xs->m_Width.GetID() ); m_SuperMSlider.Update( super_xs->m_M.GetID() ); m_SuperNSlider.Update( super_xs->m_N.GetID() ); } else if ( xsc->GetType() == XS_CIRCLE ) { DisplayGroup( &m_CircleGroup ); CircleXSec* circle_xs = dynamic_cast< CircleXSec* >( xsc ); assert( circle_xs ); m_DiameterSlider.Update( circle_xs->m_Diameter.GetID() ); } else if ( xsc->GetType() == XS_ELLIPSE ) { DisplayGroup( & m_EllipseGroup ); EllipseXSec* ellipse_xs = dynamic_cast< EllipseXSec* >( xsc ); m_EllipseHeightSlider.Update( ellipse_xs->m_Height.GetID() ); m_EllipseWidthSlider.Update( ellipse_xs->m_Width.GetID() ); } else if ( xsc->GetType() == XS_ROUNDED_RECTANGLE ) { DisplayGroup( & m_RoundedRectGroup ); RoundedRectXSec* rect_xs = dynamic_cast< RoundedRectXSec* >( xsc ); assert( rect_xs ); m_RRHeightSlider.Update( rect_xs->m_Height.GetID() ); m_RRWidthSlider.Update( rect_xs->m_Width.GetID() ); m_RRRadiusSlider.Update( rect_xs->m_Radius.GetID() ); } else if ( xsc->GetType() == XS_GENERAL_FUSE ) { DisplayGroup( &m_GenGroup ); GeneralFuseXSec* gen_xs = dynamic_cast< GeneralFuseXSec* >( xsc ); assert( gen_xs ); m_GenHeightSlider.Update( gen_xs->m_Height.GetID() ); m_GenWidthSlider.Update( gen_xs->m_Width.GetID() ); m_GenMaxWidthLocSlider.Update( gen_xs->m_MaxWidthLoc.GetID() ); m_GenCornerRadSlider.Update( gen_xs->m_CornerRad.GetID() ); m_GenTopTanAngleSlider.Update( gen_xs->m_TopTanAngle.GetID() ); m_GenBotTanAngleSlider.Update( gen_xs->m_BotTanAngle.GetID() ); m_GenTopStrSlider.Update( gen_xs->m_TopStr.GetID() ); m_GenBotStrSlider.Update( gen_xs->m_BotStr.GetID() ); m_GenUpStrSlider.Update( gen_xs->m_UpStr.GetID() ); m_GenLowStrSlider.Update( gen_xs->m_LowStr.GetID() ); } else if ( xsc->GetType() == XS_FOUR_SERIES ) { DisplayGroup( &m_FourSeriesGroup ); FourSeries* fs_xs = dynamic_cast< FourSeries* >( xsc ); assert( fs_xs ); m_FourChordSlider.Update( fs_xs->m_Chord.GetID() ); m_FourThickChordSlider.Update( fs_xs->m_ThickChord.GetID() ); m_FourCamberSlider.Update( fs_xs->m_Camber.GetID() ); m_FourCamberLocSlider.Update( fs_xs->m_CamberLoc.GetID() ); m_FourInvertButton.Update( fs_xs->m_Invert.GetID() ); m_FourNameOutput.Update( fs_xs->GetAirfoilName() ); m_FourDegreeCounter.Update( fs_xs->m_FitDegree.GetID() ); m_FourEqArcLenButton.Update( fs_xs->m_EqArcLen.GetID() ); } else if ( xsc->GetType() == XS_SIX_SERIES ) { DisplayGroup( &m_SixSeriesGroup ); SixSeries* ss_xs = dynamic_cast< SixSeries* >( xsc ); assert( ss_xs ); m_SixChordSlider.Update( ss_xs->m_Chord.GetID() ); m_SixThickChordSlider.Update( ss_xs->m_ThickChord.GetID() ); m_SixIdealClSlider.Update( ss_xs->m_IdealCl.GetID() ); m_SixASlider.Update( ss_xs->m_A.GetID() ); m_SixInvertButton.Update( ss_xs->m_Invert.GetID() ); m_SixNameOutput.Update( ss_xs->GetAirfoilName() ); m_SixSeriesChoice.Update( ss_xs->m_Series.GetID() ); m_SixDegreeCounter.Update( ss_xs->m_FitDegree.GetID() ); } else if ( xsc->GetType() == XS_BICONVEX ) { DisplayGroup( &m_BiconvexGroup ); Biconvex* bi_xs = dynamic_cast< Biconvex* >( xsc ); assert( bi_xs ); m_BiconvexChordSlider.Update( bi_xs->m_Chord.GetID() ); m_BiconvexThickChordSlider.Update( bi_xs->m_ThickChord.GetID() ); } else if ( xsc->GetType() == XS_WEDGE ) { DisplayGroup( &m_WedgeGroup ); Wedge* we_xs = dynamic_cast< Wedge* >( xsc ); assert( we_xs ); m_WedgeChordSlider.Update( we_xs->m_Chord.GetID() ); m_WedgeThickChordSlider.Update( we_xs->m_ThickChord.GetID() ); m_WedgeThickLocSlider.Update( we_xs->m_ThickLoc.GetID() ); } else if ( xsc->GetType() == XS_FILE_FUSE ) { DisplayGroup( &m_FuseFileGroup ); FileXSec* file_xs = dynamic_cast< FileXSec* >( xsc ); assert( file_xs ); m_FileHeightSlider.Update( file_xs->m_Height.GetID() ); m_FileWidthSlider.Update( file_xs->m_Width.GetID() ); } else if ( xsc->GetType() == XS_FILE_AIRFOIL ) { DisplayGroup( &m_AfFileGroup ); FileAirfoil* affile_xs = dynamic_cast< FileAirfoil* >( xsc ); assert( affile_xs ); m_AfFileChordSlider.Update( affile_xs->m_Chord.GetID() ); m_AfFileInvertButton.Update( affile_xs->m_Invert.GetID() ); m_AfFileNameOutput.Update( affile_xs->GetAirfoilName() ); m_AfFileDegreeCounter.Update( affile_xs->m_FitDegree.GetID() ); } else if ( xsc->GetType() == XS_CST_AIRFOIL ) { DisplayGroup( &m_CSTAirfoilGroup ); CSTAirfoil* cst_xs = dynamic_cast< CSTAirfoil* >( xsc ); assert( cst_xs ); int num_up = cst_xs->m_UpDeg() + 1; int num_low = cst_xs->m_LowDeg() + 1; char str[255]; sprintf( str, "%d", cst_xs->m_UpDeg() ); m_UpDegreeOutput.Update( str ); sprintf( str, "%d", cst_xs->m_LowDeg() ); m_LowDegreeOutput.Update( str ); m_CSTInvertButton.Update( cst_xs->m_Invert.GetID() ); m_CSTContLERadButton.Update( cst_xs->m_ContLERad.GetID() ); m_CSTEqArcLenButton.Update( cst_xs->m_EqArcLen.GetID() ); if ( ( m_UpCoeffSliderVec.size() != num_up ) || ( m_LowCoeffSliderVec.size() != num_low ) ) { RebuildCSTGroup( cst_xs ); } for ( int i = 0; i < num_up; i++ ) { Parm *p = cst_xs->m_UpCoeffParmVec[i]; if ( p ) { m_UpCoeffSliderVec[i].Update( p->GetID() ); } } for ( int i = 0; i < num_low; i++ ) { Parm *p = cst_xs->m_LowCoeffParmVec[i]; if ( p ) { m_LowCoeffSliderVec[i].Update( p->GetID() ); } } if ( cst_xs->m_ContLERad() && num_low > 0 ) { m_LowCoeffSliderVec[0].Deactivate(); } } m_TECloseChoice.Update( xsc->m_TECloseType.GetID() ); m_TECloseGroup.Update( xsc->m_TECloseAbsRel.GetID() ); m_CloseThickSlider.Update( xsc->m_TECloseThick.GetID() ); m_CloseThickChordSlider.Update( xsc->m_TECloseThickChord.GetID() ); if ( xsc->m_TECloseType() != CLOSE_NONE ) { m_TECloseABSButton.Activate(); m_TECloseRELButton.Activate(); if ( xsc->m_TECloseAbsRel() == ABS ) { m_CloseThickSlider.Activate(); m_CloseThickChordSlider.Deactivate(); } else { m_CloseThickSlider.Deactivate(); m_CloseThickChordSlider.Activate(); } } else { m_CloseThickSlider.Deactivate(); m_CloseThickChordSlider.Deactivate(); m_TECloseABSButton.Deactivate(); m_TECloseRELButton.Deactivate(); } m_TETrimChoice.Update( xsc->m_TETrimType.GetID() ); m_TETrimGroup.Update( xsc->m_TETrimAbsRel.GetID() ); m_TrimXSlider.Update( xsc->m_TETrimX.GetID() ); m_TrimXChordSlider.Update( xsc->m_TETrimXChord.GetID() ); m_TrimThickSlider.Update( xsc->m_TETrimThick.GetID() ); m_TrimThickChordSlider.Update( xsc->m_TETrimThickChord.GetID() ); m_TrimXSlider.Deactivate(); m_TrimXChordSlider.Deactivate(); m_TrimThickSlider.Deactivate(); m_TrimThickChordSlider.Deactivate(); m_TETrimABSButton.Deactivate(); m_TETrimRELButton.Deactivate(); if ( xsc->m_TETrimType() != TRIM_NONE ) { m_TETrimABSButton.Activate(); m_TETrimRELButton.Activate(); } if ( xsc->m_TETrimType() == TRIM_X ) { if ( xsc->m_TETrimAbsRel() == ABS ) { m_TrimXSlider.Activate(); } else { m_TrimXChordSlider.Activate(); } } else if ( xsc->m_TETrimType() == TRIM_THICK ) { if ( xsc->m_TETrimAbsRel() == ABS ) { m_TrimThickSlider.Activate(); } else { m_TrimThickChordSlider.Activate(); } } m_AFThetaSlider.Update( xsc->m_Theta.GetID() ); m_AFScaleSlider.Update( xsc->m_Scale.GetID() ); m_AFDeltaXSlider.Update( xsc->m_DeltaX.GetID() ); m_AFDeltaYSlider.Update( xsc->m_DeltaY.GetID() ); m_AFShiftLESlider.Update( xsc->m_ShiftLE.GetID() ); } } return true; }