OpenVSP API Documentation 3.52.0
Loading...
Searching...
No Matches
General API Utility Functions

This group of functions is provided for general API utilities, such as printing to stdout, performing basic math functions, and identifying basic OpenVSP information. Click here to return to the main page. More...

Functions

void vsp::VSPCheckSetup ()
void vsp::VSPRenew ()
void vsp::Print (const std::string &data, bool new_line=true)
void vsp::Print (const vec3d &data, bool new_line=true)
void vsp::Print (double data, bool new_line=true)
void vsp::Print (int data, bool new_line=true)
double vsp::Min (double x, double y)
double vsp::Max (double x, double y)
double vsp::Rad2Deg (double r)
double vsp::Deg2Rad (double d)
std::string vsp::GetVSPVersion ()
int vsp::GetVSPVersionMajor ()
int vsp::GetVSPVersionMinor ()
int vsp::GetVSPVersionChange ()
std::string vsp::GetVSPExePath ()
bool vsp::SetVSPAEROPath (const std::string &path)
std::string vsp::GetVSPAEROPath ()
bool vsp::CheckForVSPAERO (const std::string &path)
bool vsp::SetVSPHelpPath (const std::string &path)
std::string vsp::GetVSPHelpPath ()
bool vsp::CheckForVSPHelp (const std::string &path)

Detailed Description

Function Documentation

◆ CheckForVSPAERO()

bool vsp::CheckForVSPAERO ( const std::string & path)
extern

Check if all VSPAERO executables (Solver, Viewer, and Slicer) are in a given directory. Note that this function will return false if only one or two VSPAERO executables are found. An error message will indicate the executables that are missing. This may be acceptable, as only the Solver is needed in all cases. The Viewer and Slicer may not be needed.

string vspaero_path = "C:/Users/example_user/Documents/OpenVSP_3.4.5";
if ( CheckForVSPAERO( vspaero_path ) )
{
SetVSPAEROPath( vspaero_path );
}
// A directory that cannot exist must not report VSPAERO in it.
if ( CheckForVSPAERO( "/no/such/directory/anywhere" ) )
{
Print( "ERROR: CheckForVSPAERO found VSPAERO in a nonexistent directory" );
__failure++;
}
bool CheckForVSPAERO(const std::string &path)
bool SetVSPAEROPath(const std::string &path)
void Print(const std::string &data, bool new_line=true)
See also
GetVSPExePath, GetVSPAEROPath, SetVSPAEROPath
Parameters
[in]pathstring Absolute path to check for VSPAERO executables
Returns
bool Flag that indicates if all VSPAERO executables are found or not
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckForVSPHelp()

bool vsp::CheckForVSPHelp ( const std::string & path)
extern

Check if all OpenVSP help files are in a given directory.

string vsphelp_path = "C:/Users/example_user/Documents/OpenVSP_3.4.5/help";
if ( CheckForVSPHelp( vsphelp_path ) )
{
SetVSPHelpPath( vsphelp_path );
}
// A directory that cannot exist must not report help files in it.
if ( CheckForVSPHelp( "/no/such/directory/anywhere" ) )
{
Print( "ERROR: CheckForVSPHelp found help in a nonexistent directory" );
__failure++;
}
bool CheckForVSPHelp(const std::string &path)
bool SetVSPHelpPath(const std::string &path)
See also
GetVSPExePath, GetVSPAEROPath, SetVSPHelpPath
Parameters
[in]pathstring Absolute path to check for VSPAERO executables
Returns
bool Flag that indicates if OpenVSP help files are found or not
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Deg2Rad()

double vsp::Deg2Rad ( double d)
extern

Convert an angle from degrees to radians.

if ( abs( Deg2Rad( 180.0 ) - 3.14159265358979323846 ) > 1e-9 ) { Print( "ERROR: Deg2Rad" ); __failure++; }
double Deg2Rad(double d)
See also
Rad2Deg
Parameters
[in]ddouble Angle in degrees
Returns
double Angle in radians
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVSPAEROPath()

std::string vsp::GetVSPAEROPath ( )
extern

Get the path that OpenVSP will use to look for all VSPAERO executables (Solver, Slicer, and Viewer) when attempting to execute VSPAERO. If the VSPAERO executables are not in this location, they must either be copied there or the VSPAERO path must be set using SetVSPAEROPath.

