//==== Insert XSec ====// void FuselageGeom::InsertXSec( int type ) { if ( m_ActiveXSec >= NumXSec() - 1 ) { return; } FuseXSec* xs = ( FuseXSec* ) GetXSec( m_ActiveXSec ); FuseXSec* xs_1 = ( FuseXSec* ) GetXSec( m_ActiveXSec + 1 ); double x_loc_0 = xs->m_XLocPercent(); double x_loc_1 = xs_1->m_XLocPercent(); m_XSecSurf.InsertXSec( type, m_ActiveXSec ); m_ActiveXSec++; FuseXSec* inserted_xs = ( FuseXSec* ) GetXSec( m_ActiveXSec ); if ( inserted_xs ) { inserted_xs->SetRefLength( m_Length() ); inserted_xs->CopyFrom( xs ); inserted_xs->m_XLocPercent = ( x_loc_0 + x_loc_1 ) * 0.5; } Update(); }
void FuselageGeom::AddDefaultSources( double base_len ) { switch ( m_OrderPolicy() ) { case FUSE_MONOTONIC: { AddDefaultSourcesXSec( base_len, m_Length(), 0 ); AddDefaultSourcesXSec( base_len, m_Length(), m_XSecSurf.NumXSec() - 1 ); break; } case FUSE_LOOP: { int ifront = -1; double xfront = 1.0; for ( int i = 0 ; i < m_XSecSurf.NumXSec() ; i++ ) { FuseXSec* xs = ( FuseXSec* ) m_XSecSurf.FindXSec( i ); if ( xs ) { if ( xs->m_XLocPercent() < xfront ) { ifront = i; xfront = xs->m_XLocPercent(); } } } AddDefaultSourcesXSec( base_len, m_Length(), 0 ); if ( ifront >= 0 ) { AddDefaultSourcesXSec( base_len, m_Length(), ifront ); } break; } case FUSE_FREE: { AddDefaultSourcesXSec( base_len, m_Length(), 0 ); AddDefaultSourcesXSec( base_len, m_Length(), m_XSecSurf.NumXSec() - 1 ); break; } } }
void FuselageGeom::EnforceOrder( FuseXSec* xs, int indx, int policy ) { if( policy == FUSE_MONOTONIC ) { if ( indx == 0 ) { xs->m_XLocPercent.SetLowerUpperLimits( 0.0, 0.0 ); xs->m_XLocPercent.Set( 0.0 ); } else if ( indx == m_XSecSurf.NumXSec() - 1 ) { xs->m_XLocPercent.SetLowerUpperLimits( 1.0, 1.0 ); xs->m_XLocPercent.Set( 1.0 ); } else { FuseXSec* priorxs = ( FuseXSec* ) m_XSecSurf.FindXSec( indx - 1 ); FuseXSec* nextxs = ( FuseXSec* ) m_XSecSurf.FindXSec( indx + 1 ); double lower = priorxs->m_XLocPercent(); double upper = nextxs->m_XLocPercent(); xs->m_XLocPercent.SetLowerUpperLimits( lower , upper ); } } else if( policy == FUSE_LOOP ) { if ( indx == 0 ) { xs->m_XLocPercent.SetLowerUpperLimits( 1.0, 1.0 ); xs->m_XLocPercent.Set( 1.0 ); } else if ( indx == m_XSecSurf.NumXSec() - 1 ) { xs->m_XLocPercent.SetLowerUpperLimits( 1.0, 1.0 ); xs->m_XLocPercent.Set( 1.0 ); } else { xs->m_XLocPercent.SetLowerUpperLimits( 0.0, 1.0 ); } } else if( policy == FUSE_FREE ) { xs->m_XLocPercent.SetLowerUpperLimits( 0.0, 1.0 ); } }
//==== Update Pod Screen ====// bool FuselageScreen::Update() { assert( m_ScreenMgr ); Geom* geom_ptr = m_ScreenMgr->GetCurrGeom(); if ( !geom_ptr || geom_ptr->GetType().m_Type != FUSELAGE_GEOM_TYPE ) { Hide(); return false; } SkinScreen::Update(); m_NumUSlider.Deactivate(); FuselageGeom* fuselage_ptr = dynamic_cast< FuselageGeom* >( geom_ptr ); assert( fuselage_ptr ); //==== Design ====// m_LengthSlider.Update( fuselage_ptr->m_Length.GetID() ); m_DesignPolicyChoice.Update( fuselage_ptr->m_OrderPolicy.GetID() ); //==== Skin & XSec Index Display ===// int xsid = fuselage_ptr->GetActiveXSecIndex(); m_XSecIndexSelector.SetIndex( xsid ); FuseXSec* xs = ( FuseXSec* ) fuselage_ptr->GetXSec( xsid ); if ( xs ) { bool firstxs = xsid == 0; bool lastxs = xsid == ( fuselage_ptr->GetXSecSurf( 0 )->NumXSec() - 1 ); //==== XSec ====// m_SectUTessSlider.Update( xs->m_SectTessU.GetID() ); if ( firstxs ) { m_SectUTessSlider.Deactivate(); } m_XSecXSlider.Update( xs->m_XLocPercent.GetID() ); m_XSecYSlider.Update( xs->m_YLocPercent.GetID() ); m_XSecZSlider.Update( xs->m_ZLocPercent.GetID() ); m_XSecXRotSlider.Update( xs->m_XRotate.GetID() ); m_XSecYRotSlider.Update( xs->m_YRotate.GetID() ); m_XSecZRotSlider.Update( xs->m_ZRotate.GetID() ); m_XSecSpinSlider.Update( xs->m_Spin.GetID() ); if ( firstxs && ( fuselage_ptr->m_OrderPolicy() == FuselageGeom::FUSE_MONOTONIC || fuselage_ptr->m_OrderPolicy() == FuselageGeom::FUSE_LOOP ) ) { m_XSecXSlider.Deactivate(); } if ( lastxs && fuselage_ptr->m_OrderPolicy() == FuselageGeom::FUSE_MONOTONIC ) { m_XSecXSlider.Deactivate(); } if ( lastxs && fuselage_ptr->m_OrderPolicy() == FuselageGeom::FUSE_LOOP ) { m_XSecXSlider.Deactivate(); m_XSecYSlider.Deactivate(); m_XSecZSlider.Deactivate(); m_XSecXRotSlider.Deactivate(); m_XSecYRotSlider.Deactivate(); m_XSecZRotSlider.Deactivate(); m_XSecSpinSlider.Deactivate(); } XSecCurve* xsc = xs->GetXSecCurve(); if ( xsc ) { m_XSecTypeChoice.SetVal( xsc->GetType() ); if ( lastxs && fuselage_ptr->m_OrderPolicy() == FuselageGeom::FUSE_LOOP ) { m_XSecTypeChoice.Deactivate(); } else { m_XSecTypeChoice.Activate(); } if ( lastxs && fuselage_ptr->m_OrderPolicy() == FuselageGeom::FUSE_LOOP ) { DisplayGroup ( NULL); } else 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() ); } 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() ); } 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() ); } } } return true; }
//==== Update Fuselage And Cross Section Placement ====// void FuselageGeom::UpdateSurf() { m_TessUVec.clear(); int nxsec = m_XSecSurf.NumXSec(); if ( m_OrderPolicy() == FUSE_LOOP ) { FuseXSec* first_xs = (FuseXSec*) m_XSecSurf.FindXSec( 0 ); FuseXSec* last_xs = (FuseXSec*) m_XSecSurf.FindXSec( nxsec - 1 ); if ( first_xs && last_xs ) { if ( last_xs->GetXSecCurve()->GetType() != first_xs->GetXSecCurve()->GetType() ) { m_XSecSurf.ChangeXSecShape( nxsec - 1, first_xs->GetXSecCurve()->GetType() ); last_xs = (FuseXSec*) m_XSecSurf.FindXSec( nxsec - 1 ); } if( last_xs ) { last_xs->CopyFuseXSParms( first_xs ); last_xs->GetXSecCurve()->CopyFrom( first_xs->GetXSecCurve() ); } } } //==== Cross Section Curves & joint info ====// vector< rib_data_type > rib_vec; rib_vec.resize( nxsec ); //==== Update XSec Location/Rotation ====// for ( int i = 0 ; i < nxsec ; i++ ) { FuseXSec* xs = ( FuseXSec* ) m_XSecSurf.FindXSec( i ); if ( xs ) { //==== Reset Group Names ====// xs->SetGroupDisplaySuffix( i ); //==== Set X Limits ====// EnforceOrder( xs, i, m_OrderPolicy() ); xs->SetRefLength( m_Length() ); bool first = false; bool last = false; if( i == 0 ) first = true; else if( i == (nxsec-1) ) last = true; rib_vec[i] = xs->GetRib( first, last ); if ( i > 0 ) { m_TessUVec.push_back( xs->m_SectTessU() ); } } } m_MainSurfVec[0].SkinRibs( rib_vec, false ); m_MainSurfVec[0].SetMagicVParm( false ); for ( int i = 0 ; i < nxsec ; i++ ) { FuseXSec* xs = ( FuseXSec* ) m_XSecSurf.FindXSec( i ); if ( xs ) { xs->SetUnsetParms( i, m_MainSurfVec[0] ); } } if ( m_XSecSurf.GetFlipUD() ) { m_MainSurfVec[0].FlipNormal(); } }
//==== Constructor ====// FuselageGeom::FuselageGeom( Vehicle* vehicle_ptr ) : GeomXSec( vehicle_ptr ) { m_Name = "FuselageGeom"; m_Type.m_Name = "Fuselage"; m_Type.m_Type = FUSELAGE_GEOM_TYPE; m_XSecSurf.SetBasicOrientation( X_DIR, Y_DIR, XS_SHIFT_MID, false ); m_XSecSurf.SetParentContainer( GetID() ); //==== Init Parms ====// m_TessU = 16; m_TessW = 17; m_TessW.SetMultShift( 8, 1 ); m_Length.Init( "Length", "Design", this, 30.0, 1.0e-8, 1.0e12 ); m_Length.SetDescript( "Length of fuselage" ); m_OrderPolicy.Init( "OrderPolicy", "Design", this, FUSE_MONOTONIC, FUSE_MONOTONIC, NUM_FUSE_POLICY - 1 ); m_OrderPolicy.SetDescript( "XSec ordering policy for fuselage" ); m_ActiveXSec = 0; m_XSecSurf.SetXSecType( XSEC_FUSE ); m_XSecSurf.AddXSec( XS_POINT ); m_XSecSurf.AddXSec( XS_ELLIPSE ); m_XSecSurf.AddXSec( XS_ELLIPSE ); m_XSecSurf.AddXSec( XS_ELLIPSE ); m_XSecSurf.AddXSec( XS_POINT ); int j; FuseXSec* xs; j = 0; xs = ( FuseXSec* ) m_XSecSurf.FindXSec( j ); xs->SetGroupDisplaySuffix( j ); xs->m_XLocPercent = 0.0; ++j; xs = ( FuseXSec* ) m_XSecSurf.FindXSec( j ); xs->SetGroupDisplaySuffix( j ); xs->m_XLocPercent = 0.25; dynamic_cast<EllipseXSec *>( xs->GetXSecCurve() )->SetWidthHeight( 3.0, 2.5 ); ++j; xs = ( FuseXSec* ) m_XSecSurf.FindXSec( j ); xs->SetGroupDisplaySuffix( j ); xs->m_XLocPercent = 0.5; dynamic_cast<EllipseXSec *>( xs->GetXSecCurve() )->SetWidthHeight( 3.0, 2.5 ); ++j; xs = ( FuseXSec* ) m_XSecSurf.FindXSec( j ); xs->SetGroupDisplaySuffix( j ); xs->m_XLocPercent = 0.75; dynamic_cast<EllipseXSec *>( xs->GetXSecCurve() )->SetWidthHeight( 3.0, 2.5 ); ++j; xs = ( FuseXSec* ) m_XSecSurf.FindXSec( j ); xs->SetGroupDisplaySuffix( j ); xs->m_XLocPercent = 1.0; }