OpenVSP API Documentation 3.51.3
Loading...
Searching...
No Matches
Sub-Surface Functions

Functions related to Sub-Surfaces are defined in this group. Click here to return to the main page. More...

Functions

std::string vsp::AddSubSurf (const std::string &geom_id, int type, int surfindex=0)
std::string vsp::GetSubSurf (const std::string &geom_id, int index)
std::vector< std::string > vsp::GetSubSurf (const std::string &geom_id, const std::string &name)
void vsp::DeleteSubSurf (const std::string &geom_id, const std::string &sub_id)
void vsp::ReorderSubSurf (const std::string &geom_id, const std::string &sub_id, int reorder_type)
void vsp::DeleteSubSurf (const std::string &sub_id)
void vsp::SetSubSurfName (const std::string &geom_id, const std::string &sub_id, const std::string &name)
void vsp::SetSubSurfName (const std::string &sub_id, const std::string &name)
std::string vsp::GetSubSurfName (const std::string &geom_id, const std::string &sub_id)
std::string vsp::GetSubSurfName (const std::string &sub_id)
int vsp::GetSubSurfIndex (const std::string &sub_id)
std::vector< std::string > vsp::GetSubSurfIDVec (const std::string &geom_id)
std::vector< std::string > vsp::GetAllSubSurfIDs ()
int vsp::GetNumSubSurf (const std::string &geom_id)
int vsp::GetSubSurfType (const std::string &sub_id)
std::vector< std::string > vsp::GetSubSurfParmIDs (const std::string &sub_id)
void vsp::IntersectSubSurf (const std::string &sub_id)
std::string vsp::GetIntersectSubSurfGeomID (const std::string &sub_id)

Detailed Description

Function Documentation

◆ AddSubSurf()

std::string vsp::AddSubSurf ( const std::string & geom_id,
int type,
int surfindex = 0 )
extern

Add a sub-surface to the specified Geom

string wid = AddGeom( "WING", "" ); // Add Wing
// Note: Parm Group for SubSurfaces in the form: "SS_" + type + "_" + count (initialized at 1)
string ss_line_id = AddSubSurf( wid, SS_LINE ); // Add Sub Surface Line
SetParmVal( wid, "Const_Line_Value", "SubSurface_1", 0.4 ); // Change Location
if ( ss_line_id.length() == 0 || ss_line_id == "NONE" )
{
Print( "ERROR: AddSubSurf returned no id" );
__failure++;
}
@ SS_LINE
std::string AddGeom(const std::string &type, const std::string &parent=std::string())
double SetParmVal(const std::string &parm_id, double val)
std::string AddSubSurf(const std::string &geom_id, int type, int surfindex=0)
See also
SUBSURF_TYPE
Parameters
[in]geom_idstring Geom ID
[in]typeint Sub-surface type enum (i.e. SS_RECTANGLE)
[in]surfindexint Main surface index (default: 0)
Returns
string Sub-surface ID

◆ DeleteSubSurf() [1/2]

void vsp::DeleteSubSurf ( const std::string & geom_id,
const std::string & sub_id )
extern

Delete the specified sub-surface

string wid = AddGeom( "WING", "" ); // Add Wing
string ss_line_id = AddSubSurf( wid, SS_LINE ); // Add Sub Surface Line
string ss_rec_id = AddSubSurf( wid, SS_RECTANGLE ); // Add Sub Surface Rectangle
Print("Delete SS_Line\n");
int num_before_del = GetNumSubSurf( wid );
DeleteSubSurf( wid, ss_line_id );
if ( GetNumSubSurf( wid ) >= num_before_del )
{
Print( "ERROR: DeleteSubSurf removed nothing" );
__failure++;
}
int num_ss = GetNumSubSurf( wid );
string num_str = string("Number of SubSurfaces: ") + formatInt( num_ss, '' ) + string("\n");
Print( num_str );
@ SS_RECTANGLE
int GetNumSubSurf(const std::string &geom_id)
void DeleteSubSurf(const std::string &geom_id, const std::string &sub_id)
Parameters
[in]geom_idstring Geom ID
[in]sub_idstring Sub-surface ID