{
Print( "VSPAERO is not where OpenVSP thinks it is. I should move the VSPAERO executable or call SetVSPAEROPath." );
}
if ( GetVSPAEROPath().length() == 0 )
{
Print( "ERROR: GetVSPAEROPath returned an empty path" );
__failure++;
}
std::string GetVSPAEROPath()
See also
GetVSPExePath, CheckForVSPAERO, SetVSPAEROPath
Returns
string Path OpenVSP will look for VSPAERO
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVSPExePath()

std::string vsp::GetVSPExePath ( )
extern

Get the path to the OpenVSP executable. OpenVSP will assume that the VSPAERO, VSPSLICER, and VSPVIEWER are in the same directory unless instructed otherwise.

Print( "The current VSP executable path is: ", false );
string exe_path = GetVSPExePath();
Print( exe_path );
if ( exe_path.length() == 0 )
{
Print( "ERROR: GetVSPExePath returned an empty path" );
__failure++;
}
std::string GetVSPExePath()
See also
SetVSPAEROPath, CheckForVSPAERO, GetVSPAEROPath
Returns
string Path to the OpenVSP executable
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVSPHelpPath()

std::string vsp::GetVSPHelpPath ( )
extern

Get the path that OpenVSP will use to look for all OpenVSP help files. If the OpenVSP help files are not in this location, they must either be copied there or the VSPHelp path must be set using SetVSPHelpPath.

{
Print( "OpenVSP help is not where OpenVSP thinks it is. I should move the help files or call SetVSPHelpPath." );
}
if ( GetVSPHelpPath().length() == 0 )
{
Print( "ERROR: GetVSPHelpPath returned an empty path" );
__failure++;
}
std::string GetVSPHelpPath()
See also
GetVSPExePath, CheckForVSPHelp, SetVSPHelpPath
Returns
string Path OpenVSP will look for help files
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVSPVersion()

std::string vsp::GetVSPVersion ( )
extern

Get the version of the OpenVSP instance currently running

Print( "The current OpenVSP version is: ", false );
string ver = GetVSPVersion();
Print( ver );
// The string form has to agree with the numeric accessors.
string num = formatInt( GetVSPVersionMajor() ) + "." +
formatInt( GetVSPVersionMinor() ) + "." +
formatInt( GetVSPVersionChange() );
if ( ver.findFirst( num ) < 0 )
{
Print( "ERROR: GetVSPVersion does not contain " + num );
__failure++;
}
int GetVSPVersionChange()
std::string GetVSPVersion()
int GetVSPVersionMinor()
int GetVSPVersionMajor()
Returns
string OpenVSP version string (i.e. "OpenVSP 3.17.1")
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVSPVersionChange()

int vsp::GetVSPVersionChange ( )
extern

Get the change version of the OpenVSP instance currently running as an integer

Print( "The current OpenVSP version is: ", false );
int major = GetVSPVersionMajor();
int minor = GetVSPVersionMinor();
int change = GetVSPVersionChange();
Print( formatInt(major) + "." + formatInt(minor) + "." + formatInt(change) );
// OpenVSP 3 and later. Negative pieces would mean the version was never
// filled in.
if ( major < 3 || minor < 0 || change < 0 )
{
Print( "ERROR: implausible version number" );
__failure++;
}
// The pieces have to add back up to the string form.
string num = formatInt(major) + "." + formatInt(minor) + "." + formatInt(change);
if ( GetVSPVersion().findFirst( num ) < 0 )
{
Print( "ERROR: version pieces disagree with GetVSPVersion" );
__failure++;
}
Returns
int OpenVSP change version number (i.e. Y in 3.X.Y)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVSPVersionMajor()

int vsp::GetVSPVersionMajor ( )
extern

Get the major version of the OpenVSP instance currently running as an integer

Print( "The current OpenVSP version is: ", false );
int major = GetVSPVersionMajor();
int minor = GetVSPVersionMinor();
int change = GetVSPVersionChange();
Print( formatInt(major) + "." + formatInt(minor) + "." + formatInt(change) );
// OpenVSP 3 and later. Negative pieces would mean the version was never
// filled in.
if ( major < 3 || minor < 0 || change < 0 )
{
Print( "ERROR: implausible version number" );
__failure++;
}
// The pieces have to add back up to the string form.
string num = formatInt(major) + "." + formatInt(minor) + "." + formatInt(change);
if ( GetVSPVersion().findFirst( num ) < 0 )
{
Print( "ERROR: version pieces disagree with GetVSPVersion" );
__failure++;
}
Returns
int OpenVSP major version number (i.e. 3 in 3.X.Y)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVSPVersionMinor()

