OpenVSP API Documentation 3.51.3
Loading...
Searching...
No Matches
Vehicle Functions

The Vehicle group of functions are high-level commands that pertain to the entire OpenVSP model. Click here to return to the main page. More...

Functions

void vsp::Update (bool update_managers=true)
void vsp::VSPExit (int error_code)
void vsp::VSPCrash (int crash_type)
int vsp::GetAndResetUpdateCount ()
std::string vsp::GetVSPFileName ()
void vsp::ClearVSPModel ()

Detailed Description

Function Documentation

◆ ClearVSPModel()

void vsp::ClearVSPModel ( )
extern

Clear the current OpenVSP model

string fid = AddGeom( "FUSELAGE", "" ); // Add Fuselage
//==== Reset Geometry ====//
Print( string( "--->Resetting VSP model to blank slate\n" ) );
if ( FindGeoms().size() != 0 )
{
Print( "ERROR: ClearVSPModel left Geoms behind" );
__failure++;
}
std::vector< std::string > FindGeoms()
std::string AddGeom(const std::string &type, const std::string &parent=std::string())
void ClearVSPModel()

◆ GetAndResetUpdateCount()

int vsp::GetAndResetUpdateCount ( )
extern

Return the OpenVSP update count and also reset it to zero.

The OpenVSP update count tracks how many times the GUI has been told to update screens (set to dirty). It provides a simple means of testing whether the OpenVSP state has possibly changed (non-zero returned). Nothing marks a screen dirty when no GUI is running, so the count stays at zero in a plain script.

//==== Add Pod Geometry ====//
string pid = AddGeom( "POD" );
// Reading the count clears it, so a second read with nothing in between
// reports no change.
{
Print( "ERROR: the update count did not reset" );
__failure++;
}
// The count is a GUI notion. A script with no GUI running never marks a
// screen dirty, so the count stays where the read left it.
SetParmValUpdate( pid, "Length", "Design", 10.0 );
{
Print( "ERROR: the update count went negative" );
__failure++;
}
double SetParmValUpdate(const std::string &parm_id, double val)
int GetAndResetUpdateCount()
void Update(bool update_managers=true)
Returns
int OpenVSP update count

◆ GetVSPFileName()

std::string vsp::GetVSPFileName ( )
extern

Get the file name of the current OpenVSP project

string fid = AddGeom( "FUSELAGE", "" ); // Add Fuselage
string fname = "example_fuse.vsp3";
SetVSP3FileName( fname );
// A relative name is resolved against the working directory, so ask for the
// resolved name rather than assuming it comes back verbatim.
string full_name = GetVSPFileName();
//==== Save Vehicle to File ====//
Print( "\tSaving vehicle file to: ", false );
Print( fname );
if ( GetVSPFileName() != full_name || full_name.findLast( fname ) < 0 )
{
Print( "ERROR: GetVSPFileName did not report the name that was set" );
__failure++;
}
@ SET_ALL
void SetVSP3FileName(const std::string &file_name)
void WriteVSPFile(const std::string &file_name, int set=SET_ALL)
std::string GetVSPFileName()
Returns
string File name for the current OpenVSP project

◆ Update()

void vsp::Update ( bool update_managers = true)
extern

Update the entire vehicle and all lower level children. An input, which is true by default, is available to specify if managers should be updated as well. The managers are typically updated by their respective GUI, so must be updated through the API as well to avoid unexpected behavior.

string fid = AddGeom( "FUSELAGE", "" ); // Add Fuselage
string xsec_surf = GetXSecSurf( fid, 0 ); // Get First (and Only) XSec Surf
int num_xsecs = GetNumXSec( xsec_surf );
vec3d before_max = GetGeomBBoxMax( fid, 0, false );
//==== Set Tan Angles At Nose/Tail
SetXSecTanAngles( GetXSec( xsec_surf, 0 ), XSEC_BOTH_SIDES, 90 );
SetXSecTanAngles( GetXSec( xsec_surf, num_xsecs - 1 ), XSEC_BOTH_SIDES, -90 );
Update(); // Force Surface Update
vec3d after_max = GetGeomBBoxMax( fid, 0, false );
// Blunting the nose and tail pushes the surface out, which only shows up in
// the bounding box once Update() has rebuilt it.
if ( dist( before_max, after_max ) < 1e-9 )
{
Print( "ERROR: Update did not rebuild the surface" );
__failure++;
}
Definition Vec3d.h:243
@ XSEC_BOTH_SIDES
vec3d GetGeomBBoxMax(const std::string &geom_id, int main_surf_ind=0, bool ref_frame_is_absolute=true)
std::string GetXSecSurf(const std::string &geom_id, int index)
std::string GetXSec(const std::string &xsec_surf_id, int xsec_index)
int GetNumXSec(const std::string &xsec_surf_id)
double dist(const vec3d &a, const vec3d &b)
Parameters
update_managersbool Flag to indicate if managers should be updated

◆ VSPCrash()

void vsp::VSPCrash ( int crash_type)
extern

Cause OpenVSP to crash in a variety of ways.

Parameters
[in]crash_typeint Type of crash to attempt.

◆ VSPExit()

void vsp::VSPExit ( int error_code)
extern

Exit the program with a specific error code

Parameters
[in]error_codeint Error code