OpenVSP API Documentation 3.52.0
Loading...
Searching...
No Matches
Fit Model Functions

This group of functions supports the Fit Model Tool, which adjusts a model until its surfaces pass through a set of known points. Each point to match is set up as a target point: a point in space paired with the surface of a Geom, either pinned to a surface coordinate or free to slide along the surface. One or more Parms are then nominated as variables. Together these define a least squares problem, which is solved with a Levenberg-Marquardt algorithm where the free surface coordinates and the nominated Parms are the degrees of freedom and every target point contributes three residuals. Unlike the GUI, the API takes target points directly as coordinates rather than through a point cloud Geom and mouse selection. Click here to return to the main page. More...

Functions

void vsp::ResetFitModel ()
int vsp::AddFitModelTargetPt (const std::string &geom_id, int surf_indx, const vec3d &pt, int u_type=FIT_MODEL_FREE, int w_type=FIT_MODEL_FREE, double u=0.0, double w=0.0)
int vsp::AddFitModelTargetPtFixedU (const std::string &geom_id, int surf_indx, const vec3d &pt, double u)
int vsp::AddFitModelTargetPtFixedW (const std::string &geom_id, int surf_indx, const vec3d &pt, double w)
int vsp::AddFitModelTargetPtFixedUW (const std::string &geom_id, int surf_indx, const vec3d &pt, double u, double w)
void vsp::AddFitModelTargetPts (const std::string &geom_id, int surf_indx, const std::vector< vec3d > &pt_vec)
void vsp::AddFitModelTargetPtsFixedU (const std::string &geom_id, int surf_indx, const std::vector< vec3d > &pt_vec, double u)
void vsp::AddFitModelTargetPtsFixedUs (const std::string &geom_id, int surf_indx, const std::vector< vec3d > &pt_vec, const std::vector< double > &u_vec)
void vsp::AddFitModelTargetPtsFixedW (const std::string &geom_id, int surf_indx, const std::vector< vec3d > &pt_vec, double w)
void vsp::AddFitModelTargetPtsFixedWs (const std::string &geom_id, int surf_indx, const std::vector< vec3d > &pt_vec, const std::vector< double > &w_vec)
void vsp::AddFitModelTargetPtsFixedUW (const std::string &geom_id, int surf_indx, const std::vector< vec3d > &pt_vec, double u, double w)
void vsp::AddFitModelTargetPtsFixedUWs (const std::string &geom_id, int surf_indx, const std::vector< vec3d > &pt_vec, const std::vector< double > &u_vec, const std::vector< double > &w_vec)
void vsp::DelFitModelTargetPt (int index)
void vsp::DelAllFitModelTargetPts ()
void vsp::SortFitModelTargetPtsByDist ()
int vsp::MoveFitModelTargetPt (int index, int reorder_type)
int vsp::GetNumFitModelTargetPts ()
vec3d vsp::GetFitModelTargetPt (int index)
void vsp::SetFitModelTargetPt (int index, const vec3d &pt)
std::string vsp::GetFitModelTargetPtGeom (int index)
void vsp::SetFitModelTargetPtGeom (int index, const std::string &geom_id)
int vsp::GetFitModelTargetPtSurfIndx (int index)
void vsp::SetFitModelTargetPtSurfIndx (int index, int surf_indx)
double vsp::GetFitModelTargetPtU (int index)
double vsp::GetFitModelTargetPtW (int index)
double vsp::GetFitModelTargetPtDist (int index)
void vsp::SetFitModelTargetPtUW (int index, double u, double w)
int vsp::GetFitModelTargetPtUType (int index)
void vsp::SetFitModelTargetPtUType (int index, int u_type)
int vsp::GetFitModelTargetPtWType (int index)
void vsp::SetFitModelTargetPtWType (int index, int w_type)
vec3d vsp::GetFitModelTargetPtSurfPt (int index)
void vsp::AddFitModelVar (const std::string &parm_id)
void vsp::DelFitModelVar (const std::string &parm_id)
void vsp::DelAllFitModelVars ()
int vsp::GetNumFitModelVars ()
std::string vsp::GetFitModelVar (int index)
std::vector< std::string > vsp::GetFitModelVarVec ()
void vsp::SearchFitModelTargetUW ()
void vsp::RefineFitModelTargetUW ()
double vsp::UpdateFitModelDist ()
double vsp::GetFitModelDist ()
int vsp::GetNumFitModelOptVars ()
int vsp::OptimizeFitModel ()
bool vsp::CanUndoFitModel ()
bool vsp::UndoFitModel ()
void vsp::SaveFitModelFile (const std::string &file_name)
int vsp::LoadFitModelFile (const std::string &file_name)

Detailed Description

Function Documentation

◆ AddFitModelTargetPt()

int vsp::AddFitModelTargetPt ( const std::string & geom_id,
int surf_indx,
const vec3d & pt,
int u_type = FIT_MODEL_FREE,
int w_type = FIT_MODEL_FREE,
double u = 0.0,
double w = 0.0 )
extern

Add a target point to the Fit Model Tool. The point is paired with the first surface of the given Geom. Each direction may be pinned to the supplied surface coordinate ( FIT_MODEL_FIXED ) or left free to slide along the surface ( FIT_MODEL_FREE ). The supplied coordinate is used for a pinned direction; a free one is searched onto the nearest point of the surface as the point is added, so what is passed for it does not matter.

Called with a Geom and a point alone this leaves both directions free, matching AddFitModelTargetPts. It is the general form: use it to walk a loop of points that each want their own pinned or free directions and their own coordinates. Where every point in a group wants the same treatment, the named forms say so more plainly.

