OpenVSP API Documentation 3.41.0
 
Loading...
Searching...
No Matches
Geom Functions

This group of functions is available for adding, deleting, and modifying OpenVSP Geoms through the API. Click here to return to the main page. More...

Functions

std::vector< std::string > vsp::GetGeomTypes ()
 
std::string vsp::AddGeom (const std::string &type, const std::string &parent=std::string())
 
void vsp::UpdateGeom (const std::string &geom_id)
 
void vsp::DeleteGeom (const std::string &geom_id)
 
void vsp::DeleteGeomVec (const std::vector< std::string > &del_vec)
 
void vsp::CutGeomToClipboard (const std::string &geom_id)
 
void vsp::CopyGeomToClipboard (const std::string &geom_id)
 
std::vector< std::string > vsp::PasteGeomClipboard (const std::string &parent=std::string())
 
std::vector< std::string > vsp::FindGeoms ()
 
std::vector< std::string > vsp::FindGeomsWithName (const std::string &name)
 
std::string vsp::FindGeom (const std::string &name, int index)
 
void vsp::SetGeomName (const std::string &geom_id, const std::string &name)
 
std::string vsp::GetGeomName (const std::string &geom_id)
 
std::vector< std::string > vsp::GetGeomParmIDs (const std::string &geom_id)
 
std::string vsp::GetGeomTypeName (const std::string &geom_id)
 
std::string vsp::GetGeomParent (const std::string &geom_id)
 
std::vector< std::string > vsp::GetGeomChildren (const std::string &geom_id)
 
int vsp::GetNumMainSurfs (const std::string &geom_id)
 
int vsp::GetTotalNumSurfs (const std::string &geom_id)
 
int vsp::GetGeomVSPSurfType (const std::string &geom_id, int main_surf_ind=0)
 
int vsp::GetGeomVSPSurfCfdType (const std::string &geom_id, int main_surf_ind=0)
 
vec3d vsp::GetGeomBBoxMax (const std::string &geom_id, int main_surf_ind=0, bool ref_frame_is_absolute=true)
 
vec3d vsp::GetGeomBBoxMin (const std::string &geom_id, int main_surf_ind=0, bool ref_frame_is_absolute=true)
 
void vsp::SetDriverGroup (const std::string &geom_id, int section_index, int driver_0, int driver_1=-1, int driver_2=-1)
 

Detailed Description

Function Documentation

◆ AddGeom()

std::string vsp::AddGeom ( const std::string & type,
const std::string & parent = std::string() )
extern

Add a new Geom of given type as a child of the specified parent. If no parent or an invalid parent is given, the Geom is placed at the top level

//==== Add Wing Geometry ====//
string wing_id = AddGeom( "WING" );
std::string AddGeom(const std::string &type, const std::string &parent=std::string())
Parameters
[in]typeGeom type (i.e FUSELAGE, POD, etc.)
[in]parentParent Geom ID
Returns
Geom ID

◆ CopyGeomToClipboard()

void vsp::CopyGeomToClipboard ( const std::string & geom_id)
extern

Copy Geom from current location and store on clipboard

//==== Add Pod Geometries ====//
string pid1 = AddGeom( "POD", "" );
string pid2 = AddGeom( "POD", "" );
PasteGeomClipboard( pid2 ); // Paste Pod 1 as child of Pod 2
array< string > @geom_ids = FindGeoms();
if ( geom_ids.size() != 3 ) { Print( "---> Error: API Copy/Paste Geom " ); }
std::vector< std::string > PasteGeomClipboard(const std::string &parent=std::string())
std::vector< std::string > FindGeoms()
void CopyGeomToClipboard(const std::string &geom_id)
See also
PasteGeomClipboard
Parameters
[in]geom_idstring Geom ID

◆ CutGeomToClipboard()

void vsp::CutGeomToClipboard ( const std::string & geom_id)
extern

Cut Geom from current location and store on clipboard

