ON_Polyline Class Reference

#include <opennurbs_polyline.h>

Inheritance diagram for ON_Polyline:
ON_3dPointArray ON_SimpleArray< ON_3dPoint >

Public Member Functions

 ON_Polyline ()
 
 ON_Polyline (const ON_3dPointArray &)
 
 ~ON_Polyline ()
 
int Clean (double tolerance=0.0)
 Removes duplicate points that result in zero length segments. More...
 
bool ClosestPointTo (const ON_3dPoint &test_point, double *t) const
 Find a point on the polyline that is closest to test_point. More...
 
bool ClosestPointTo (const ON_3dPoint &test_point, double *t, int segment_index0, int segment_index1) const
 Find a point on the polyline that is closest to test_point. More...
 
ON_3dPoint ClosestPointTo (const ON_3dPoint &test_point) const
 Find a point on the polyline that is closest to test_point. More...
 
bool CreateCircumscribedPolygon (const ON_Circle &circle, int side_count)
 Create a regular polygon circumscribe about a circle. The midpoints of the polygon's edges will be tanget to the circle. More...
 
bool CreateInscribedPolygon (const ON_Circle &circle, int side_count)
 Create a regular polygon inscribed in a circle. The vertices of the polygon will be on the circle. More...
 
bool CreateStarPolygon (const ON_Circle &circle, double other_radius, int side_count)
 Create a regular star polygon. The star begins at circle.PointAt(0) and the vertices alternate between being on circle and begin on a concentric circle of other_radius. More...
 
ON_3dVector DerivativeAt (double t) const
 Evaluate the polyline first derivative at a parameter. More...
 
bool IsClosed (double tolerance=0.0) const
 Test a polyline to see if it is closed. More...
 
bool IsValid (double tolerance=0.0) const
 Checks that polyline has at least two points and that sequential points are distinct. If the polyline has 2 or 3 points, then the start and end point must be distinct. More...
 
double Length () const
 
ON_Polylineoperator= (const ON_3dPointArray &)
 
ON_3dPoint PointAt (double t) const
 Evaluate the polyline location at a parameter. More...
 
int PointCount () const
 
int SegmentCount () const
 
ON_3dVector SegmentDirection (int segment_index) const
 
ON_3dVector SegmentTangent (int segment_index) const
 
ON_3dVector TangentAt (double t) const
 Evaluate the polyline unit tangent at a parameter. More...
 
- Public Member Functions inherited from ON_3dPointArray
 ON_3dPointArray ()
 see ON_SimpleArray class definition comments for constructor documentation More...
 
 ON_3dPointArray (int)
 
 ON_3dPointArray (const ON_SimpleArray< ON_3dPoint > &)
 
 ON_3dPointArray (const ON_SimpleArray< ON_3fPoint > &)
 
ON_BoundingBox BoundingBox () const
 Get 3d axis aligned bounding box. More...
 
bool Create (int point_dimension, int bRational, int point_count, int point_stride, const double *points)
 Create 3d point list More...
 
bool Create (int point_dimension, int bRational, int point_count, int point_stride, const float *points)
 Create 3d point list More...
 
bool GetBBox (double boxmin[3], double boxmax[3], bool bGrowBox=false) const
 Get axis aligned bounding box. More...
 
bool GetBoundingBox (ON_BoundingBox &bbox, int bGrowBox=false) const
 Get 3d axis aligned bounding box or the union of the input box with the point list's bounding box. More...
 
bool GetClosestPoint (ON_3dPoint P, int *closest_point_index, double maximum_distance=0.0) const
 Get the index of the point in the array that is closest to P. More...
 
bool GetTightBoundingBox (ON_BoundingBox &tight_bbox, bool bGrowBox=false, const ON_Xform *xform=nullptr) const
 Get tight bounding box of the point list. More...
 
ON_3dPointArrayoperator= (const ON_3dPointArray &)
 
ON_3dPointArrayoperator= (const ON_SimpleArray< ON_3fPoint > &)
 
bool Rotate (double sin_angle, double cos_angle, const ON_3dVector &axis_of_rotation, const ON_3dPoint &center_of_rotation)
 Rotate points about a center and axis. A positive angle results in a counter-clockwise rotation about the axis of rotation. More...
 
bool Rotate (double angle_in_radians, const ON_3dVector &axis_of_rotation, const ON_3dPoint &center_of_rotation)
 Rotate points about a center and axis. A positive angle results in a counter-clockwise rotation about the axis of rotation. More...
 
bool SwapCoordinates (int i, int j)
 Swaps point coordinate values with indices i and j. More...
 
bool Transform (const ON_Xform &xform)
 Transform points by applying xform to each point. More...
 
bool Translate (const ON_3dVector &delta)
 Translate a polyline More...
 
- Public Member Functions inherited from ON_SimpleArray< ON_3dPoint >
 ON_SimpleArray () ON_NOEXCEPT
 construction //////////////////////////////////////////////////////// More...
 
 ON_SimpleArray (const ON_SimpleArray< ON_3dPoint > &)
 Copy constructor. More...
 
 ON_SimpleArray (size_t)
 