int vsp::GetVSPVersionMinor ( )
extern

Get the minor version of the OpenVSP instance currently running as an integer

Print( "The current OpenVSP version is: ", false );
int major = GetVSPVersionMajor();
int minor = GetVSPVersionMinor();
int change = GetVSPVersionChange();
Print( formatInt(major) + "." + formatInt(minor) + "." + formatInt(change) );
// OpenVSP 3 and later. Negative pieces would mean the version was never
// filled in.
if ( major < 3 || minor < 0 || change < 0 )
{
Print( "ERROR: implausible version number" );
__failure++;
}
// The pieces have to add back up to the string form.
string num = formatInt(major) + "." + formatInt(minor) + "." + formatInt(change);
if ( GetVSPVersion().findFirst( num ) < 0 )
{
Print( "ERROR: version pieces disagree with GetVSPVersion" );
__failure++;
}
Returns
int OpenVSP minor version number (i.e. X in 3.X.Y)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Max()

double vsp::Max ( double x,
double y )
extern

Get the larger of two values.

if ( abs( Max( 2.0, 5.0 ) - 5.0 ) > 1e-12 ) { Print( "ERROR: Max" ); __failure++; }
if ( abs( Max( 5.0, 2.0 ) - 5.0 ) > 1e-12 ) { Print( "ERROR: Max" ); __failure++; }
double Max(double x, double y)
See also
Min
Parameters
[in]xdouble First value
[in]ydouble Second value
Returns
double The larger of the two
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Min()

double vsp::Min ( double x,
double y )
extern

Get the smaller of two values.

if ( abs( Min( 2.0, 5.0 ) - 2.0 ) > 1e-12 ) { Print( "ERROR: Min" ); __failure++; }
if ( abs( Min( 5.0, 2.0 ) - 2.0 ) > 1e-12 ) { Print( "ERROR: Min" ); __failure++; }
double Min(double x, double y)
See also
Max
Parameters
[in]xdouble First value
[in]ydouble Second value
Returns
double The smaller of the two
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Print() [1/4]

void vsp::Print ( const std::string & data,
bool new_line = true )
extern

Print a string to stdout. Print to stdout. Writes the value and, unless asked not to, a newline; there is nothing to check in an example beyond the call itself.

Print( "Hello from the OpenVSP API" );
See also
Min, Max, Rad2Deg, Deg2Rad
Parameters
[in]datastring Text to print
[in]new_linebool Follow the text with a newline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Print() [2/4]

void vsp::Print ( const vec3d & data,
bool new_line = true )
extern

Print a vec3d to stdout, as its three coordinates. Print to stdout. Writes the value and, unless asked not to, a newline; there is nothing to check in an example beyond the call itself.

Print( vec3d( 1.0, 2.0, 3.0 ) );
Definition Vec3d.h:238
See also
Print
Parameters
[in]datavec3d Point to print
[in]new_linebool Follow the point with a newline
Here is the call graph for this function:

◆ Print() [3/4]

void vsp::Print ( double data,
bool new_line = true )
extern

Print a double to stdout. Print to stdout. Writes the value and, unless asked not to, a newline; there is nothing to check in an example beyond the call itself.

Print( 3.14159 );
See also
Print
Parameters
[in]datadouble Value to print
[in]new_linebool Follow the value with a newline
Here is the call graph for this function:

◆ Print() [4/4]

void vsp::Print ( int data,
bool new_line = true )
extern

Print an integer to stdout. Print to stdout. Writes the value and, unless asked not to, a newline; there is nothing to check in an example beyond the call itself.

Print( 42 );
See also
Print
Parameters
[in]dataint Value to print
[in]new_linebool Follow the value with a newline
Here is the call graph for this function:

◆ Rad2Deg()

double vsp::Rad2Deg ( double r)
extern

Convert an angle from radians to degrees.