//==== Add Pod Geometries ====//
string pid1 = AddGeom( "POD", "" );
string pid2 = AddGeom( "POD", "" );
PasteGeomClipboard( pid2 ); // Paste Pod 1 as child of Pod 2
array< string > @geom_ids = FindGeoms();
if ( geom_ids.size() != 2 ) { Print( "---> Error: API Cut/Paste Geom " ); }
void CutGeomToClipboard(const std::string &geom_id)
See also
PasteGeomClipboard
Parameters
[in]geom_idstring Geom ID

◆ DeleteGeom()

void vsp::DeleteGeom ( const std::string & geom_id)
extern

Delete a particular Geom

//==== Add Wing Geometry ====//
string wing_id = AddGeom( "WING" );
//==== Add Pod Geometry ====//
string pod_id = AddGeom( "POD" );
DeleteGeom( wing_id );
void DeleteGeom(const std::string &geom_id)
Parameters
[in]geom_idstring Geom ID

◆ DeleteGeomVec()

void vsp::DeleteGeomVec ( const std::vector< std::string > & del_vec)
extern

Delete multiple Geoms

//==== Add Pod Geometry ====//
string pid = AddGeom( "POD", "" );
string rid = ExecAnalysis( "CompGeom" );
array<string>@ mesh_id_vec = GetStringResults( rid, "Mesh_GeomID" );
DeleteGeomVec( mesh_id_vec );
std::string ExecAnalysis(const std::string &analysis)
void DeleteGeomVec(const std::vector< std::string > &del_vec)
const std::vector< std::string > & GetStringResults(const std::string &id, const std::string &name, int index=0)
Parameters
[in]del_vecvector<string> Vector of Geom IDs

◆ FindGeom()

std::string vsp::FindGeom ( const std::string & name,
int index )
extern

Find and return the Geom ID with the specified name at given index. Equivalent to FindGeomsWithName( name )[index].

//==== Add Pod Geometry ====//
string pid = AddGeom( "POD", "" );
SetGeomName( pid, "ExamplePodName" );
string geom_id = FindGeom( "ExamplePodName", 0 );
array< string > @geom_ids = FindGeomsWithName( "ExamplePodName" );
if ( geom_ids[0] != geom_id )
{
Print( "---> Error: API FindGeom & FindGeomsWithName" );
}
std::vector< std::string > FindGeomsWithName(const std::string &name)
std::string FindGeom(const std::string &name, int index)
void SetGeomName(const std::string &geom_id, const std::string &name)
See also
FindGeomsWithName
Parameters
[in]nameGeom name
[in]index
Returns
Geom ID with name at specified index

◆ FindGeoms()

std::vector< std::string > vsp::FindGeoms ( )
extern

Find and return all Geom IDs in the model

//==== Add Pod Geometries ====//
string pod1 = AddGeom( "POD", "" );
string pod2 = AddGeom( "POD", "" );
//==== There Should Be Two Geoms =====//
array< string > @geom_ids = FindGeoms();
if ( geom_ids.size() != 2 ) { Print( "---> Error: API FindGeoms " ); }
Returns
Array of all Geom IDs

◆ FindGeomsWithName()

std::vector< std::string > vsp::FindGeomsWithName ( const std::string & name)
extern

Find and return all Geom IDs with the specified name

//==== Add Pod Geometry ====//
string pid = AddGeom( "POD", "" );
SetGeomName( pid, "ExamplePodName" );
array< string > @geom_ids = FindGeomsWithName( "ExamplePodName" );
if ( geom_ids.size() != 1 )
{
Print( "---> Error: API FindGeomsWithName " );
}
See also
FindGeom
Parameters
[in]nameGeom name
Returns
Array of Geom IDs

◆ GetGeomBBoxMax()

vec3d vsp::GetGeomBBoxMax ( const std::string & geom_id,
int main_surf_ind = 0,
bool ref_frame_is_absolute = true )
extern

Get the the maximum coordinate of the bounding box of a Geom with given main surface index. The Geom bounding box may be specified in absolute or body reference frame.