string pid = AddGeom( "POD" );
vec3d pnt = CompPnt01( pid, 0, 0.5, 0.0 );
int index = AddFitModelTargetPt( pid, 0, pnt, FIT_MODEL_FREE, FIT_MODEL_FREE );
if ( index != 0 ) { Print( "ERROR: AddFitModelTargetPt" ); __failure++; }
if ( GetNumFitModelTargetPts() != 1 ) { Print( "ERROR: AddFitModelTargetPt" ); __failure++; }
void Print(const std::string &data, bool new_line=true)
@ FIT_MODEL_FREE
Definition APIDefines.h:769
int AddFitModelTargetPt(const std::string &geom_id, int surf_indx, const vec3d &pt, int u_type=FIT_MODEL_FREE, int w_type=FIT_MODEL_FREE, double u=0.0, double w=0.0)
int GetNumFitModelTargetPts()
std::string AddGeom(const std::string &type, const std::string &parent=std::string())
vec3d CompPnt01(const std::string &geom_id, const int &surf_indx, const double &u, const double &w)
void Update(bool update_managers=true)
Definition Vec3d.h:238
See also
FIT_MODEL_TARGET_TYPE, AddFitModelTargetPtFixedU, AddFitModelTargetPtFixedW, AddFitModelTargetPtFixedUW, AddFitModelTargetPts
Parameters
[in]geom_idstring Geom ID of the surface the point is matched to
[in]surf_indxint Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1
[in]ptvec3d Point to be matched, in model coordinates
[in]u_typeint Fit model target type enum for the U direction (i.e. FIT_MODEL_FREE)
[in]w_typeint Fit model target type enum for the W direction (i.e. FIT_MODEL_FREE)
[in]udouble Starting U surface coordinate in [0, 1]
[in]wdouble Starting W surface coordinate in [0, 1]
Returns
int Index of the new target point
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddFitModelTargetPtFixedU()

int vsp::AddFitModelTargetPtFixedU ( const std::string & geom_id,
int surf_indx,
const vec3d & pt,
double u )
extern

Add one target point held at a U surface coordinate and free to slide in W. The single point counterpart of AddFitModelTargetPtsFixedU. The W of the point is searched onto the surface as it is added.

string pid = AddGeom( "POD" );
AddFitModelTargetPtFixedU( pid, 0, CompPnt01( pid, 0, 0.5, 0.25 ), 0.5 );
if ( GetFitModelTargetPtUType( 0 ) != FIT_MODEL_FIXED ) { Print( "ERROR: AddFitModelTargetPtFixedU" ); __failure++; }
if ( abs( GetFitModelTargetPtU( 0 ) - 0.5 ) > 1e-6 ) { Print( "ERROR: AddFitModelTargetPtFixedU" ); __failure++; }
if ( UpdateFitModelDist() > 1e-4 ) { Print( "ERROR: AddFitModelTargetPtFixedU" ); __failure++; }
@ FIT_MODEL_FIXED
Definition APIDefines.h:768
int GetFitModelTargetPtUType(int index)
double UpdateFitModelDist()
int AddFitModelTargetPtFixedU(const std::string &geom_id, int surf_indx, const vec3d &pt, double u)
double GetFitModelTargetPtU(int index)
See also
AddFitModelTargetPtsFixedU, AddFitModelTargetPtFixedW, AddFitModelTargetPt
Parameters
[in]geom_idstring Geom ID of the surface the point is matched to
[in]surf_indxint Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1
[in]ptvec3d Point to be matched, in model coordinates
[in]udouble U surface coordinate in [0, 1] to hold the point at
Returns
int Index of the new target point
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddFitModelTargetPtFixedUW()

int vsp::AddFitModelTargetPtFixedUW ( const std::string & geom_id,
int surf_indx,
const vec3d & pt,
double u,
double w )
extern

Add one target point pinned to a surface coordinate, free in neither direction. The single point counterpart of AddFitModelTargetPtsFixedUW. Nothing is searched; the point contributes no degrees of freedom, so the fit has only the model's own Parms to work with.

string pid = AddGeom( "POD" );
AddFitModelTargetPtFixedUW( pid, 0, CompPnt01( pid, 0, 0.5, 0.25 ), 0.5, 0.25 );
if ( GetNumFitModelOptVars() != 0 ) { Print( "ERROR: AddFitModelTargetPtFixedUW" ); __failure++; }
if ( UpdateFitModelDist() > 1e-6 ) { Print( "ERROR: AddFitModelTargetPtFixedUW" ); __failure++; }
int GetNumFitModelOptVars()
int AddFitModelTargetPtFixedUW(const std::string &geom_id, int surf_indx, const vec3d &pt, double u, double w)
See also
AddFitModelTargetPtsFixedUW, AddFitModelTargetPt
Parameters
[in]geom_idstring Geom ID of the surface the point is matched to
[in]surf_indxint Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1
[in]ptvec3d Point to be matched, in model coordinates
[in]udouble U surface coordinate in [0, 1] to hold the point at
[in]wdouble W surface coordinate in [0, 1] to hold the point at
Returns
int Index of the new target point
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddFitModelTargetPtFixedW()

int vsp::AddFitModelTargetPtFixedW ( const std::string & geom_id,
int surf_indx,
const vec3d & pt,
double w )
extern

Add one target point held at a W surface coordinate and free to slide in U. The single point counterpart of AddFitModelTargetPtsFixedW. The U of the point is searched onto the surface as it is added.

string pid = AddGeom( "POD" );
AddFitModelTargetPtFixedW( pid, 0, CompPnt01( pid, 0, 0.5, 0.25 ), 0.25 );
if ( GetFitModelTargetPtWType( 0 ) != FIT_MODEL_FIXED ) { Print( "ERROR: AddFitModelTargetPtFixedW" ); __failure++; }
if ( abs( GetFitModelTargetPtW( 0 ) - 0.25 ) > 1e-6 ) { Print( "ERROR: AddFitModelTargetPtFixedW" ); __failure++; }
if ( UpdateFitModelDist() > 1e-4 ) { Print( "ERROR: AddFitModelTargetPtFixedW" ); __failure++; }
double GetFitModelTargetPtW(int index)
int GetFitModelTargetPtWType(int index)
int AddFitModelTargetPtFixedW(const std::string &geom_id, int surf_indx, const vec3d &pt, double w)
See also
AddFitModelTargetPtsFixedW, AddFitModelTargetPtFixedU, AddFitModelTargetPt
Parameters
[in]geom_idstring Geom ID of the surface the point is matched to
[in]surf_indxint Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1
[in]ptvec3d Point to be matched, in model coordinates
[in]wdouble W surface coordinate in [0, 1] to hold the point at
Returns
int Index of the new target point
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddFitModelTargetPts()

void vsp::AddFitModelTargetPts ( const std::string & geom_id,
int surf_indx,
const std::vector< vec3d > & pt_vec )
extern

Add a group of target points to the Fit Model Tool, all matched to the same Geom, each free to slide anywhere on the surface. This is the API's replacement for selecting points of a point cloud with the mouse. Every point is placed on the nearest point of the surface as it is added, searching the whole surface, so no starting coordinate is asked for: a caller is unlikely to have a useful guess for a free coordinate. Where the topology does tell you where a point belongs, use one of the fixed variants instead.

