OpenVSP API Documentation  3.38.0
Functions
Edit Curve XSec Functions

Functions for modifying XSecs of type XS_EDIT_CURVE are defined here. Click here to return to the main page. More...

Functions

void vsp::EditXSecInitShape (const std::string &xsec_id)
 
void vsp::EditXSecConvertTo (const std::string &xsec_id, const int &newtype)
 
std::vector< double > vsp::GetEditXSecUVec (const std::string &xsec_id)
 
std::vector< vec3dvsp::GetEditXSecCtrlVec (const std::string &xsec_id, const bool non_dimensional=true)
 
void vsp::SetEditXSecPnts (const std::string &xsec_id, std::vector< double > u_vec, std::vector< vec3d > control_pts, std::vector< double > r_vec)
 
void vsp::EditXSecDelPnt (const std::string &xsec_id, const int &indx)
 
int vsp::EditXSecSplit01 (const std::string &xsec_id, const double &u)
 
void vsp::MoveEditXSecPnt (const std::string &xsec_id, const int &indx, const vec3d &new_pnt)
 
void vsp::ConvertXSecToEdit (const std::string &geom_id, const int &indx=0)
 
std::vector< bool > vsp::GetEditXSecFixedUVec (const std::string &xsec_id)
 
void vsp::SetEditXSecFixedUVec (const std::string &xsec_id, std::vector< bool > fixed_u_vec)
 
void vsp::ReparameterizeEditXSec (const std::string &xsec_id)
 

Detailed Description

Function Documentation

◆ ConvertXSecToEdit()

void vsp::ConvertXSecToEdit ( const std::string &  geom_id,
const int &  indx = 0 
)

Convert any XSec type into an EditCurveXSec. This function will work for BOR Geoms, in which case the input XSec index is ignored.

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
// Convert Rounded Rectangle to Edit Curve type XSec
// Identify XSec 1
string xsec_1 = GetXSec( xsec_surf, 1 );
// Get the control points for the default shape
array < vec3d > xsec1_pts = GetEditXSecCtrlVec( xsec_1, true ); // The returned control points will not be scaled by width and height
std::vector< vec3d > GetEditXSecCtrlVec(const std::string &xsec_id, const bool non_dimensional=true)
void ConvertXSecToEdit(const std::string &geom_id, const int &indx=0)
@ XS_ROUNDED_RECTANGLE
Definition: APIDefines.h:1383
std::string AddGeom(const std::string &type, const std::string &parent=std::string())
std::string GetXSecSurf(const std::string &geom_id, int index)
std::string GetXSec(const std::string &xsec_surf_id, int xsec_index)
void ChangeXSecShape(const std::string &xsec_surf_id, int xsec_index, int type)
Parameters
[in]geom_idstring Geom ID
[in]indxXSec index

◆ EditXSecConvertTo()

void vsp::EditXSecConvertTo ( const std::string &  xsec_id,
const int &  newtype 
)

Convert the EditCurveXSec curve type to the specified new type. Note, EditCurveXSec uses the same enumerations for PCurve to identify curve type, but APPROX_CEDIT is not supported at this time.

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
ChangeXSecShape( xsec_surf, 1, XS_EDIT_CURVE );
// Identify XSec 1
string xsec_1 = GetXSec( xsec_surf, 1 );
// Set XSec 1 to Linear
void EditXSecConvertTo(const std::string &xsec_id, const int &newtype)
@ XS_EDIT_CURVE
Definition: APIDefines.h:1390
@ LINEAR
Definition: APIDefines.h:951
See also
PCURV_TYPE
Parameters
[in]xsec_idXSec ID
[in]newtypeNew curve type enum (i.e. CEDIT)

◆ EditXSecDelPnt()

void vsp::EditXSecDelPnt ( const std::string &  xsec_id,
const int &  indx 
)

