Example #1
0
void StructureMgrSingleton::ShowAllParts()
{
    FeaStructure* fea_struct = GetFeaStruct( m_CurrStructIndex );
    Vehicle* veh = VehicleMgr.GetVehicle();

    if ( fea_struct && veh )
    {
        string parent_id = fea_struct->GetParentGeomID();
        veh->HideAll();

        Geom* parent = veh->FindGeom( parent_id );
        if ( parent )
        {
            parent->SetSetFlag( 1, true ); //add to shown
            parent->SetSetFlag( 2, false ); //remove from show
        }

        vector < FeaPart* > part_vec = fea_struct->GetFeaPartVec();

        for ( size_t i = 0; i < part_vec.size(); i++ )
        {
            part_vec[i]->m_DrawFeaPartFlag.Set( true );
        }

        vector < SubSurface* > ss_vec = fea_struct->GetFeaSubSurfVec();

        for ( size_t i = 0; i < ss_vec.size(); i++ )
        {
            ss_vec[i]->m_DrawFeaPartFlag.Set( true );
        }
    }
}
Example #2
0
//==== Get the geom pointer matching a given comp_id ====//
Geom* SubSurfaceMgrSingleton::GetGeom( string comp_id )
{
    Vehicle* veh = VehicleMgr.GetVehicle();
    if ( !veh )
    {
        return NULL;
    }

    return veh->FindGeom( comp_id );
}
Example #3
0
//==== Add Parm To Current Custom Geom ====//
string CustomGeomMgrSingleton::AddParm( int type, const string & name, const string & group )
{
    Vehicle* veh = VehicleMgr.GetVehicle();
    Geom* gptr = veh->FindGeom( m_CurrGeom );

    //==== Check If Geom is Valid and Correct Type ====//
    if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE )
    {
        CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr );

        return custom_geom->AddParm( type, name, group );
    }

    return string();
}
Example #4
0
//==== Init Custom Geom ====//
void CustomGeomMgrSingleton::InitGeom( const string& id, const string& module_name )
{
    Vehicle* veh = VehicleMgr.GetVehicle();
    Geom* gptr = veh->FindGeom( id );

    //==== Check If Geom is Valid and Correct Type ====//
    if ( gptr && gptr->GetType().m_Type == CUSTOM_GEOM_TYPE )
    {
        m_CurrGeom = id;
        CustomGeom* custom_geom = dynamic_cast<CustomGeom*>( gptr );
        custom_geom->SetScriptModuleName( module_name );
        custom_geom->InitGeom();

        m_ModuleGeomIDMap[ module_name ] = id;
    }
}
Example #5
0
void SubSurface::UpdateDrawObjs()
{
    if ( !m_UpdateDrawFlag )
    {
        return;
    }

    Vehicle* veh = VehicleMgr.GetVehicle();
    if ( !veh )
    {
        return;
    }
    Geom* geom = veh->FindGeom( m_CompID );
    m_DrawObjVec.clear();
    if ( geom )
    {
        vector< VspSurf > surf_vec;
        geom->GetSurfVec( surf_vec );
        int ncopy = geom->GetNumSymmCopies();

        m_DrawObjVec.resize( m_LVec.size()*ncopy, DrawObj() );
        int ind = 0;
        for ( int ls = 0 ; ls < ( int )m_LVec.size() ; ls++ )
        {
            int num_pnts = CompNumDrawPnts( geom );
            int *num_pnts_ptr = NULL;
            if ( num_pnts > 0 )
            {
                num_pnts_ptr = &num_pnts;
            }

            int isurf = m_MainSurfIndx();

            vector < int > symms = geom->GetSymmIndexs( isurf );
            assert( ncopy == symms.size() );

            for ( int s = 0 ; s < ncopy ; s++ )
            {
                m_LVec[ls].UpdateDrawObj( &surf_vec[symms[s]], geom, m_DrawObjVec[ind], num_pnts_ptr );
                ind++;
            }
        }
    }
}
Example #6
0
void SSControlSurf::UpdateDrawObjs()
{
    SubSurface::UpdateDrawObjs();

    Vehicle* veh = VehicleMgr.GetVehicle();
    if ( !veh )
    {
        return;
    }
    Geom* geom = veh->FindGeom( m_CompID );
    if ( geom )
    {
        vector< VspSurf > surf_vec;
        geom->GetSurfVec( surf_vec );
        int ncopy = geom->GetNumSymmCopies();

        m_HingeDO.m_PntVec.clear();
        m_HingeDO.m_LineWidth = 2.0;
        m_HingeDO.m_Type = DrawObj::VSP_LINES;
        m_HingeDO.m_GeomID = m_ID + string( "_ss_hinge" );
        m_HingeDO.m_GeomChanged = true;

        m_ArrowDO.m_PntVec.clear();
        m_ArrowDO.m_Type = DrawObj::VSP_SHADED_TRIS;
        m_ArrowDO.m_GeomID = m_ID + string( "_ss_arrow" );
        m_ArrowDO.m_GeomChanged = true;

        for ( int i = 0; i < 4; i++ )
        {
            m_ArrowDO.m_MaterialInfo.Ambient[i] = 0.2;
            m_ArrowDO.m_MaterialInfo.Diffuse[i] = 0.1;
            m_ArrowDO.m_MaterialInfo.Specular[i] = 0.7;
            m_ArrowDO.m_MaterialInfo.Emission[i] = 0.0;
        }
        m_ArrowDO.m_MaterialInfo.Diffuse[3] = 0.5;
        m_ArrowDO.m_MaterialInfo.Shininess = 5.0;


        int isurf = m_MainSurfIndx();

        vector < int > symms = geom->GetSymmIndexs( isurf );
        assert( ncopy == symms.size() );

        int npt = m_UWStart.size();

        for ( int s = 0 ; s < ncopy ; s++ )
        {
            VspSurf* surf = &( surf_vec[ symms[ s ] ] );

            vec3d pst, pend;
            for ( int i = 0; i < npt; i++ )
            {
                pst = pst + surf->CompPnt01( m_UWStart[i].x(), m_UWStart[i].y() );
                pend = pend + surf->CompPnt01( m_UWEnd[i].x(), m_UWEnd[i].y() );
            }
            pst = pst / ( 1.0 * npt );
            pend = pend / ( 1.0 * npt );

            vec3d pmid = ( pst + pend ) * 0.5;

            vec3d dir = pend - pst;
            double len = dir.mag();
            dir.normalize();

            m_HingeDO.m_PntVec.push_back( pst );
            m_HingeDO.m_PntVec.push_back( pend );

            MakeCircleArrow( pmid, dir, 0.25, m_HingeDO, m_ArrowDO );
        }
        m_ArrowDO.m_NormVec = vector <vec3d> ( m_ArrowDO.m_PntVec.size() );
    }
}
Example #7
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;
}