string pid = AddGeom( "POD" );
array < vec3d > pts;
pts.push_back( CompPnt01( pid, 0, 0.25, 0.0 ) );
pts.push_back( CompPnt01( pid, 0, 0.50, 0.0 ) );
pts.push_back( CompPnt01( pid, 0, 0.75, 0.0 ) );
AddFitModelTargetPts( pid, 0, pts );
if ( GetNumFitModelTargetPts() != 3 ) { Print( "ERROR: AddFitModelTargetPts" ); __failure++; }
if ( UpdateFitModelDist() > 1e-4 ) { Print( "ERROR: AddFitModelTargetPts" ); __failure++; }
void AddFitModelTargetPts(const std::string &geom_id, int surf_indx, const std::vector< vec3d > &pt_vec)
See also
AddFitModelTargetPtsFixedU, AddFitModelTargetPtsFixedW, AddFitModelTargetPtsFixedUW, SearchFitModelTargetUW
Parameters
[in]geom_idstring Geom ID of the surface the points are matched to
[in]surf_indxint Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1
[in]pt_vecvector<vec3d> Points to be matched, in model coordinates
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddFitModelTargetPtsFixedU()

void vsp::AddFitModelTargetPtsFixedU ( const std::string & geom_id,
int surf_indx,
const std::vector< vec3d > & pt_vec,
double u )
extern

Add a group of target points held at one U surface coordinate and free to slide in W. Use this where the topology says which station the points belong to but not where around it, such as points measured around one fuselage frame. The W of each point is searched onto the surface as it is added.

string pid = AddGeom( "POD" );
array < vec3d > pts;
pts.push_back( CompPnt01( pid, 0, 0.5, 0.10 ) );
pts.push_back( CompPnt01( pid, 0, 0.5, 0.35 ) );
pts.push_back( CompPnt01( pid, 0, 0.5, 0.60 ) );
AddFitModelTargetPtsFixedU( pid, 0, pts, 0.5 );
if ( GetFitModelTargetPtUType( 0 ) != FIT_MODEL_FIXED ) { Print( "ERROR: AddFitModelTargetPtsFixedU" ); __failure++; }
if ( abs( GetFitModelTargetPtU( 0 ) - 0.5 ) > 1e-6 ) { Print( "ERROR: AddFitModelTargetPtsFixedU" ); __failure++; }
void AddFitModelTargetPtsFixedU(const std::string &geom_id, int surf_indx, const std::vector< vec3d > &pt_vec, double u)
See also
AddFitModelTargetPtsFixedUs, AddFitModelTargetPtsFixedW, AddFitModelTargetPts
Parameters
[in]geom_idstring Geom ID of the surface the points are matched to
[in]surf_indxint Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1
[in]pt_vecvector<vec3d> Points to be matched, in model coordinates
[in]udouble U surface coordinate in [0, 1] to hold every point at
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddFitModelTargetPtsFixedUs()

void vsp::AddFitModelTargetPtsFixedUs ( const std::string & geom_id,
int surf_indx,
const std::vector< vec3d > & pt_vec,
const std::vector< double > & u_vec )
extern

Add a group of target points, each held at its own U surface coordinate and free to slide in W. The two vectors are paired by index and must be the same length. The W of each point is searched onto the surface as it is added.

string pid = AddGeom( "POD" );
array < vec3d > pts;
array < double > us;
pts.push_back( CompPnt01( pid, 0, 0.25, 0.1 ) ); us.push_back( 0.25 );
pts.push_back( CompPnt01( pid, 0, 0.50, 0.1 ) ); us.push_back( 0.50 );
pts.push_back( CompPnt01( pid, 0, 0.75, 0.1 ) ); us.push_back( 0.75 );
AddFitModelTargetPtsFixedUs( pid, 0, pts, us );
if ( abs( GetFitModelTargetPtU( 2 ) - 0.75 ) > 1e-6 ) { Print( "ERROR: AddFitModelTargetPtsFixedUs" ); __failure++; }
void AddFitModelTargetPtsFixedUs(const std::string &geom_id, int surf_indx, const std::vector< vec3d > &pt_vec, const std::vector< double > &u_vec)
See also
AddFitModelTargetPtsFixedU, AddFitModelTargetPtsFixedWs
Parameters
[in]geom_idstring Geom ID of the surface the points are matched to
[in]surf_indxint Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1
[in]pt_vecvector<vec3d> Points to be matched, in model coordinates
[in]u_vecvector<double> U surface coordinate in [0, 1] for each point, same length as pt_vec
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddFitModelTargetPtsFixedUW()

void vsp::AddFitModelTargetPtsFixedUW ( const std::string & geom_id,
int surf_indx,
const std::vector< vec3d > & pt_vec,
double u,
double w )
extern

Add a group of target points all held at one surface coordinate, free in neither direction. Every point is pinned to the same place on the surface, which suits repeated measurements of one identifiable feature. To pin each point to its own coordinate, use AddFitModelTargetPtsFixedUWs.

string pid = AddGeom( "POD" );
array < vec3d > pts;
pts.push_back( CompPnt01( pid, 0, 0.5, 0.25 ) );
AddFitModelTargetPtsFixedUW( pid, 0, pts, 0.5, 0.25 );
if ( GetFitModelTargetPtUType( 0 ) != FIT_MODEL_FIXED ) { Print( "ERROR: AddFitModelTargetPtsFixedUW" ); __failure++; }
if ( GetFitModelTargetPtWType( 0 ) != FIT_MODEL_FIXED ) { Print( "ERROR: AddFitModelTargetPtsFixedUW" ); __failure++; }
if ( UpdateFitModelDist() > 1e-6 ) { Print( "ERROR: AddFitModelTargetPtsFixedUW" ); __failure++; }
void AddFitModelTargetPtsFixedUW(const std::string &geom_id, int surf_indx, const std::vector< vec3d > &pt_vec, double u, double w)
See also
AddFitModelTargetPtsFixedUWs, AddFitModelTargetPt
Parameters
[in]geom_idstring Geom ID of the surface the points are matched to
[in]surf_indxint Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1
[in]pt_vecvector<vec3d> Points to be matched, in model coordinates
[in]udouble U surface coordinate in [0, 1] to hold every point at
[in]wdouble W surface coordinate in [0, 1] to hold every point at
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddFitModelTargetPtsFixedUWs()

void vsp::AddFitModelTargetPtsFixedUWs ( const std::string & geom_id,
int surf_indx,
const std::vector< vec3d > & pt_vec,
const std::vector< double > & u_vec,
const std::vector< double > & w_vec )
extern

