Rhino C++ API  9.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ON_PointPairing Class Reference

#include <opennurbs_point.h>

Public Types

enum  : unsigned { DefaultPointCount = 400 }
 
enum  List : unsigned { List::None = 0, List::A = 1, List::B = 2, List::AandB = 3 }
 The ON_PointPairing::List enum is used to specify a point list. More...
 

Public Member Functions

 ON_PointPairing ()=default
 
 ON_PointPairing (const ON_PointPairing &)=default
 
 ~ON_PointPairing ()=default
 
bool AppendPoint (ON_PointPairing::List point_list, ON_3dPoint P)
 
bool AppendPoint (ON_PointPairing::List point_list, ON_3dPoint P, double bias)
 
const double * BiasArrayForExperts (ON_PointPairing::List point_list) const
 
double ChamferDistance (bool bNormalized) const
 The chamfer distance is the sum of the distances from each point in A[] to the nearest point in B[], plus the sum of the distances from each point in B[] to the nearest point in A[]. More...
 
void Clear ()
 
void ClearPairing ()
 
void ClearPoints (ON_PointPairing::List point_list)
 
bool CopyList (ON_PointPairing::List source, ON_PointPairing::List destination)
 CopyList() is typically used to copy one list to the other. More...
 
bool EvaluationsCached () const
 This is useful if you need to know when the values returned by PairingDeviation() and ChamferDistance() are cached or need to be evaluated from scratch. More...
 
const ON_3dPoint FirstPoint (ON_PointPairing::List point_list) const
 
const ON_3dPoint LastPoint (ON_PointPairing::List point_list) const
 
const ON_Line MaximumSeparation (ON_PointPairing::List list) const
 Get a line connecting the points in A[] and B[] that have the maximum separation. The from point is always an A[] point. The to point is always a B[] point. More...
 
const ON_2udex MaximumSeparationPair (ON_PointPairing::List list) const
 Get the indices of the points in A[] and B[] that have the maximum separation. The i component of the returned ON_2dex is always an index into A[]. The j component of the returned ON_2dex is always an index into B[]. More...
 
ON_PointPairingoperator= (const ON_PointPairing &)=default
 
const unsigned PairCount () const
 
const ON_2udex Pairing (unsigned point_index) const
 If A[] and B[] are the point lists, then the point in B[] closest to A[k] is B[Pairing(k).j] and the point in A[] closest to B[k] is A[Pairing(k).i]. More...
 
const ON_2udexPairingArrayForExperts () const
 
double PairingDeviation (bool bNormalized) const
 The pairing deviation is 1/2 the sum of the squared distances from each point in A[] to the nearest point in B[], plus the sum of the squared distances from each point in B[] to the nearest point in A[]. The 1/2 is applied to simplify derivative caluculations involving distance squared. More...
 
const ON_SHA1_Hash PairingHash () const
 
const ON_3dPoint Point (ON_PointPairing::List point_list, unsigned point_index) const
 
const ON_3dPointPointArrayForExperts (ON_PointPairing::List point_list) const
 
const unsigned PointCount (ON_PointPairing::List point_list) const
 
const ON_SHA1_Hash PointHash (ON_PointPairing::List point_list) const
 
const ON_BoundingBox PointsBoundingBox (ON_PointPairing::List point_list) const
 
bool ReservePointCapacity (ON_PointPairing::List point_list, size_t capacity)
 
bool SetPointCount (ON_PointPairing::List point_list, size_t point_count)
 
bool SetPoints (ON_PointPairing::List point_list, const ON_SimpleArray< ON_3dPoint > &points)
 Set the points in the specified list to points[]. More...
 
bool SetPoints (ON_PointPairing::List point_list, size_t point_count, const ON_3dPoint *points, const double *biases)
 Set the points in the specified list to points[]. More...
 
bool SetPointsFromCurve (ON_PointPairing::List point_list, double maximum_chord_variance, const class ON_Curve &curve, ON_Interval curve_subdomain, size_t point_count)
 Set a point list by evluating a curve. More...
 
bool SetPointsFromSurface (ON_PointPairing::List point_list, const class ON_Surface &surface, ON_Interval surface_subdomain0, ON_Interval surface_subdomain1, bool bPeriodicPoints0, bool bPeriodicPoints1, size_t point_count0, size_t point_count1)
 
const ON_wString ToString () const
 
bool ValidPairs () const
 

Static Public Member Functions

static double Normalizer (size_t point_count, bool bPeriodicPoints)
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : unsigned
Enumerator
DefaultPointCount 

◆ List

enum ON_PointPairing::List : unsigned
strong

The ON_PointPairing::List enum is used to specify a point list.

Enumerator
None 

Unset pointlist

Point list A

Point list B

AandB 

Point lists A and B

Constructor & Destructor Documentation

◆ ON_PointPairing() [1/2]

ON_PointPairing::ON_PointPairing ( )
default

◆ ~ON_PointPairing()

ON_PointPairing::~ON_PointPairing ( )
default

◆ ON_PointPairing() [2/2]

ON_PointPairing::ON_PointPairing ( const ON_PointPairing )
default

Member Function Documentation

◆ AppendPoint() [1/2]

bool ON_PointPairing::AppendPoint ( ON_PointPairing::List  point_list,
ON_3dPoint  P 
)

◆ AppendPoint() [2/2]

bool ON_PointPairing::AppendPoint ( ON_PointPairing::List  point_list,
ON_3dPoint  P,
double  bias 
)

◆ BiasArrayForExperts()

const double* ON_PointPairing::BiasArrayForExperts ( ON_PointPairing::List  point_list) const

◆ ChamferDistance()

double ON_PointPairing::ChamferDistance ( bool  bNormalized) const

The chamfer distance is the sum of the distances from each point in A[] to the nearest point in B[], plus the sum of the distances from each point in B[] to the nearest point in A[].

Parameters
bNormalizedWhen bNormalized is true, the sum described above is divided by 2*PairCount() and the returned value is the average of the distances in the sums. The normalized value is useful when studying the effect the number of points on the ChamferDistance and when you want to work with smaller values on large point sets.
Returns
If A[] and B[] have the same number of points, then the chamfer distance between A[] and B[] is returned. Otherwise ON_DBL_QNAN is returned.

◆ Clear()

void ON_PointPairing::Clear ( )

◆ ClearPairing()

void ON_PointPairing::ClearPairing ( )

◆ ClearPoints()

void ON_PointPairing::ClearPoints ( ON_PointPairing::List  point_list)

◆ CopyList()

bool ON_PointPairing::CopyList ( ON_PointPairing::List  source,
ON_PointPairing::List  destination 
)

CopyList() is typically used to copy one list to the other.

Parameters
sourceA or B.
destinationA or B. If source and destination identify the same list, nothing is changed.
Returns
True if the copy was successful. False if the input parameters were invalid.

◆ EvaluationsCached()

bool ON_PointPairing::EvaluationsCached ( ) const

This is useful if you need to know when the values returned by PairingDeviation() and ChamferDistance() are cached or need to be evaluated from scratch.

Returns
True if the PairingDeviation() and ChamferDistance() evaluations are cached.

◆ FirstPoint()

const ON_3dPoint ON_PointPairing::FirstPoint ( ON_PointPairing::List  point_list) const

◆ LastPoint()

const ON_3dPoint ON_PointPairing::LastPoint ( ON_PointPairing::List  point_list) const

◆ MaximumSeparation()

const ON_Line ON_PointPairing::MaximumSeparation ( ON_PointPairing::List  list) const

Get a line connecting the points in A[] and B[] that have the maximum separation. The from point is always an A[] point. The to point is always a B[] point.

Parameters
listlist = ON_PointPairing::List::A or ON_PointPairing::List::B. If list = A, then the maximum separation from a point in A[] to its closest point is B[] is returned. If list = B, then the maximum separation from a point in B[] to its closest point is A[] is returned. Note that these are typially different lines.
Returns
A line connecting the maximum separation points.