Delete an EditCurveXSec control point. Note, cubic Bezier intermediate control points (those not on the curve) cannot be deleted. The previous and next Bezier control point will be deleted along with the point on the curve. Regardless of curve type, the first and last points may not be deleted.

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
ChangeXSecShape( xsec_surf, 2, XS_EDIT_CURVE );
// Identify XSec 2
string xsec_2 = GetXSec( xsec_surf, 2 );
// Turn off R/L symmetry
SetParmVal( GetXSecParm( xsec_2, "SymType"), SYM_NONE );
array < vec3d > old_pnts = GetEditXSecCtrlVec( xsec_2, true ); // The returned control points will not be scaled by width and height
EditXSecDelPnt( xsec_2, 3 ); // Remove control point at bottom of circle
array < vec3d > new_pnts = GetEditXSecCtrlVec( xsec_2, true ); // The returned control points will not be scaled by width and height
if ( old_pnts.size() - new_pnts.size() != 3 )
{
Print( "Error: EditXSecDelPnt");
}
void EditXSecDelPnt(const std::string &xsec_id, const int &indx)
@ SYM_NONE
Definition: APIDefines.h:1166
double SetParmVal(const std::string &parm_id, double val)
std::string GetXSecParm(const std::string &xsec_id, const std::string &name)
Parameters
[in]xsec_idXSec ID
[in]indxControl point index

◆ EditXSecInitShape()

void vsp::EditXSecInitShape ( const std::string &  xsec_id)

Initialize the EditCurveXSec to the current value of m_ShapeType (i.e. EDIT_XSEC_ELLIPSE)

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
ChangeXSecShape( xsec_surf, 2, XS_EDIT_CURVE );
// Identify XSec 2
string xsec_2 = GetXSec( xsec_surf, 2 );
// Set XSec 2 to linear
EditXSecInitShape( xsec_2 ); // Change back to default ellipse
void EditXSecInitShape(const std::string &xsec_id)
See also
INIT_EDIT_XSEC_TYPE
Parameters
[in]xsec_idXSec ID

◆ EditXSecSplit01()

int vsp::EditXSecSplit01 ( const std::string &  xsec_id,
const double &  u 
)

Split the EditCurveXSec at the specified U value

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
ChangeXSecShape( xsec_surf, 2, XS_EDIT_CURVE );
// Identify XSec 2
string xsec_2 = GetXSec( xsec_surf, 2 );
// Turn off R/L symmetry
SetParmVal( GetXSecParm( xsec_2, "SymType"), SYM_NONE );
array < vec3d > old_pnts = GetEditXSecCtrlVec( xsec_2, true ); // The returned control points will not be scaled by width and height
int new_pnt_ind = EditXSecSplit01( xsec_2, 0.375 );
array < vec3d > new_pnts = GetEditXSecCtrlVec( xsec_2, true ); // The returned control points will not be scaled by width and height
if ( new_pnts.size() - old_pnts.size() != 3 )
{
Print( "Error: EditXSecSplit01");
}
int EditXSecSplit01(const std::string &xsec_id, const double &u)
Parameters
[in]xsec_idXSec ID
[in]uU value to split the curve at (0 - 1)
Returns
Index of the point added from the split

◆ GetEditXSecCtrlVec()

std::vector< vec3d > vsp::GetEditXSecCtrlVec ( const std::string &  xsec_id,
const bool  non_dimensional = true 
)

Get the control point vector for an EditCurveXSec. Note, the returned array of vec3d values will be represented in 2D with Z set to 0.

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
ChangeXSecShape( xsec_surf, 1, XS_EDIT_CURVE );
// Identify XSec 1
string xsec_1 = GetXSec( xsec_surf, 1 );
// Get the control points for the default shape
array < vec3d > xsec1_pts = GetEditXSecCtrlVec( xsec_1, true ); // The returned control points will not be scaled by width and height
Print( "Normalized Bottom Point of XSecCurve: " + xsec1_pts[3].x() + ", " + xsec1_pts[3].y() + ", " + xsec1_pts[3].z() );
Parameters
[in]xsec_idXSec ID
[in]non_dimensionalTrue to get the points non-dimensionalized, False to get them scaled by m_Width and m_Height
Returns
Array of control points

◆ GetEditXSecFixedUVec()

std::vector< bool > vsp::GetEditXSecFixedUVec ( const std::string &  xsec_id)