Add a group of target points, each pinned to its own surface coordinate and free in neither direction. The three vectors are paired by index and must all be the same length. Use this where every point has been identified on the surface already, so the fit has only the model's own Parms to work with.

string pid = AddGeom( "POD" );
array < vec3d > pts;
array < double > us;
array < double > ws;
pts.push_back( CompPnt01( pid, 0, 0.25, 0.1 ) ); us.push_back( 0.25 ); ws.push_back( 0.1 );
pts.push_back( CompPnt01( pid, 0, 0.50, 0.4 ) ); us.push_back( 0.50 ); ws.push_back( 0.4 );
pts.push_back( CompPnt01( pid, 0, 0.75, 0.7 ) ); us.push_back( 0.75 ); ws.push_back( 0.7 );
AddFitModelTargetPtsFixedUWs( pid, 0, pts, us, ws );
if ( GetNumFitModelOptVars() != 0 ) { Print( "ERROR: AddFitModelTargetPtsFixedUWs" ); __failure++; }
if ( UpdateFitModelDist() > 1e-6 ) { Print( "ERROR: AddFitModelTargetPtsFixedUWs" ); __failure++; }
void AddFitModelTargetPtsFixedUWs(const std::string &geom_id, int surf_indx, const std::vector< vec3d > &pt_vec, const std::vector< double > &u_vec, const std::vector< double > &w_vec)
See also
AddFitModelTargetPtsFixedUW, AddFitModelTargetPtsFixedUs, AddFitModelTargetPtsFixedWs
Parameters
[in]geom_idstring Geom ID of the surface the points are matched to
[in]surf_indxint Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1
[in]pt_vecvector<vec3d> Points to be matched, in model coordinates
[in]u_vecvector<double> U surface coordinate in [0, 1] for each point, same length as pt_vec
[in]w_vecvector<double> W surface coordinate in [0, 1] for each point, same length as pt_vec
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddFitModelTargetPtsFixedW()

void vsp::AddFitModelTargetPtsFixedW ( const std::string & geom_id,
int surf_indx,
const std::vector< vec3d > & pt_vec,
double w )
extern

Add a group of target points held at one W surface coordinate and free to slide in U. Use this where the topology says which line around the section the points belong to but not where along it, such as points measured along a wing's leading edge. The U of each point is searched onto the surface as it is added.

string pid = AddGeom( "POD" );
array < vec3d > pts;
pts.push_back( CompPnt01( pid, 0, 0.25, 0.5 ) );
pts.push_back( CompPnt01( pid, 0, 0.50, 0.5 ) );
pts.push_back( CompPnt01( pid, 0, 0.75, 0.5 ) );
AddFitModelTargetPtsFixedW( pid, 0, pts, 0.5 );
if ( GetFitModelTargetPtWType( 0 ) != FIT_MODEL_FIXED ) { Print( "ERROR: AddFitModelTargetPtsFixedW" ); __failure++; }
if ( abs( GetFitModelTargetPtW( 0 ) - 0.5 ) > 1e-6 ) { Print( "ERROR: AddFitModelTargetPtsFixedW" ); __failure++; }
void AddFitModelTargetPtsFixedW(const std::string &geom_id, int surf_indx, const std::vector< vec3d > &pt_vec, double w)
See also
AddFitModelTargetPtsFixedWs, AddFitModelTargetPtsFixedU, AddFitModelTargetPts
Parameters
[in]geom_idstring Geom ID of the surface the points are matched to
[in]surf_indxint Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1
[in]pt_vecvector<vec3d> Points to be matched, in model coordinates
[in]wdouble W surface coordinate in [0, 1] to hold every point at
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddFitModelTargetPtsFixedWs()

void vsp::AddFitModelTargetPtsFixedWs ( const std::string & geom_id,
int surf_indx,
const std::vector< vec3d > & pt_vec,
const std::vector< double > & w_vec )
extern

Add a group of target points, each held at its own W surface coordinate and free to slide in U. The two vectors are paired by index and must be the same length. The U of each point is searched onto the surface as it is added.

string pid = AddGeom( "POD" );
array < vec3d > pts;
array < double > ws;
pts.push_back( CompPnt01( pid, 0, 0.3, 0.10 ) ); ws.push_back( 0.10 );
pts.push_back( CompPnt01( pid, 0, 0.3, 0.35 ) ); ws.push_back( 0.35 );
pts.push_back( CompPnt01( pid, 0, 0.3, 0.60 ) ); ws.push_back( 0.60 );
AddFitModelTargetPtsFixedWs( pid, 0, pts, ws );
if ( abs( GetFitModelTargetPtW( 2 ) - 0.60 ) > 1e-6 ) { Print( "ERROR: AddFitModelTargetPtsFixedWs" ); __failure++; }
void AddFitModelTargetPtsFixedWs(const std::string &geom_id, int surf_indx, const std::vector< vec3d > &pt_vec, const std::vector< double > &w_vec)
See also
AddFitModelTargetPtsFixedW, AddFitModelTargetPtsFixedUs
Parameters
[in]geom_idstring Geom ID of the surface the points are matched to
[in]surf_indxint Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1
[in]pt_vecvector<vec3d> Points to be matched, in model coordinates
[in]w_vecvector<double> W surface coordinate in [0, 1] for each point, same length as pt_vec
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddFitModelVar()

void vsp::AddFitModelVar ( const std::string & parm_id)
extern

Nominate a Parm as a variable for the Fit Model Tool to adjust. Choosing Parms that are not independent of one another, or that have much the same effect on the surface, can leave the optimizer a very long time in converging. Nominating the same Parm twice does nothing and reports an error.

string pid = AddGeom( "POD" );
string len = GetParm( pid, "Length", "Design" );
if ( GetNumFitModelVars() != 1 ) { Print( "ERROR: AddFitModelVar" ); __failure++; }
int GetNumFitModelVars()
void AddFitModelVar(const std::string &parm_id)
std::string GetParm(const std::string &geom_id, const std::string &name, const std::string &group)
See also
DelFitModelVar, OptimizeFitModel
Parameters
[in]parm_idstring Parm ID
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CanUndoFitModel()

bool vsp::CanUndoFitModel ( )
extern

Check whether the last Fit Model operation can be undone. False before anything has been run, after an undo has already been used, and when the variables or target points have changed since – a snapshot describes one arrangement of them and cannot be applied to another.

string pid = AddGeom( "POD" );
if ( CanUndoFitModel() ) { Print( "ERROR: CanUndoFitModel" ); __failure++; }
array< vec3d > pts;
pts.push_back( CompPnt01( pid, 0, 0.2, 0.3 ) );
pts.push_back( CompPnt01( pid, 0, 0.5, 0.6 ) );
AddFitModelTargetPts( pid, 0, pts );
AddFitModelVar( GetParm( pid, "Length", "Design" ) );
if ( !CanUndoFitModel() ) { Print( "ERROR: CanUndoFitModel" ); __failure++; }
int OptimizeFitModel()
bool CanUndoFitModel()
See also
UndoFitModel, OptimizeFitModel
Returns
bool True if there is something to undo
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DelAllFitModelTargetPts()

void vsp::DelAllFitModelTargetPts ( )
extern

Delete every target point from the Fit Model Tool, leaving the variables alone.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.5, 0.0 ) );
if ( GetNumFitModelTargetPts() != 0 ) { Print( "ERROR: DelAllFitModelTargetPts" ); __failure++; }
void DelAllFitModelTargetPts()
See also
DelFitModelTargetPt, ResetFitModel
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DelAllFitModelVars()

void vsp::DelAllFitModelVars ( )
extern

Withdraw every Parm from the Fit Model Tool's variables, leaving the target points alone.

string pid = AddGeom( "POD" );
AddFitModelVar( GetParm( pid, "Length", "Design" ) );
if ( GetNumFitModelVars() != 0 ) { Print( "ERROR: DelAllFitModelVars" ); __failure++; }
void DelAllFitModelVars()
See also
DelFitModelVar, ResetFitModel
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DelFitModelTargetPt()

void vsp::DelFitModelTargetPt ( int index)
extern

Delete one target point from the Fit Model Tool. The points after it move down one index.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.25, 0.0 ) );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.75, 0.0 ) );
if ( GetNumFitModelTargetPts() != 1 ) { Print( "ERROR: DelFitModelTargetPt" ); __failure++; }
void DelFitModelTargetPt(int index)
See also
DelAllFitModelTargetPts
Parameters
[in]indexint Target point index
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DelFitModelVar()

void vsp::DelFitModelVar ( const std::string & parm_id)
extern

Withdraw a Parm from the Fit Model Tool's variables.

string pid = AddGeom( "POD" );
string len = GetParm( pid, "Length", "Design" );
if ( GetNumFitModelVars() != 0 ) { Print( "ERROR: DelFitModelVar" ); __failure++; }
void DelFitModelVar(const std::string &parm_id)
See also
AddFitModelVar, DelAllFitModelVars
Parameters
[in]parm_idstring Parm ID
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFitModelDist()

double vsp::GetFitModelDist ( )
extern

Get the distance measure last computed, without recomputing it. Reports -1 if the last computation had no target points to measure.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.5, 0.25 ), FIT_MODEL_FIXED, FIT_MODEL_FIXED, 0.5, 0.25 );
if ( GetFitModelDist() > 1e-6 ) { Print( "ERROR: GetFitModelDist" ); __failure++; }
double GetFitModelDist()
See also
UpdateFitModelDist
Returns
double Root mean square distance last computed
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFitModelTargetPt()

vec3d vsp::GetFitModelTargetPt ( int index)
extern

Get the point a target point is trying to match. This is the point supplied when it was added, not the point currently on the surface; for that, see GetFitModelTargetPtSurfPt.

string pid = AddGeom( "POD" );
vec3d pnt = vec3d( 3.0, 1.0, 2.0 );
AddFitModelTargetPt( pid, 0, pnt );
vec3d pnt_out = GetFitModelTargetPt( 0 );
if ( dist( pnt, pnt_out ) > 1e-6 ) { Print( "ERROR: GetFitModelTargetPt" ); __failure++; }
vec3d GetFitModelTargetPt(int index)
double dist(const vec3d &a, const vec3d &b)
See also
SetFitModelTargetPt, GetFitModelTargetPtSurfPt
Parameters
[in]indexint Target point index
Returns
vec3d Point to be matched
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFitModelTargetPtDist()

double vsp::GetFitModelTargetPtDist ( int index)
extern

Get the distance from a target point to the surface point it is matched to.

The Fit Model browser shows this in its Dist column and the API can sort the target points by it, so it was the one quantity a script could order by without being able to read. Meaningful after Update, which is what recomputes it.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.5, 0.25 ), FIT_MODEL_FIXED, FIT_MODEL_FIXED, 0.5, 0.25 );
if ( GetFitModelTargetPtDist( 0 ) > 1e-6 ) { Print( "ERROR: GetFitModelTargetPtDist" ); __failure++; }
double GetFitModelTargetPtDist(int index)
See also
SortFitModelTargetPtsByDist
Parameters
[in]indexint Target point index
Returns
double Distance from the target point to the surface
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFitModelTargetPtGeom()

std::string vsp::GetFitModelTargetPtGeom ( int index)
extern

Get the Geom a target point is matched to.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.5, 0.0 ) );
if ( GetFitModelTargetPtGeom( 0 ) != pid ) { Print( "ERROR: GetFitModelTargetPtGeom" ); __failure++; }
std::string GetFitModelTargetPtGeom(int index)
See also
SetFitModelTargetPtGeom
Parameters
[in]indexint Target point index
Returns
string Geom ID of the matched surface
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFitModelTargetPtSurfIndx()

int vsp::GetFitModelTargetPtSurfIndx ( int index)
extern

Get the surface of the matched Geom a target point is paired with.

string pid = AddGeom( "POD" );
SetParmVal( FindParm( pid, "Sym_Planar_Flag", "Sym" ), SYM_XZ );
AddFitModelTargetPt( pid, 1, CompPnt01( pid, 1, 0.5, 0.25 ) );
if ( GetFitModelTargetPtSurfIndx( 0 ) != 1 ) { Print( "ERROR: GetFitModelTargetPtSurfIndx" ); __failure++; }
if ( UpdateFitModelDist() > 1e-4 ) { Print( "ERROR: GetFitModelTargetPtSurfIndx" ); __failure++; }
@ SYM_XZ
int GetFitModelTargetPtSurfIndx(int index)
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)
See also
SetFitModelTargetPtSurfIndx, GetFitModelTargetPtGeom
Parameters
[in]indexint Target point index
Returns
int Index of the matched surface of the Geom
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFitModelTargetPtSurfPt()

vec3d vsp::GetFitModelTargetPtSurfPt ( int index)
extern