//==== Add Pod Geometry ====//
string pid = AddGeom( "POD" );
SetParmVal( FindParm( pid, "Y_Rotation", "XForm" ), 45 );
SetParmVal( FindParm( pid, "Z_Rotation", "XForm" ), 25 );
vec3d max_pnt = GetGeomBBoxMax( pid, 0, false );
Definition Vec3d.h:235
vec3d GetGeomBBoxMax(const std::string &geom_id, int main_surf_ind=0, bool ref_frame_is_absolute=true)
std::string FindParm(const std::string &parm_container_id, const std::string &parm_name, const std::string &group_name)
double SetParmVal(const std::string &parm_id, double val)
void Update(bool update_managers=true)
See also
GetGeomBBoxMin
Parameters
[in]geom_idstring Geom ID
[in]main_surf_indMain surface index
[in]ref_frame_is_absoluteFlag to specify absolute or body reference frame
Returns
Maximum coordinate of the bounding box

◆ GetGeomBBoxMin()

vec3d vsp::GetGeomBBoxMin ( const std::string & geom_id,
int main_surf_ind = 0,
bool ref_frame_is_absolute = true )
extern

Get the the minimum coordinate of the bounding box of a Geom with given main surface index. The Geom bounding box may be specified in absolute or body reference frame.

//==== Add Pod Geometry ====//
string pid = AddGeom( "POD" );
SetParmVal( FindParm( pid, "Y_Rotation", "XForm" ), 45 );
SetParmVal( FindParm( pid, "Z_Rotation", "XForm" ), 25 );
vec3d min_pnt = GetGeomBBoxMin( pid, 0, false );
vec3d GetGeomBBoxMin(const std::string &geom_id, int main_surf_ind=0, bool ref_frame_is_absolute=true)
See also
GetGeomBBoxMax
Parameters
[in]geom_idstring Geom ID
[in]main_surf_indMain surface index
[in]ref_frame_is_absoluteFlag to specify absolute or body reference frame
Returns
Minimum coordinate of the bounding box

◆ GetGeomChildren()

std::vector< std::string > vsp::GetGeomChildren ( const std::string & geom_id)
extern

Get the IDs for each child of the input parent Geom.

//==== Add Parent and Child Geometry ====//
string pod1 = AddGeom( "POD" );
string pod2 = AddGeom( "POD", pod1 );
string pod3 = AddGeom( "POD", pod2 );
Print( "Children of Pod #1: " );
array<string> children = GetGeomChildren( pod1 );
for ( int i = 0; i < int( children.size() ); i++ )
{
Print( "\t", false );
Print( children[i] );
}
std::vector< std::string > GetGeomChildren(const std::string &geom_id)
Parameters
[in]geom_idstring Geom ID
Returns
vector<string> Vector of child Geom IDs

◆ GetGeomName()

std::string vsp::GetGeomName ( const std::string & geom_id)
extern

Get the name of a specific Geom

//==== Add Pod Geometry ====//
string pid = AddGeom( "POD", "" );
SetGeomName( pid, "ExamplePodName" );
string name_str = "Geom Name: " + GetGeomName( pid );
Print( name_str );
std::string GetGeomName(const std::string &geom_id)
Parameters
[in]geom_idstring Geom ID
Returns
Geom name

◆ GetGeomParent()

std::string vsp::GetGeomParent ( const std::string & geom_id)
extern

Get the parent Geom ID for the input child Geom. "NONE" is returned if the Geom has no parent.

//==== Add Parent and Child Geometry ====//
string pod1 = AddGeom( "POD" );
string pod2 = AddGeom( "POD", pod1 );
Print( "Parent ID of Pod #2: ", false );
Print( GetGeomParent( pod2 ) );
std::string GetGeomParent(const std::string &geom_id)
Parameters
[in]geom_idstring Geom ID
Returns
string Parent Geom ID

◆ GetGeomParmIDs()

std::vector< std::string > vsp::GetGeomParmIDs ( const std::string & geom_id)
extern

Get all Parm IDs associated with this Geom Parm container

//==== Add Pod Geometry ====//
string pid = AddGeom( "POD", "" );
Print( string( "---> Test Get Parm Arrays" ) );
array< string > @parm_array = GetGeomParmIDs( pid );
if ( parm_array.size() < 1 ) { Print( "---> Error: API GetGeomParmIDs " ); }
std::vector< std::string > GetGeomParmIDs(const std::string &geom_id)
Parameters
[in]geom_idstring Geom ID
Returns
Array of Parm IDs

◆ GetGeomTypeName()

std::string vsp::GetGeomTypeName ( const std::string & geom_id)
extern

Get the type name of specified Geom (i.e. FUSELAGE)

//==== Add Wing Geometry ====//
string wing_id = AddGeom( "WING" );
Print( "Geom Type Name: ", false );
Print( GetGeomTypeName( wing_id ) );
std::string GetGeomTypeName(const std::string &geom_id)
Parameters
[in]geom_idstring Geom ID
Returns
Geom type name

◆ GetGeomTypes()

std::vector< std::string > vsp::GetGeomTypes ( )
extern

Get an array of all Geom types (i.e FUSELAGE, POD, etc.)

//==== Add Pod Geometries ====//
string pod1 = AddGeom( "POD", "" );
string pod2 = AddGeom( "POD", "" );
array< string > @type_array = GetGeomTypes();
if ( type_array[0] != "POD" ) { Print( "---> Error: API GetGeomTypes " ); }
std::vector< std::string > GetGeomTypes()
Returns
Array of Geom type names

◆ GetGeomVSPSurfCfdType()

int vsp::GetGeomVSPSurfCfdType ( const std::string & geom_id,
int main_surf_ind = 0 )
extern

Get the VSP surface CFD type of the specified Geom

//==== Add Wing Geometry ====//
string wing_id = AddGeom( "WING" );
if ( GetGeomVSPSurfCfdType( wing_id ) != CFD_NORMAL )
{
Print( "---> Error: API GetGeomVSPSurfCfdType " );
}
@ CFD_NORMAL
int GetGeomVSPSurfCfdType(const std::string &geom_id, int main_surf_ind=0)
See also
VSP_SURF_CFD_TYPE
Parameters
[in]geom_idstring Geom ID
[in]main_surf_indMain surface index
Returns
VSP surface CFD type enum (i.e. CFD_TRANSPARENT)

◆ GetGeomVSPSurfType()

int vsp::GetGeomVSPSurfType ( const std::string & geom_id,
int main_surf_ind = 0 )
extern

Get the VSP surface type of the specified Geom

//==== Add Wing Geometry ====//
string wing_id = AddGeom( "WING" );
if ( GetGeomVSPSurfType( wing_id ) != WING_SURF )
{
Print( "---> Error: API GetGeomVSPSurfType " );
}
@ WING_SURF
int GetGeomVSPSurfType(const std::string &geom_id, int main_surf_ind=0)
See also
VSP_SURF_TYPE
Parameters
[in]geom_idstring Geom ID
[in]main_surf_indMain surface index
Returns
VSP surface type enum (i.e. DISK_SURF)

◆ GetNumMainSurfs()

int vsp::GetNumMainSurfs ( const std::string & geom_id)
extern

Get the number of main surfaces for the specified Geom. Multiple main surfaces may exist for CustoGeoms, propellors, etc., but does not include surfaces created due to symmetry.

//==== Add Prop Geometry ====//
string prop_id = AddGeom( "PROP" );
int num_surf = 0;
num_surf = GetNumMainSurfs( prop_id ); // Should be the same as the number of blades
Print( "Number of Propeller Surfaces: ", false );
Print( num_surf );
int GetNumMainSurfs(const std::string &geom_id)
Parameters
[in]geom_idstring Geom ID
Returns
int Number of main surfaces

◆ GetTotalNumSurfs()

int vsp::GetTotalNumSurfs ( const std::string & geom_id)
extern

Get the total number of surfaces for the specified Geom. This is equivalent to the number of main surface multiplied by the number of symmetric copies.

//==== Add Wing Geometry ====//
string wing_id = AddGeom( "WING" );
int num_surf = 0;
num_surf = GetTotalNumSurfs( wing_id ); // Wings default with XZ symmetry on -> 2 surfaces
Print( "Total Number of Wing Surfaces: ", false );
Print( num_surf );
int GetTotalNumSurfs(const std::string &geom_id)
Parameters
[in]geom_idstring Geom ID
Returns
Number of main surfaces

◆ PasteGeomClipboard()

std::vector< std::string > vsp::PasteGeomClipboard ( const std::string & parent = std::string())
extern

Paste Geom from clipboard into the model. The Geom is pasted as a child of the specified parent, but will be placed at top level if no parent or an invalid one is provided.

//==== Add Pod Geometries ====//
string pid1 = AddGeom( "POD", "" );
string pid2 = AddGeom( "POD", "" );
PasteGeomClipboard( pid2 ); // Paste Pod 1 as child of Pod 2
array< string > @geom_ids = FindGeoms();
if ( geom_ids.size() != 2 ) { Print( "---> Error: API Cut/Paste Geom " ); }
Parameters
[in]parentstring Parent Geom ID
Returns
vector<string> Vector of pasted Geom IDs

◆ SetDriverGroup()

void vsp::SetDriverGroup ( const std::string & geom_id,
int section_index,
int driver_0,
int driver_1 = -1,
int driver_2 = -1 )
extern

Set the driver group for a wing section or a XSecCurve. Care has to be taken when setting these driver groups to ensure a valid combination.

//==== Add Wing Geometry and Set Parms ====//
string wing_id = AddGeom( "WING", "" );
//==== Set Wing Section Controls ====//
//==== Set Parms ====//
SetParmVal( wing_id, "Root_Chord", "XSec_1", 2 );
SetParmVal( wing_id, "Tip_Chord", "XSec_1", 1 );
@ ROOTC_WSECT_DRIVER
@ TIPC_WSECT_DRIVER
@ AR_WSECT_DRIVER
void SetDriverGroup(const std::string &geom_id, int section_index, int driver_0, int driver_1=-1, int driver_2=-1)
See also
WING_DRIVERS, XSEC_DRIVERS
Parameters
[in]geom_idstring Geom ID
[in]section_indexWing section index
[in]driver_0First driver enum (i.e. SPAN_WSECT_DRIVER)
[in]driver_1Second driver enum (i.e. ROOTC_WSECT_DRIVER)
[in]driver_2Third driver enum (i.e. TIPC_WSECT_DRIVER)

◆ SetGeomName()

void vsp::SetGeomName ( const std::string & geom_id,
const std::string & name )
extern

Set the name of the specified Geom

//==== Add Pod Geometry ====//
string pid = AddGeom( "POD", "" );
SetGeomName( pid, "ExamplePodName" );
array< string > @geom_ids = FindGeomsWithName( "ExamplePodName" );
if ( geom_ids.size() != 1 )
{
Print( "---> Error: API FindGeomsWithName " );
}
Parameters
[in]geom_idstring Geom ID
[in]nameGeom name

◆ UpdateGeom()

void vsp::UpdateGeom ( const std::string & geom_id)
extern

Perform an update for the specified Geom

//==== Add Wing Geometry ====//
string wing_id = AddGeom( "WING" );
//==== Add Pod Geometry ====//
string pod_id = AddGeom( "POD" );
SetParmVal( pod_id, "X_Rel_Location", "XForm", 5.0 );
UpdateGeom( pod_id ); // Faster than updating the whole vehicle
void UpdateGeom(const std::string &geom_id)
See also
Update()
Parameters
[in]geom_idstring Geom ID