Point Cloud Library (PCL)  1.14.1-dev
opennurbs_polyline.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(ON_POLYLINE_INC_)
18 #define ON_POLYLINE_INC_
19 
20 class ON_CLASS ON_Polyline : public ON_3dPointArray
21 {
22 public:
27 
28  // Description:
29  // Create a regular polygon inscribed in a circle.
30  // The vertices of the polygon will be on the circle.
31  // Parameters:
32  // circle - [in]
33  // side_count - [in] (>=3) number of sides
34  // Returns:
35  // true if successful. false if circle is invalid or
36  // side_count < 3.
38  const ON_Circle& circle,
39  int side_count
40  );
41 
42  // Description:
43  // Create a regular polygon circumscribe about a circle.
44  // The midpoints of the polygon's edges will be tangent to the
45  // circle.
46  // Parameters:
47  // circle - [in]
48  // side_count - [in] (>=3) number of sides
49  // Returns:
50  // true if successful. false if circle is invalid or
51  // side_count < 3.
53  const ON_Circle& circle,
54  int side_count
55  );
56 
57  // Description:
58  // Create a regular star polygon.
59  // The star begins at circle.PointAt(0) and the vertices alternate
60  // between being on circle and begin on a concentric circle of
61  // other_radius.
62  // Parameters:
63  // circle - [in] circle star polygon starts on
64  // other_radius - [in] radius of other circle
65  // corner_count - [in] (>=3) number of corners on circle
66  // There will be 2*corner_count sides and 2*corner_count
67  // vertices.
68  // Returns:
69  // true if successful. false if circle is invalid, other_radius < 0.0,
70  // or side_count < 3.
72  const ON_Circle& circle,
73  double other_radius,
74  int side_count
75  );
76 
77  // Description:
78  // Checks that polyline has at least two points
79  // and that sequential points are distinct. If the
80  // polyline has 2 or 3 points, then the start and end
81  // point must be distinct.
82  // Parameters:
83  // tolerance - [in] tolerance used to check for duplicate points.
84  // Returns:
85  // true if polyline is valid.
86  // See Also:
87  // ON_Polyline::Clean.
88  bool IsValid(
89  double tolerance = 0.0
90  ) const;
91 
92  // Description:
93  // Removes duplicate points that result in zero length segments.
94  // Parameters:
95  // tolerance - [in] tolerance used to check for duplicate points.
96  // Returns:
97  // Number of points removed.
98  // Remarks:
99  // If the distance between points polyline[i] and polyline[i+1]
100  // is <= tolerance, then the point with index (i+1) is removed.
101  int Clean(
102  double tolerance = 0.0
103  );
104 
105  // Returns:
106  // Number of points in the polyline.
107  int PointCount() const;
108 
109  // Returns:
110  // Number of segments in the polyline.
111  int SegmentCount() const;
112 
113  // Description:
114  // Test a polyline to see if it is closed.
115  // Returns:
116  // true if polyline has 4 or more points, the distance between the
117  // start and end points is <= tolerance, and there is a
118  // point in the polyline whose distance from the start and end
119  // points is > tolerance.
120  bool IsClosed(
121  double tolerance = 0.0
122  ) const;
123 
124 
125  // Returns:
126  // Length of the polyline.
127  double Length() const;
128 
129  // Parameters:
130  // segment_index - [in] zero based segment index
131  // Returns:
132  // vector = point[segment_index+1] - point[segment_index].
134  int segment_index
135  ) const;
136 
137  // Parameters:
138  // segment_index - [in] zero based segment index
139  // Returns:
140  // Unit vector in the direction of the segment
142  int segment_index
143  ) const;
144 
145  // Description:
146  // Evaluate the polyline location at a parameter.
147  // Parameters:
148  // t - [in] the i-th segment goes from i <= t < i+1
149  ON_3dPoint PointAt( double t ) const;
150 
151  // Description:
152  // Evaluate the polyline first derivative at a parameter.
153  // Parameters:
154  // t - [in] the i-th segment goes from i <= t < i+1
155  ON_3dVector DerivativeAt( double t ) const;
156 
157  // Description:
158  // Evaluate the polyline unit tangent at a parameter.
159  // Parameters:
160  // t - [in] the i-th segment goes from i <= t < i+1
161  ON_3dVector TangentAt( double t ) const;
162 
163  // Description:
164  // Find a point on the polyline that is closest
165  // to test_point.
166  // Parameters:
167  // test_point - [in]
168  // t - [out] parameter for a point on the polyline that
169  // is closest to test_point. If mulitple solutions
170  // exist, then the smallest solution is returned.
171  // Returns:
172  // true if successful.
174  const ON_3dPoint& test_point,
175  double* t
176  ) const;
177 
178  // Description:
179  // Find a point on the polyline that is closest
180  // to test_point.
181  // Parameters:
182  // test_point - [in]
183  // t - [out] parameter for a point on the polyline that
184  // is closest to test_point. If mulitple solutions
185  // exist, then the smallest solution is returned.
186  // segment_index0 - [in] index of segment where search begins
187  // segment_index1 - [in] index of segment where search ends
188  // This segment is NOT searched.
189  // Example:
190  // Search segments 3,4, and 5 for the point closest to (0,0,0).
191  // double t;
192  // ClosestPointTo( ON_3dPoint(0,0,0), &t, 3, 6 );
193  // Returns:
194  // true if successful.
196  const ON_3dPoint& test_point,
197  double* t,
198  int segment_index0, // index of segment where search begins
199  int segment_index1 // index + 1 of segment where search stops
200  ) const;
201 
202  // Description:
203  // Find a point on the polyline that is closest
204  // to test_point.
205  // Parameters:
206  // test_point - [in]
207  // Returns:
208  // point on polyline.
210  const ON_3dPoint& test_point
211  ) const;
212 
213 };
214 
215 #endif
ON_3dVector SegmentDirection(int segment_index) const
int PointCount() const
bool CreateCircumscribedPolygon(const ON_Circle &circle, int side_count)
bool ClosestPointTo(const ON_3dPoint &test_point, double *t, int segment_index0, int segment_index1) const
ON_Polyline & operator=(const ON_3dPointArray &)
bool CreateInscribedPolygon(const ON_Circle &circle, int side_count)
int SegmentCount() const
ON_3dVector TangentAt(double t) const
ON_3dPoint PointAt(double t) const
double Length() const
ON_3dPoint ClosestPointTo(const ON_3dPoint &test_point) const
bool IsClosed(double tolerance=0.0) const
bool IsValid(double tolerance=0.0) const
ON_3dVector DerivativeAt(double t) const
ON_3dVector SegmentTangent(int segment_index) const
bool ClosestPointTo(const ON_3dPoint &test_point, double *t) const
ON_Polyline(const ON_3dPointArray &)
bool CreateStarPolygon(const ON_Circle &circle, double other_radius, int side_count)
int Clean(double tolerance=0.0)