virtual ~ON_SimpleArray ()
 
void Append (const ON_3dPoint &)
 
void Append (int, const ON_3dPoint *)
 
ON_3dPointAppendNew ()
 array operations //////////////////////////////////////////////////// More...
 
ON_3dPointArray ()
 
const ON_3dPointArray () const
 
ON_3dPointAt (int)
 At(index) returns nullptr if index < 0 or index >= count. More...
 
ON_3dPointAt (unsigned int)
 
ON_3dPointAt (ON__INT64)
 
ON_3dPointAt (ON__UINT64)
 
const ON_3dPointAt (int) const
 
const ON_3dPointAt (unsigned int) const
 
const ON_3dPointAt (ON__INT64) const
 
const ON_3dPointAt (ON__UINT64) const
 
int BinarySearch (const ON_3dPoint *, int(*)(const ON_3dPoint *, const ON_3dPoint *)) const
 
int BinarySearch (const ON_3dPoint *, int(*)(const ON_3dPoint *, const ON_3dPoint *), int) const
 
int Capacity () const
 
int Count () const
 query /////////////////////////////////////////////////////////////// More...
 
ON__UINT32 DataCRC (ON__UINT32 current_remainder) const
 
void Destroy ()
 
void EmergencyDestroy (void)
 emergency bailout /////////////////////////////////////////////////// More...
 
void Empty ()
 
ON_3dPointFirst ()
 
const ON_3dPointFirst () const
 
bool HeapSort (int(*)(const ON_3dPoint *, const ON_3dPoint *))
 
void Insert (int, const ON_3dPoint &)
 
ON_3dPointKeepArray ()
 Expert user tool to take charge of the memory used by the dyanmic array. More...
 
ON_3dPointLast ()
 
const ON_3dPointLast () const
 
void MemSet (unsigned char)
 
int NewCapacity () const
 
 operator const ON_3dPoint * () const
 
 operator ON_3dPoint * ()
 
ON_SimpleArray< ON_3dPoint > & operator= (const ON_SimpleArray< ON_3dPoint > &)
 
ON_3dPointoperator[] (int)
 
ON_3dPointoperator[] (unsigned int)
 
ON_3dPointoperator[] (ON__INT64)
 
ON_3dPointoperator[] (ON__UINT64)
 
const ON_3dPointoperator[] (int) const
 
const ON_3dPointoperator[] (unsigned int) const
 
const ON_3dPointoperator[] (ON__INT64) const
 
const ON_3dPointoperator[] (ON__UINT64) const
 
bool Permute (const int *)
 
bool QuickSort (int(*)(const ON_3dPoint *, const ON_3dPoint *))
 
virtual ON_3dPointRealloc (ON_3dPoint *, int)
 low level memory managment ////////////////////////////////////////// More...
 
void Remove ()
 
virtual void Remove (int)
 
ON_3dPointReserve (size_t)
 memory managment //////////////////////////////////////////////////// More...
 
void Reverse ()
 
int Search (const ON_3dPoint &) const
 
int Search (const ON_3dPoint *, int(*)(const ON_3dPoint *, const ON_3dPoint *)) const
 
void SetArray (ON_3dPoint *)
 Do not use this version of SetArray(). Use the one that takes a pointer, count and capacity. More...
 
void SetArray (ON_3dPoint *, int, int)
 Expert user tool to set the memory used by the dyanmic array. More...
 
ON_3dPointSetCapacity (size_t)
 
void SetCount (int)
 low level memory managment ////////////////////////////////////////// More...
 
void Shrink ()
 
unsigned int SizeOfArray () const
 
unsigned int SizeOfElement () const
 
bool Sort (ON::sort_algorithm sort_algorithm, int *, int(*)(const ON_3dPoint *, const ON_3dPoint *)) const
 Sort() fills in the index[] array so that array[index[i]] <= array[index[i+1]]. The array is not modified. More...
 
bool Sort (ON::sort_algorithm sort_algorithm, int *, int(*)(const ON_3dPoint *, const ON_3dPoint *, void *), void *) const
 Sort() fills in the index[] array so that array[index[i]] <= array[index[i+1]]. The array is not modified. More...
 
void Swap (int, int)
 
unsigned int UnsignedCount () const
 
void Zero ()
 

Additional Inherited Members

- Protected Member Functions inherited from ON_SimpleArray< ON_3dPoint >
void Move (int, int, int)
 implimentation ////////////////////////////////////////////////////// More...
 
- Protected Attributes inherited from ON_SimpleArray< ON_3dPoint >
ON_3dPointm_a
 
int m_capacity
 
int m_count
 

Constructor & Destructor Documentation

◆ ON_Polyline() [1/2]

ON_Polyline::ON_Polyline ( )

◆ ~ON_Polyline()

ON_Polyline::~ON_Polyline ( )

◆ ON_Polyline() [2/2]

ON_Polyline::ON_Polyline ( const ON_3dPointArray )

Member Function Documentation

◆ Clean()

int ON_Polyline::Clean ( double  tolerance = 0.0)