Get the point currently on the surface at a target point's surface coordinate. The distance from here to the target point is what the optimizer is driving to zero.

string pid = AddGeom( "POD" );
vec3d pnt = CompPnt01( pid, 0, 0.5, 0.25 );
if ( dist( pnt, surf_pnt ) > 1e-6 ) { Print( "ERROR: GetFitModelTargetPtSurfPt" ); __failure++; }
vec3d GetFitModelTargetPtSurfPt(int index)
See also
GetFitModelTargetPt, UpdateFitModelDist
Parameters
[in]indexint Target point index
Returns
vec3d Point on the surface at the target point's surface coordinate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFitModelTargetPtU()

double vsp::GetFitModelTargetPtU ( int index)
extern

Get the U surface coordinate of a target point.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.5, 0.25 ), FIT_MODEL_FIXED, FIT_MODEL_FIXED, 0.5, 0.25 );
if ( abs( GetFitModelTargetPtU( 0 ) - 0.5 ) > 1e-6 ) { Print( "ERROR: GetFitModelTargetPtU" ); __failure++; }
See also
GetFitModelTargetPtW, SetFitModelTargetPtUW
Parameters
[in]indexint Target point index
Returns
double U surface coordinate in [0, 1]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFitModelTargetPtUType()

int vsp::GetFitModelTargetPtUType ( int index)
extern

Get whether the U direction of a target point is pinned or free.

string pid = AddGeom( "POD" );
if ( GetFitModelTargetPtUType( 0 ) != FIT_MODEL_FIXED ) { Print( "ERROR: GetFitModelTargetPtUType" ); __failure++; }
See also
FIT_MODEL_TARGET_TYPE, SetFitModelTargetPtUType
Parameters
[in]indexint Target point index
Returns
int Fit model target type enum (i.e. FIT_MODEL_FREE)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFitModelTargetPtW()

double vsp::GetFitModelTargetPtW ( int index)
extern

Get the W surface coordinate of a target point.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.5, 0.25 ), FIT_MODEL_FIXED, FIT_MODEL_FIXED, 0.5, 0.25 );
if ( abs( GetFitModelTargetPtW( 0 ) - 0.25 ) > 1e-6 ) { Print( "ERROR: GetFitModelTargetPtW" ); __failure++; }
See also
GetFitModelTargetPtU, SetFitModelTargetPtUW
Parameters
[in]indexint Target point index
Returns
double W surface coordinate in [0, 1]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFitModelTargetPtWType()

int vsp::GetFitModelTargetPtWType ( int index)
extern

Get whether the W direction of a target point is pinned or free.

string pid = AddGeom( "POD" );
if ( GetFitModelTargetPtWType( 0 ) != FIT_MODEL_FIXED ) { Print( "ERROR: GetFitModelTargetPtWType" ); __failure++; }
See also
FIT_MODEL_TARGET_TYPE, SetFitModelTargetPtWType
Parameters
[in]indexint Target point index
Returns
int Fit model target type enum (i.e. FIT_MODEL_FREE)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFitModelVar()

std::string vsp::GetFitModelVar ( int index)
extern

Get the Parm ID of one Fit Model Tool variable. The variables are held sorted by name, so this index need not follow the order they were added in.

string pid = AddGeom( "POD" );
string len = GetParm( pid, "Length", "Design" );
if ( GetFitModelVar( 0 ) != len ) { Print( "ERROR: GetFitModelVar" ); __failure++; }
std::string GetFitModelVar(int index)
See also
GetFitModelVarVec
Parameters
[in]indexint Variable index
Returns
string Parm ID
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFitModelVarVec()

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

Get the Parm IDs of every Fit Model Tool variable.

string pid = AddGeom( "POD" );
AddFitModelVar( GetParm( pid, "Length", "Design" ) );
array < string > @var_array = GetFitModelVarVec();
if ( var_array.size() != 1 ) { Print( "ERROR: GetFitModelVarVec" ); __failure++; }
std::vector< std::string > GetFitModelVarVec()
See also
GetFitModelVar
Returns
vector<string> Parm IDs of every variable
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNumFitModelOptVars()

int vsp::GetNumFitModelOptVars ( )
extern

Get the number of degrees of freedom the optimization problem has: one for each variable, plus one for each free direction of each target point.

string pid = AddGeom( "POD" );
AddFitModelVar( GetParm( pid, "Length", "Design" ) );
if ( GetNumFitModelOptVars() != 3 ) { Print( "ERROR: GetNumFitModelOptVars" ); __failure++; }
See also
OptimizeFitModel
Returns
int Number of degrees of freedom
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNumFitModelTargetPts()

int vsp::GetNumFitModelTargetPts ( )
extern

Get the number of target points held by the Fit Model Tool.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.5, 0.0 ) );
if ( GetNumFitModelTargetPts() != 1 ) { Print( "ERROR: GetNumFitModelTargetPts" ); __failure++; }
See also
AddFitModelTargetPt
Returns
int Number of target points
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNumFitModelVars()

int vsp::GetNumFitModelVars ( )
extern

Get the number of Parms nominated as Fit Model Tool variables.

string pid = AddGeom( "POD" );
AddFitModelVar( GetParm( pid, "Length", "Design" ) );
if ( GetNumFitModelVars() != 1 ) { Print( "ERROR: GetNumFitModelVars" ); __failure++; }
See also
AddFitModelVar
Returns
int Number of variables
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadFitModelFile()

int vsp::LoadFitModelFile ( const std::string & file_name)
extern

Read target points and variables from a .fit file, adding them to whatever the Fit Model Tool already holds. Call ResetFitModel first to read into an empty tool.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.5, 0.0 ) );
SaveFitModelFile( "TestFitModel.fit" );
LoadFitModelFile( "TestFitModel.fit" );
if ( GetNumFitModelTargetPts() != 1 ) { Print( "ERROR: LoadFitModelFile" ); __failure++; }
void ResetFitModel()
int LoadFitModelFile(const std::string &file_name)
void SaveFitModelFile(const std::string &file_name)
See also
SaveFitModelFile, ResetFitModel
Parameters
[in]file_namestring Name of the .fit file to read
Returns
int Zero on success, or a nonzero code describing why the file could not be read
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MoveFitModelTargetPt()

int vsp::MoveFitModelTargetPt ( int index,
int reorder_type )
extern

