This group of functions works with clouds of points – imported, or made from a MeshGeom such as the one a planar slice produces – and narrows them down to the points wanted. In the GUI a cloud is whittled down by selecting and hiding points with the mouse, which projects a screen rectangle into three dimensions and is only as good as that projection. Through the API the points are handed about as plain vectors of coordinates and filtered by where they actually are, which is both exact and repeatable. Filters come in keep and remove pairs, so a selection is inverted by asking for the other one, and there are set operations for combining the results. Click here to return to the main page.
More...
|
| std::string | vsp::CreatePtCloudGeomFromPts (const std::vector< vec3d > &pt_vec, const std::string &name) |
| std::vector< vec3d > | vsp::KeepPtsInBBox (const std::vector< vec3d > &pt_vec, const vec3d &min_pt, const vec3d &max_pt) |
| std::vector< vec3d > | vsp::RemovePtsInBBox (const std::vector< vec3d > &pt_vec, const vec3d &min_pt, const vec3d &max_pt) |
| std::vector< vec3d > | vsp::KeepPtsInRange (const std::vector< vec3d > &pt_vec, int dir_index, double low, double high) |
| std::vector< vec3d > | vsp::RemovePtsInRange (const std::vector< vec3d > &pt_vec, int dir_index, double low, double high) |
| std::vector< vec3d > | vsp::KeepPtsAbove (const std::vector< vec3d > &pt_vec, int dir_index, double val) |
| std::vector< vec3d > | vsp::KeepPtsBelow (const std::vector< vec3d > &pt_vec, int dir_index, double val) |
| std::vector< vec3d > | vsp::KeepPtsNearPt (const std::vector< vec3d > &pt_vec, const vec3d ¢er, double radius) |
| std::vector< vec3d > | vsp::RemovePtsNearPt (const std::vector< vec3d > &pt_vec, const vec3d ¢er, double radius) |
| std::vector< vec3d > | vsp::KeepPtsNearGeom (const std::vector< vec3d > &pt_vec, const std::string &geom_id, int surf_indx, double tol) |
| std::vector< vec3d > | vsp::RemovePtsNearGeom (const std::vector< vec3d > &pt_vec, const std::string &geom_id, int surf_indx, double tol) |
| std::vector< vec3d > | vsp::UniquePts (const std::vector< vec3d > &pt_vec, double tol) |
| std::vector< vec3d > | vsp::UnionPts (const std::vector< vec3d > &pt_vec_a, const std::vector< vec3d > &pt_vec_b, double tol) |
| std::vector< vec3d > | vsp::IntersectPts (const std::vector< vec3d > &pt_vec_a, const std::vector< vec3d > &pt_vec_b, double tol) |
| std::vector< vec3d > | vsp::SubtractPts (const std::vector< vec3d > &pt_vec_a, const std::vector< vec3d > &pt_vec_b, double tol) |
| std::string | vsp::CreatePtCloudGeom (const std::string &geom_id) |
◆ CreatePtCloudGeom()
| std::string vsp::CreatePtCloudGeom |
( |
const std::string & | geom_id | ) |
|
|
extern |
Make a Point Cloud Geom out of the vertices of a MeshGeom. This is the Mesh screen's Convert to Point Cloud button, and it is the usual way into a fit: take a planar slice of a model, which leaves a MeshGeom, and turn that into points to match.
if (
GetPtCloudPnts( cloud_id ).size() == 0 ) {
Print(
"ERROR: CreatePtCloudGeom" ); __failure++; }
void Print(const std::string &data, bool new_line=true)
std::string ComputePlaneSlice(int set, int num_slices, const vec3d &norm, bool auto_bnd, double start_bnd=0, double end_bnd=0, bool measureduct=false)
std::vector< vec3d > GetPtCloudPnts(const std::string &geom_id)
std::string AddGeom(const std::string &type, const std::string &parent=std::string())
std::string CreatePtCloudGeom(const std::string &geom_id)
void Update(bool update_managers=true)
- See also
- GetPtCloudPnts, CreatePtCloudGeomFromPts, ComputePlaneSlice
- Parameters
-
| [in] | geom_id | string MeshGeom ID to take the vertices of |
- Returns
- string Geom ID of the new Point Cloud Geom
◆ CreatePtCloudGeomFromPts()
| std::string vsp::CreatePtCloudGeomFromPts |
( |
const std::vector< vec3d > & | pt_vec, |
|
|
const std::string & | name ) |
|
extern |
Make a Point Cloud Geom out of a set of points. This is how a set worked out in a script is put back into the model, so it can be looked at in the GUI and saved with the file. The counterpart of GetPtCloudPnts.
array < vec3d > pts;
pts.push_back(
vec3d( 0.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 2.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 4.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 6.0, 0.0, 0.0 ) );
if (
GetPtCloudPnts( cloud_id ).size() != 4 ) {
Print(
"ERROR: CreatePtCloudGeomFromPts" ); __failure++; }
std::string CreatePtCloudGeomFromPts(const std::vector< vec3d > &pt_vec, const std::string &name)
- See also
- GetPtCloudPnts, CreatePtCloudGeom
- Parameters
-
| [in] | pt_vec | vector<vec3d> Points to place in the new Geom |
| [in] | name | string Name for the new Geom, or an empty string for the default |
- Returns
- string Geom ID of the new Point Cloud Geom
◆ IntersectPts()
| std::vector< vec3d > vsp::IntersectPts |
( |
const std::vector< vec3d > & | pt_vec_a, |
|
|
const std::vector< vec3d > & | pt_vec_b, |
|
|
double | tol ) |
|
extern |
Keep the points of the first set that also appear, within tol, in the second. Answered with a spatial tree over the second set rather than by comparing every pair.
array < vec3d > pts;
pts.push_back(
vec3d( 0.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 2.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 4.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 6.0, 0.0, 0.0 ) );
if ( both.size() != 2 ) {
Print(
"ERROR: IntersectPts" ); __failure++; }
std::vector< vec3d > KeepPtsInRange(const std::vector< vec3d > &pt_vec, int dir_index, double low, double high)
std::vector< vec3d > IntersectPts(const std::vector< vec3d > &pt_vec_a, const std::vector< vec3d > &pt_vec_b, double tol)
- See also
- SubtractPts, UnionPts
- Parameters
-
| [in] | pt_vec_a | vector<vec3d> Set to take points from |
| [in] | pt_vec_b | vector<vec3d> Set to test against |
| [in] | tol | double Distance within which two points count as the same point |
- Returns
- vector<vec3d> Points of the first set that appear in the second
◆ KeepPtsAbove()
| std::vector< vec3d > vsp::KeepPtsAbove |
( |
const std::vector< vec3d > & | pt_vec, |
|
|
int | dir_index, |
|
|
double | val ) |
|
extern |
Keep the points whose coordinate along one axis is greater than a value. Together with KeepPtsBelow this splits a set in two: the two answers are complements, so no separate remove call is wanted.
array < vec3d > pts;
pts.push_back(
vec3d( 0.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 2.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 4.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 6.0, 0.0, 0.0 ) );
if ( aft.size() != 2 ) {
Print(
"ERROR: KeepPtsAbove" ); __failure++; }
std::vector< vec3d > KeepPtsAbove(const std::vector< vec3d > &pt_vec, int dir_index, double val)
- See also
- KeepPtsBelow, KeepPtsInRange
- Parameters
-
| [in] | pt_vec | vector<vec3d> Points to filter |
| [in] | dir_index | int Direction index enum (i.e. X_DIR) |
| [in] | val | double Value to compare against |
- Returns
- vector<vec3d> Points above the value
◆ KeepPtsBelow()
| std::vector< vec3d > vsp::KeepPtsBelow |
( |
const std::vector< vec3d > & | pt_vec, |
|
|
int | dir_index, |
|
|
double | val ) |
|
extern |
Keep the points whose coordinate along one axis is less than or equal to a value. The complement of KeepPtsAbove.
array < vec3d > pts;
pts.push_back(
vec3d( 0.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 2.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 4.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 6.0, 0.0, 0.0 ) );
if ( fwd.size() != 2 ) {
Print(
"ERROR: KeepPtsBelow" ); __failure++; }
std::vector< vec3d > KeepPtsBelow(const std::vector< vec3d > &pt_vec, int dir_index, double val)
- See also
- KeepPtsAbove, KeepPtsInRange
- Parameters
-
| [in] | pt_vec | vector<vec3d> Points to filter |
| [in] | dir_index | int Direction index enum (i.e. X_DIR) |
| [in] | val | double Value to compare against |
- Returns
- vector<vec3d> Points at or below the value
◆ KeepPtsInBBox()
| std::vector< vec3d > vsp::KeepPtsInBBox |
( |
const std::vector< vec3d > & | pt_vec, |
|
|
const vec3d & | min_pt, |
|
|
const vec3d & | max_pt ) |
|
extern |
Keep the points inside an axis aligned box. This is what the GUI's rectangle selection is reaching for, done in three dimensions rather than through a screen projection.
array < vec3d > pts;
pts.push_back(
vec3d( 0.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 2.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 4.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 6.0, 0.0, 0.0 ) );
if ( inside.size() != 2 ) {
Print(
"ERROR: KeepPtsInBBox" ); __failure++; }
std::vector< vec3d > KeepPtsInBBox(const std::vector< vec3d > &pt_vec, const vec3d &min_pt, const vec3d &max_pt)
- See also
- RemovePtsInBBox, KeepPtsInRange
- Parameters
-
| [in] | pt_vec | vector<vec3d> Points to filter |
| [in] | min_pt | vec3d Corner of the box with the smallest coordinates |
| [in] | max_pt | vec3d Corner of the box with the largest coordinates |
- Returns
- vector<vec3d> Points inside the box
◆ KeepPtsInRange()
| std::vector< vec3d > vsp::KeepPtsInRange |
( |
const std::vector< vec3d > & | pt_vec, |
|
|
int | dir_index, |
|
|
double | low, |
|
|
double | high ) |
|
extern |
Keep the points whose coordinate along one axis falls between two values, inclusive.
array < vec3d > pts;
pts.push_back(
vec3d( 0.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 2.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 4.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 6.0, 0.0, 0.0 ) );
if ( mid.size() != 2 ) {
Print(
"ERROR: KeepPtsInRange" ); __failure++; }
- See also
- RemovePtsInRange, KeepPtsAbove, KeepPtsBelow
- Parameters
-
| [in] | pt_vec | vector<vec3d> Points to filter |
| [in] | dir_index | int Direction index enum (i.e. X_DIR) |
| [in] | low | double Lowest coordinate to keep |
| [in] | high | double Highest coordinate to keep |
- Returns
- vector<vec3d> Points within the range
◆ KeepPtsNearGeom()
| std::vector< vec3d > vsp::KeepPtsNearGeom |
( |
const std::vector< vec3d > & | pt_vec, |
|
|
const std::string & | geom_id, |
|
|
int | surf_indx, |
|
|
double | tol ) |
|
extern |
Keep the points lying within tol of a surface. This narrows a cloud – a slice through a whole model, say – down to the component being fitted. Unlike the other filters this one costs a surface projection for every point rather than a comparison, so on a large cloud it is worth cutting the set down with one of the cheap filters first.
array < vec3d > pts;
pts.push_back(
CompPnt01( pid, 0, 0.5, 0.25 ) );
pts.push_back(
vec3d( 0.0, 100.0, 0.0 ) );
if ( on_body.size() != 1 ) {
Print(
"ERROR: KeepPtsNearGeom" ); __failure++; }
std::vector< vec3d > KeepPtsNearGeom(const std::vector< vec3d > &pt_vec, const std::string &geom_id, int surf_indx, double tol)
vec3d CompPnt01(const std::string &geom_id, const int &surf_indx, const double &u, const double &w)
- See also
- RemovePtsNearGeom, KeepPtsInBBox
- Parameters
-
| [in] | pt_vec | vector<vec3d> Points to filter |
| [in] | geom_id | string Geom ID of the surface to measure against |
| [in] | surf_indx | int Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1 |
| [in] | tol | double Distance within which to keep points |
- Returns
- vector<vec3d> Points lying within tol of the surface
◆ KeepPtsNearPt()
| std::vector< vec3d > vsp::KeepPtsNearPt |
( |
const std::vector< vec3d > & | pt_vec, |
|
|
const vec3d & | center, |
|
|
double | radius ) |
|
extern |
Keep the points within a distance of a given point.
array < vec3d > pts;
pts.push_back(
vec3d( 0.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 2.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 4.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 6.0, 0.0, 0.0 ) );
if ( near.size() != 1 ) {
Print(
"ERROR: KeepPtsNearPt" ); __failure++; }
std::vector< vec3d > KeepPtsNearPt(const std::vector< vec3d > &pt_vec, const vec3d ¢er, double radius)
- See also
- RemovePtsNearPt
- Parameters
-
| [in] | pt_vec | vector<vec3d> Points to filter |
| [in] | center | vec3d Point to measure from |
| [in] | radius | double Distance within which to keep points |
- Returns
- vector<vec3d> Points within the radius
◆ RemovePtsInBBox()
| std::vector< vec3d > vsp::RemovePtsInBBox |
( |
const std::vector< vec3d > & | pt_vec, |
|
|
const vec3d & | min_pt, |
|
|
const vec3d & | max_pt ) |
|
extern |
Drop the points inside an axis aligned box, keeping the rest. The complement of KeepPtsInBBox, which is how a selection is inverted.
array < vec3d > pts;
pts.push_back(
vec3d( 0.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 2.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 4.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 6.0, 0.0, 0.0 ) );
if ( outside.size() != 2 ) {
Print(
"ERROR: RemovePtsInBBox" ); __failure++; }
std::vector< vec3d > RemovePtsInBBox(const std::vector< vec3d > &pt_vec, const vec3d &min_pt, const vec3d &max_pt)
- See also
- KeepPtsInBBox
- Parameters
-
| [in] | pt_vec | vector<vec3d> Points to filter |
| [in] | min_pt | vec3d Corner of the box with the smallest coordinates |
| [in] | max_pt | vec3d Corner of the box with the largest coordinates |
- Returns
- vector<vec3d> Points outside the box
◆ RemovePtsInRange()
| std::vector< vec3d > vsp::RemovePtsInRange |
( |
const std::vector< vec3d > & | pt_vec, |
|
|
int | dir_index, |
|
|
double | low, |
|
|
double | high ) |
|
extern |
Drop the points whose coordinate along one axis falls between two values, keeping the rest.
array < vec3d > pts;
pts.push_back(
vec3d( 0.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 2.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 4.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 6.0, 0.0, 0.0 ) );
if ( ends.size() != 2 ) {
Print(
"ERROR: RemovePtsInRange" ); __failure++; }
std::vector< vec3d > RemovePtsInRange(const std::vector< vec3d > &pt_vec, int dir_index, double low, double high)
- See also
- KeepPtsInRange
- Parameters
-
| [in] | pt_vec | vector<vec3d> Points to filter |
| [in] | dir_index | int Direction index enum (i.e. X_DIR) |
| [in] | low | double Lowest coordinate to drop |
| [in] | high | double Highest coordinate to drop |
- Returns
- vector<vec3d> Points outside the range
◆ RemovePtsNearGeom()
| std::vector< vec3d > vsp::RemovePtsNearGeom |
( |
const std::vector< vec3d > & | pt_vec, |
|
|
const std::string & | geom_id, |
|
|
int | surf_indx, |
|
|
double | tol ) |
|
extern |
Drop the points lying within tol of a surface, keeping the rest. Useful for taking one component's points out of a cloud that covers several. Costs a surface projection per point.
array < vec3d > pts;
pts.push_back(
CompPnt01( pid, 0, 0.5, 0.25 ) );
pts.push_back(
vec3d( 0.0, 100.0, 0.0 ) );
if ( off_body.size() != 1 ) {
Print(
"ERROR: RemovePtsNearGeom" ); __failure++; }
std::vector< vec3d > RemovePtsNearGeom(const std::vector< vec3d > &pt_vec, const std::string &geom_id, int surf_indx, double tol)
- See also
- KeepPtsNearGeom
- Parameters
-
| [in] | pt_vec | vector<vec3d> Points to filter |
| [in] | geom_id | string Geom ID of the surface to measure against |
| [in] | surf_indx | int Index of the surface of that Geom, from 0 to GetNumTotalSurfs() - 1 |
| [in] | tol | double Distance within which to drop points |
- Returns
- vector<vec3d> Points lying further than tol from the surface
◆ RemovePtsNearPt()
| std::vector< vec3d > vsp::RemovePtsNearPt |
( |
const std::vector< vec3d > & | pt_vec, |
|
|
const vec3d & | center, |
|
|
double | radius ) |
|
extern |
Drop the points within a distance of a given point, keeping the rest.
array < vec3d > pts;
pts.push_back(
vec3d( 0.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 2.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 4.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 6.0, 0.0, 0.0 ) );
if ( far.size() != 3 ) {
Print(
"ERROR: RemovePtsNearPt" ); __failure++; }
std::vector< vec3d > RemovePtsNearPt(const std::vector< vec3d > &pt_vec, const vec3d ¢er, double radius)
- See also
- KeepPtsNearPt
- Parameters
-
| [in] | pt_vec | vector<vec3d> Points to filter |
| [in] | center | vec3d Point to measure from |
| [in] | radius | double Distance within which to drop points |
- Returns
- vector<vec3d> Points outside the radius
◆ SubtractPts()
| std::vector< vec3d > vsp::SubtractPts |
( |
const std::vector< vec3d > & | pt_vec_a, |
|
|
const std::vector< vec3d > & | pt_vec_b, |
|
|
double | tol ) |
|
extern |
Keep the points of the first set that do not appear, within tol, in the second. This is how a group already dealt with is taken back out of a working set.
array < vec3d > pts;
pts.push_back(
vec3d( 0.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 2.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 4.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 6.0, 0.0, 0.0 ) );
if ( rest.size() != 2 ) {
Print(
"ERROR: SubtractPts" ); __failure++; }
std::vector< vec3d > SubtractPts(const std::vector< vec3d > &pt_vec_a, const std::vector< vec3d > &pt_vec_b, double tol)
- See also
- IntersectPts, UnionPts
- Parameters
-
| [in] | pt_vec_a | vector<vec3d> Set to take points from |
| [in] | pt_vec_b | vector<vec3d> Set to remove |
| [in] | tol | double Distance within which two points count as the same point |
- Returns
- vector<vec3d> Points of the first set that do not appear in the second
◆ UnionPts()
| std::vector< vec3d > vsp::UnionPts |
( |
const std::vector< vec3d > & | pt_vec_a, |
|
|
const std::vector< vec3d > & | pt_vec_b, |
|
|
double | tol ) |
|
extern |
Put two sets of points together, keeping one of any that fall within tol of one another.
array < vec3d > pts;
pts.push_back(
vec3d( 0.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 2.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 4.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 6.0, 0.0, 0.0 ) );
array < vec3d > all =
UnionPts( fwd, aft, 1e-8 );
if ( all.size() != 4 ) {
Print(
"ERROR: UnionPts" ); __failure++; }
std::vector< vec3d > UnionPts(const std::vector< vec3d > &pt_vec_a, const std::vector< vec3d > &pt_vec_b, double tol)
- See also
- SubtractPts, IntersectPts, UniquePts
- Parameters
-
| [in] | pt_vec_a | vector<vec3d> First set of points |
| [in] | pt_vec_b | vector<vec3d> Second set of points |
| [in] | tol | double Distance within which two points count as the same point |
- Returns
- vector<vec3d> Points of either set
◆ UniquePts()
| std::vector< vec3d > vsp::UniquePts |
( |
const std::vector< vec3d > & | pt_vec, |
|
|
double | tol ) |
|
extern |
Drop the repeated points of a set, keeping one of each group that falls within tol of one another. Answered with a spatial tree rather than by comparing every pair.
array < vec3d > pts;
pts.push_back(
vec3d( 0.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 2.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 4.0, 0.0, 0.0 ) );
pts.push_back(
vec3d( 6.0, 0.0, 0.0 ) );
array < vec3d > twice;
for ( int i = 0 ; i < int( pts.size() ) ; i++ )
{
twice.push_back( pts[i] );
twice.push_back( pts[i] );
}
array < vec3d > once =
UniquePts( twice, 1e-8 );
if ( once.size() != 4 ) {
Print(
"ERROR: UniquePts" ); __failure++; }
std::vector< vec3d > UniquePts(const std::vector< vec3d > &pt_vec, double tol)
- See also
- UnionPts
- Parameters
-
| [in] | pt_vec | vector<vec3d> Points to filter |
| [in] | tol | double Distance within which two points count as the same point |
- Returns
- vector<vec3d> Points with the repeats removed