Get the vector of fixed U flags for each control point in an EditCurveXSec. The fixed U flag is used to hold the U parameter of the control point constant when performing an equal arc length reparameterization of the curve.

// Add Wing
string wid = AddGeom( "WING" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( wid, 0 );
ChangeXSecShape( xsec_surf, 1, XS_EDIT_CURVE );
// Identify XSec 1
string xsec_1 = GetXSec( xsec_surf, 1 );
array < bool > @ fixed_u_vec = GetEditXSecFixedUVec( xsec_1 );
fixed_u_vec[3] = true; // change a flag
SetEditXSecFixedUVec( xsec_1, fixed_u_vec );
std::vector< bool > GetEditXSecFixedUVec(const std::string &xsec_id)
void SetEditXSecFixedUVec(const std::string &xsec_id, std::vector< bool > fixed_u_vec)
void ReparameterizeEditXSec(const std::string &xsec_id)
See also
SetEditXSecFixedUVec, ReparameterizeEditXSec
Parameters
[in]xsec_idXSec ID
Returns
Array of bool values for each control point

◆ GetEditXSecUVec()

std::vector< double > vsp::GetEditXSecUVec ( const std::string &  xsec_id)

Get the U parameter vector for an EditCurveXSec. The vector will be in increasing order with a range of 0 - 1.

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
ChangeXSecShape( xsec_surf, 2, XS_EDIT_CURVE );
// Identify XSec 2
string xsec_2 = GetXSec( xsec_surf, 2 );
// Set XSec 2 to linear
array < double > u_vec = GetEditXSecUVec( xsec_2 );
if ( u_vec[1] - 0.25 > 1e-6 )
{
Print( "Error: GetEditXSecUVec" );
}
std::vector< double > GetEditXSecUVec(const std::string &xsec_id)
Parameters
[in]xsec_idXSec ID
Returns
Array of U parameter values

◆ MoveEditXSecPnt()

void vsp::MoveEditXSecPnt ( const std::string &  xsec_id,
const int &  indx,
const vec3d new_pnt 
)

Move an EditCurveXSec control point. The XSec points are nondimensionalized by m_Width and m_Height and defined in 2D, so the Z value of the new coordinate point will be ignored.

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
ChangeXSecShape( xsec_surf, 1, XS_EDIT_CURVE );
// Identify XSec 1
string xsec_1 = GetXSec( xsec_surf, 1 );
// Turn off R/L symmetry
SetParmVal( GetXSecParm( xsec_1, "SymType"), SYM_NONE );
// Get the control points for the default shape
array < vec3d > xsec1_pts = GetEditXSecCtrlVec( xsec_1, true ); // The returned control points will not be scaled by width and height
// Identify a control point that lies on the curve and shift it in Y
int move_pnt_ind = 3;
vec3d new_pnt = vec3d( xsec1_pts[move_pnt_ind].x(), 2 * xsec1_pts[move_pnt_ind].y(), 0.0 );
// Move the control point
MoveEditXSecPnt( xsec_1, move_pnt_ind, new_pnt );
array < vec3d > new_pnts = GetEditXSecCtrlVec( xsec_1, true ); // The returned control points will not be scaled by width and height
if ( dist( new_pnt, new_pnts[move_pnt_ind] ) > 1e-6 )
{
Print( "Error: MoveEditXSecPnt" );
}
Definition: Vec3d.h:235
void MoveEditXSecPnt(const std::string &xsec_id, const int &indx, const vec3d &new_pnt)
double dist(const vec3d &a, const vec3d &b)
Parameters
[in]xsec_idXSec ID
[in]indxControl point index
[in]new_pntCoordinate of the new point

◆ ReparameterizeEditXSec()

void vsp::ReparameterizeEditXSec ( const std::string &  xsec_id)

Perform an equal arc length repareterization on an EditCurveXSec. The reparameterization is performed between specific U values if the Fixed U flag is true. This allows corners, such as at 0.25, 0.5, and 0.75 U, to be held constant while everything between them is reparameterized.

// Add Wing
string wid = AddGeom( "WING" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( wid, 0 );
ChangeXSecShape( xsec_surf, 1, XS_EDIT_CURVE );
// Identify XSec 1
string xsec_1 = GetXSec( xsec_surf, 1 );
array < bool > @ fixed_u_vec = GetEditXSecFixedUVec( xsec_1 );
fixed_u_vec[3] = true; // change a flag
SetEditXSecFixedUVec( xsec_1, fixed_u_vec );
See also
SetEditXSecFixedUVec, GetEditXSecFixedUVec
Parameters
[in]xsec_idXSec ID

◆ SetEditXSecFixedUVec()

void vsp::SetEditXSecFixedUVec ( const std::string &  xsec_id,
std::vector< bool >  fixed_u_vec 
)

Set the vector of fixed U flags for each control point in an EditCurveXSec. The fixed U flag is used to hold the U parameter of the control point constant when performing an equal arc length reparameterization of the curve.

// Add Wing
string wid = AddGeom( "WING" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( wid, 0 );
ChangeXSecShape( xsec_surf, 1, XS_EDIT_CURVE );
// Identify XSec 1
string xsec_1 = GetXSec( xsec_surf, 1 );
array < bool > @ fixed_u_vec = GetEditXSecFixedUVec( xsec_1 );
fixed_u_vec[3] = true; // change a flag
SetEditXSecFixedUVec( xsec_1, fixed_u_vec );
See also
GetEditXSecFixedUVec, ReparameterizeEditXSec
Parameters
[in]xsec_idXSec ID
[in]fixed_u_vecArray of fixed U flags

◆ SetEditXSecPnts()

void vsp::SetEditXSecPnts ( const std::string &  xsec_id,
std::vector< double >  u_vec,
std::vector< vec3d control_pts,
std::vector< double >  r_vec 
)

Set the U parameter vector and the control point vector for an EditCurveXSec. The arrays must be of equal length, with the values for U defined in increasing order and range 0 - 1. The input control points to SetEditXSecPnts must be nondimensionalized in the approximate range of [-0.5, 0.5].

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
ChangeXSecShape( xsec_surf, 2, XS_EDIT_CURVE );
// Identify XSec 2
string xsec_2 = GetXSec( xsec_surf, 2 );
// Set XSec 2 to linear
// Turn off R/L symmetry
SetParmVal( GetXSecParm( xsec_2, "SymType"), SYM_NONE );
// Define a square
array < vec3d > xsec2_pts(5);
xsec2_pts[0] = vec3d( 0.5, 0.5, 0.0 );
xsec2_pts[1] = vec3d( 0.5, -0.5, 0.0 );
xsec2_pts[2] = vec3d( -0.5, -0.5, 0.0 );
xsec2_pts[3] = vec3d( -0.5, 0.5, 0.0 );
xsec2_pts[4] = vec3d( 0.5, 0.5, 0.0 );
// u vec must start at 0.0 and end at 1.0
array < double > u_vec(5);
u_vec[0] = 0.0;
u_vec[1] = 0.25;
u_vec[2] = 0.5;
u_vec[3] = 0.75;
u_vec[4] = 1.0;
array < double > r_vec(5);
r_vec[0] = 0.0;
r_vec[1] = 0.0;
r_vec[2] = 0.0;
r_vec[3] = 0.0;
r_vec[4] = 0.0;
SetEditXSecPnts( xsec_2, u_vec, xsec2_pts, r_vec ); // Note: points are unscaled by the width and height parms
array < vec3d > new_pnts = GetEditXSecCtrlVec( xsec_2, true ); // The returned control points will not be scaled by width and height
if ( dist( new_pnts[3], xsec2_pts[3] ) > 1e-6 )
{
Print( "Error: SetEditXSecPnts");
}
void SetEditXSecPnts(const std::string &xsec_id, std::vector< double > u_vec, std::vector< vec3d > control_pts, std::vector< double > r_vec)
Parameters
[in]xsec_idXSec ID
[in]u_vecArray of U parameter values
[in]r_vecArray of R parameter values
[in]control_ptsNondimensionalized array of control points