QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_arccurve.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
16#if !defined(ON_GEOMETRY_CURVE_ARC_INC_)
17#define ON_GEOMETRY_CURVE_ARC_INC_
18
19
20/*
21Description:
22 ON_ArcCurve is used to represent arcs and circles.
23 ON_ArcCurve.IsCircle() returns true if the curve
24 is a complete circle.
25Details:
26 an ON_ArcCurve is a subcurve of a circle, with a
27 constant speed parameterization. The parameterization is
28 an affine linear reparameterzation of the underlying arc
29 m_arc onto the domain m_t.
30
31 A valid ON_ArcCurve has Radius()>0 and 0<AngleRadians()<=2*PI
32 and a strictly increasing Domain().
33*/
35{
37
38public:
41 virtual ~ON_ArcCurve();
42
43 // virtual ON_Object::SizeOf override
44 unsigned int SizeOf() const;
45
46 // virtual ON_Object::DataCRC override
47 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const;
48
49 /*
50 Description:
51 Create an arc curve with domain (0,arc.Length()).
52 */
54 const ON_Arc& arc
55 );
56
57 /*
58 Description:
59 Create an arc curve with domain (t0,t1)
60 */
62 const ON_Arc& arc,
63 double t0,
64 double t1
65 );
66
67 /*
68 Description:
69 Creates a curve that is a complete circle with
70 domain (0,circle.Length()).
71 */
73 const ON_Circle& circle
74 );
75
76 /*
77 Description:
78 Creates a curve that is a complete circle with domain (t0,t1).
79 */
81 const ON_Circle& circle,
82 double t0,
83 double t1
84 );
85
86
88
89 /*
90 Description:
91 Create an arc curve with domain (0,arc.Length()).
92 */
93 ON_ArcCurve& operator=(const ON_Arc& arc);
94
95 /*
96 Description:
97 Creates a curve that is a complete circle with
98 domain (0,circle.Length()).
99 */
100 ON_ArcCurve& operator=(const ON_Circle& circle);
101
103 // ON_Object overrides
104
105 /*
106 Description:
107 A valid ON_ArcCurve has Radius()>0 and 0<AngleRadians()<=2*PI
108 and a strictly increasing Domain().
109 Parameters:
110 text_log - [in] if the object is not valid and text_log
111 is not NULL, then a brief englis description of the
112 reason the object is not valid is appened to the log.
113 The information appended to text_log is suitable for
114 low-level debugging purposes by programmers and is
115 not intended to be useful as a high level user
116 interface tool.
117 Returns:
118 @untitled table
119 true object is valid
120 false object is invalid, uninitialized, etc.
121 Remarks:
122 Overrides virtual ON_Object::IsValid
123 */
124 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
125
126 void Dump( ON_TextLog& ) const;
127
129 ON_BinaryArchive& // open binary file
130 ) const;
131
133 ON_BinaryArchive& // open binary file
134 );
135
137 // ON_Geometry overrides
138
139 int Dimension() const;
140
141 ON_BOOL32 GetBBox( // returns true if successful
142 double*, // minimum
143 double*, // maximum
144 ON_BOOL32 = false // true means grow box
145 ) const;
146
147 /*
148 Description:
149 Get tight bounding box of the arc.
150 Parameters:
151 tight_bbox - [in/out] tight bounding box
152 bGrowBox -[in] (default=false)
153 If true and the input tight_bbox is valid, then returned
154 tight_bbox is the union of the input tight_bbox and the
155 arc's tight bounding box.
156 xform -[in] (default=NULL)
157 If not NULL, the tight bounding box of the transformed
158 arc is calculated. The arc is not modified.
159 Returns:
160 True if the returned tight_bbox is set to a valid
161 bounding box.
162 */
164 ON_BoundingBox& tight_bbox,
165 int bGrowBox = false,
166 const ON_Xform* xform = 0
167 ) const;
168
169
171 const ON_Xform&
172 );
173
175 // ON_Curve overrides
176
177 // Description:
178 // virtual ON_Curve::SetDomain override.
179 // Set the domain of the curve
180 // Parameters:
181 // t0 - [in]
182 // t1 - [in] new domain will be [t0,t1]
183 // Returns:
184 // true if successful.
186 double t0,
187 double t1
188 );
189
190 ON_Interval Domain() const;
191
192 bool ChangeDimension(
193 int desired_dimension
194 );
195
197 double t
198 );
199
200 int SpanCount() const; // number of smooth spans in curve
201
202 ON_BOOL32 GetSpanVector( // span "knots"
203 double* // array of length SpanCount() + 1
204 ) const; //
205
206 int Degree( // returns maximum algebraic degree of any span
207 // ( or a good estimate if curve spans are not algebraic )
208 ) const;
209
210 ON_BOOL32 IsLinear( // true if curve locus is a line segment between
211 // between specified points
212 double = ON_ZERO_TOLERANCE // tolerance to use when checking linearity
213 ) const;
214
215 ON_BOOL32 IsArc( // ON_Arc.m_angle > 0 if curve locus is an arc between
216 // specified points
217 const ON_Plane* = NULL, // if not NULL, test is performed in this plane
218 ON_Arc* = NULL, // if not NULL and true is returned, then arc parameters
219 // are filled in
220 double = 0.0 // tolerance to use when checking
221 ) const;
222
224 ON_Plane* = NULL, // if not NULL and true is returned, then plane parameters
225 // are filled in
226 double = 0.0 // tolerance to use when checking
227 ) const;
228
230 const ON_Plane&, // plane to test
231 double = 0.0 // tolerance to use when checking
232 ) const;
233
234 ON_BOOL32 IsClosed( // true if curve is closed (either curve has
235 void // clamped end knots and euclidean location of start
236 ) const; // CV = euclidean location of end CV, or curve is
237 // periodic.)
238
239 ON_BOOL32 IsPeriodic( // true if curve is a single periodic segment
240 void
241 ) const;
242
243 bool IsContinuous(
244 ON::continuity c,
245 double t,
246 int* hint = NULL,
247 double point_tolerance=ON_ZERO_TOLERANCE,
248 double d1_tolerance=ON_ZERO_TOLERANCE,
249 double d2_tolerance=ON_ZERO_TOLERANCE,
250 double cos_angle_tolerance=0.99984769515639123915701155881391,
251 double curvature_tolerance=ON_SQRT_EPSILON
252 ) const;
253
254 ON_BOOL32 Reverse(); // reverse parameterizatrion
255 // Domain changes from [a,b] to [-b,-a]
256
257 /*
258 Description:
259 Force the curve to start at a specified point.
260 Parameters:
261 start_point - [in]
262 Returns:
263 true if successful.
264 Remarks:
265 Some end points cannot be moved. Be sure to check return
266 code.
267 See Also:
268 ON_Curve::SetEndPoint
269 ON_Curve::PointAtStart
270 ON_Curve::PointAtEnd
271 */
273 ON_3dPoint start_point
274 );
275
276 /*
277 Description:
278 Force the curve to end at a specified point.
279 Parameters:
280 end_point - [in]
281 Returns:
282 true if successful.
283 Remarks:
284 Some end points cannot be moved. Be sure to check return
285 code.
286 See Also:
287 ON_Curve::SetStartPoint
288 ON_Curve::PointAtStart
289 ON_Curve::PointAtEnd
290 */
292 ON_3dPoint end_point
293 );
294
295 ON_BOOL32 Evaluate( // returns false if unable to evaluate
296 double, // evaluation parameter
297 int, // number of derivatives (>=0)
298 int, // array stride (>=Dimension())
299 double*, // array of length stride*(ndir+1)
300 int = 0, // optional - determines which side to evaluate from
301 // 0 = default
302 // < 0 to evaluate from below,
303 // > 0 to evaluate from above
304 int* = 0 // optional - evaluation hint (int) used to speed
305 // repeated evaluations
306 ) const;
307
308 ON_BOOL32 Trim( const ON_Interval& );
309
310 // Description:
311 // Where possible, analytically extends curve to include domain.
312 // Parameters:
313 // domain - [in] if domain is not included in curve domain,
314 // curve will be extended so that its domain includes domain.
315 // Will not work if curve is closed. Original curve is identical
316 // to the restriction of the resulting curve to the original curve domain,
317 // Returns:
318 // true if successful.
319 bool Extend(
320 const ON_Interval& domain
321 );
322
323 /*
324 Description:
325 Splits (divides) the arc at the specified parameter.
326 The parameter must be in the interior of the arc's domain.
327 The ON_Curve pointers passed to ON_ArcCurve::Split must
328 either be NULL or point to ON_ArcCurve objects.
329 If a pointer is NULL, then an ON_ArcCurve will be created
330 in Split(). You may pass "this" as left_side or right_side.
331 Parameters:
332 t - [in] parameter to split the curve at in the
333 interval returned by Domain().
334 left_side - [out] left portion of curve returned here.
335 If not NULL, left_side must point to an ON_ArcCuve.
336 right_side - [out] right portion of curve returned here
337 If not NULL, right_side must point to an ON_ArcCuve.
338 Remarks:
339 Overrides virtual ON_Curve::Split.
340 */
341 virtual
343 double t,
344 ON_Curve*& left_side,
345 ON_Curve*& right_side
346 ) const;
347
349 // Find parameter of the point on a curve that is closest to test_point.
350 // If the maximum_distance parameter is > 0, then only points whose distance
351 // to the given point is <= maximum_distance will be returned. Using a
352 // positive value of maximum_distance can substantially speed up the search.
353 // If the sub_domain parameter is not NULL, then the search is restricted
354 // to the specified portion of the curve.
355 //
356 // true if returned if the search is successful. false is returned if
357 // the search fails.
358 bool GetClosestPoint( const ON_3dPoint&, // test_point
359 double*, // parameter of local closest point returned here
360 double = 0.0, // maximum_distance
361 const ON_Interval* = NULL // sub_domain
362 ) const;
363
365 // Find parameter of the point on a curve that is locally closest to
366 // the test_point. The search for a local close point starts at
367 // seed_parameter. If the sub_domain parameter is not NULL, then
368 // the search is restricted to the specified portion of the curve.
369 //
370 // true if returned if the search is successful. false is returned if
371 // the search fails.
372 ON_BOOL32 GetLocalClosestPoint( const ON_3dPoint&, // test_point
373 double, // seed_parameter
374 double*, // parameter of local closest point returned here
375 const ON_Interval* = NULL // sub_domain
376 ) const;
377
378 // virtual ON_Curve override
379 int IntersectSelf(
381 double intersection_tolerance = 0.0,
382 const ON_Interval* curve_domain = 0
383 ) const;
384
386 // Length of curve.
387 // true if returned if the length calculation is successful.
388 // false is returned if the length is not calculated.
389 //
390 // The arc length will be computed so that
391 // (returned length - real length)/(real length) <= fractional_tolerance
392 // More simply, if you want N significant figures in the answer, set the
393 // fractional_tolerance to 1.0e-N. For "nice" curves, 1.0e-8 works
394 // fine. For very high degree nurbs and nurbs with bad parameterizations,
395 // use larger values of fractional_tolerance.
396 ON_BOOL32 GetLength( // returns true if length successfully computed
397 double*, // length returned here
398 double = 1.0e-8, // fractional_tolerance
399 const ON_Interval* = NULL // (optional) sub_domain
400 ) const;
401
402 /*
403 Description:
404 Used to quickly find short curves.
405 Parameters:
406 tolerance - [in] (>=0)
407 sub_domain - [in] If not NULL, the test is performed
408 on the interval that is the intersection of
409 sub_domain with Domain().
410 Returns:
411 True if the length of the curve is <= tolerance.
412 Remarks:
413 Faster than calling Length() and testing the
414 result.
415 */
416 bool IsShort(
417 double tolerance,
418 const ON_Interval* sub_domain = NULL
419 ) const;
420
421 // Description:
422 // virtual ON_Curve::GetNormalizedArcLengthPoint override.
423 // Get the parameter of the point on the curve that is a
424 // prescribed arc length from the start of the curve.
425 // Parameters:
426 // s - [in] normalized arc length parameter. E.g., 0 = start
427 // of curve, 1/2 = midpoint of curve, 1 = end of curve.
428 // t - [out] parameter such that the length of the curve
429 // from its start to t is arc_length.
430 // fractional_tolerance - [in] desired fractional precision.
431 // fabs(("exact" length from start to t) - arc_length)/arc_length <= fractional_tolerance
432 // sub_domain - [in] If not NULL, the calculation is performed on
433 // the specified sub-domain of the curve.
434 // Returns:
435 // true if successful
437 double s,
438 double* t,
439 double fractional_tolerance = 1.0e-8,
440 const ON_Interval* sub_domain = NULL
441 ) const;
442
443 /*
444 Description:
445 virtual ON_Curve::GetNormalizedArcLengthPoints override.
446 Get the parameter of the point on the curve that is a
447 prescribed arc length from the start of the curve.
448 Parameters:
449 count - [in] number of parameters in s.
450 s - [in] array of normalized arc length parameters. E.g., 0 = start
451 of curve, 1/2 = midpoint of curve, 1 = end of curve.
452 t - [out] array of curve parameters such that the length of the
453 curve from its start to t[i] is s[i]*curve_length.
454 absolute_tolerance - [in] if absolute_tolerance > 0, then the difference
455 between (s[i+1]-s[i])*curve_length and the length of the curve
456 segment from t[i] to t[i+1] will be <= absolute_tolerance.
457 fractional_tolerance - [in] desired fractional precision for each segment.
458 fabs("true" length - actual length)/(actual length) <= fractional_tolerance
459 sub_domain - [in] If not NULL, the calculation is performed on
460 the specified sub-domain of the curve. A 0.0 s value corresponds to
461 sub_domain->Min() and a 1.0 s value corresponds to sub_domain->Max().
462 Returns:
463 true if successful
464 */
466 int count,
467 const double* s,
468 double* t,
469 double absolute_tolerance = 0.0,
470 double fractional_tolerance = 1.0e-8,
471 const ON_Interval* sub_domain = NULL
472 ) const;
473
474 // virtual ON_Curve::GetNurbForm override
475 int GetNurbForm( // returns 0: unable to create NURBS representation
476 // with desired accuracy.
477 // 1: success - returned NURBS parameterization
478 // matches the curve's to wthe desired accuracy
479 // 2: success - returned NURBS point locus matches
480 // the curve's to the desired accuracy but, on
481 // the interior of the curve's domain, the
482 // curve's parameterization and the NURBS
483 // parameterization may not match to the
484 // desired accuracy.
486 double = 0.0,
487 const ON_Interval* = NULL // OPTIONAL subdomain of arc curve
488 ) const;
489
490 // virtual ON_Curve::HasNurbForm override
491 int HasNurbForm( // returns 0: unable to create NURBS representation
492 // with desired accuracy.
493 // 1: success - NURBS parameterization
494 // matches the curve's
495 // 2: success - returned NURBS point locus matches
496 // the curve'sbut, on
497 // the interior of the curve's domain, the
498 // curve's parameterization and the NURBS
499 // parameterization may not match to the
500 // desired accuracy.
501 ) const;
502
503 // virtual ON_Curve::GetCurveParameterFromNurbFormParameter override
505 double, // nurbs_t
506 double* // curve_t
507 ) const;
508
509 // virtual ON_Curve::GetNurbFormParameterFromCurveParameter override
511 double, // curve_t
512 double* // nurbs_t
513 ) const;
514
515
516 /*
517 Description:
518 Returns true if this arc curve is a complete circle.
519 */
520 bool IsCircle() const;
521
522 // Returns:
523 // The arc's radius.
524 double Radius() const;
525
526 // Returns:
527 // The arc's subtended angle in radians.
528 double AngleRadians() const;
529
530 // Returns:
531 // The arc's subtended angle in degrees.
532 double AngleDegrees() const;
533
534
536
538
539 // evaluation domain (always increasing)
540 // ( m_t[i] corresponds to m_arc.m_angle[i] )
542
543 // The dimension of a arc curve can be 2 or 3.
544 // (2 so ON_ArcCurve can be used as a trimming curve)
545 int m_dim;
546
547};
548
549
550#endif
@ Transform
Definition RSMetaType.h:67
Definition opennurbs_point.h:403
Definition opennurbs_arccurve.h:35
ON_OBJECT_DECLARE(ON_ArcCurve)
int m_dim
Definition opennurbs_arccurve.h:545
ON_Interval m_t
Definition opennurbs_arccurve.h:541
ON_Arc m_arc
Definition opennurbs_arccurve.h:537
Definition opennurbs_arc.h:34
Definition opennurbs_archive.h:152
Definition opennurbs_bounding_box.h:25
Definition opennurbs_circle.h:33
Definition opennurbs_curve.h:88
virtual bool IsContinuous(ON::continuity c, double t, int *hint=NULL, double point_tolerance=ON_ZERO_TOLERANCE, double d1_tolerance=ON_ZERO_TOLERANCE, double d2_tolerance=ON_ZERO_TOLERANCE, double cos_angle_tolerance=0.99984769515639123915701155881391, double curvature_tolerance=ON_SQRT_EPSILON) const
Definition opennurbs_curve.cpp:602
virtual ON_BOOL32 IsArc(const ON_Plane *plane=NULL, ON_Arc *arc=NULL, double tolerance=ON_ZERO_TOLERANCE) const
Definition opennurbs_curve.cpp:248
bool GetTightBoundingBox(ON_BoundingBox &tight_bbox, int bGrowBox=false, const ON_Xform *xform=0) const
Definition opennurbs_basic.cpp:333
virtual int GetNurbForm(ON_NurbsCurve &nurbs_curve, double tolerance=0.0, const ON_Interval *subdomain=NULL) const
Definition opennurbs_curve.cpp:2625
virtual ON_BOOL32 ChangeClosedCurveSeam(double t)
Definition opennurbs_curve.cpp:117
virtual ON_BOOL32 GetNormalizedArcLengthPoint(double s, double *t, double fractional_tolerance=1.0e-8, const ON_Interval *sub_domain=NULL) const
Definition opennurbs_curve.cpp:2489
virtual bool GetClosestPoint(const ON_3dPoint &, double *t, double maximum_distance=0.0, const ON_Interval *sub_domain=NULL) const
Definition opennurbs_basic.cpp:322
virtual bool ChangeDimension(int desired_dimension)
Definition opennurbs_curve.cpp:124
virtual ON_BOOL32 Evaluate(double t, int der_count, int v_stride, double *v, int side=0, int *hint=0) const =0
ON_Curve & operator=(const ON_Curve &)
Definition opennurbs_curve.cpp:26
virtual int Degree() const =0
virtual int IntersectSelf(ON_SimpleArray< ON_X_EVENT > &x, double intersection_tolerance=0.0, const ON_Interval *curve_domain=0) const
Definition opennurbs_basic.cpp:343
unsigned int SizeOf() const
Definition opennurbs_curve.cpp:52
virtual int HasNurbForm() const
Definition opennurbs_curve.cpp:2635
virtual ON_BOOL32 GetLocalClosestPoint(const ON_3dPoint &test_point, double seed_parameter, double *t, const ON_Interval *sub_domain=0) const
Definition opennurbs_curve.cpp:1209
virtual ON_BOOL32 SetStartPoint(ON_3dPoint start_point)
Definition opennurbs_curve.cpp:779
virtual ON_BOOL32 IsPeriodic() const
Definition opennurbs_curve.cpp:444
virtual ON_BOOL32 Split(double t, ON_Curve *&left_side, ON_Curve *&right_side) const
Definition opennurbs_curve.cpp:2614
bool IsShort(double tolerance, const ON_Interval *sub_domain=NULL) const
Definition opennurbs_curve.cpp:1482
virtual bool Extend(const ON_Interval &domain)
Definition opennurbs_curve.cpp:2521
virtual ON_BOOL32 GetNormalizedArcLengthPoints(int count, const double *s, double *t, double absolute_tolerance=0.0, double fractional_tolerance=1.0e-8, const ON_Interval *sub_domain=NULL) const
Definition opennurbs_curve.cpp:2500
virtual ON_BOOL32 IsClosed() const
Definition opennurbs_curve.cpp:408
virtual ON_BOOL32 Reverse()=0
virtual ON_BOOL32 GetCurveParameterFromNurbFormParameter(double nurbs_t, double *curve_t) const
Definition opennurbs_curve.cpp:2659
bool SetDomain(ON_Interval domain)
Definition opennurbs_curve.cpp:105
virtual ON_BOOL32 GetLength(double *length, double fractional_tolerance=1.0e-8, const ON_Interval *sub_domain=NULL) const
Definition opennurbs_curve.cpp:1220
virtual ON_BOOL32 SetEndPoint(ON_3dPoint end_point)
Definition opennurbs_curve.cpp:784
virtual int SpanCount() const =0
virtual ON_BOOL32 GetNurbFormParameterFromCurveParameter(double curve_t, double *nurbs_t) const
Definition opennurbs_curve.cpp:2668
virtual ON_BOOL32 GetSpanVector(double *knots) const =0
virtual ON_BOOL32 IsLinear(double tolerance=ON_ZERO_TOLERANCE) const
Definition opennurbs_curve.cpp:184
virtual ON_BOOL32 IsPlanar(ON_Plane *plane=NULL, double tolerance=ON_ZERO_TOLERANCE) const
Definition opennurbs_curve.cpp:317
virtual ON_Interval Domain() const =0
virtual ON_BOOL32 Trim(const ON_Interval &domain)
Definition opennurbs_curve.cpp:2514
virtual ON_BOOL32 IsInPlane(const ON_Plane &test_plane, double tolerance=ON_ZERO_TOLERANCE) const =0
virtual ON_BOOL32 GetBBox(double *boxmin, double *boxmax, int bGrowBox=false) const =0
virtual int Dimension() const =0
Definition opennurbs_point.h:46
Definition opennurbs_nurbscurve.h:27
virtual ON__UINT32 DataCRC(ON__UINT32 current_remainder) const
Definition opennurbs_object.cpp:1689
virtual void Dump(ON_TextLog &) const
Definition opennurbs_object.cpp:1695
virtual ON_BOOL32 IsValid(ON_TextLog *text_log=NULL) const =0
virtual ON_BOOL32 Read(ON_BinaryArchive &binary_archive)
Definition opennurbs_object.cpp:1734
virtual ON_BOOL32 Write(ON_BinaryArchive &binary_archive) const
Definition opennurbs_object.cpp:1714
Definition opennurbs_plane.h:20
Definition opennurbs_array.h:46
Definition opennurbs_textlog.h:20
Definition opennurbs_xform.h:28
#define ON_ZERO_TOLERANCE
Definition opennurbs_defines.h:238
#define ON_CLASS
Definition opennurbs_defines.h:91
#define ON_SQRT_EPSILON
Definition opennurbs_defines.h:147
char s
Definition opennurbs_string.cpp:32
#define NULL
Definition opennurbs_system.h:256
int ON_BOOL32
Definition opennurbs_system.h:362
unsigned int ON__UINT32
Definition opennurbs_system.h:326