Move one target point within the Fit Model Tool's list, and return where it ended up. Target points are addressed by index, so this renumbers them – an index held across the call names a different point afterwards. Order does not change the fit; it is the order the points are listed and stepped through in.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.25, 0.0 ) );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.50, 0.0 ) );
vec3d last_pnt = CompPnt01( pid, 0, 0.75, 0.0 );
AddFitModelTargetPt( pid, 0, last_pnt );
if ( newindex != 0 ) { Print( "ERROR: MoveFitModelTargetPt" ); __failure++; }
if ( abs( GetFitModelTargetPt( 0 ).x() - last_pnt.x() ) > 1e-6 ) { Print( "ERROR: MoveFitModelTargetPt" ); __failure++; }
@ REORDER_MOVE_TOP
int MoveFitModelTargetPt(int index, int reorder_type)
double x() const
Definition Vec3d.h:531
See also
SortFitModelTargetPtsByDist, GetFitModelTargetPt, REORDER_TYPE
Parameters
[in]indexint Index of target point to move
[in]reorder_typeint Enum specifying reordering type (i.e. REORDER_MOVE_UP, REORDER_MOVE_DOWN, REORDER_MOVE_TOP, REORDER_MOVE_BOTTOM)
Returns
int Index the target point ended up at
Here is the call graph for this function:
Here is the caller graph for this function:

◆ OptimizeFitModel()

int vsp::OptimizeFitModel ( )
extern

Adjust the variables, and any free target point surface coordinates, until the surfaces pass as close as they can to the target points. A Levenberg-Marquardt algorithm solves the least squares problem, with three residuals per target point. Least squares needs at least as many conditions as unknowns, so at least three target points are needed for every three degrees of freedom; GetNumFitModelOptVars counts the latter. The return value is the termination code of the solver: 0 reports that the inputs were not usable, which generally means the variables chosen are not independent or do not move the surface at all.

string pid = AddGeom( "POD" );
string len = GetParm( pid, "Length", "Design" );
// Sample points from the pod, then stretch it away from them.
array < vec3d > pts;
pts.push_back( CompPnt01( pid, 0, 0.25, 0.0 ) );
pts.push_back( CompPnt01( pid, 0, 0.50, 0.0 ) );
pts.push_back( CompPnt01( pid, 0, 0.75, 0.0 ) );
double len0 = GetParmVal( len );
SetParmVal( len, 1.4 * len0 );
AddFitModelTargetPts( pid, 0, pts );
// Fitting the points back should have recovered the original length.
if ( abs( GetParmVal( len ) - len0 ) > 1e-3 ) { Print( "ERROR: OptimizeFitModel" ); __failure++; }
double GetParmVal(const std::string &parm_id)
See also
AddFitModelTargetPts, AddFitModelVar, UpdateFitModelDist
Returns
int Termination code of the least squares solver
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RefineFitModelTargetUW()

void vsp::RefineFitModelTargetUW ( )
extern

Move every free target point to the closest point on its surface, starting from where the point currently sits. This is faster than SearchFitModelTargetUW but can settle on a nearby answer rather than the best one. Fixed directions are left where they are.

string pid = AddGeom( "POD" );
vec3d pnt = CompPnt01( pid, 0, 0.5, 0.25 );
AddFitModelTargetPt( pid, 0, pnt, FIT_MODEL_FREE, FIT_MODEL_FREE, 0.45, 0.25 );
if ( UpdateFitModelDist() > 1e-4 ) { Print( "ERROR: RefineFitModelTargetUW" ); __failure++; }
void RefineFitModelTargetUW()
See also
SearchFitModelTargetUW, UpdateFitModelDist
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetFitModel()

void vsp::ResetFitModel ( )
extern

Clear the Fit Model Tool, removing every target point and every variable.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, vec3d( 3.0, 0.0, 0.0 ) );
if ( GetNumFitModelTargetPts() != 0 ) { Print( "ERROR: ResetFitModel" ); __failure++; }
See also
DelAllFitModelTargetPts, DelAllFitModelVars
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveFitModelFile()

void vsp::SaveFitModelFile ( const std::string & file_name)
extern

Write the Fit Model Tool's target points and variables to a .fit file.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.5, 0.0 ) );
AddFitModelVar( GetParm( pid, "Length", "Design" ) );
SaveFitModelFile( "TestFitModel.fit" );
See also
LoadFitModelFile
Parameters
[in]file_namestring Name of the .fit file to write
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SearchFitModelTargetUW()

void vsp::SearchFitModelTargetUW ( )
extern

Move every free target point to the closest point on its surface, searching the whole surface rather than working from where the point currently sits. This is slower than RefineFitModelTargetUW but does not depend on a good starting coordinate, so it is what lifts a point off a seam it has become stuck against. Fixed directions are left where they are.

string pid = AddGeom( "POD" );
vec3d pnt = CompPnt01( pid, 0, 0.5, 0.25 );
if ( UpdateFitModelDist() > 1e-4 ) { Print( "ERROR: SearchFitModelTargetUW" ); __failure++; }
void SearchFitModelTargetUW()
See also
RefineFitModelTargetUW, UpdateFitModelDist
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFitModelTargetPt()

void vsp::SetFitModelTargetPt ( int index,
const vec3d & pt )
extern

Move the point a target point is trying to match.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, vec3d( 0.0, 0.0, 0.0 ) );
SetFitModelTargetPt( 0, vec3d( 3.0, 1.0, 2.0 ) );
if ( dist( GetFitModelTargetPt( 0 ), vec3d( 3.0, 1.0, 2.0 ) ) > 1e-6 ) { Print( "ERROR: SetFitModelTargetPt" ); __failure++; }
void SetFitModelTargetPt(int index, const vec3d &pt)
See also
GetFitModelTargetPt
Parameters
[in]indexint Target point index
[in]ptvec3d Point to be matched, in model coordinates
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFitModelTargetPtGeom()

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

Match a target point to a different Geom.

string pid = AddGeom( "POD" );
string fid = AddGeom( "FUSELAGE" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.5, 0.0 ) );
if ( GetFitModelTargetPtGeom( 0 ) != fid ) { Print( "ERROR: SetFitModelTargetPtGeom" ); __failure++; }
void SetFitModelTargetPtGeom(int index, const std::string &geom_id)
See also
GetFitModelTargetPtGeom
Parameters
[in]indexint Target point index
[in]geom_idstring Geom ID of the surface the point is matched to
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFitModelTargetPtSurfIndx()

void vsp::SetFitModelTargetPtSurfIndx ( int index,
int surf_indx )
extern

Pair a target point with a different surface of the Geom it is already matched to. The index must be in range on that Geom. Note that surfaces are numbered by position, so turning symmetry on or off, or changing the number of copies of a Geom, changes which surface an index names.