◆ MaximumSeparationPair()

const ON_2udex ON_PointPairing::MaximumSeparationPair ( ON_PointPairing::List  list) const

Get the indices of the points in A[] and B[] that have the maximum separation. The i component of the returned ON_2dex is always an index into A[]. The j component of the returned ON_2dex is always an index into B[].

Parameters
listlist = ON_PointPairing::List::A or ON_PointPairing::List::B. If list = A, then the maximum separation from a point in A[] to its closest point is B[] is returned. If list = B, then the maximum separation from a point in B[] to its closest point is A[] is returned. Note that these are typially different pairs.
Returns
An ON_2udex "pair" where the maximum separation points are A[pair.i], B[pair.j].

◆ Normalizer()

static double ON_PointPairing::Normalizer ( size_t  point_count,
bool  bPeriodicPoints 
)
static

◆ operator=()

ON_PointPairing& ON_PointPairing::operator= ( const ON_PointPairing )
default

◆ PairCount()

const unsigned ON_PointPairing::PairCount ( ) const
Returns
If both point lists have the same number of points, then that number is returned. Otherwise 0 is returned.

◆ Pairing()

const ON_2udex ON_PointPairing::Pairing ( unsigned  point_index) const

If A[] and B[] are the point lists, then the point in B[] closest to A[k] is B[Pairing(k).j] and the point in A[] closest to B[k] is A[Pairing(k).i].

Parameters
point_index0 <= point_index < PairCount()
Returns
If the A and B point lists have the same number of points, then the pairing indices described above are returned. Otherwise ON_2udex::Unset is returned.

◆ PairingArrayForExperts()

const ON_2udex* ON_PointPairing::PairingArrayForExperts ( ) const

◆ PairingDeviation()

double ON_PointPairing::PairingDeviation ( bool  bNormalized) const

The pairing deviation is 1/2 the sum of the squared distances from each point in A[] to the nearest point in B[], plus the sum of the squared distances from each point in B[] to the nearest point in A[]. The 1/2 is applied to simplify derivative caluculations involving distance squared.

Parameters
bNormalizedWhen bNormalized is true, the sum described above is divided by PairCount() and the returned value is the average of the squared distances in the sums. The normalized value is useful when studying the effect of the number of points on the PairingDeviation value and when you want to work with smaller values on large point sets.
Returns
If A[] and B[] have the same number of points, then the pairing deviation between A[] and B[] is returned. Otherwise ON_DBL_QNAN is returned.

◆ PairingHash()

const ON_SHA1_Hash ON_PointPairing::PairingHash ( ) const

Returns
A SHA1 hash of the points in in both lists and the paring information.

◆ Point()

const ON_3dPoint ON_PointPairing::Point ( ON_PointPairing::List  point_list,
unsigned  point_index 
) const

◆ PointArrayForExperts()

const ON_3dPoint* ON_PointPairing::PointArrayForExperts ( ON_PointPairing::List  point_list) const

◆ PointCount()

const unsigned ON_PointPairing::PointCount ( ON_PointPairing::List  point_list) const
Parameters
point_list
Returns
Returns the number of points in the list of points specified by point_list.

◆ PointHash()

const ON_SHA1_Hash ON_PointPairing::PointHash ( ON_PointPairing::List  point_list) const
Parameters
point_list
Returns
A SHA1 hash of the points in the specified lists.

◆ PointsBoundingBox()

const ON_BoundingBox ON_PointPairing::PointsBoundingBox ( ON_PointPairing::List  point_list) const

◆ ReservePointCapacity()

bool ON_PointPairing::ReservePointCapacity ( ON_PointPairing::List  point_list,
size_t  capacity 
)

◆ SetPointCount()

bool ON_PointPairing::SetPointCount ( ON_PointPairing::List  point_list,
size_t  point_count 
)

◆ SetPoints() [1/2]

bool ON_PointPairing::SetPoints ( ON_PointPairing::List  point_list,
const ON_SimpleArray< ON_3dPoint > &  points 
)

Set the points in the specified list to points[].

Parameters
point_listSpecifies which list to set.
pointsThe asociated bias will be 1 for all points.
Returns
True if successful

◆ SetPoints() [2/2]

bool ON_PointPairing::SetPoints ( ON_PointPairing::List  point_list,
size_t  point_count,
const ON_3dPoint points,
const double *  biases 
)

Set the points in the specified list to points[].

Parameters
point_listSpecifies which list to set.
point_countNumber of points in the points[] array.
points
biasesIf biases is not nullptr, it must point to an array of point_count doubles. The points will have the bias applied in the ChamferDistance() and PairingDeviation() evaluations. Typically bias values >= 1 and are employed when the PairingDeviation() is used as part of an optimization objective function.
Returns
True if successful.

◆ SetPointsFromCurve()

bool ON_PointPairing::SetPointsFromCurve ( ON_PointPairing::List  point_list,
double  maximum_chord_variance,
const class ON_Curve curve,
ON_Interval  curve_subdomain,
size_t  point_count 
)

Set a point list by evluating a curve.

Parameters
point_listSpecifies which point list(s) will be set.
maximum_chord_varianceThere are two ways to sample points from the curve, equal parameter and equal arc length. Equal parameter sampling samples the curve at equally spaced parameter values. Equal arc length sampling samples the curve at equally spaced arc length values. In general, equal parameter sampling is faster while equal arc length sampling produces more uniformly distributed points. The maximum_chord_variance parameter controls what type of sampling is used. If maximum_chord_variance = 1.0, then equal arc length sampling is unconditionally used. If maximum_chord_variance > 1.0, then equal arc length sampling is used if the ratio of (longest chord) / (shortest chord) calculated from the equal parameter points is > maximum_chord_variance. Otherwise, equal parameter sampling is used unconditionally. Suggestion: If you want equal parameter sampling, plass ON_DBL_QNAN. If you want equal arc length sampling, plass 1.0. If you want to strike a balance between speed and a uniform sampling, pass 4.0.
curveThe curve is evaluated to create the point list.
curve_subdomainIf you want to restrict the evaluation to subset of the curve, pass an increasing interval that is contained in curve.Domain(). If you want to evaluate of the entire curve, pass curve.Domain(), ON_Interval::EmptyInterval, or ON_Interval::Nan.
bPeriodicPoints


Parameters
point_count


Returns
True if the points were set.

◆ SetPointsFromSurface()

bool ON_PointPairing::SetPointsFromSurface ( ON_PointPairing::List  point_list,
const class ON_Surface surface,
ON_Interval  surface_subdomain0,
ON_Interval  surface_subdomain1,
bool  bPeriodicPoints0,
bool  bPeriodicPoints1,
size_t  point_count0,
size_t  point_count1 
)

Parameters
point_listSpecifies which point list(s) will be set.
surfaceThe surface is evaluated to create the point list.
surface_subdomain0If you want to restrict the evaluation to subset of the surface, pass an increasing interval that is contained in surface.Domain(0). If you want to evaluate of the entire surface, pass surface.Domain(0), ON_Interval::EmptyInterval, or ON_Interval::Nan.
surface_subdomain1If you want to restrict the evaluation to subset of the surface, pass an increasing interval that is contained in surface.Domain(1). If you want to evaluate of the entire surface, pass surface.Domain(1), ON_Interval::EmptyInterval, or ON_Interval::Nan.
bPeriodicPoints0


Parameters
bPeriodicPoints1


Parameters
point_count0Grid count in the first parameter domain direction. The total number of pionts will be is point_count0 * point_count1.


Parameters
point_count1Grid count in the second domain direction. The total number of pionts will be is point_count0 * point_count1.


Returns
True if the points were set.

◆ ToString()

const ON_wString ON_PointPairing::ToString ( ) const

◆ ValidPairs()

bool ON_PointPairing::ValidPairs ( ) const
Returns
True if both point list are non empty and have the same number of points.