◆ DeleteSubSurf() [2/2]

void vsp::DeleteSubSurf ( const std::string & sub_id)
extern

Delete the specified sub-surface

string wid = AddGeom( "WING", "" ); // Add Wing
string ss_line_id = AddSubSurf( wid, SS_LINE ); // Add Sub Surface Line
string ss_rec_id = AddSubSurf( wid, SS_RECTANGLE ); // Add Sub Surface Rectangle
Print("Delete SS_Line\n");
int num_before_del = GetNumSubSurf( wid );
DeleteSubSurf( ss_line_id );
if ( GetNumSubSurf( wid ) >= num_before_del )
{
Print( "ERROR: DeleteSubSurf removed nothing" );
__failure++;
}
int num_ss = GetNumSubSurf( wid );
string num_str = string("Number of SubSurfaces: ") + formatInt( num_ss, '' ) + string("\n");
Print( num_str );
Parameters
[in]sub_idstring Sub-surface ID

◆ GetAllSubSurfIDs()

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

Get a vector of all sub-surface IDs for the entire model

Returns
vector<string> Array of sub-surface IDs

◆ GetIntersectSubSurfGeomID()

std::string vsp::GetIntersectSubSurfGeomID ( const std::string & sub_id)
extern

Set Geom ID to intersect parent with to create intersection SS_INTERSECT type subsurfaces

string pid = AddGeom( "POD", "" );
string p2id = AddGeom( "POD", "" );
string xpod2 = GetParm( p2id, "X_Rel_Location", "XForm" );
SetParmVal( xpod2, 4.0 );
string zrotpod2 = GetParm( p2id, "Z_Rel_Rotation", "XForm" );
SetParmVal( zrotpod2, 60.0 );
string sub_id = AddSubSurf( pid, SS_INTERSECT );
SetIntersectSubSurfGeomID( sub_id, p2id );
IntersectSubSurf( sub_id );
// The sub-surface is an intersection of the two Pods, and it belongs to the
// first one.
if ( GetSubSurfType( sub_id ) != SS_INTERSECT )
{
Print( "ERROR: the sub-surface is not an intersection" );
__failure++;
}
array< string > @sub_ids = GetSubSurfIDVec( pid );
if ( sub_ids.size() != 1 || sub_ids[0] != sub_id )
{
Print( "ERROR: the intersection sub-surface is not on the Geom it was added to" );
__failure++;
}
// Naming a Geom that does not exist has to be rejected.
SetIntersectSubSurfGeomID( sub_id, "NOSUCHGEOM" );
IntersectSubSurf( sub_id );
if ( GetNumTotalErrors() == 0 )
{
Print( "ERROR: a bad Geom ID was accepted for the intersection" );
__failure++;
}
// That error was raised deliberately, so take it back off the queue.
while ( GetNumTotalErrors() > 0 )
{
ErrorObj err = PopLastError();
}
@ SS_INTERSECT
std::string GetParm(const std::string &geom_id, const std::string &name, const std::string &group)
std::vector< std::string > GetSubSurfIDVec(const std::string &geom_id)
void IntersectSubSurf(const std::string &sub_id)
int GetSubSurfType(const std::string &sub_id)
void Update(bool update_managers=true)
Parameters
[in]sub_idstring Sub-surface ID
[in]geom_idstring Geom ID to intersect with parent to create subsurface

Get the Geom ID that an SS_INTERSECT type sub-surface intersects its parent with

