OpenVSP API Documentation 3.51.3
Loading...
Searching...
No Matches
Snap-To Functions

This group of API functions provide the capabilities available in the Snap-To tool. Click here to return to the main page. More...

Functions

double vsp::ComputeMinClearanceDistance (const std::string &geom_id, int set=SET_ALL, bool useMode=false, const std::string &modeID=std::string())
double vsp::SnapParm (const std::string &parm_id, double target_min_dist, bool inc_flag, int set=SET_ALL, bool useMode=false, const std::string &modeID=std::string())

Detailed Description

Function Documentation

◆ ComputeMinClearanceDistance()

double vsp::ComputeMinClearanceDistance ( const std::string & geom_id,
int set = SET_ALL,
bool useMode = false,
const std::string & modeID = std::string() )
extern

Compute the minimum clearance distance for the specified geometry

string fid = AddGeom( "FUSELAGE", "" ); // Add Fuselage
string pid = AddGeom( "POD", "" ); // Add Pod
string x = GetParm( pid, "X_Rel_Location", "XForm" );
SetParmVal( x, 3.0 );
double min_dist = ComputeMinClearanceDistance( pid, SET_ALL );
// The Pod was moved clear of the Fuselage, so there is a real gap between
// them. Sliding it back into the Fuselage has to close that gap.
if ( min_dist <= 0.0 )
{
Print( "ERROR: ComputeMinClearanceDistance reports no clearance between separated Geoms" );
__failure++;
}
SetParmVal( x, 0.0 );
if ( ComputeMinClearanceDistance( pid, SET_ALL ) >= min_dist )
{
Print( "ERROR: ComputeMinClearanceDistance did not close as the Geoms came together" );
__failure++;
}
@ SET_ALL
std::string AddGeom(const std::string &type, const std::string &parent=std::string())
double SetParmVal(const std::string &parm_id, double val)
std::string GetParm(const std::string &geom_id, const std::string &name, const std::string &group)
double ComputeMinClearanceDistance(const std::string &geom_id, int set=SET_ALL, bool useMode=false, const std::string &modeID=std::string())
void Update(bool update_managers=true)
Parameters
[in]geom_idstring Geom ID
[in]setint Collision set enum (i.e. SET_ALL)
[in]useModebool Flag determine if mode is used instead of sets
[in]modeIDstring ID of Mode to use
Returns
double Minimum clearance distance

◆ SnapParm()

double vsp::SnapParm ( const std::string & parm_id,
double target_min_dist,
bool inc_flag,
int set = SET_ALL,
bool useMode = false,
const std::string & modeID = std::string() )
extern

Snap the specified Parm to input target minimum clearance distance

//Add Geoms
string fid = AddGeom( "FUSELAGE", "" ); // Add Fuselage
string pid = AddGeom( "POD", "" ); // Add Pod
string x = GetParm( pid, "X_Rel_Location", "XForm" );
SetParmVal( x, 3.0 );
double min_dist = SnapParm( x, 0.1, true, SET_ALL );
// Snapping moves the Parm until the clearance reaches the target, so the
// Parm has to have moved and the clearance has to end up where it was
// asked for.
if ( closeTo( GetParmVal( x ), 3.0, 1e-9 ) )
{
Print( "ERROR: SnapParm did not move the Parm" );
__failure++;
}
if ( !closeTo( ComputeMinClearanceDistance( pid, SET_ALL ), 0.1, 1e-4 ) )
{
Print( "ERROR: SnapParm did not reach the target clearance" );
__failure++;
}
if ( !closeTo( min_dist, ComputeMinClearanceDistance( pid, SET_ALL ), 1e-4 ) )
{
Print( "ERROR: SnapParm reported a clearance it did not reach" );
__failure++;
}
double GetParmVal(const std::string &parm_id)
double SnapParm(const std::string &parm_id, double target_min_dist, bool inc_flag, int set=SET_ALL, bool useMode=false, const std::string &modeID=std::string())
Parameters
[in]parm_idstring Parm ID
[in]target_min_distdouble Target minimum clearance distance
[in]inc_flagbool Direction indication flag. If true, upper parm limit is used and direction is set to positive
[in]setint Collision set enum (i.e. SET_ALL)
[in]useModebool Flag determine if mode is used instead of sets
[in]modeIDstring ID of Mode to use
Returns
double Minimum clearance distance