Removes duplicate points that result in zero length segments.

Parameters
tolerance[in] tolerance used to check for duplicate points.
Returns
Number of points removed.

If the distance between points polyline[i] and polyline[i+1] is <= tolerance, then the point with index (i+1) is removed.

◆ ClosestPointTo() [1/3]

bool ON_Polyline::ClosestPointTo ( const ON_3dPoint test_point,
double *  t 
) const

Find a point on the polyline that is closest to test_point.

Parameters
test_point[in]
t[out] parameter for a point on the polyline that is closest to test_point. If mulitple solutions exist, then the smallest solution is returned.
Returns
true if successful.

◆ ClosestPointTo() [2/3]

bool ON_Polyline::ClosestPointTo ( const ON_3dPoint test_point,
double *  t,
int  segment_index0,
int  segment_index1 
) const

Find a point on the polyline that is closest to test_point.

Parameters
test_point[in]
t[out] parameter for a point on the polyline that is closest to test_point. If mulitple solutions exist, then the smallest solution is returned.
segment_index0[in] index of segment where search begins
segment_index1[in] index of segment where search ends This segment is NOT searched.
Returns
true if successful.
Search segments 3,4, and 5 for the point closest to (0,0,0).
double t;
ClosestPointTo( ON_3dPoint(0,0,0), &t, 3, 6 );

◆ ClosestPointTo() [3/3]

ON_3dPoint ON_Polyline::ClosestPointTo ( const ON_3dPoint test_point) const

Find a point on the polyline that is closest to test_point.

Parameters
test_point[in]
Returns
point on polyline.

◆ CreateCircumscribedPolygon()

bool ON_Polyline::CreateCircumscribedPolygon ( const ON_Circle circle,
int  side_count 
)

Create a regular polygon circumscribe about a circle. The midpoints of the polygon's edges will be tanget to the circle.

Parameters
circle[in]
side_count[in] (>=3) number of sides
Returns
true if successful. false if circle is invalid or side_count < 3.

◆ CreateInscribedPolygon()

bool ON_Polyline::CreateInscribedPolygon ( const ON_Circle circle,
int  side_count 
)

Create a regular polygon inscribed in a circle. The vertices of the polygon will be on the circle.

Parameters
circle[in]
side_count[in] (>=3) number of sides
Returns
true if successful. false if circle is invalid or side_count < 3.

◆ CreateStarPolygon()

bool ON_Polyline::CreateStarPolygon ( const ON_Circle circle,
double  other_radius,
int  side_count 
)

Create a regular star polygon. The star begins at circle.PointAt(0) and the vertices alternate between being on circle and begin on a concentric circle of other_radius.

Parameters
circle[in] circle star polygon starts on
other_radius[in] radius of other circle
corner_count[in] (>=3) number of corners on circle There will be 2*corner_count sides and 2*corner_count vertices.
Returns
true if successful. false if circle is invalid, other_radius < 0.0, or side_count < 3.

◆ DerivativeAt()

ON_3dVector ON_Polyline::DerivativeAt ( double  t) const

Evaluate the polyline first derivative at a parameter.

Parameters
t[in] the i-th segment goes from i <= t < i+1

◆ IsClosed()

bool ON_Polyline::IsClosed ( double  tolerance = 0.0) const

Test a polyline to see if it is closed.

Returns
true if polyline has 4 or more points, the distance between the start and end points is <= tolerance, and there is a point in the polyline whose distance from the start and end points is > tolerance.

◆ IsValid()

bool ON_Polyline::IsValid ( double  tolerance = 0.0) const

Checks that polyline has at least two points and that sequential points are distinct. If the polyline has 2 or 3 points, then the start and end point must be distinct.

Parameters
tolerance[in] tolerance used to check for duplicate points.
Returns
true if polyline is valid.
See also
ON_Polyline::Clean.

◆ Length()

double ON_Polyline::Length ( ) const
Returns
Length of the polyline.

◆ operator=()

ON_Polyline& ON_Polyline::operator= ( const ON_3dPointArray )

◆ PointAt()

ON_3dPoint ON_Polyline::PointAt ( double  t) const

Evaluate the polyline location at a parameter.

Parameters
t[in] the i-th segment goes from i <= t < i+1

◆ PointCount()

int ON_Polyline::PointCount ( ) const
Returns
Number of points in the polyline.

◆ SegmentCount()

int ON_Polyline::SegmentCount ( ) const
Returns
Number of segments in the polyline.

◆ SegmentDirection()

ON_3dVector ON_Polyline::SegmentDirection ( int  segment_index) const
Parameters
segment_index[in] zero based segment index
Returns
vector = point[segment_index+1] - point[segment_index].

◆ SegmentTangent()

ON_3dVector ON_Polyline::SegmentTangent ( int  segment_index) const
Parameters
segment_index[in] zero based segment index
Returns
Unit vector in the direction of the segment

◆ TangentAt()

ON_3dVector ON_Polyline::TangentAt ( double  t) const

Evaluate the polyline unit tangent at a parameter.

Parameters
t[in] the i-th segment goes from i <= t < i+1