if ( abs( Rad2Deg( 3.14159265358979323846 ) - 180.0 ) > 1e-9 ) { Print( "ERROR: Rad2Deg" ); __failure++; }
double Rad2Deg(double r)
See also
Deg2Rad
Parameters
[in]rdouble Angle in radians
Returns
double Angle in degrees
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetVSPAEROPath()

bool vsp::SetVSPAEROPath ( const std::string & path)
extern

Set the path to the VSPAERO executables (Solver, Viewer, and Slicer). By default, OpenVSP will assume that the VSPAERO executables are in the same directory as the VSP executable. However, this may need to be changed when using certain API languages like MATLAB and Python. For example, Python may treat the location of the Python executable as the VSP executable path, so either the VSPAERO executable needs to be moved to the same directory or this function can be called to tell Python where to look for VSPAERO.

string orig_path = GetVSPAEROPath();
{
string vspaero_path = "C:/Users/example_user/Documents/OpenVSP_3.4.5";
SetVSPAEROPath( vspaero_path );
}
// A directory with no VSPAERO in it has to be rejected, and rejecting it
// must leave the stored path alone.
if ( SetVSPAEROPath( "/no/such/directory/anywhere" ) )
{
Print( "ERROR: SetVSPAEROPath accepted a nonexistent directory" );
__failure++;
}
if ( GetVSPAEROPath() != orig_path )
{
Print( "ERROR: a rejected SetVSPAEROPath changed the stored path" );
__failure++;
}
See also
GetVSPExePath, CheckForVSPAERO, GetVSPAEROPath
Parameters
[in]pathstring Absolute path to directory containing VSPAERO executable
Returns
bool Flag that indicates whether or not the path was set correctly
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetVSPHelpPath()

bool vsp::SetVSPHelpPath ( const std::string & path)
extern

Set the path to the OpenVSP help files. By default, OpenVSP will assume that the OpenVSP help directory is in the same directory as the VSP executable. However, this may need to be changed when using certain API languages like MATLAB and Python. For example, Python may treat the location of the Python executable as the VSP executable path, so either the VSPAERO executable needs to be moved to the same directory or this function can be called to tell Python where to look for help.

string orig_path = GetVSPHelpPath();
{
string vsphelp_path = "C:/Users/example_user/Documents/OpenVSP_3.4.5/help";
SetVSPHelpPath( vsphelp_path );
}
// A directory with no help files in it has to be rejected, and rejecting it
// must leave the stored path alone.
if ( SetVSPHelpPath( "/no/such/directory/anywhere" ) )
{
Print( "ERROR: SetVSPHelpPath accepted a nonexistent directory" );
__failure++;
}
if ( GetVSPHelpPath() != orig_path )
{
Print( "ERROR: a rejected SetVSPHelpPath changed the stored path" );
__failure++;
}
See also
GetVSPExePath, CheckForVSPHelp, GetVSPHelpPath
Parameters
[in]pathstring Absolute path to directory containing OpenVSP help files
Returns
bool Flag that indicates whether or not the path was set correctly
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VSPCheckSetup()

void vsp::VSPCheckSetup ( )
extern

Check if OpenVSP has been initialized successfully. If not, the OpenVSP instance will be exited. This call should be placed at the beginning of all API scripts.

// A failed setup exits OpenVSP outright, so reaching this point is most of
// the test. Confirm the model is actually usable.
array< string > @type_array = GetGeomTypes();
if ( type_array.length() == 0 )
{
Print( "ERROR: VSPCheckSetup did not leave a usable model" );
__failure++;
}
// Continue to do things...
void VSPCheckSetup()
std::vector< std::string > GetGeomTypes()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VSPRenew()

void vsp::VSPRenew ( )
extern

Clear and reinitialize OpenVSP to all default settings

//==== Add Pod Geometry ====//
string pod_id = AddGeom( "POD" );
SetParmVal( pod_id, "Y_Rel_Location", "XForm", 2.0 );
if ( FindGeoms().size() != 0 ) { Print( "ERROR: VSPRenew" ); __failure++; }
void VSPRenew()
std::vector< std::string > FindGeoms()
std::string AddGeom(const std::string &type, const std::string &parent=std::string())
double SetParmVal(const std::string &parm_id, double val)
Here is the call graph for this function:
Here is the caller graph for this function: