QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_nurbscurve.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
17//
18// Definition of NURBS curve
19//
21
22#if !defined(OPENNURBS_NURBSCURVE_INC_)
23#define OPENNURBS_NURBSCURVE_INC_
24
25class ON_NurbsCurve;
27{
29
30public:
31 /*
32 Description:
33 Use ON_NurbsCurve::New(...) instead of new ON_NurbsCurve(...)
34 Returns:
35 Pointer to an ON_NurbsCurve. Destroy by calling delete.
36 Remarks:
37 See static ON_Brep* ON_Brep::New() for details.
38 */
39 static ON_NurbsCurve* New();
40 static ON_NurbsCurve* New(
41 const ON_NurbsCurve& nurbs_curve
42 );
43 static ON_NurbsCurve* New(
44 const ON_BezierCurve& bezier_curve
45 );
46 static ON_NurbsCurve* New(
47 int dimension,
48 ON_BOOL32 bIsRational,
49 int order,
50 int cv_count
51 );
52
55
56 // Description:
57 // Create a NURBS curve equal to bezier with domain [0,1].
58 // Parameters:
59 // bezier_curve - [in]
61 const ON_BezierCurve& bezier_curve
62 );
63
64 // Description:
65 // Create a NURBS curve with knot a cv memory allocated.
66 // Parameters:
67 // dimension - [in] (>= 1)
68 // bIsRational - [in] true to make a rational NURBS
69 // order - [in] (>= 2) The order=degree+1
70 // cv_count - [in] (>= order) number of control vertices
72 int dimension,
73 ON_BOOL32 bIsRational,
74 int order,
75 int cv_count
76 );
77
78 // virtual ON_Object::SizeOf override
79 unsigned int SizeOf() const;
80
81 // virtual ON_Object::DataCRC override
82 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const;
83
84 /*
85 Description:
86 See if this and other are same NURBS geometry.
87 Parameters:
88 other - [in] other NURBS curve
89 bIgnoreParameterization - [in] if true, parameterization
90 and orientaion are ignored.
91 tolerance - [in] tolerance to use when comparing
92 control points.
93 Returns:
94 true if curves are tne same.
95 */
96 bool IsDuplicate(
97 const ON_NurbsCurve& other,
98 bool bIgnoreParameterization,
99 double tolerance = ON_ZERO_TOLERANCE
100 ) const;
101
102 // Description:
103 // Zeros all fields.
104 void Initialize(void);
105
106 // Description:
107 // Create a NURBS curve with knot a cv memory allocated.
108 // Parameters:
109 // dimension - [in] (>= 1)
110 // bIsRational - [in] true to make a rational NURBS
111 // order - [in] (>= 2) The order=degree+1
112 // cv_count - [in] (>= order) number of control vertices
113 bool Create(
114 int dimension,
115 ON_BOOL32 bIsRational,
116 int order,
117 int cv_count
118 );
119
120 // Description:
121 // Create a clamped uniform NURBS curve from a list
122 // of control points
123 // Parameters:
124 // dimension - [in] 1, 2 or 3
125 // order - [in] (>=2) order=degree+1
126 // point_count - [in] (>=order) number of control vertices
127 // point - [in] array of control vertex locations.
128 // knot_delta - [in] (>0.0) knot spacing
129 // Returns:
130 // true if successful
131 bool CreateClampedUniformNurbs(
132 int dimension,
133 int order,
134 int point_count,
135 const ON_3dPoint* point,
136 double knot_delta = 1.0
137 );
138
139 // Description:
140 // Create a periodic uniform NURBS curve from a list
141 // of control points
142 // Parameters:
143 // dimension - [in] 1, 2 or 3
144 // order - [in] (>=2) order=degree+1
145 // point_count - [in] (>=max(3,order-1)) number of distinct control vertices
146 // point - [in] array of distinct control vertex locations.
147 // knot_delta - [in] (>0.0) knot spacing
148 // Returns:
149 // true if successful
150 bool CreatePeriodicUniformNurbs(
151 int dimension,
152 int order,
153 int point_count,
154 const ON_3dPoint* point,
155 double knot_delta = 1.0
156 );
157
158 // Description:
159 // Deallocate knot and cv memory. Zeros all fields.
160 void Destroy();
161
162 virtual ~ON_NurbsCurve();
163
164 // Description:
165 // Call if memory used by ON_NurbsCurve becomes invalid.
166 void EmergencyDestroy();
167
169
170 // Description:
171 // Set NURBS curve equal to bezier with domain [0,1].
172 // Parameters:
173 // bezier_curve - [in]
175 const ON_BezierCurve& bezier_curve
176 );
177
179 // ON_Object overrides
180
181 /*
182 Description:
183 Tests an object to see if its data members are correctly
184 initialized.
185 Parameters:
186 text_log - [in] if the object is not valid and text_log
187 is not NULL, then a brief englis description of the
188 reason the object is not valid is appened to the log.
189 The information appended to text_log is suitable for
190 low-level debugging purposes by programmers and is
191 not intended to be useful as a high level user
192 interface tool.
193 Returns:
194 @untitled table
195 true object is valid
196 false object is invalid, uninitialized, etc.
197 Remarks:
198 Overrides virtual ON_Object::IsValid
199 */
200 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
201
202 // Description:
203 // virtual ON_Object::Dump override
204 void Dump(
205 ON_TextLog& dump
206 ) const;
207
208 // Description:
209 // virtual ON_Object::Write override
211 ON_BinaryArchive& binary_archive
212 ) const;
213
214 // Description:
215 // virtual ON_Object::Read override
217 ON_BinaryArchive& binary_archive
218 );
219
221 // ON_Geometry overrides
222
223 // Description:
224 // virtual ON_Geometry::Dimension override
225 // Returns:
226 // value of m_dim
227 int Dimension() const;
228
229 // Description:
230 // virtual ON_Geometry::GetBBox override
231 // Calculates axis aligned bounding box.
232 // Parameters:
233 // boxmin - [in/out] array of Dimension() doubles
234 // boxmax - [in/out] array of Dimension() doubles
235 // bGrowBox - [in] (default=false)
236 // If true, then the union of the input bbox and the
237 // object's bounding box is returned in bbox.
238 // If false, the object's bounding box is returned in bbox.
239 // Returns:
240 // true if object has bounding box and calculation was successful
241 ON_BOOL32 GetBBox( // returns true if successful
242 double* boxmin,
243 double* boxmax,
244 int bGrowBox = false
245 ) const;
246
247 // Description:
248 // virtual ON_Geometry::Transform override.
249 // Transforms the NURBS curve.
250 //
251 // Parameters:
252 // xform - [in] transformation to apply to object.
253 //
254 // Remarks:
255 // When overriding this function, be sure to include a call
256 // to ON_Object::TransformUserData() which takes care of
257 // transforming any ON_UserData that may be attached to
258 // the object.
260 const ON_Xform& xform
261 );
262
263 // virtual ON_Geometry::IsDeformable() override
264 bool IsDeformable() const;
265
266 // virtual ON_Geometry::MakeDeformable() override
267 bool MakeDeformable();
268
269 // Description:
270 // virtual ON_Geometry::SwapCoordinates override.
271 // Swaps control vertex coordinate values with indices i and j.
272 // Parameters:
273 // i - [in] coordinate index
274 // j - [in] coordinate index
276 int i,
277 int j
278 );
279
280 // virtual ON_Geometry override
281 bool Morph( const ON_SpaceMorph& morph );
282
283 // virtual ON_Geometry override
284 bool IsMorphable() const;
285
287 // ON_Curve overrides
288
289 // Description:
290 // virtual ON_Curve::Domain override.
291 // Returns:
292 // domain of the NURBS curve.
293 ON_Interval Domain() const;
294
295 // Description:
296 // virtual ON_Curve::SetDomain override.
297 // Set the domain of the curve
298 // Parameters:
299 // t0 - [in]
300 // t1 - [in] new domain will be [t0,t1]
301 // Returns:
302 // true if successful.
304 double t0,
305 double t1
306 );
307
308 /*
309 Description:
310 If this curve is closed, then modify it so that
311 the start/end point is at curve parameter t.
312 Parameters:
313 t - [in] curve parameter of new start/end point. The
314 returned curves domain will start at t.
315 Returns:
316 true if successful.
317 Remarks:
318 Overrides virtual ON_Curve::ChangeClosedCurveSeam
319 */
321 double t
322 );
323
324 // Description:
325 // virtual ON_Curve::SpanCount override.
326 // Get number of nonempty smooth (c-infinity) spans in curve
327 // Returns:
328 // Number of nonempty smooth (c-infinity) spans.
329 // Remarks:
330 // A nonempty span is bracked by knots m_knot[i] < m_knot[i+1]
331 // with m_order-2 <= i < m_cv_count-1.
332 int SpanCount() const;
333
334 // Description:
335 // virtual ON_Curve::GetSpanVector override.
336 // Get number of parameters of distinct knots in NURBS curve's domain.
337 // Parameters:
338 // knot_values - [out] an array of length SpanCount()+1 is
339 // filled in with the distinct knot values in the list
341 // Returns:
342 // true if successful
344 double* knot_values
345 ) const; //
346
347 // Description:
348 // virtual ON_Curve::Degree override.
349 // Returns:
350 // m_order-1
351 int Degree() const;
352
353 // Description:
354 // virtual ON_Curve::GetParameterTolerance override.
355 ON_BOOL32 GetParameterTolerance( // returns tminus < tplus: parameters tminus <= s <= tplus
356 double t,
357 double* tminus,
358 double* tplus
359 ) const;
360
361 // Description:
362 // virtual ON_Curve::IsLinear override.
364 double tolerance = ON_ZERO_TOLERANCE
365 ) const;
366
367 /*
368 Description:
369 Several types of ON_Curve can have the form of a polyline including
370 a degree 1 ON_NurbsCurve, an ON_PolylineCurve, and an ON_PolyCurve
371 all of whose segments are some form of polyline. IsPolyline tests
372 a curve to see if it can be represented as a polyline.
373 Parameters:
374 pline_points - [out] if not NULL and true is returned, then the
375 points of the polyline form are returned here.
376 t - [out] if not NULL and true is returned, then the parameters of
377 the polyline points are returned here.
378 Returns:
379 @untitled table
380 0 curve is not some form of a polyline
381 >=2 number of points in polyline form
382 */
383 int IsPolyline(
384 ON_SimpleArray<ON_3dPoint>* pline_points = NULL,
386 ) const;
387
388 // Description:
389 // virtual ON_Curve::IsArc override.
391 const ON_Plane* plane = NULL,
392 ON_Arc* arc = NULL,
393 double tolerance = ON_ZERO_TOLERANCE
394 ) const;
395
396 // Description:
397 // virtual ON_Curve::IsPlanar override.
399 ON_Plane* plane = NULL,
400 double tolerance = ON_ZERO_TOLERANCE
401 ) const;
402
403 // Description:
404 // virtual ON_Curve::IsInPlane override.
406 const ON_Plane& test_plane,
407 double tolerance = ON_ZERO_TOLERANCE
408 ) const;
409
410 // Description:
411 // virtual ON_Curve::IsClosed override.
412 // Returns:
413 // true if NURBS curve is closed. (Either curve has
414 // clamped end knots and euclidean location of start
415 // CV = euclidean location of end CV, or curve is
416 // periodic.)
417 ON_BOOL32 IsClosed() const;
418
419 // Description:
420 // virtual ON_Curve::IsPeriodic override.
421 // Returns:
422 // true if NURBS curve is periodic (degree > 1,
423 // periodic knot vector, last degree many CVs
424 // are duplicates of first degree many CVs).
425 ON_BOOL32 IsPeriodic() const;
426
427 /*
428 Description:
429 Search for a derivatitive, tangent, or curvature discontinuity.
430 Parameters:
431 c - [in] type of continity to test for. If ON::C1_continuous
432 t0 - [in] search begins at t0
433 t1 - [in] (t0 < t1) search ends at t1
434 t - [out] if a discontinuity is found, the *t reports the
435 parameter at the discontinuity.
436 hint - [in/out] if GetNextDiscontinuity will be called repeatedly,
437 passing a "hint" with initial value *hint=0 will increase the speed
438 of the search.
439 dtype - [out] if not NULL, *dtype reports the kind of discontinuity
440 found at *t. A value of 1 means the first derivative or unit tangent
441 was discontinuous. A value of 2 means the second derivative or
442 curvature was discontinuous.
443 cos_angle_tolerance - [in] default = cos(1 degree) Used only when
444 c is ON::G1_continuous or ON::G2_continuous. If the cosine
445 of the angle between two tangent vectors
446 is <= cos_angle_tolerance, then a G1 discontinuity is reported.
447 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when
448 c is ON::G2_continuous. If K0 and K1 are curvatures evaluated
449 from above and below and |K0 - K1| > curvature_tolerance,
450 then a curvature discontinuity is reported.
451 Returns:
452 true if a discontinuity was found on the interior of the interval (t0,t1).
453 Remarks:
454 Overrides ON_Curve::GetNextDiscontinuity.
455 */
457 ON::continuity c,
458 double t0,
459 double t1,
460 double* t,
461 int* hint=NULL,
462 int* dtype=NULL,
463 double cos_angle_tolerance=0.99984769515639123915701155881391,
464 double curvature_tolerance=ON_SQRT_EPSILON
465 ) const;
466
467 /*
468 Description:
469 Test continuity at a curve parameter value.
470 Parameters:
471 c - [in] continuity to test for
472 t - [in] parameter to test
473 hint - [in] evaluation hint
474 point_tolerance - [in] if the distance between two points is
475 greater than point_tolerance, then the curve is not C0.
476 d1_tolerance - [in] if the difference between two first derivatives is
477 greater than d1_tolerance, then the curve is not C1.
478 d2_tolerance - [in] if the difference between two second derivatives is
479 greater than d2_tolerance, then the curve is not C2.
480 cos_angle_tolerance - [in] default = cos(1 degree) Used only when
481 c is ON::G1_continuous or ON::G2_continuous. If the cosine
482 of the angle between two tangent vectors
483 is <= cos_angle_tolerance, then a G1 discontinuity is reported.
484 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when
485 c is ON::G2_continuous. If K0 and K1 are curvatures evaluated
486 from above and below and |K0 - K1| > curvature_tolerance,
487 then a curvature discontinuity is reported.
488 Returns:
489 true if the curve has at least the c type continuity at the parameter t.
490 Remarks:
491 Overrides ON_Curve::IsContinuous.
492 */
493 bool IsContinuous(
494 ON::continuity c,
495 double t,
496 int* hint = NULL,
497 double point_tolerance=ON_ZERO_TOLERANCE,
498 double d1_tolerance=ON_ZERO_TOLERANCE,
499 double d2_tolerance=ON_ZERO_TOLERANCE,
500 double cos_angle_tolerance=0.99984769515639123915701155881391,
501 double curvature_tolerance=ON_SQRT_EPSILON
502 ) const;
503
504 /*
505 Description:
506 Force the curve to start at a specified point.
507 Parameters:
508 start_point - [in]
509 Returns:
510 true if successful.
511 Remarks:
512 Some end points cannot be moved. Be sure to check return
513 code.
514 See Also:
515 ON_Curve::SetEndPoint
516 ON_Curve::PointAtStart
517 ON_Curve::PointAtEnd
518 */
519 //virtual
521 ON_3dPoint start_point
522 );
523
524 /*
525 Description:
526 Force the curve to end at a specified point.
527 Parameters:
528 end_point - [in]
529 Returns:
530 true if successful.
531 Remarks:
532 Some end points cannot be moved. Be sure to check return
533 code.
534 See Also:
535 ON_Curve::SetStartPoint
536 ON_Curve::PointAtStart
537 ON_Curve::PointAtEnd
538 */
539 //virtual
541 ON_3dPoint end_point
542 );
543
544 // Description:
545 // virtual ON_Curve::Reverse override.
546 // Reverse parameterizatrion by negating all knots
547 // and reversing the order of the control vertices.
548 // Remarks:
549 // Domain changes from [a,b] to [-b,-a]
551
552 // Description:
553 // virtual ON_Curve::Evaluate override.
554 ON_BOOL32 Evaluate( // returns false if unable to evaluate
555 double, // evaluation parameter
556 int, // number of derivatives (>=0)
557 int, // array stride (>=Dimension())
558 double*, // array of length stride*(ndir+1)
559 int = 0, // optional - determines which side to evaluate from
560 // 0 = default
561 // < 0 to evaluate from below,
562 // > 0 to evaluate from above
563 int* = 0 // optional - evaluation hint (int) used to speed
564 // repeated evaluations
565 ) const;
566
567 bool GetClosestPoint(
568 const ON_3dPoint&, // test_point
569 double* t, // parameter of local closest point returned here
570 double maximum_distance = 0.0, // maximum_distance
571 const ON_Interval* sub_domain = NULL // sub_domain
572 ) const;
573
574 // Description:
575 // Get the length of the curve.
576 // Parameters:
577 // length - [out] length returned here.
578 // t - [out] parameter such that the length of the curve
579 // from its start to t is arc_length.
580 // fractional_tolerance - [in] desired fractional precision.
581 // fabs(("exact" length from start to t) - arc_length)/arc_length <= fractional_tolerance
582 // sub_domain - [in] If not NULL, the calculation is performed on
583 // the specified sub-domain of the curve.
584 // Returns:
585 // true if returned if the length calculation is successful.
586 // false is returned if the length is not calculated.
587 // Remarks:
588 // The arc length will be computed so that
589 // (returned length - real length)/(real length) <= fractional_tolerance
590 // More simply, if you want N significant figures in the answer, set the
591 // fractional_tolerance to 1.0e-N. For "nice" curves, 1.0e-8 works
592 // fine. For very high degree NURBS and NURBS with bad parameterizations,
593 // use larger values of fractional_tolerance.
595 double* length,
596 double fractional_tolerance = 1.0e-8,
597 const ON_Interval* sub_domain = NULL
598 ) const;
599
600 /*
601 Description:
602 Looks for segments that are shorter than tolerance
603 that can be removed. If bRemoveShortSegments is true,
604 then the short segments are removed. Does not change the
605 domain, but it will change the relative parameterization.
606 Parameters:
607 tolerance - [in]
608 bRemoveShortSegments - [in] If true, then short segments
609 are removed.
610 Returns:
611 True if removable short segments can were found.
612 False if no removable short segments can were found.
613 See Also:
614 ON_NurbsCurve::RepairBadKnots
615 */
617 double tolerance,
618 bool bRemoveShortSegments = true
619 );
620
621 /*
622 Description:
623 Looks for problems caused by knots that are close together
624 or have mulitplicity >= order. If bRepair is true, the problems
625 are fixed. Does not change the domain.
626 Parameters:
627 knot_tolerance - [in] >= 0 When in doubt, use zero.
628 bRepair - [in] If true, then problems are repaired.
629 Otherwise this function looks for problemsn that
630 can be repaired, but does not modify the curve.
631 Returns:
632 True if bad knots were found and can be repaired.
633 See Also:
634 ON_NurbsCurve::RemoveShortSegments
635 */
636 bool RepairBadKnots(
637 double knot_tolerance=0.0,
638 bool bRepair = true
639 );
640
641 // Description:
642 // virtual ON_Curve::Trim override.
643 ON_BOOL32 Trim( const ON_Interval& );
644
645 // Description:
646 // Where possible, analytically extends curve to include domain.
647 // Parameters:
648 // domain - [in] if domain is not included in curve domain,
649 // curve will be extended so that its domain includes domain.
650 // Will not work if curve is closed. Original curve is identical
651 // to the restriction of the resulting curve to the original curve domain,
652 // Returns:
653 // true if successful.
654 bool Extend(
655 const ON_Interval& domain
656 );
657
658 // Description:
659 // virtual ON_Curve::Split override.
660 //
661 // Split() divides the curve at the specified parameter. The parameter
662 // must be in the interior of the curve's domain. The pointers passed
663 // to ON_NurbsCurve::Split must either be NULL or point to an ON_NurbsCurve.
664 // If the pointer is NULL, then a curve will be created
665 // in Split(). You may pass "this" as one of the pointers to Split().
666 // For example,
667 //
668 // ON_NurbsCurve right_side;
669 // crv.Split( crv.Domain().Mid() &crv, &right_side );
670 //
671 // would split crv at the parametric midpoint, put the left side in crv,
672 // and return the right side in right_side.
674 double, // t = curve parameter to split curve at
675 ON_Curve*&, // left portion returned here (must be an ON_NurbsCurve)
676 ON_Curve*& // right portion returned here (must be an ON_NurbsCurve)
677 ) const;
678
679 // Description:
680 // virtual ON_Curve::GetNurbForm override.
681 int GetNurbForm( // returns 0: unable to create NURBS representation
682 // with desired accuracy.
683 // 1: success - returned NURBS parameterization
684 // matches the curve's to wthe desired accuracy
685 // 2: success - returned NURBS point locus matches
686 // the curve's to the desired accuracy but, on
687 // the interior of the curve's domain, the
688 // curve's parameterization and the NURBS
689 // parameterization may not match to the
690 // desired accuracy.
692 double = 0.0,
693 const ON_Interval* = NULL // OPTIONAL subdomain of curve
694 ) const;
695
696 // Description:
697 // virtual ON_Curve::HasNurbForm override.
698 int HasNurbForm( // returns 0: unable to create NURBS representation
699 // with desired accuracy.
700 // 1: success - returned NURBS parameterization
701 // matches the curve's to wthe desired accuracy
702 // 2: success - returned NURBS point locus matches
703 // the curve's to the desired accuracy but, on
704 // the interior of the curve's domain, the
705 // curve's parameterization and the NURBS
706 // parameterization may not match to the
707 // desired accuracy.
708 ) const;
709
710 // Description:
711 // virtual ON_Curve::GetCurveParameterFromNurbFormParameter override
713 double, // nurbs_t
714 double* // curve_t
715 ) const;
716
717 // Description:
718 // virtual ON_Curve::GetNurbFormParameterFromCurveParameter override
720 double, // curve_t
721 double* // nurbs_t
722 ) const;
723
724public:
725
727 // Interface
728
729 bool IsRational( // true if NURBS curve is rational
730 void
731 ) const;
732
733 int CVSize( // number of doubles per control vertex
734 void // = IsRational() ? Dim()+1 : Dim()
735 ) const;
736
737 int Order( // order = degree + 1
738 void
739 ) const;
740
741 int CVCount( // number of control vertices
742 void
743 ) const;
744
745 int KnotCount( // total number of knots in knot vector
746 void
747 ) const;
748
749 /*
750 Description:
751 Expert user function to get a pointer to control vertex
752 memory. If you are not an expert user, please use
753 ON_NurbsCurve::GetCV( ON_3dPoint& ) or
754 ON_NurbsCurve::GetCV( ON_4dPoint& ).
755 Parameters:
756 cv_index - [in]
757 Returns:
758 Pointer to control vertex.
759 Remarks:
760 If the NURBS curve is rational, the format of the
761 returned array is a homogeneos rational point with
762 length m_dim+1. If the NURBS curve is not rational,
763 the format of the returned array is a nonrational
764 euclidean point with length m_dim.
765 See Also
766 ON_NurbsCurve::CVStyle
767 ON_NurbsCurve::GetCV
768 ON_NurbsCurve::Weight
769 */
770 double* CV(
771 int cv_index
772 ) const;
773
774 /*
775 Description:
776 Returns the style of control vertices in the m_cv array.
777 Returns:
778 @untitled table
779 ON::not_rational m_is_rat is false
780 ON::homogeneous_rational m_is_rat is true
781 */
782 ON::point_style CVStyle() const;
783
784
785 double Weight( // get value of control vertex weight
786 int // CV index ( >= 0 and < CVCount() )
787 ) const;
788
789 ON_BOOL32 SetWeight( // get value of control vertex weight
790 int, // CV index ( >= 0 and < CVCount() )
791 double
792 );
793
794 ON_BOOL32 SetCV( // set a single control vertex
795 int, // CV index ( >= 0 and < CVCount() )
796 ON::point_style, // style of input point
797 const double* // value of control vertex
798 );
799
800 ON_BOOL32 SetCV( // set a single control vertex
801 int, // CV index ( >= 0 and < CVCount() )
802 const ON_3dPoint& // value of control vertex
803 // If NURBS is rational, weight
804 // will be set to 1.
805 );
806
807 ON_BOOL32 SetCV( // set a single control vertex
808 int, // CV index ( >= 0 and < CVCount() )
809 const ON_4dPoint& // value of control vertex
810 // If NURBS is not rational, euclidean
811 // location of homogeneous point will
812 // be used.
813 );
814
815 ON_BOOL32 GetCV( // get a single control vertex
816 int, // CV index ( >= 0 and < CVCount() )
817 ON::point_style, // style to use for output point
818 double* // array of length >= CVSize()
819 ) const;
820
821 ON_BOOL32 GetCV( // get a single control vertex
822 int, // CV index ( >= 0 and < CVCount() )
823 ON_3dPoint& // gets euclidean cv when NURBS is rational
824 ) const;
825
826 ON_BOOL32 GetCV( // get a single control vertex
827 int, // CV index ( >= 0 and < CVCount() )
828 ON_4dPoint& // gets homogeneous cv
829 ) const;
830
831 // Description:
832 // Set knot value.
833 // Parameters:
834 // knot_index - [in] 0 <= knot_index <= KnotCount()-1
835 // knot_value - [in]
836 // Remarks:
837 // m_knot[] must exist. Use ReserveKnotCapacity to
838 // allocate m_knot[].
839 // Returns:
840 // true if successful
841 // See Also:
842 // ON_NurbsCurve::ReserveKnotCapacity
843 bool SetKnot(
844 int knot_index,
845 double knot_value
846 );
847
848 // Description:
849 // Get knot value.
850 // Parameters:
851 // knot_index - [in] 0 <= knot_index <= KnotCount()-1
852 // Returns:
853 // knot value = m_knot[knot_index]
854 // See Also:
855 // ON_NurbsCurve::SetKnot, ON_NurbsCurve::KnotMultiplicity
856 double Knot(
857 int knot_index
858 ) const;
859
860 // Description:
861 // Get knot multiplicity.
862 // Parameters:
863 // knot_index - [in] 0 <= knot_index <= KnotCount()-1
864 // Returns:
865 // knot multiplicity = m_knot[knot_index]
866 // See Also:
867 // ON_NurbsCurve::SetKnot, ON_NurbsCurve::Knot,
868 // ON_NurbsCurve::InsertKnot
869 int KnotMultiplicity(
870 int knot_index
871 ) const;
872
873 // Description:
874 // Get pointer to knot vector array.
875 // Returns:
876 // pointer to knot vector array (m_knot).
877 // See Also:
878 // ON_NurbsCurve::SetKnot, ON_NurbsCurve::Knot,
879 // ON_NurbsCurve::InsertKnot
880 const double* Knot() const;
881
882 // Description:
883 // Make knot vector a clamped uniform knot vector
884 // based on the current values of m_order and m_cv_count.
885 // Does not change values of control vertices.
886 // Parameters:
887 // delta - [in] (>0.0) knot spacing.
888 // Returns:
889 // true if successful.
890 // Remarks:
891 // Allocates m_knot[] if it is not big enough.
892 // See Also:
893 // ON_MakeClampedUniformKnotVector
894 bool MakeClampedUniformKnotVector(
895 double delta = 1.0
896 );
897
898 // Description:
899 // Make knot vector a periodic uniform knot vector
900 // based on the current values of m_order and m_cv_count.
901 // Does not change values of control vertices.
902 // Parameters:
903 // delta - [in] (>0.0) knot spacing.
904 // Returns:
905 // true if successful.
906 // Remarks:
907 // Allocates m_knot[] if it is not big enough.
908 // See Also:
909 // ON_MakePeriodicUniformKnotVector
910 bool MakePeriodicUniformKnotVector(
911 double delta = 1.0
912 );
913
914 bool IsClamped( // determine if knot vector is clamped
915 int = 2 // end to check: 0 = start, 1 = end, 2 = start and end
916 ) const;
917
918 double SuperfluousKnot(
919 int // 0 = start, 1 = end
920 ) const;
921
922 double GrevilleAbcissa(
923 int // index (0 <= index < CVCount(dir)
924 ) const;
925
926 bool GetGrevilleAbcissae( // see ON_GetGrevilleAbcissae() for details
927 double* // g[cv_count]
928 ) const;
929
930 bool ZeroCVs(); // zeros control vertices and, if rational, sets weights to 1
931
932 // Description:
933 // Clamp end knots. Does not modify control points.
934 // Parameters:
935 // end - [in] 0 = clamp start, 1 = clamp end, 2 = clamp start and end
936 // Returns:
937 // true if successful
938 bool ClampEnd(
939 int end
940 );
941
942 // Description:
943 // Insert a knot and update cv locations.
944 // Parameters:
945 // knot_value - [in] m_knot[order-2] < knot_value < m_knot[m_cv_count-1]
946 // knot_multiplicity - [in] 1 to degree - includes multiplicity of existing knots.
947 // Remarks:
948 // Does not change parameterization or locus of curve.
949 // Returns:
950 // true if successful
951 bool InsertKnot(
952 double knot_value,
953 int knot_multiplicity
954 );
955
956 bool MakeRational();
957
958 bool MakeNonRational();
959
960 bool IncreaseDegree(
961 int desired_degree
962 );
963
964 bool ChangeDimension(
965 int desired_dimension
966 );
967
968 bool Append( const ON_NurbsCurve& );
969
971 // Tools for managing CV and knot memory
972 bool ReserveCVCapacity(
973 int // number of doubles to reserve
974 );
975 bool ReserveKnotCapacity(
976 int // number of doubles to reserve
977 );
978
980 // returns the length of the control polygon
981 double ControlPolygonLength() const;
982
984 // Converts a span of the NURBS curve into a bezier. If
985 // the span is empty
986 // (m_knot[span_index+m_order-2] == m_knot[span_index+m_order-1]),
987 // then false is returned.
988 bool ConvertSpanToBezier(
989 int, // span_index (0 <= span_index <= m_cv_count-m_order)
990 ON_BezierCurve& // bezier returned here
991 ) const;
992
994 // Returns true if the NURBS curve has bezier spans
995 // (all distinct knots have multiplitity = degree)
996 bool HasBezierSpans() const;
997
998 /*
999 Description:
1000 Clamps ends and adds knots so the NURBS curve has bezier spans
1001 (all distinct knots have multiplitity = degree).
1002 Paremeters:
1003 bSetEndWeightsToOne - [in] If true and the first or last weight is
1004 not one, then the first and last spans are reparameterized so
1005 that the end weights are one.
1006 Returns:
1007 true if successful.
1008 */
1009 bool MakePiecewiseBezier(
1010 bool bSetEndWeightsToOne = false
1011 );
1012
1013 /*
1014 Description:
1015 Use a combination of scaling and reparameterization to change
1016 the end weights to the specified values.
1017 Parameters:
1018 w0 - [in] weight for first cv
1019 w1 - [in] weight for last cv
1020 Returns:
1021 true if successful.
1022 See Also:
1023 ON_ChangeRationalNurbsCurveEndWeights
1024 Remarks:
1025 The domain, eucleanean locations of the control points,
1026 and locus of the curve do not change, but the weights,
1027 homogeneous cv values and internal knot values may change.
1028 If w0 and w1 are 1 and the curve is not rational, the
1029 curve is not changed.
1030 */
1031 bool ChangeEndWeights( double w0, double w1 );
1032
1033 /*
1034 Description:
1035 Use a linear fractional transformation to reparameterize
1036 the NURBS curve. This does not change the curve's domain.
1037 Parameters:
1038 c - [in]
1039 reparameterization constant (generally speaking, c should be > 0).
1040 The control points and knots are adjusted so that
1041 output_nurbs(t) = input_nurbs(lambda(t)), where
1042 lambda(t) = c*t/( (c-1)*t + 1 ).
1043 Note that lambda(0) = 0, lambda(1) = 1, lambda'(t) > 0,
1044 lambda'(0) = c and lambda'(1) = 1/c.
1045 Returns:
1046 true if successful.
1047 Remarks:
1048 The cv and knot values are values are changed so that
1049 output_nurbs(t) = input_nurbs(lambda(t)).
1050 See Also:
1051 ON_ReparameterizeRationalNurbsCurve
1052 */
1053 bool Reparameterize( double c );
1054
1055
1056
1058 // Implementation
1059public:
1060 // NOTE: These members are left "public" so that expert users may efficiently
1061 // create NURBS curves using the default constructor and borrow the
1062 // knot and CV arrays from their native NURBS representation.
1063 // No technical support will be provided for users who access these
1064 // members directly. If you can't get your stuff to work, then use
1065 // the constructor with the arguments and the SetKnot() and SetCV()
1066 // functions to fill in the arrays.
1067
1068 int m_dim; // (>=1)
1069
1070 int m_is_rat; // 1 for rational B-splines. (Rational control
1071 // vertices use homogeneous form.)
1072 // 0 for non-rational B-splines. (Control
1073 // verticies do not have a weight coordinate.)
1074
1075 int m_order; // order = degree+1 (>=2)
1076
1077 int m_cv_count; // number of control vertices ( >= order )
1078
1079 // knot vector memory
1080
1081 int m_knot_capacity; // If m_knot_capacity > 0, then m_knot[]
1082 // is an array of at least m_knot_capacity
1083 // doubles whose memory is managed by the
1084 // ON_NurbsCurve class using rhmalloc(),
1085 // onrealloc(), and rhfree().
1086 // If m_knot_capacity is 0 and m_knot is
1087 // not NULL, then m_knot[] is assumed to
1088 // be big enough for any requested operation
1089 // and m_knot[] is not deleted by the
1090 // destructor.
1091
1092 double* m_knot; // Knot vector. ( The knot vector has length
1093 // m_order+m_cv_count-2. )
1094
1095 // control vertex net memory
1096
1097 int m_cv_stride; // The pointer to start of "CV[i]" is
1098 // m_cv + i*m_cv_stride.
1099
1100 int m_cv_capacity; // If m_cv_capacity > 0, then m_cv[] is an array
1101 // of at least m_cv_capacity doubles whose
1102 // memory is managed by the ON_NurbsCurve
1103 // class using rhmalloc(), onrealloc(), and rhfree().
1104 // If m_cv_capacity is 0 and m_cv is not
1105 // NULL, then m_cv[] is assumed to be big enough
1106 // for any requested operation and m_cv[] is not
1107 // deleted by the destructor.
1108
1109 double* m_cv; // Control points.
1110 // If m_is_rat is false, then control point is
1111 //
1112 // ( CV(i)[0], ..., CV(i)[m_dim-1] ).
1113 //
1114 // If m_is_rat is true, then the control point
1115 // is stored in HOMOGENEOUS form and is
1116 //
1117 // [ CV(i)[0], ..., CV(i)[m_dim] ].
1118 //
1119};
1120
1121#endif
@ Transform
Definition RSMetaType.h:67
int i
Copyright (c) 2011-2018 by Andrew Mustun.
Definition autostart.js:32
Definition opennurbs_point.h:403
Definition opennurbs_point.h:555
Definition opennurbs_arc.h:34
Definition opennurbs_bezier.h:148
Definition opennurbs_archive.h:152
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
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 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 bool GetNextDiscontinuity(ON::continuity c, double t0, double t1, double *t, int *hint=NULL, int *dtype=NULL, double cos_angle_tolerance=0.99984769515639123915701155881391, double curvature_tolerance=ON_SQRT_EPSILON) const
Definition opennurbs_curve.cpp:450
unsigned int SizeOf() const
Definition opennurbs_curve.cpp:52
virtual int HasNurbForm() const
Definition opennurbs_curve.cpp:2635
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 RemoveShortSegments(double tolerance, bool bRemoveShortSegments=true)
Definition opennurbs_curve.cpp:2425
virtual bool Extend(const ON_Interval &domain)
Definition opennurbs_curve.cpp:2521
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 int IsPolyline(ON_SimpleArray< ON_3dPoint > *pline_points=NULL, ON_SimpleArray< double > *pline_t=NULL) const
Definition opennurbs_curve.cpp:174
virtual ON_BOOL32 GetParameterTolerance(double t, double *tminus, double *tplus) const
Definition opennurbs_curve.cpp:161
virtual bool IsDeformable() const
Definition opennurbs_geometry.cpp:205
virtual ON_BOOL32 GetBBox(double *boxmin, double *boxmax, int bGrowBox=false) const =0
virtual ON_BOOL32 SwapCoordinates(int i, int j)
Definition opennurbs_geometry.cpp:135
virtual bool MakeDeformable()
Definition opennurbs_geometry.cpp:210
virtual bool Morph(const ON_SpaceMorph &morph)
Definition opennurbs_geometry.cpp:254
virtual int Dimension() const =0
virtual bool IsMorphable() const
Definition opennurbs_geometry.cpp:259
Definition opennurbs_point.h:46
Definition opennurbs_nurbscurve.h:27
int m_order
Definition opennurbs_nurbscurve.h:1075
int m_cv_capacity
Definition opennurbs_nurbscurve.h:1100
int m_dim
Definition opennurbs_nurbscurve.h:1068
int m_cv_count
Definition opennurbs_nurbscurve.h:1077
int m_cv_stride
Definition opennurbs_nurbscurve.h:1097
ON_OBJECT_DECLARE(ON_NurbsCurve)
double * m_cv
Definition opennurbs_nurbscurve.h:1109
double * m_knot
Definition opennurbs_nurbscurve.h:1092
int m_is_rat
Definition opennurbs_nurbscurve.h:1070
int m_knot_capacity
Definition opennurbs_nurbscurve.h:1081
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_xform.h:1146
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
#define NULL
Definition opennurbs_system.h:256
int ON_BOOL32
Definition opennurbs_system.h:362
unsigned int ON__UINT32
Definition opennurbs_system.h:326