Exemplo n.º 1
0
//==== Get the sub surfaces from all geoms ====//
vector< SubSurface* > SubSurfaceMgrSingleton::GetSubSurfs()
{
    vector< SubSurface* > ret_vec;
    Vehicle* veh = VehicleMgr.GetVehicle();
    if( !veh )
    {
        return ret_vec;
    }

    vector<Geom*> geoms = veh->FindGeomVec( veh->GetGeomVec() );
    for ( int i = 0 ; i < ( int )geoms.size() ; i++ )
    {
        const vector< SubSurface* > SubSurfVec = geoms[i]->GetSubSurfVec();
        for ( int j = 0 ; j < ( int )SubSurfVec.size() ; j++ )
        {
            ret_vec.push_back( SubSurfVec[j] );
        }
    }

    return ret_vec;
}
Exemplo n.º 2
0
//==== Get All FeaStructures ====//
vector < FeaStructure* > StructureMgrSingleton::GetAllFeaStructs()
{
    vector < FeaStructure* > feastructvec;

    Vehicle* veh = VehicleMgr.GetVehicle();

    if ( veh )
    {
        vector< Geom* > geom_vec = veh->FindGeomVec( veh->GetGeomVec( false ) );

        for ( unsigned int i = 0; i < geom_vec.size(); i++ )
        {
            vector < FeaStructure* > geomstructvec = geom_vec[i]->GetFeaStructVec();

            for ( unsigned int j = 0; j < geomstructvec.size(); j++ )
            {
                feastructvec.push_back( geomstructvec[j] );
            }
        }
    }

    return feastructvec;
}
Exemplo n.º 3
0
void SVGOptionsScreen::GetScale( int write_set )
{
    bool foundgeom = false;

    Vehicle *veh = VehicleMgr.GetVehicle();

    vector< Geom* > geom_vec = veh->FindGeomVec( veh->GetGeomVec( false ) );
    BndBox svgbox;
    for ( int i = 0 ; i < ( int )geom_vec.size() ; i++ )
    {
        if ( geom_vec[i]->GetSetFlag( write_set ) )
        {
            svgbox.Update( geom_vec[i]->GetBndBox() );
            foundgeom = true;
        }
    }

    if ( !foundgeom )
    {
        veh->m_Scale.Set( 0 ); // Set to 0 if no geoms are in the set
        return;
    }

    double length = svgbox.DiagDist();
    double convert_scale;

    if ( length >= 1.0 )
    {
        convert_scale = floor2scale( length, pow( 10.0, mag( length ) ) );
    }
    else
    {
        convert_scale = floor2scale( length, pow( 10.0, mag( length ) - 1 ) );
    }

    veh->m_Scale.Set( convert_scale );
}
Exemplo n.º 4
0
bool ManageTextureScreen::Update()
{
    assert( m_ScreenMgr );

    Vehicle* veh = m_ScreenMgr->GetVehiclePtr();
    vector< Geom* > select_vec = veh->GetActiveGeomPtrVec();

    if ( select_vec.size() != 1 )
    {
        Hide();
        return false;
    }

    // Redo list on each update.
    m_TextureMgrUI->compChoice->clear();
    m_CompDropDownList.clear();

    std::vector<Geom *> geomVec = veh->FindGeomVec( veh->GetGeomVec() );
    for( int i = 0; i < ( int )geomVec.size(); i++ )
    {
        CompDropDownItem item;
        item.GeomName = geomVec[i]->GetName();
        item.GeomID = geomVec[i]->GetID();

        // Hack to add duplicate names
        char str[256];
        sprintf( str, "%d", i );
        item.GUIIndex = m_TextureMgrUI->compChoice->add( str );

        m_CompDropDownList.push_back( item );
    }
    // Fill Hacked char array with correct names.
    for( int i = 0; i < ( int )m_CompDropDownList.size(); i++ )
    {
        m_TextureMgrUI->compChoice->replace( m_CompDropDownList[i].GUIIndex, m_CompDropDownList[i].GeomName.c_str() );
    }

    // Set compChoice to current selected and update texture dropdown list.
    for( int i = 0; i < ( int )m_CompDropDownList.size(); i++ )
    {
        if( m_CompDropDownList[i].GeomID == select_vec[0]->GetID() )
        {
            m_TextureMgrUI->compChoice->value( m_CompDropDownList[i].GUIIndex );

            // Update Texture Dropdown List. //

            // Redo texture list on each update.
            m_TextureMgrUI->textureChoice->clear();
            m_TexDropDownList.clear();

            // Clear preview window.
            VSPGraphic::Viewport * viewport = m_GlWin->getGraphicEngine()->getDisplay()->getViewport();
            assert( viewport );
            viewport->getBackground()->removeImage();

            // Load Textures...
            TextureMgr * texMgr = select_vec[0]->m_GuiDraw.getTextureMgr();
            std::vector<Texture*> texInfos = texMgr->FindTextureVec( texMgr->GetTextureVec() );
            for( int j = 0; j < ( int )texInfos.size(); j++ )
            {
                TexDropDownItem item;
                item.TexInfo = texInfos[j];

                // Hack to add duplicate names
                char str[256];
                sprintf( str, "%d", j );
                item.GUIIndex = m_TextureMgrUI->textureChoice->add( str );

                m_TexDropDownList.push_back( item );
            }
            // Fill Hacked char array with correct names.
            for( int j = 0; j < ( int )m_TexDropDownList.size(); j++ )
            {
                m_TextureMgrUI->textureChoice->replace( m_TexDropDownList[j].GUIIndex, m_TexDropDownList[j].TexInfo->GetName().c_str() );
            }
            if( !m_TexDropDownList.empty() )
            {
                if( m_SelectedTexItem )
                {
                    m_TextureMgrUI->textureChoice->value( m_SelectedTexItem->GUIIndex );
                }
                else
                {
                    // On refresh list, if nothing is selected, pick last item on list.
                    m_TextureMgrUI->textureChoice->value( m_TexDropDownList[m_TexDropDownList.size() - 1].GUIIndex );
                }
                UpdateCurrentSelected();

                assert( m_SelectedTexItem );

                viewport->getBackground()->attachImage( VSPGraphic::GlobalTextureRepo()->
                    get2DTexture( m_SelectedTexItem->TexInfo->m_FileName.c_str() ) );
            }
            else
            {
                ResetCurrentSelected();

                // Force redraw empty list.
                m_TextureMgrUI->textureChoice->redraw();
            }

            // Update Sliders and Buttons.
            if( m_SelectedTexItem )
            {
                Texture * info = select_vec[0]->m_GuiDraw.getTextureMgr()->FindTexture( m_SelectedTexItem->TexInfo->GetID() );

                m_TextureMgrUI->textureNameInput->value( info->GetName().c_str() );

                m_UScaleSlider.Update( info->m_UScale.GetID() );
                m_WScaleSlider.Update( info->m_WScale.GetID() );

                m_UPosSlider.Update( info->m_U.GetID() );
                m_WPosSlider.Update( info->m_W.GetID() );

                m_TransparencySlider.Update( info->m_Transparency.GetID() );

                m_FlipUButton.Update( info->m_FlipU.GetID() );
                m_FlipWButton.Update( info->m_FlipW.GetID() );
            }
            break;
        }
    }
    m_GlWin->redraw();
    return true;
}
Exemplo n.º 5
0
bool VSPAEROScreen::Update()
{
    Vehicle *veh = VehicleMgr.GetVehicle();

    VSPAEROMgr.Update();

    if( veh )
    {
        //check if the degenfile name has changed
        string t_ModelNameBase = VSPAEROMgr.m_ModelNameBase;  //m_ModelNameBase is built from calling veh->getExportFileName();
        if( !t_ModelNameBase.empty() && strcmp( m_ModelNameBasePrevious.c_str(), t_ModelNameBase.c_str() ) != 0 )
        {
            ReadSetup();
        }
        m_ModelNameBasePrevious = t_ModelNameBase;

        // Reference Wing Choice
        //    find & list all Wing type geometries
        vector <string> geomVec = veh->GetGeomVec();

        m_RefWingChoice.ClearItems();
        m_WingGeomVec.clear();
        map <string, int> WingCompIDMap;
        int iwing = 0;
        for ( int i = 0 ; i < ( int )geomVec.size() ; i++ )
        {
            char str[256];
            Geom* g = veh->FindGeom( geomVec[i] );
            if ( g )
            {
                sprintf( str, "%d_%s", i, g->GetName().c_str() );

                if( g->GetType().m_Type == MS_WING_GEOM_TYPE )
                {
                    m_RefWingChoice.AddItem( str );
                    WingCompIDMap[ geomVec[i] ] = iwing;
                    m_WingGeomVec.push_back( geomVec[i] );
                    iwing ++;
                }
            }
        }
        m_RefWingChoice.UpdateItems();
        //    Update selected value
        string refGeomID = VSPAEROMgr.m_RefGeomID;
        if( refGeomID.length() == 0 && m_WingGeomVec.size() > 0 )
        {
            // Handle case default case.
            refGeomID = m_WingGeomVec[0];
            VSPAEROMgr.m_RefGeomID = refGeomID;
            // Re-trigger reference quantity update with default component.
            VSPAEROMgr.Update();
        }
        m_RefWingChoice.SetVal( WingCompIDMap[ refGeomID ] );


        // Update available set choices
        m_GeomSetChoice.ClearItems();
        m_CGSetChoice.ClearItems();

        vector <string> setVec = veh->GetSetNameVec();
        for ( int iSet = 0; iSet < setVec.size(); iSet++ )
        {
            m_GeomSetChoice.AddItem( setVec[iSet] );
            m_CGSetChoice.AddItem( setVec[iSet] );
        }
        m_GeomSetChoice.UpdateItems();
        m_CGSetChoice.UpdateItems();

        m_GeomSetChoice.SetVal( VSPAEROMgr.m_GeomSet() );
        m_CGSetChoice.SetVal( VSPAEROMgr.m_CGGeomSet() );


        // Case Setup
        m_AeroMethodToggleGroup.Update( VSPAEROMgr.m_AnalysisMethod.GetID() );
        switch ( VSPAEROMgr.m_AnalysisMethod.Get() )
        {
        case vsp::VSPAERO_ANALYSIS_METHOD::VORTEX_LATTICE:

            m_DegenFileName.Activate();
            m_DegenFileButton.Activate();

            m_CompGeomFileName.Deactivate();
            m_CompGeomFileButton.Deactivate();

            break;

        case vsp::VSPAERO_ANALYSIS_METHOD::PANEL:

            m_DegenFileName.Deactivate();
            m_DegenFileButton.Deactivate();

            m_CompGeomFileName.Activate();
            m_CompGeomFileButton.Activate();

            break;

        default:
            //do nothing; this should not be reachable
            break;
        }

        m_DegenFileName.Update( veh->getExportFileName( vsp::DEGEN_GEOM_CSV_TYPE ) );
        m_CompGeomFileName.Update( veh->getExportFileName( vsp::VSPAERO_PANEL_TRI_TYPE ) );

        m_NCPUSlider.Update( VSPAEROMgr.m_NCPU.GetID() );
        m_StabilityCalcToggle.Update( VSPAEROMgr.m_StabilityCalcFlag.GetID() );
        m_BatchCalculationToggle.Update( VSPAEROMgr.m_BatchModeFlag.GetID() );
        //printf("m_SolverProcess.m_ThreadID = %lu\n", m_SolverProcess.m_ThreadID);
        if( m_SolverThreadIsRunning )
        {
            m_ComputeGeometryButton.Deactivate();
        }
        else
        {
            m_ComputeGeometryButton.Activate();
        }


        // Wake Options
        m_WakeNumIterSlider.Update( VSPAEROMgr.m_WakeNumIter.GetID() );
        m_WakeAvgStartIterSlider.Update( VSPAEROMgr.m_WakeAvgStartIter.GetID() );
        m_WakeSkipUntilIterSlider.Update( VSPAEROMgr.m_WakeSkipUntilIter.GetID() );


        // Reference Quantities
        m_RefToggle.Update( VSPAEROMgr.m_RefFlag.GetID() );
        m_SrefSlider.Update( VSPAEROMgr.m_Sref.GetID() );
        m_brefSlider.Update( VSPAEROMgr.m_bref.GetID() );
        m_crefSlider.Update( VSPAEROMgr.m_cref.GetID() );


        // CG Position
        m_NumSliceSlider.Update( VSPAEROMgr.m_NumMassSlice.GetID() );
        m_XcgSlider.Update( VSPAEROMgr.m_Xcg.GetID() );
        m_YcgSlider.Update( VSPAEROMgr.m_Ycg.GetID() );
        m_ZcgSlider.Update( VSPAEROMgr.m_Zcg.GetID() );


        // Flow Condition
        // Alpha
        m_AlphaStartInput.Update( VSPAEROMgr.m_AlphaStart.GetID() );
        m_AlphaEndInput.Update( VSPAEROMgr.m_AlphaEnd.GetID() );
        m_AlphaNptsInput.Update( VSPAEROMgr.m_AlphaNpts.GetID() );
        if ( VSPAEROMgr.m_AlphaNpts.Get() == 1 )
        {
            m_AlphaEndInput.Deactivate();
        }
        else if ( VSPAEROMgr.m_AlphaNpts.Get() > 1 )
        {
            m_AlphaEndInput.Activate();
        }
        // Beta
        m_BetaStartInput.Update( VSPAEROMgr.m_BetaStart.GetID() );
        m_BetaEndInput.Update( VSPAEROMgr.m_BetaEnd.GetID() );
        m_BetaNptsInput.Update( VSPAEROMgr.m_BetaNpts.GetID() );
        if ( VSPAEROMgr.m_BetaNpts.Get() == 1 )
        {
            m_BetaEndInput.Deactivate();
        }
        else if ( VSPAEROMgr.m_BetaNpts.Get() > 1 )
        {
            m_BetaEndInput.Activate();
        }
        // Mach
        m_MachStartInput.Update( VSPAEROMgr.m_MachStart.GetID() );
        m_MachEndInput.Update( VSPAEROMgr.m_MachEnd.GetID() );
        m_MachNptsInput.Update( VSPAEROMgr.m_MachNpts.GetID() );
        if ( VSPAEROMgr.m_MachNpts.Get() == 1 )
        {
            m_MachEndInput.Deactivate();
        }
        else if ( VSPAEROMgr.m_MachNpts.Get() > 1 )
        {
            m_MachEndInput.Activate();
        }

        // Create Setup Button
        if( veh->GetVSPAEROCmd().empty()             ||
                !FileExist( VSPAEROMgr.m_DegenFileFull ) ||
                m_SolverThreadIsRunning                  ||
                m_SolverSetupThreadIsRunning             ||
                ( ( VSPAEROMgr.m_AnalysisMethod.Get() == vsp::VSPAERO_ANALYSIS_METHOD::PANEL ) && ( !FileExist( VSPAEROMgr.m_CompGeomFileFull ) ) ) )
        {
            m_SetupButton.Deactivate();
        }
        else
        {
            m_SetupButton.Activate();
        }
        // Kill Solver Setup Button
        if( m_SolverSetupThreadIsRunning )
        {
            m_KillSolverSetupButton.Activate();
        }
        else
        {
            m_KillSolverSetupButton.Deactivate();
        }

        // Setup Text Display
        m_SetupDividerBox->copy_label( std::string( "Setup File: " + GetFilename( VSPAEROMgr.m_SetupFile ) ).c_str() );
        // Read Setup Button
        if( !FileExist( VSPAEROMgr.m_SetupFile ) )
        {
            m_ReadSetup.Deactivate();
        }
        else
        {
            m_ReadSetup.Activate();
        }
        // Save Setup Button
        if( veh->GetVSPAEROCmd().empty() || m_SolverThreadIsRunning || m_SolverSetupThreadIsRunning )
        {
            m_SaveSetup.Deactivate();
        }
        else
        {
            m_SaveSetup.Activate();
        }

        // Solver Button
        if( veh->GetVSPAEROCmd().empty()             ||
                !FileExist( VSPAEROMgr.m_DegenFileFull ) ||
                !FileExist( VSPAEROMgr.m_SetupFile )     ||
                m_SolverThreadIsRunning                  ||
                ( VSPAEROMgr.m_AnalysisMethod.Get() == vsp::VSPAERO_ANALYSIS_METHOD::PANEL && !FileExist( VSPAEROMgr.m_CompGeomFileFull ) ) )
        {
            m_SolverButton.Deactivate();
        }
        else
        {
            m_SolverButton.Activate();
        }
        // Kill Solver Button
        if( m_SolverThreadIsRunning )
        {
            m_KillSolverButton.Activate();
        }
        else
        {
            m_KillSolverButton.Deactivate();
        }

        // Plot Window Button
        if( veh->GetVSPAEROCmd().empty()             ||
                !FileExist( VSPAEROMgr.m_DegenFileFull ) ||
                !FileExist( VSPAEROMgr.m_SetupFile )     ||
                ( VSPAEROMgr.m_AnalysisMethod.Get() == vsp::VSPAERO_ANALYSIS_METHOD::PANEL && !FileExist( VSPAEROMgr.m_CompGeomFileFull ) ) )
        {
            m_PlotButton.Deactivate();
        }
        else
        {
            m_PlotButton.Activate();
        }

        // Viewer Button
        if( veh->GetVIEWERCmd().empty() || m_SolverThreadIsRunning || m_ViewerProcess.IsRunning() || !FileExist( VSPAEROMgr.m_AdbFile ) )
        {
            m_ViewerButton.Deactivate();
        }
        else
        {
            m_ViewerButton.Activate();
        }

        // Export Button
        if ( ResultsMgr.GetNumResults( "VSPAERO_Wrapper" ) == 0 )
        {
            m_ExportResultsToCsvButton.Deactivate();
        }
        else
        {
            m_ExportResultsToCsvButton.Activate();
        }

    }

    m_FLTK_Window->redraw();

    return false;
}