string pid = AddGeom( "POD", "" );
string p2id = AddGeom( "POD", "" );
string sub_id = AddSubSurf( pid, SS_INTERSECT );
SetIntersectSubSurfGeomID( sub_id, p2id );
if ( GetIntersectSubSurfGeomID( sub_id ) != p2id )
{
Print( "ERROR: GetIntersectSubSurfGeomID did not report the Geom that was set" );
__failure++;
}
// A sub-surface of the wrong type has to be rejected.
string line_id = AddSubSurf( pid, SS_LINE );
if ( GetNumTotalErrors() == 0 )
{
Print( "ERROR: GetIntersectSubSurfGeomID accepted a sub-surface of the wrong type" );
__failure++;
}
// That error was raised deliberately, so take it back off the queue.
while ( GetNumTotalErrors() > 0 )
{
ErrorObj err = PopLastError();
}
std::string GetIntersectSubSurfGeomID(const std::string &sub_id)
See also
SetIntersectSubSurfGeomID, IntersectSubSurf
Parameters
[in]sub_idstring Sub-surface ID
Returns
string Geom ID the sub-surface intersects with

◆ GetNumSubSurf()

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

Get the number of sub-surfaces for the specified Geom

string wid = AddGeom( "WING", "" ); // Add Wing
string ss_line_id = AddSubSurf( wid, SS_LINE ); // Add Sub Surface Line
string ss_rec_id = AddSubSurf( wid, SS_RECTANGLE ); // Add Sub Surface Rectangle
int num_ss = GetNumSubSurf( wid );
if ( num_ss != 2 )
{
Print( "ERROR: GetNumSubSurf, two were added" );
__failure++;
}
string num_str = string("Number of SubSurfaces: ") + num_ss + string("\n");
Print( num_str );
Parameters
[in]geom_idstring Geom ID
Returns
int Number of Sub-surfaces

◆ GetSubSurf() [1/2]

std::vector< std::string > vsp::GetSubSurf ( const std::string & geom_id,
const std::string & name )
extern

Get the ID of the specified sub-surface

string wid = AddGeom( "WING", "" ); // Add Wing
string ss_rec_1 = AddSubSurf( wid, SS_RECTANGLE ); // Add Sub Surface Rectangle #1
string ss_rec_2 = AddSubSurf( wid, SS_RECTANGLE ); // Add Sub Surface Rectangle #2
Print( ss_rec_2, false );
Print( " = ", false );
Print( GetSubSurf( wid, 1 ) );
// Sub-surfaces come back in the order they were added.
if ( GetSubSurf( wid, 0 ) != ss_rec_1 || GetSubSurf( wid, 1 ) != ss_rec_2 )
{
Print( "ERROR: GetSubSurf did not report the sub-surfaces in order" );
__failure++;
}
// The index form and the ID vector have to agree.
array< string > @id_vec = GetSubSurfIDVec( wid );
if ( id_vec.size() != 2 || id_vec[1] != GetSubSurf( wid, 1 ) )
{
Print( "ERROR: GetSubSurf disagrees with GetSubSurfIDVec" );
__failure++;
}
// An index past the end has to be rejected.
GetSubSurf( wid, 2 );
if ( GetNumTotalErrors() == 0 )
{
Print( "ERROR: GetSubSurf accepted an index past the end" );
__failure++;
}
// That error was raised deliberately, so take it back off the queue.
while ( GetNumTotalErrors() > 0 )
{
ErrorObj err = PopLastError();
}
std::string GetSubSurf(const std::string &geom_id, int index)
Parameters
[in]geom_idstring Geom ID
[in]namestring Sub surface name
Returns
vector<string> Vector of sub-surface ID

◆ GetSubSurf() [2/2]

std::string vsp::GetSubSurf ( const std::string & geom_id,
int index )
extern

Get the ID of the specified sub-surface

string wid = AddGeom( "WING", "" ); // Add Wing
string ss_rec_1 = AddSubSurf( wid, SS_RECTANGLE ); // Add Sub Surface Rectangle #1
string ss_rec_2 = AddSubSurf( wid, SS_RECTANGLE ); // Add Sub Surface Rectangle #2
Print( ss_rec_2, false );
Print( " = ", false );
Print( GetSubSurf( wid, 1 ) );
// Sub-surfaces come back in the order they were added.
if ( GetSubSurf( wid, 0 ) != ss_rec_1 || GetSubSurf( wid, 1 ) != ss_rec_2 )
{
Print( "ERROR: GetSubSurf did not report the sub-surfaces in order" );
__failure++;
}
// The index form and the ID vector have to agree.
array< string > @id_vec = GetSubSurfIDVec( wid );
if ( id_vec.size() != 2 || id_vec[1] != GetSubSurf( wid, 1 ) )
{
Print( "ERROR: GetSubSurf disagrees with GetSubSurfIDVec" );
__failure++;
}
// An index past the end has to be rejected.
GetSubSurf( wid, 2 );
if ( GetNumTotalErrors() == 0 )
{
Print( "ERROR: GetSubSurf accepted an index past the end" );
__failure++;
}
// That error was raised deliberately, so take it back off the queue.
while ( GetNumTotalErrors() > 0 )
{
ErrorObj err = PopLastError();
}
Parameters
[in]geom_idstring Geom ID
[in]indexint Sub-surface index
Returns
string Sub-surface ID

◆ GetSubSurfIDVec()

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

Get a vector of all sub-surface IDs for the specified geometry

string wid = AddGeom( "WING", "" ); // Add Wing
string ss_line_id = AddSubSurf( wid, SS_LINE ); // Add Sub Surface Line
string ss_rec_id = AddSubSurf( wid, SS_RECTANGLE ); // Add Sub Surface Rectangle
array<string> id_vec = GetSubSurfIDVec( wid );
if ( id_vec.length() == 0 )
{
Print( "ERROR: GetSubSurfIDVec returned nothing" );
__failure++;
}
string id_type_str = string( "SubSurface IDs and Type Indexes -> ");
for ( uint i = 0; i < uint(id_vec.length()); i++ )
{
id_type_str += id_vec[i];
id_type_str += string(": ");
id_type_str += GetSubSurfType(id_vec[i]);
id_type_str += string("\t");
}
id_type_str += string("\n");
Print( id_type_str );
Parameters
[in]geom_idstring Geom ID
Returns
vector<int> Array of sub-surface IDs

◆ GetSubSurfIndex()

int vsp::GetSubSurfIndex ( const std::string & sub_id)
extern

Get the index of the specified sub-surface in its parent Geom's sub-surface vector

string wid = AddGeom( "WING", "" ); // Add Wing
string ss_line_id = AddSubSurf( wid, SS_LINE ); // Add Sub Surface Line
string ss_rec_id = AddSubSurf( wid, SS_RECTANGLE ); // Add Sub Surface Rectangle
int ind = GetSubSurfIndex( ss_rec_id );
string ind_str = string("Index of SS_Rectangle: ") + ind + string("\n");
Print( ind_str );
// The rectangle was added second, so it sits at index 1.
if ( ind != 1 || GetSubSurfIndex( ss_line_id ) != 0 )
{
Print( "ERROR: GetSubSurfIndex did not report the order they were added" );
__failure++;
}
// The index has to lead back to the same sub-surface.
if ( GetSubSurf( wid, ind ) != ss_rec_id )
{
Print( "ERROR: GetSubSurfIndex disagrees with GetSubSurf" );
__failure++;
}
int GetSubSurfIndex(const std::string &sub_id)
Parameters
[in]sub_idstring Sub-surface ID
Returns
int Sub-surface index

◆ GetSubSurfName() [1/2]

std::string vsp::GetSubSurfName ( const std::string & geom_id,
const std::string & sub_id )
extern

Get the name of the specified sub-surface

string wid = AddGeom( "WING", "" ); // Add Wing
string ss_rec_id = AddSubSurf( wid, SS_RECTANGLE ); // Add Sub Surface Rectangle
string rec_name = GetSubSurfName( wid, ss_rec_id );
if ( rec_name.length() == 0 )
{
Print( "ERROR: GetSubSurfName returned nothing" );
__failure++;
}
string name_str = string("Current Name of SS_Rectangle: ") + rec_name + string("\n");
Print( name_str );
std::string GetSubSurfName(const std::string &geom_id, const std::string &sub_id)
Parameters
[in]geom_idstring Geom ID
[in]sub_idstring Sub-surface ID
Returns
string Sub-surface name

◆ GetSubSurfName() [2/2]

std::string vsp::GetSubSurfName ( const std::string & sub_id)
extern

Get the name of the specified sub-surface

string wid = AddGeom( "WING", "" ); // Add Wing
string ss_rec_id = AddSubSurf( wid, SS_RECTANGLE ); // Add Sub Surface Rectangle
string rec_name = GetSubSurfName( wid, ss_rec_id );
if ( rec_name.length() == 0 )
{
Print( "ERROR: GetSubSurfName returned nothing" );
__failure++;
}
string name_str = string("Current Name of SS_Rectangle: ") + rec_name + string("\n");
Print( name_str );
Parameters
[in]sub_idstring Sub-surface ID
Returns
string Sub-surface name

◆ GetSubSurfParmIDs()

std::vector< std::string > vsp::GetSubSurfParmIDs ( const std::string & sub_id)
extern

Get the vector of Parm IDs for specified sub-surface

string wid = AddGeom( "WING", "" ); // Add Wing
string ss_line_id = AddSubSurf( wid, SS_LINE ); // Add Sub Surface Line
// Get and list all Parm info for SS_Line
array<string> parm_id_vec = GetSubSurfParmIDs( ss_line_id );
if ( parm_id_vec.length() == 0 )
{
Print( "ERROR: GetSubSurfParmIDs returned nothing" );
__failure++;
}
for ( uint i = 0; i < uint(parm_id_vec.length()); i++ )
{
string id_name_str = string("\tName: ") + GetParmName( parm_id_vec[i] ) + string(", Group: ") + GetParmDisplayGroupName( parm_id_vec[i] ) +
string(", ID: ") + parm_id_vec[i] + string("\n");
Print( id_name_str );
}
std::string GetParmName(const std::string &parm_id)
std::string GetParmDisplayGroupName(const std::string &parm_id)
std::vector< std::string > GetSubSurfParmIDs(const std::string &sub_id)
Parameters
[in]sub_idstring Sub-surface ID
Returns
vector<string> Vector of Parm IDs

◆ GetSubSurfType()

int vsp::GetSubSurfType ( const std::string & sub_id)
extern

Get the type for the specified sub-surface (i.e. SS_RECTANGLE)

string wid = AddGeom( "WING", "" ); // Add Wing
string ss_line_id = AddSubSurf( wid, SS_LINE ); // Add Sub Surface Line
string ss_rec_id = AddSubSurf( wid, SS_RECTANGLE ); // Add Sub Surface Rectangle
array<string> id_vec = GetSubSurfIDVec( wid );
// Each sub-surface has to report the type it was created as.
if ( GetSubSurfType( ss_line_id ) != SS_LINE || GetSubSurfType( ss_rec_id ) != SS_RECTANGLE )
{
Print( "ERROR: GetSubSurfType did not report the type that was added" );
__failure++;
}
string id_type_str = string( "SubSurface IDs and Type Indexes -> ");
for ( uint i = 0; i < uint(id_vec.length()); i++ )
{
id_type_str += id_vec[i];
id_type_str += string(": ");
id_type_str += GetSubSurfType(id_vec[i]);
id_type_str += string("\t");
}
id_type_str += string("\n");
Print( id_type_str );
See also
SUBSURF_TYPE
Parameters
[in]sub_idstring Sub-surface ID
Returns
int Sub-surface type enum (i.e. SS_RECTANGLE)

◆ IntersectSubSurf()

void vsp::IntersectSubSurf ( const std::string & sub_id)
extern

Trigger intersection for SS_INTERSECT type subsurfaces

string pid = AddGeom( "POD", "" );
string p2id = AddGeom( "POD", "" );
string xpod2 = GetParm( p2id, "X_Rel_Location", "XForm" );
SetParmVal( xpod2, 4.0 );
string zrotpod2 = GetParm( p2id, "Z_Rel_Rotation", "XForm" );
SetParmVal( zrotpod2, 60.0 );
string sub_id = AddSubSurf( pid, SS_INTERSECT );
SetIntersectSubSurfGeomID( sub_id, p2id );
IntersectSubSurf( sub_id );
// The sub-surface is an intersection of the two Pods, and it belongs to the
// first one.
if ( GetSubSurfType( sub_id ) != SS_INTERSECT )
{
Print( "ERROR: the sub-surface is not an intersection" );
__failure++;
}
array< string > @sub_ids = GetSubSurfIDVec( pid );
if ( sub_ids.size() != 1 || sub_ids[0] != sub_id )
{
Print( "ERROR: the intersection sub-surface is not on the Geom it was added to" );
__failure++;
}
// Naming a Geom that does not exist has to be rejected.
SetIntersectSubSurfGeomID( sub_id, "NOSUCHGEOM" );
IntersectSubSurf( sub_id );
if ( GetNumTotalErrors() == 0 )
{
Print( "ERROR: a bad Geom ID was accepted for the intersection" );
__failure++;
}
// That error was raised deliberately, so take it back off the queue.
while ( GetNumTotalErrors() > 0 )
{
ErrorObj err = PopLastError();
}
Parameters
[in]sub_idstring Sub-surface ID

◆ ReorderSubSurf()

void vsp::ReorderSubSurf ( const std::string & geom_id,
const std::string & sub_id,
int reorder_type )
extern

Move a sub-surface within its parent Geom's sub-surface list, the way the move buttons on the Sub-Surface tab do. Sub-surfaces are applied in list order, so where one sits decides which of two overlapping sub-surfaces tags a given piece of the surface.

string wing_id = AddGeom( "WING", "" );
string ss_line = AddSubSurf( wing_id, SS_LINE );
string ss_rect = AddSubSurf( wing_id, SS_RECTANGLE );
if ( GetSubSurf( wing_id, 0 ) != ss_line )
{
Print( "ERROR: the sub-surfaces did not start in creation order" );
__failure++;
}
ReorderSubSurf( wing_id, ss_rect, REORDER_MOVE_TOP );
if ( GetSubSurf( wing_id, 0 ) != ss_rect )
{
Print( "ERROR: ReorderSubSurf did not move the sub-surface" );
__failure++;
}
@ REORDER_MOVE_TOP
void ReorderSubSurf(const std::string &geom_id, const std::string &sub_id, int reorder_type)
See also
AddSubSurf, DeleteSubSurf
Parameters
[in]geom_idstring Geom ID
[in]sub_idstring Sub-surface ID
[in]reorder_typeint Reorder type enum (see REORDER_TYPE)

◆ SetSubSurfName() [1/2]

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

Set the name of the specified sub-surface

string wid = AddGeom( "WING", "" ); // Add Wing
string ss_rec_id = AddSubSurf( wid, SS_RECTANGLE ); // Add Sub Surface Rectangle
string new_name = string("New_SS_Rec_Name");
SetSubSurfName( wid, ss_rec_id, new_name );
if ( GetSubSurfName( wid, ss_rec_id ) != new_name )
{
Print( "ERROR: SetSubSurfName did not take" );
__failure++;
}
void SetSubSurfName(const std::string &geom_id, const std::string &sub_id, const std::string &name)
Parameters
[in]geom_idstring Geom ID
[in]sub_idstring Sub-surface ID
[in]namestring Sub-surface name

◆ SetSubSurfName() [2/2]

void vsp::SetSubSurfName ( const std::string & sub_id,
const std::string & name )
extern

Set the name of the specified sub-surface

string wid = AddGeom( "WING", "" ); // Add Wing
string ss_rec_id = AddSubSurf( wid, SS_RECTANGLE ); // Add Sub Surface Rectangle
string new_name = string("New_SS_Rec_Name");
SetSubSurfName( ss_rec_id, new_name );
if ( GetSubSurfName( ss_rec_id ) != new_name )
{
Print( "ERROR: SetSubSurfName did not take" );
__failure++;
}
Parameters
[in]sub_idstring Sub-surface ID
[in]namestring Sub-surface name