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) |
|
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.
| [in] | geom_id | string Geom ID of the surface the point is matched to |
| [in] | surf_indx | int Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1 |
| [in] | pt | vec3d Point to be matched, in model coordinates |
| [in] | u_type | int Fit model target type enum for the U direction (i.e. FIT_MODEL_FREE) |
| [in] | w_type | int Fit model target type enum for the W direction (i.e. FIT_MODEL_FREE) |
| [in] | u | double Starting U surface coordinate in [0, 1] |
| [in] | w | double Starting W surface coordinate in [0, 1] |
|
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.
| [in] | geom_id | string Geom ID of the surface the point is matched to |
| [in] | surf_indx | int Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1 |
| [in] | pt | vec3d Point to be matched, in model coordinates |
| [in] | u | double U surface coordinate in [0, 1] to hold the point at |
|
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.
| [in] | geom_id | string Geom ID of the surface the point is matched to |
| [in] | surf_indx | int Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1 |
| [in] | pt | vec3d Point to be matched, in model coordinates |
| [in] | u | double U surface coordinate in [0, 1] to hold the point at |
| [in] | w | double W surface coordinate in [0, 1] to hold the point at |
|
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.
| [in] | geom_id | string Geom ID of the surface the point is matched to |
| [in] | surf_indx | int Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1 |
| [in] | pt | vec3d Point to be matched, in model coordinates |
| [in] | w | double W surface coordinate in [0, 1] to hold the point at |
|
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.
| [in] | geom_id | string Geom ID of the surface the points are matched to |
| [in] | surf_indx | int Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1 |
| [in] | pt_vec | vector<vec3d> Points to be matched, in model coordinates |
|
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.
| [in] | geom_id | string Geom ID of the surface the points are matched to |
| [in] | surf_indx | int Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1 |
| [in] | pt_vec | vector<vec3d> Points to be matched, in model coordinates |
| [in] | u | double U surface coordinate in [0, 1] to hold every point at |
|
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.
| [in] | geom_id | string Geom ID of the surface the points are matched to |
| [in] | surf_indx | int Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1 |
| [in] | pt_vec | vector<vec3d> Points to be matched, in model coordinates |
| [in] | u_vec | vector<double> U surface coordinate in [0, 1] for each point, same length as pt_vec |
|
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.
| [in] | geom_id | string Geom ID of the surface the points are matched to |
| [in] | surf_indx | int Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1 |
| [in] | pt_vec | vector<vec3d> Points to be matched, in model coordinates |
| [in] | u | double U surface coordinate in [0, 1] to hold every point at |
| [in] | w | double W surface coordinate in [0, 1] to hold every point at |
|
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.
| [in] | geom_id | string Geom ID of the surface the points are matched to |
| [in] | surf_indx | int Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1 |
| [in] | pt_vec | vector<vec3d> Points to be matched, in model coordinates |
| [in] | u_vec | vector<double> U surface coordinate in [0, 1] for each point, same length as pt_vec |
| [in] | w_vec | vector<double> W surface coordinate in [0, 1] for each point, same length as pt_vec |
|
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.
| [in] | geom_id | string Geom ID of the surface the points are matched to |
| [in] | surf_indx | int Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1 |
| [in] | pt_vec | vector<vec3d> Points to be matched, in model coordinates |
| [in] | w | double W surface coordinate in [0, 1] to hold every point at |
|
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.
| [in] | geom_id | string Geom ID of the surface the points are matched to |
| [in] | surf_indx | int Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1 |
| [in] | pt_vec | vector<vec3d> Points to be matched, in model coordinates |
| [in] | w_vec | vector<double> W surface coordinate in [0, 1] for each point, same length as pt_vec |
|
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.
| [in] | parm_id | string Parm ID |
|
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.
|
extern |
Delete every target point from the Fit Model Tool, leaving the variables alone.
|
extern |
Withdraw every Parm from the Fit Model Tool's variables, leaving the target points alone.
|
extern |
Delete one target point from the Fit Model Tool. The points after it move down one index.
| [in] | index | int Target point index |
|
extern |
Withdraw a Parm from the Fit Model Tool's variables.
| [in] | parm_id | string Parm ID |
|
extern |
Get the distance measure last computed, without recomputing it. Reports -1 if the last computation had no target points to measure.
|
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.
| [in] | index | int Target point 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.
| [in] | index | int Target point index |
|
extern |
Get the Geom a target point is matched to.
| [in] | index | int Target point index |
|
extern |
Get the surface of the matched Geom a target point is paired with.
| [in] | index | int Target point 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.
| [in] | index | int Target point index |
|
extern |
Get the U surface coordinate of a target point.
| [in] | index | int Target point index |
|
extern |
Get whether the U direction of a target point is pinned or free.
| [in] | index | int Target point index |
|
extern |
Get the W surface coordinate of a target point.
| [in] | index | int Target point index |
|
extern |
Get whether the W direction of a target point is pinned or free.
| [in] | index | int Target point 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.
| [in] | index | int Variable index |
|
extern |
Get the Parm IDs of every Fit Model Tool variable.
|
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.
|
extern |
Get the number of target points held by the Fit Model Tool.
|
extern |
Get the number of Parms nominated as Fit Model Tool variables.
|
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.
| [in] | file_name | string Name of the .fit file to read |
|
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.
| [in] | index | int Index of target point to move |
| [in] | reorder_type | int Enum specifying reordering type (i.e. REORDER_MOVE_UP, REORDER_MOVE_DOWN, REORDER_MOVE_TOP, REORDER_MOVE_BOTTOM) |
|
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.
|
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.
|
extern |
Clear the Fit Model Tool, removing every target point and every variable.
|
extern |
Write the Fit Model Tool's target points and variables to a .fit file.
| [in] | file_name | string Name of the .fit file to write |
|
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.
|
extern |
Move the point a target point is trying to match.
| [in] | index | int Target point index |
| [in] | pt | vec3d Point to be matched, in model coordinates |
|
extern |
Match a target point to a different Geom.
| [in] | index | int Target point index |
| [in] | geom_id | string Geom ID of the surface the point is matched to |
|
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.
| [in] | index | int Target point index |
| [in] | surf_indx | int Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1 |
|
extern |
Pin or free the U direction of a target point.
| [in] | index | int Target point index |
| [in] | u_type | int Fit model target type enum (i.e. FIT_MODEL_FREE) |
|
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.
| [in] | index | int Target point index |
| [in] | u | double U surface coordinate in [0, 1] |
| [in] | w | double W surface coordinate in [0, 1] |
|
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.
| [in] | index | int Target point index |
| [in] | w_type | int Fit model target type enum (i.e. FIT_MODEL_FREE) |
|
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.
|
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.
|
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.