string pid = AddGeom( "POD" );
SetParmVal( FindParm( pid, "Sym_Planar_Flag", "Sym" ), SYM_XZ );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 1, 0.5, 0.25 ) );
if ( GetFitModelTargetPtSurfIndx( 0 ) != 1 ) { Print( "ERROR: SetFitModelTargetPtSurfIndx" ); __failure++; }
if ( UpdateFitModelDist() > 1e-4 ) { Print( "ERROR: SetFitModelTargetPtSurfIndx" ); __failure++; }
void SetFitModelTargetPtSurfIndx(int index, int surf_indx)
See also
GetFitModelTargetPtSurfIndx, SetFitModelTargetPtGeom
Parameters
[in]indexint Target point index
[in]surf_indxint Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFitModelTargetPtUType()

void vsp::SetFitModelTargetPtUType ( int index,
int u_type )
extern

Pin or free the U direction of a target point.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.5, 0.0 ) );
if ( GetFitModelTargetPtUType( 0 ) != FIT_MODEL_FIXED ) { Print( "ERROR: SetFitModelTargetPtUType" ); __failure++; }
void SetFitModelTargetPtUType(int index, int u_type)
See also
FIT_MODEL_TARGET_TYPE, GetFitModelTargetPtUType
Parameters
[in]indexint Target point index
[in]u_typeint Fit model target type enum (i.e. FIT_MODEL_FREE)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFitModelTargetPtUW()

void vsp::SetFitModelTargetPtUW ( int index,
double u,
double w )
extern

Set the surface coordinate of a target point. For a fixed direction this is where the point is held; for a free direction it is only where the search starts.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.5, 0.25 ) );
SetFitModelTargetPtUW( 0, 0.5, 0.25 );
if ( abs( GetFitModelTargetPtU( 0 ) - 0.5 ) > 1e-6 ) { Print( "ERROR: SetFitModelTargetPtUW" ); __failure++; }
void SetFitModelTargetPtUW(int index, double u, double w)
See also
GetFitModelTargetPtU, GetFitModelTargetPtW
Parameters
[in]indexint Target point index
[in]udouble U surface coordinate in [0, 1]
[in]wdouble W surface coordinate in [0, 1]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFitModelTargetPtWType()

void vsp::SetFitModelTargetPtWType ( int index,
int w_type )
extern

Pin or free the W direction of a target point. W often wraps around the surface, and a free W that has wandered to the seam can leave the optimizer stuck; SearchFitModelTargetUW will lift it off.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.5, 0.0 ) );
if ( GetFitModelTargetPtWType( 0 ) != FIT_MODEL_FIXED ) { Print( "ERROR: SetFitModelTargetPtWType" ); __failure++; }
void SetFitModelTargetPtWType(int index, int w_type)
See also
FIT_MODEL_TARGET_TYPE, GetFitModelTargetPtWType, SearchFitModelTargetUW
Parameters
[in]indexint Target point index
[in]w_typeint Fit model target type enum (i.e. FIT_MODEL_FREE)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SortFitModelTargetPtsByDist()

void vsp::SortFitModelTargetPtsByDist ( )
extern

Reorder the target points worst fit first, by descending distance from each point to the surface it is matched to. The distances are recomputed before sorting, so the order describes the model as it stands. Target points are addressed by index, so this renumbers them – an index held across the call names a different point afterwards.

string pid = AddGeom( "POD" );
vec3d near_pnt = CompPnt01( pid, 0, 0.5, 0.25 );
vec3d far_pnt = vec3d( near_pnt.x(), near_pnt.y(), near_pnt.z() + 1.0 );
AddFitModelTargetPtFixedUW( pid, 0, near_pnt, 0.5, 0.25 );
AddFitModelTargetPtFixedUW( pid, 0, far_pnt, 0.5, 0.25 );
if ( abs( GetFitModelTargetPt( 0 ).z() - far_pnt.z() ) > 1e-6 ) { Print( "ERROR: SortFitModelTargetPtsByDist" ); __failure++; }
void SortFitModelTargetPtsByDist()
double y() const
Definition Vec3d.h:563
double z() const
Definition Vec3d.h:595
See also
UpdateFitModelDist, GetFitModelTargetPt
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UndoFitModel()

bool vsp::UndoFitModel ( )
extern

Undo the last Fit Model operation, putting back the Parm values and the free surface coordinates of the target points as they were before OptimizeFitModel, SearchFitModelTargetUW or RefineFitModelTargetUW was run. One level deep: the snapshot is spent once it has been used.

string pid = AddGeom( "POD" );
string length = GetParm( pid, "Length", "Design" );
array< vec3d > pts;
pts.push_back( CompPnt01( pid, 0, 0.2, 0.3 ) );
pts.push_back( CompPnt01( pid, 0, 0.5, 0.6 ) );
AddFitModelTargetPts( pid, 0, pts );
AddFitModelVar( length );
SetParmVal( length, 7.0 );
if ( !UndoFitModel() ) { Print( "ERROR: UndoFitModel" ); __failure++; }
//==== The Parm is back where it was before the fit ====//
if ( abs( GetParmVal( length ) - 7.0 ) > 1e-6 ) { Print( "ERROR: UndoFitModel" ); __failure++; }
//==== And there is nothing left to undo ====//
if ( UndoFitModel() ) { Print( "ERROR: UndoFitModel" ); __failure++; }
bool UndoFitModel()
See also
CanUndoFitModel, OptimizeFitModel, SearchFitModelTargetUW, RefineFitModelTargetUW
Returns
bool True if a previous state was restored
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateFitModelDist()

double vsp::UpdateFitModelDist ( )
extern

Recompute and return how far the model is from the target points. The measure is the root mean square of the distance from each target point to the point on its surface. Zero is the wanted answer, so it does not also stand for having nothing to measure; with no target points this reports -1.

string pid = AddGeom( "POD" );
AddFitModelTargetPt( pid, 0, CompPnt01( pid, 0, 0.5, 0.25 ), FIT_MODEL_FIXED, FIT_MODEL_FIXED, 0.5, 0.25 );
if ( UpdateFitModelDist() > 1e-6 ) { Print( "ERROR: UpdateFitModelDist" ); __failure++; }
See also
GetFitModelDist, OptimizeFitModel
Returns
double Root mean square distance from the target points to the surfaces, or -1 when there are no target points to measure
Here is the call graph for this function:
Here is the caller graph for this function: