QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_curve.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 virtual parametric curve
19//
21
22#if !defined(OPENNURBS_CURVE_INC_)
23#define OPENNURBS_CURVE_INC_
24
25class ON_Curve;
26class ON_Plane;
27class ON_Arc;
28class ON_NurbsCurve;
29class ON_CurveTree;
30
31
34
35
37{
38public:
40
41 // If main_seg_count <= 0, then both these parameters are ignored.
42 // If main_seg_count > 0, then sub_seg_count must be >= 1. In this
43 // case the curve will be broken into main_seg_count equally spaced
44 // chords. If needed, each of these chords can be split into as many
45 // sub_seg_count sub-parts if the subdivision is necessary for the
46 // mesh to meet the other meshing constraints. In particular, if
47 // sub_seg_count = 0, then the curve is broken into main_seg_count
48 // pieces and no further testing is performed.
51
54
55 // Maximum angle (in radians) between unit tangents at adjacent
56 // vertices.
58
59 // Maximum permitted value of
60 // distance chord midpoint to curve) / (length of chord)
61 double m_max_chr;
62
63 // If max_aspect < 1.0, the parameter is ignored.
64 // If 1 <= max_aspect < sqrt(2), it is treated as if
65 // max_aspect = sqrt(2).
66 // This parameter controls the maximum permitted value of
67 // (length of longest chord) / (length of shortest chord)
69
70 // If tolerance = 0, the parameter is ignored.
71 // This parameter controls the maximum permitted value of the
72 // distance from the curve to the mesh.
74
75 // If m_min_edge_length = 0, the parameter is ignored.
76 // This parameter controls the minimum permitted edge length.
78
79 // If max_edge_length = 0, the parameter is ignored.
80 // This parameter controls the maximum permitted edge length.
82
85};
86
88{
89 // pure virtual class for curve objects
90
91 // Any object derived from ON_Curve should have a
92 // ON_OBJECT_DECLARE(ON_...);
93 // as the last line of its class definition and a
94 // ON_OBJECT_IMPLEMENT( ON_..., ON_baseclass );
95 // in a .cpp file.
96 //
97 // See the definition of ON_Object for details.
99
100public:
101 // virtual ON_Object::DestroyRuntimeCache override
102 void DestroyRuntimeCache( bool bDelete = true );
103
104public:
105 ON_Curve();
106 ON_Curve(const ON_Curve&);
107 ON_Curve& operator=(const ON_Curve&);
108 virtual ~ON_Curve();
109
110 // virtual ON_Object::SizeOf override
111 unsigned int SizeOf() const;
112
113 // virtual ON_Geometry override
114 bool EvaluatePoint( const class ON_ObjRef& objref, ON_3dPoint& P ) const;
115
116 /*
117 Description:
118 Get a duplicate of the curve.
119 Returns:
120 A duplicate of the curve.
121 Remarks:
122 The caller must delete the returned curve.
123 For non-ON_CurveProxy objects, this simply duplicates the curve using
124 ON_Object::Duplicate.
125 For ON_CurveProxy objects, this duplicates the actual proxy curve
126 geometry and, if necessary, trims and reverse the result to that
127 the returned curve's parameterization and locus match the proxy curve's.
128 */
129 virtual
130 ON_Curve* DuplicateCurve() const;
131
132 // Description:
133 // overrides virtual ON_Object::ObjectType.
134 // Returns:
135 // ON::curve_object
136 ON::object_type ObjectType() const;
137
138 /*
139 Description:
140 Get tight bounding box of the curve.
141 Parameters:
142 tight_bbox - [in/out] tight bounding box
143 bGrowBox -[in] (default=false)
144 If true and the input tight_bbox is valid, then returned
145 tight_bbox is the union of the input tight_bbox and the
146 curve's tight bounding box.
147 xform -[in] (default=NULL)
148 If not NULL, the tight bounding box of the transformed
149 curve is calculated. The curve is not modified.
150 Returns:
151 True if the returned tight_bbox is set to a valid
152 bounding box.
153 */
155 ON_BoundingBox& tight_bbox,
156 int bGrowBox = false,
157 const ON_Xform* xform = 0
158 ) const;
159
161 // curve interface
162
163 // Description:
164 // Gets domain of the curve
165 // Parameters:
166 // t0 - [out]
167 // t1 - [out] domain is [*t0, *t1]
168 // Returns:
169 // true if successful.
170 ON_BOOL32 GetDomain( double* t0, double* t1 ) const;
171
172 // Returns:
173 // domain of the curve.
174 virtual
175 ON_Interval Domain() const = 0;
176
177 /*
178 Description:
179 Set the domain of the curve.
180 Parameters:
181 domain - [in] increasing interval
182 Returns:
183 true if successful.
184 */
185 bool SetDomain( ON_Interval domain );
186
187 // Description:
188 // Set the domain of the curve
189 // Parameters:
190 // t0 - [in]
191 // t1 - [in] new domain will be [t0,t1]
192 // Returns:
193 // true if successful.
194 virtual
195 ON_BOOL32 SetDomain(
196 double t0,
197 double t1
198 );
199
200
201 /*
202 Description:
203 If this curve is closed, then modify it so that
204 the start/end point is at curve parameter t.
205 Parameters:
206 t - [in] curve parameter of new start/end point. The
207 returned curves domain will start at t.
208 Returns:
209 true if successful.
210 */
211 virtual
212 ON_BOOL32 ChangeClosedCurveSeam(
213 double t
214 );
215
216 /*
217 Description:
218 Change the dimension of a curve.
219 Parameters:
220 desired_dimension - [in]
221 Returns:
222 true if the curve's dimension was already desired_dimension
223 or if the curve's dimension was successfully changed to
224 desired_dimension.
225 */
226 virtual
227 bool ChangeDimension(
228 int desired_dimension
229 );
230
231
232 // Description:
233 // Get number of nonempty smooth (c-infinity) spans in curve
234 // Returns:
235 // Number of nonempty smooth (c-infinity) spans.
236 virtual
237 int SpanCount() const = 0;
238
239 // Description:
240 // Get number of parameters of "knots".
241 // Parameters:
242 // knots - [out] an array of length SpanCount()+1 is filled in
243 // with the parameters where the curve is not smooth (C-infinity).
244 // Returns:
245 // true if successful
246 virtual
248 double* knots
249 ) const = 0; //
250
252 // If t is in the domain of the curve, GetSpanVectorIndex() returns the
253 // span vector index "i" such that span_vector[i] <= t <= span_vector[i+1].
254 // The "side" parameter determines which span is selected when t is at the
255 // end of a span.
256 virtual
257 ON_BOOL32 GetSpanVectorIndex(
258 double t , // [IN] t = evaluation parameter
259 int side, // [IN] side 0 = default, -1 = from below, +1 = from above
260 int* span_vector_index, // [OUT] span vector index
261 ON_Interval* span_domain // [OUT] domain of the span containing "t"
262 ) const;
263
264 // Description:
265 // Returns maximum algebraic degree of any span
266 // or a good estimate if curve spans are not algebraic.
267 // Returns:
268 // degree
269 virtual
270 int Degree() const = 0;
271
272 // Description:
273 // Returns maximum algebraic degree of any span
274 // or a good estimate if curve spans are not algebraic.
275 // Returns:
276 // degree
277 virtual
278 ON_BOOL32 GetParameterTolerance( // returns tminus < tplus: parameters tminus <= s <= tplus
279 double t, // [IN] t = parameter in domain
280 double* tminus, // [OUT] tminus
281 double* tplus // [OUT] tplus
282 ) const;
283
284 // Description:
285 // Test a curve to see if the locus if its points is a line segment.
286 // Parameters:
287 // tolerance - [in] // tolerance to use when checking linearity
288 // Returns:
289 // true if the ends of the curve are farther than tolerance apart
290 // and the maximum distance from any point on the curve to
291 // the line segment connecting the curve's ends is <= tolerance.
292 virtual
293 ON_BOOL32 IsLinear(
294 double tolerance = ON_ZERO_TOLERANCE
295 ) const;
296
297 /*
298 Description:
299 Several types of ON_Curve can have the form of a polyline including
300 a degree 1 ON_NurbsCurve, an ON_PolylineCurve, and an ON_PolyCurve
301 all of whose segments are some form of polyline. IsPolyline tests
302 a curve to see if it can be represented as a polyline.
303 Parameters:
304 pline_points - [out] if not NULL and true is returned, then the
305 points of the polyline form are returned here.
306 t - [out] if not NULL and true is returned, then the parameters of
307 the polyline points are returned here.
308 Returns:
309 @untitled table
310 0 curve is not some form of a polyline
311 >=2 number of points in polyline form
312 */
313 virtual
314 int IsPolyline(
315 ON_SimpleArray<ON_3dPoint>* pline_points = NULL,
317 ) const;
318
319 // Description:
320 // Test a curve to see if the locus if its points is an arc or circle.
321 // Parameters:
322 // plane - [in] if not NULL, test is performed in this plane
323 // arc - [out] if not NULL and true is returned, then arc parameters
324 // are filled in
325 // tolerance - [in] tolerance to use when checking
326 // Returns:
327 // ON_Arc.m_angle > 0 if curve locus is an arc between
328 // specified points. If ON_Arc.m_angle is 2.0*ON_PI, then the curve
329 // is a circle.
330 virtual
331 ON_BOOL32 IsArc(
332 const ON_Plane* plane = NULL,
333 ON_Arc* arc = NULL,
334 double tolerance = ON_ZERO_TOLERANCE
335 ) const;
336
337 virtual
338 bool IsEllipse(
339 const ON_Plane* plane = NULL,
340 ON_Ellipse* ellipse = NULL,
341 double tolerance = ON_ZERO_TOLERANCE
342 ) const;
343
344 // Description:
345 // Test a curve to see if it is planar.
346 // Parameters:
347 // plane - [out] if not NULL and true is returned,
348 // the plane parameters are filled in.
349 // tolerance - [in] tolerance to use when checking
350 // Returns:
351 // true if there is a plane such that the maximum distance from
352 // the curve to the plane is <= tolerance.
353 virtual
354 ON_BOOL32 IsPlanar(
355 ON_Plane* plane = NULL,
356 double tolerance = ON_ZERO_TOLERANCE
357 ) const;
358
359 // Description:
360 // Test a curve to see if it lies in a specific plane.
361 // Parameters:
362 // test_plane - [in]
363 // tolerance - [in] tolerance to use when checking
364 // Returns:
365 // true if the maximum distance from the curve to the
366 // test_plane is <= tolerance.
367 virtual
369 const ON_Plane& test_plane,
370 double tolerance = ON_ZERO_TOLERANCE
371 ) const = 0;
372
373 /*
374 Description:
375 Decide if it makes sense to close off this curve by moving
376 the endpoint to the start based on start-end gap size and length
377 of curve as approximated by chord defined by 6 points.
378 Parameters:
379 tolerance - [in] maximum allowable distance between start and end.
380 if start - end gap is greater than tolerance, returns false
381 min_abs_size - [in] if greater than 0.0 and none of the interior sampled
382 points are at least min_abs_size from start, returns false.
383 min_rel_size - [in] if greater than 1.0 and chord length is less than
384 min_rel_size*gap, returns false.
385 Returns:
386 true if start and end points are close enough based on above conditions.
387 */
388
389 bool IsClosable(
390 double tolerance,
391 double min_abs_size = 0.0,
392 double min_rel_size = 10.0
393 ) const;
394
395 // Description:
396 // Test a curve to see if it is closed.
397 // Returns:
398 // true if the curve is closed.
399 virtual
400 ON_BOOL32 IsClosed() const;
401
402 // Description:
403 // Test a curve to see if it is periodic.
404 // Returns:
405 // true if the curve is closed and at least C2 at the start/end.
406 virtual
407 ON_BOOL32 IsPeriodic() const;
408
409 /*
410 Description:
411 Search for a derivatitive, tangent, or curvature
412 discontinuity.
413 Parameters:
414 c - [in] type of continity to test for.
415 t0 - [in] Search begins at t0. If there is a discontinuity
416 at t0, it will be ignored. This makes it
417 possible to repeatedly call GetNextDiscontinuity
418 and step through the discontinuities.
419 t1 - [in] (t0 != t1) If there is a discontinuity at t1 is
420 will be ingored unless c is a locus discontinuity
421 type and t1 is at the start or end of the curve.
422 t - [out] if a discontinuity is found, then *t reports the
423 parameter at the discontinuity.
424 hint - [in/out] if GetNextDiscontinuity will be called
425 repeatedly, passing a "hint" with initial value *hint=0
426 will increase the speed of the search.
427 dtype - [out] if not NULL, *dtype reports the kind of
428 discontinuity found at *t. A value of 1 means the first
429 derivative or unit tangent was discontinuous. A value
430 of 2 means the second derivative or curvature was
431 discontinuous. A value of 0 means teh curve is not
432 closed, a locus discontinuity test was applied, and
433 t1 is at the start of end of the curve.
434 cos_angle_tolerance - [in] default = cos(1 degree) Used only
435 when c is ON::G1_continuous or ON::G2_continuous. If the
436 cosine of the angle between two tangent vectors is
437 <= cos_angle_tolerance, then a G1 discontinuity is reported.
438 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used
439 only when c is ON::G2_continuous. If K0 and K1 are
440 curvatures evaluated from above and below and
441 |K0 - K1| > curvature_tolerance, then a curvature
442 discontinuity is reported.
443 Returns:
444 Parametric continuity tests c = (C0_continuous, ..., G2_continuous):
445
446 true if a parametric discontinuity was found strictly
447 between t0 and t1. Note well that all curves are
448 parametrically continuous at the ends of their domains.
449
450 Locus continuity tests c = (C0_locus_continuous, ...,G2_locus_continuous):
451
452 true if a locus discontinuity was found strictly between
453 t0 and t1 or at t1 is the at the end of a curve.
454 Note well that all open curves (IsClosed()=false) are locus
455 discontinuous at the ends of their domains. All closed
456 curves (IsClosed()=true) are at least C0_locus_continuous at
457 the ends of their domains.
458 */
459 virtual
460 bool GetNextDiscontinuity(
461 ON::continuity c,
462 double t0,
463 double t1,
464 double* t,
465 int* hint=NULL,
466 int* dtype=NULL,
467 double cos_angle_tolerance=0.99984769515639123915701155881391,
468 double curvature_tolerance=ON_SQRT_EPSILON
469 ) const;
470
471 /*
472 Description:
473 Test continuity at a curve parameter value.
474 Parameters:
475 c - [in] type of continuity to test for. Read ON::continuity
476 comments for details.
477 t - [in] parameter to test
478 hint - [in] evaluation hint
479 point_tolerance - [in] if the distance between two points is
480 greater than point_tolerance, then the curve is not C0.
481 d1_tolerance - [in] if the difference between two first derivatives is
482 greater than d1_tolerance, then the curve is not C1.
483 d2_tolerance - [in] if the difference between two second derivatives is
484 greater than d2_tolerance, then the curve is not C2.
485 cos_angle_tolerance - [in] default = cos(1 degree) Used only when
486 c is ON::G1_continuous or ON::G2_continuous. If the cosine
487 of the angle between two tangent vectors
488 is <= cos_angle_tolerance, then a G1 discontinuity is reported.
489 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when
490 c is ON::G2_continuous. If K0 and K1 are curvatures evaluated
491 from above and below and |K0 - K1| > curvature_tolerance,
492 then a curvature discontinuity is reported.
493 Returns:
494 true if the curve has at least the c type continuity at
495 the parameter t.
496 */
497 virtual
498 bool IsContinuous(
499 ON::continuity c,
500 double t,
501 int* hint = NULL,
502 double point_tolerance=ON_ZERO_TOLERANCE,
503 double d1_tolerance=ON_ZERO_TOLERANCE,
504 double d2_tolerance=ON_ZERO_TOLERANCE,
505 double cos_angle_tolerance=0.99984769515639123915701155881391,
506 double curvature_tolerance=ON_SQRT_EPSILON
507 ) const;
508
509
510 // Description:
511 // Reverse the direction of the curve.
512 // Returns:
513 // true if curve was reversed.
514 // Remarks:
515 // If reveresed, the domain changes from [a,b] to [-b,-a]
516 virtual
518
519
520 /*
521 Description:
522 Force the curve to start at a specified point.
523 Parameters:
524 start_point - [in]
525 Returns:
526 true if successful.
527 Remarks:
528 Some end points cannot be moved. Be sure to check return
529 code.
530 See Also:
531 ON_Curve::SetEndPoint
532 ON_Curve::PointAtStart
533 ON_Curve::PointAtEnd
534 */
535 virtual
536 ON_BOOL32 SetStartPoint(
537 ON_3dPoint start_point
538 );
539
540 /*
541 Description:
542 Force the curve to end at a specified point.
543 Parameters:
544 end_point - [in]
545 Returns:
546 true if successful.
547 Remarks:
548 Some end points cannot be moved. Be sure to check return
549 code.
550 See Also:
551 ON_Curve::SetStartPoint
552 ON_Curve::PointAtStart
553 ON_Curve::PointAtEnd
554 */
555 virtual
556 ON_BOOL32 SetEndPoint(
557 ON_3dPoint end_point
558 );
559
560 // Description:
561 // Evaluate point at a parameter.
562 // Parameters:
563 // t - [in] evaluation parameter
564 // Returns:
565 // Point (location of curve at the parameter t).
566 // Remarks:
567 // No error handling.
568 // See Also:
569 // ON_Curve::EvPoint
570 // ON_Curve::PointAtStart
571 // ON_Curve::PointAtEnd
572 ON_3dPoint PointAt(
573 double t
574 ) const;
575
576 // Description:
577 // Evaluate point at the start of the curve.
578 // Parameters:
579 // t - [in] evaluation parameter
580 // Returns:
581 // Point (location of the start of the curve.)
582 // Remarks:
583 // No error handling.
584 // See Also:
585 // ON_Curve::PointAt
586 ON_3dPoint PointAtStart() const;
587
588 // Description:
589 // Evaluate point at the end of the curve.
590 // Parameters:
591 // t - [in] evaluation parameter
592 // Returns:
593 // Point (location of the end of the curve.)
594 // Remarks:
595 // No error handling.
596 // See Also:
597 // ON_Curve::PointAt
598 ON_3dPoint PointAtEnd() const;
599
600 // Description:
601 // Evaluate first derivative at a parameter.
602 // Parameters:
603 // t - [in] evaluation parameter
604 // Returns:
605 // First derivative of the curve at the parameter t.
606 // Remarks:
607 // No error handling.
608 // See Also:
609 // ON_Curve::Ev1Der
610 ON_3dVector DerivativeAt(
611 double t
612 ) const;
613
614 // Description:
615 // Evaluate unit tangent vector at a parameter.
616 // Parameters:
617 // t - [in] evaluation parameter
618 // Returns:
619 // Unit tangent vector of the curve at the parameter t.
620 // Remarks:
621 // No error handling.
622 // See Also:
623 // ON_Curve::EvTangent
624 ON_3dVector TangentAt(
625 double t
626 ) const;
627
628 // Description:
629 // Evaluate the curvature vector at a parameter.
630 // Parameters:
631 // t - [in] evaluation parameter
632 // Returns:
633 // curvature vector of the curve at the parameter t.
634 // Remarks:
635 // No error handling.
636 // See Also:
637 // ON_Curve::EvCurvature
638 ON_3dVector CurvatureAt(
639 double t
640 ) const;
641
642 // Description:
643 // Return a 3d frame at a parameter.
644 // Parameters:
645 // t - [in] evaluation parameter
646 // plane - [out] the frame is returned here
647 // Returns:
648 // true if successful
649 // See Also:
650 // ON_Curve::PointAt, ON_Curve::TangentAt,
651 // ON_Curve::Ev1Der, Ev2Der
652 ON_BOOL32 FrameAt( double t, ON_Plane& plane) const;
653
654 // Description:
655 // Evaluate point at a parameter with error checking.
656 // Parameters:
657 // t - [in] evaluation parameter
658 // point - [out] value of curve at t
659 // side - [in] optional - determines which side to evaluate from
660 // =0 default
661 // <0 to evaluate from below,
662 // >0 to evaluate from above
663 // hint - [in/out] optional evaluation hint used to speed repeated evaluations
664 // Returns:
665 // false if unable to evaluate.
666 // See Also:
667 // ON_Curve::PointAt
668 // ON_Curve::EvTangent
669 // ON_Curve::Evaluate
670 ON_BOOL32 EvPoint(
671 double t,
672 ON_3dPoint& point,
673 int side = 0,
674 int* hint = 0
675 ) const;
676
677 // Description:
678 // Evaluate first derivative at a parameter with error checking.
679 // Parameters:
680 // t - [in] evaluation parameter
681 // point - [out] value of curve at t
682 // first_derivative - [out] value of first derivative at t
683 // side - [in] optional - determines which side to evaluate from
684 // =0 default
685 // <0 to evaluate from below,
686 // >0 to evaluate from above
687 // hint - [in/out] optional evaluation hint used to speed repeated evaluations
688 // Returns:
689 // false if unable to evaluate.
690 // See Also:
691 // ON_Curve::EvPoint
692 // ON_Curve::Ev2Der
693 // ON_Curve::EvTangent
694 // ON_Curve::Evaluate
695 ON_BOOL32 Ev1Der(
696 double t,
697 ON_3dPoint& point,
698 ON_3dVector& first_derivative,
699 int side = 0,
700 int* hint = 0
701 ) const;
702
703 // Description:
704 // Evaluate second derivative at a parameter with error checking.
705 // Parameters:
706 // t - [in] evaluation parameter
707 // point - [out] value of curve at t
708 // first_derivative - [out] value of first derivative at t
709 // second_derivative - [out] value of second derivative at t
710 // side - [in] optional - determines which side to evaluate from
711 // =0 default
712 // <0 to evaluate from below,
713 // >0 to evaluate from above
714 // hint - [in/out] optional evaluation hint used to speed repeated evaluations
715 // Returns:
716 // false if unable to evaluate.
717 // See Also:
718 // ON_Curve::Ev1Der
719 // ON_Curve::EvCurvature
720 // ON_Curve::Evaluate
721 ON_BOOL32 Ev2Der(
722 double t,
723 ON_3dPoint& point,
724 ON_3dVector& first_derivative,
725 ON_3dVector& second_derivative,
726 int side = 0,
727 int* hint = 0
728 ) const;
729
730 /*
731 Description:
732 Evaluate unit tangent at a parameter with error checking.
733 Parameters:
734 t - [in] evaluation parameter
735 point - [out] value of curve at t
736 tangent - [out] value of unit tangent
737 side - [in] optional - determines which side to evaluate from
738 =0 default
739 <0 to evaluate from below,
740 >0 to evaluate from above
741 hint - [in/out] optional evaluation hint used to speed repeated evaluations
742 Returns:
743 false if unable to evaluate.
744 See Also:
745 ON_Curve::TangentAt
746 ON_Curve::Ev1Der
747 */
748 ON_BOOL32 EvTangent(
749 double t,
750 ON_3dPoint& point,
751 ON_3dVector& tangent,
752 int side = 0,
753 int* hint = 0
754 ) const;
755
756 /*
757 Description:
758 Evaluate unit tangent and curvature at a parameter with error checking.
759 Parameters:
760 t - [in] evaluation parameter
761 point - [out] value of curve at t
762 tangent - [out] value of unit tangent
763 kappa - [out] value of curvature vector
764 side - [in] optional - determines which side to evaluate from
765 =0 default
766 <0 to evaluate from below,
767 >0 to evaluate from above
768 hint - [in/out] optional evaluation hint used to speed repeated evaluations
769 Returns:
770 false if unable to evaluate.
771 See Also:
772 ON_Curve::CurvatureAt
773 ON_Curve::Ev2Der
774 ON_EvCurvature
775 */
776 ON_BOOL32 EvCurvature(
777 double t,
778 ON_3dPoint& point,
779 ON_3dVector& tangent,
780 ON_3dVector& kappa,
781 int side = 0,
782 int* hint = 0
783 ) const;
784
785 /*
786 Description:
787 This evaluator actually does all the work. The other ON_Curve
788 evaluation tools call this virtual function.
789 Parameters:
790 t - [in] evaluation parameter ( usually in Domain() ).
791 der_count - [in] (>=0) number of derivatives to evaluate
792 v_stride - [in] (>=Dimension()) stride to use for the v[] array
793 v - [out] array of length (der_count+1)*v_stride
794 curve(t) is returned in (v[0],...,v[m_dim-1]),
795 curve'(t) is retuned in (v[v_stride],...,v[v_stride+m_dim-1]),
796 curve"(t) is retuned in (v[2*v_stride],...,v[2*v_stride+m_dim-1]),
797 etc.
798 side - [in] optional - determines which side to evaluate from
799 =0 default
800 <0 to evaluate from below,
801 >0 to evaluate from above
802 hint - [in/out] optional evaluation hint used to speed repeated evaluations
803 Returns:
804 false if unable to evaluate.
805 See Also:
806 ON_Curve::EvPoint
807 ON_Curve::Ev1Der
808 ON_Curve::Ev2Der
809 */
810 virtual
812 double t,
813 int der_count,
814 int v_stride,
815 double* v,
816 int side = 0,
817 int* hint = 0
818 ) const = 0;
819
821 // Find parameter of the point on a curve that is closest to test_point.
822 // If the maximum_distance parameter is > 0, then only points whose distance
823 // to the given point is <= maximum_distance will be returned. Using a
824 // positive value of maximum_distance can substantially speed up the search.
825 // If the sub_domain parameter is not NULL, then the search is restricted
826 // to the specified portion of the curve.
827 //
828 // true if returned if the search is successful. false is returned if
829 // the search fails.
830 virtual
831 bool GetClosestPoint(
832 const ON_3dPoint&, // test_point
833 double* t, // parameter of local closest point returned here
834 double maximum_distance = 0.0, // maximum_distance
835 const ON_Interval* sub_domain = NULL // sub_domain
836 ) const;
837
839 // Find parameter of the point on a curve that is locally closest to
840 // the test_point. The search for a local close point starts at
841 // seed_parameter. If the sub_domain parameter is not NULL, then
842 // the search is restricted to the specified portion of the curve.
843 //
844 // true if returned if the search is successful. false is returned if
845 // the search fails.
846 virtual
847 ON_BOOL32 GetLocalClosestPoint(
848 const ON_3dPoint& test_point,
849 double seed_parameter,
850 double* t,
851 const ON_Interval* sub_domain = 0
852 ) const;
853
854 /*
855 Description:
856 Find curve's self intersection points.
857 Parameters:
858 x - [out]
859 Intersection events are appended to this array.
860 intersection_tolerance - [in]
861 curve_domain - [in] optional restriction
862 Returns:
863 Number of intersection events appended to x.
864 */
865 virtual
866 int IntersectSelf(
868 double intersection_tolerance = 0.0,
869 const ON_Interval* curve_domain = 0
870 ) const;
871
872 /*
873 Description:
874 Intersect this curve with curveB.
875 Parameters:
876 curveB - [in]
877 x - [out] Intersection events are appended to this array.
878 intersection_tolerance - [in] If the distance from a point
879 on this curve to curveB is <= intersection tolerance,
880 then the point will be part of an intersection event.
881 If the input intersection_tolerance <= 0.0, then 0.001 is used.
882 overlap_tolerance - [in] If t1 and t2 are parameters of this
883 curve's intersection events and the distance from curve(t) to
884 curveB is <= overlap_tolerance for every t1 <= t <= t2,
885 then the event will be returened as an overlap event.
886 If the input overlap_tolerance <= 0.0, then
887 intersection_tolerance*2.0 is used.
888 curveA_domain - [in] optional restriction on this curve's domain
889 curveB_domain - [in] optional restriction on curveB domain
890 Returns:
891 Number of intersection events appended to x.
892 */
893 int IntersectCurve(
894 const ON_Curve* curveB,
896 double intersection_tolerance = 0.0,
897 double overlap_tolerance = 0.0,
898 const ON_Interval* curveA_domain = 0,
899 const ON_Interval* curveB_domain = 0
900 ) const;
901
902 /*
903 Description:
904 Intersect this curve with surfaceB.
905
906 Parameters:
907 surfaceB - [in]
908
909 x - [out]
910 Intersection events are appended to this array.
911 intersection_tolerance - [in]
912 If the distance from a point on this curve to the surface
913 is <= intersection tolerance, then the point will be part
914 of an intersection event, or there is an intersection event
915 the point leads to. If the input intersection_tolerance <= 0.0,
916 then 0.001 is used.
917
918 overlap_tolerance - [in]
919 If the input overlap_tolerance <= 0.0, then
920 2.0*intersection_tolerance is used. Otherwise, overlap
921 tolerance must be >= intersection_tolerance.
922 In all cases, the intersection calculation is performed
923 with an overlap_tolerance that is >= intersection_tolerance.
924 If t1 and t2 are curve parameters of intersection events
925 and the distance from curve(t) to the surface
926 is <= overlap_tolerance for every t1 <= t <= t2, then the
927 event will be returned as an overlap event.
928
929 curveA_domain - [in]
930 optional restriction on this curve's domain
931
932 surfaceB_udomain - [in]
933 optional restriction on surfaceB u domain
934
935 surfaceB_vdomain - [in]
936 optional restriction on surfaceB v domain
937
938 Returns:
939 Number of intersection events appended to x.
940 */
941 int IntersectSurface(
942 const ON_Surface* surfaceB,
944 double intersection_tolerance = 0.0,
945 double overlap_tolerance = 0.0,
946 const ON_Interval* curveA_domain = 0,
947 const ON_Interval* surfaceB_udomain = 0,
948 const ON_Interval* surfaceB_vdomain = 0
949 ) const;
950
951
952 /*
953 Description:
954 Get the length of the curve.
955 Parameters:
956 length - [out] length returned here.
957 fractional_tolerance - [in] desired fractional precision.
958 fabs(("exact" length from start to t) - arc_length)/arc_length <= fractional_tolerance
959 sub_domain - [in] If not NULL, the calculation is performed on
960 the specified sub-domain of the curve (must be non-decreasing)
961 Returns:
962 true if returned if the length calculation is successful.
963 false is returned if the length is not calculated.
964 Remarks:
965 The arc length will be computed so that
966 (returned length - real length)/(real length) <= fractional_tolerance
967 More simply, if you want N significant figures in the answer, set the
968 fractional_tolerance to 1.0e-N. For "nice" curves, 1.0e-8 works
969 fine. For very high degree NURBS and NURBS with bad parameterizations,
970 use larger values of fractional_tolerance.
971 */
972 virtual
973 ON_BOOL32 GetLength(
974 double* length,
975 double fractional_tolerance = 1.0e-8,
976 const ON_Interval* sub_domain = NULL
977 ) const;
978
979 // obsolete - use ON_Curve::GetLength
980 //__declspec(deprecated) ON_BOOL32 Length(
981 // double* length,
982 // double fractional_tolerance = 1.0e-8,
983 // const ON_Interval* sub_domain = NULL
984 // ) const;
985
986 /*
987 Description:
988 Used to quickly find short curves.
989 Parameters:
990 tolerance - [in] (>=0)
991 sub_domain - [in] If not NULL, the test is performed
992 on the interval that is the intersection of
993 sub_domain with Domain().
994 Returns:
995 True if the length of the curve is <= tolerance.
996 Remarks:
997 Faster than calling Length() and testing the
998 result.
999 */
1000 bool IsShort(
1001 double tolerance,
1002 const ON_Interval* sub_domain = NULL
1003 ) const;
1004
1005 /*
1006 Description:
1007 Looks for segments that are shorter than tolerance
1008 that can be removed. If bRemoveShortSegments is true,
1009 then the short segments are removed. Does not change the
1010 domain, but it will change the relative parameterization.
1011 Parameters:
1012 tolerance - [in]
1013 bRemoveShortSegments - [in] If true, then short segments
1014 are removed.
1015 Returns:
1016 True if removable short segments can were found.
1017 False if no removable short segments can were found.
1018 */
1019 bool RemoveShortSegments(
1020 double tolerance,
1021 bool bRemoveShortSegments = true
1022 );
1023
1024 /*
1025 Description:
1026 Get the parameter of the point on the curve that is a
1027 prescribed arc length from the start of the curve.
1028 Parameters:
1029 s - [in] normalized arc length parameter. E.g., 0 = start
1030 of curve, 1/2 = midpoint of curve, 1 = end of curve.
1031 t - [out] parameter such that the length of the curve
1032 from its start to t is arc_length.
1033 fractional_tolerance - [in] desired fractional precision.
1034 fabs(("exact" length from start to t) - arc_length)/arc_length <= fractional_tolerance
1035 sub_domain - [in] If not NULL, the calculation is performed on
1036 the specified sub-domain of the curve.
1037 Returns:
1038 true if successful
1039 */
1040 virtual
1041 ON_BOOL32 GetNormalizedArcLengthPoint(
1042 double s,
1043 double* t,
1044 double fractional_tolerance = 1.0e-8,
1045 const ON_Interval* sub_domain = NULL
1046 ) const;
1047
1048 /*
1049 Description:
1050 Get the parameter of the point on the curve that is a
1051 prescribed arc length from the start of the curve.
1052 Parameters:
1053 count - [in] number of parameters in s.
1054 s - [in] array of normalized arc length parameters. E.g., 0 = start
1055 of curve, 1/2 = midpoint of curve, 1 = end of curve.
1056 t - [out] array of curve parameters such that the length of the
1057 curve from its start to t[i] is s[i]*curve_length.
1058 absolute_tolerance - [in] if absolute_tolerance > 0, then the difference
1059 between (s[i+1]-s[i])*curve_length and the length of the curve
1060 segment from t[i] to t[i+1] will be <= absolute_tolerance.
1061 fractional_tolerance - [in] desired fractional precision for each segment.
1062 fabs("true" length - actual length)/(actual length) <= fractional_tolerance
1063 sub_domain - [in] If not NULL, the calculation is performed on
1064 the specified sub-domain of the curve. A 0.0 s value corresponds to
1065 sub_domain->Min() and a 1.0 s value corresponds to sub_domain->Max().
1066 Returns:
1067 true if successful
1068 */
1069 virtual
1070 ON_BOOL32 GetNormalizedArcLengthPoints(
1071 int count,
1072 const double* s,
1073 double* t,
1074 double absolute_tolerance = 0.0,
1075 double fractional_tolerance = 1.0e-8,
1076 const ON_Interval* sub_domain = NULL
1077 ) const;
1078
1079 // Description:
1080 // Removes portions of the curve outside the specified interval.
1081 // Parameters:
1082 // domain - [in] interval of the curve to keep. Portions of the
1083 // curve before curve(domain[0]) and after curve(domain[1]) are
1084 // removed.
1085 // Returns:
1086 // true if successful.
1087 virtual
1089 const ON_Interval& domain
1090 );
1091
1092 // Description:
1093 // Pure virtual function. Default returns false.
1094 // Where possible, analytically extends curve to include domain.
1095 // Parameters:
1096 // domain - [in] if domain is not included in curve domain,
1097 // curve will be extended so that its domain includes domain.
1098 // Will not work if curve is closed. Original curve is identical
1099 // to the restriction of the resulting curve to the original curve domain,
1100 // Returns:
1101 // true if successful.
1102 virtual
1103 bool Extend(
1104 const ON_Interval& domain
1105 );
1106
1107 /*
1108 Description:
1109 Splits (divides) the curve at the specified parameter.
1110 The parameter must be in the interior of the curve's domain.
1111 The pointers passed to Split must either be NULL or point to
1112 an ON_Curve object of the same type. If the pointer is NULL,
1113 then a curve will be created in Split(). You may pass "this"
1114 as left_side or right_side.
1115 Parameters:
1116 t - [in] parameter to split the curve at in the
1117 interval returned by Domain().
1118 left_side - [out] left portion of curve returned here
1119 right_side - [out] right portion of curve returned here
1120 Returns:
1121 true - The curve was split into two pieces.
1122 false - The curve could not be split. For example if the parameter is
1123 too close to an endpoint.
1124
1125 Example:
1126 For example, if crv were an ON_NurbsCurve, then
1127
1128 ON_NurbsCurve right_side;
1129 crv.Split( crv.Domain().Mid() &crv, &right_side );
1130
1131 would split crv at the parametric midpoint, put the left side
1132 in crv, and return the right side in right_side.
1133 */
1134 virtual
1135 ON_BOOL32 Split(
1136 double t,
1137 ON_Curve*& left_side,
1138 ON_Curve*& right_side
1139 ) const;
1140
1141 /*
1142 Description:
1143 Get a NURBS curve representation of this curve.
1144 Parameters:
1145 nurbs_curve - [out] NURBS representation returned here
1146 tolerance - [in] tolerance to use when creating NURBS
1147 representation.
1148 subdomain - [in] if not NULL, then the NURBS representation
1149 for this portion of the curve is returned.
1150 Returns:
1151 0 unable to create NURBS representation
1152 with desired accuracy.
1153 1 success - returned NURBS parameterization
1154 matches the curve's to wthe desired accuracy
1155 2 success - returned NURBS point locus matches
1156 the curve's to the desired accuracy and the
1157 domain of the NURBS curve is correct. On
1158 However, This curve's parameterization and
1159 the NURBS curve parameterization may not
1160 match to the desired accuracy. This situation
1161 happens when getting NURBS representations of
1162 curves that have a transendental parameterization
1163 like circles
1164 Remarks:
1165 This is a low-level virtual function. If you do not need
1166 the parameterization information provided by the return code,
1167 then ON_Curve::NurbsCurve may be easier to use.
1168 See Also:
1169 ON_Curve::NurbsCurve
1170 */
1171 virtual
1172 int GetNurbForm(
1173 ON_NurbsCurve& nurbs_curve,
1174 double tolerance = 0.0,
1175 const ON_Interval* subdomain = NULL
1176 ) const;
1177 /*
1178 Description:
1179 Does a NURBS curve representation of this curve.
1180 Parameters:
1181 Returns:
1182 0 unable to create NURBS representation
1183 with desired accuracy.
1184 1 success - NURBS parameterization
1185 matches the curve's to wthe desired accuracy
1186 2 success - NURBS point locus matches
1187 the curve's and the
1188 domain of the NURBS curve is correct.
1189 However, This curve's parameterization and
1190 the NURBS curve parameterization may not
1191 match. This situation
1192 happens when getting NURBS representations of
1193 curves that have a transendental parameterization
1194 like circles
1195 Remarks:
1196 This is a low-level virtual function.
1197 See Also:
1198 ON_Curve::GetNurbForm
1199 ON_Curve::NurbsCurve
1200 */
1201 virtual
1202 int HasNurbForm() const;
1203
1204 /*
1205 Description:
1206 Get a NURBS curve representation of this curve.
1207 Parameters:
1208 pNurbsCurve - [in/out] if not NULL, this ON_NurbsCurve
1209 will be used to store the NURBS representation
1210 of the curve will be returned.
1211 tolerance - [in] tolerance to use when creating NURBS
1212 representation.
1213 subdomain - [in] if not NULL, then the NURBS representation
1214 for this portion of the curve is returned.
1215 Returns:
1216 NULL or a NURBS representation of the curve.
1217 Remarks:
1218 See ON_Surface::GetNurbForm for important details about
1219 the NURBS surface parameterization.
1220 See Also:
1221 ON_Curve::GetNurbForm
1222 */
1223 ON_NurbsCurve* NurbsCurve(
1224 ON_NurbsCurve* pNurbsCurve = NULL,
1225 double tolerance = 0.0,
1226 const ON_Interval* subdomain = NULL
1227 ) const;
1228
1229 // Description:
1230 // Convert a NURBS curve parameter to a curve parameter
1231 //
1232 // Parameters:
1233 // nurbs_t - [in] nurbs form parameter
1234 // curve_t - [out] curve parameter
1235 //
1236 // Remarks:
1237 // If GetNurbForm returns 2, this function converts the curve
1238 // parameter to the NURBS curve parameter.
1239 //
1240 // See Also:
1241 // ON_Curve::GetNurbForm, ON_Curve::GetNurbFormParameterFromCurveParameter
1242 virtual
1243 ON_BOOL32 GetCurveParameterFromNurbFormParameter(
1244 double nurbs_t,
1245 double* curve_t
1246 ) const;
1247
1248 // Description:
1249 // Convert a curve parameter to a NURBS curve parameter.
1250 //
1251 // Parameters:
1252 // curve_t - [in] curve parameter
1253 // nurbs_t - [out] nurbs form parameter
1254 //
1255 // Remarks:
1256 // If GetNurbForm returns 2, this function converts the curve
1257 // parameter to the NURBS curve parameter.
1258 //
1259 // See Also:
1260 // ON_Curve::GetNurbForm, ON_Curve::GetCurveParameterFromNurbFormParameter
1261 virtual
1262 ON_BOOL32 GetNurbFormParameterFromCurveParameter(
1263 double curve_t,
1264 double* nurbs_t
1265 ) const;
1266
1267
1268 // Description:
1269 // Destroys the runtime curve tree used to speed closest
1270 // point and intersection calcuations.
1271 // Remarks:
1272 // If the geometry of the curve is modified in any way,
1273 // then call DestroyCurveTree(); The curve tree is
1274 // created as needed.
1275 void DestroyCurveTree();
1276
1277 // Description:
1278 // Get the runtime curve tree used to speed closest point
1279 // and intersection calcuations.
1280 // Returns:
1281 // Pointer to the curve tree.
1282 const ON_CurveTree* CurveTree() const;
1283
1284 virtual
1285 ON_CurveTree* CreateCurveTree() const;
1286
1287 /*
1288 Description:
1289 Calculate length mass properties of the curve.
1290 Parameters:
1291 mp - [out]
1292 bLength - [in] true to calculate length
1293 bFirstMoments - [in] true to calculate volume first moments,
1294 length, and length centroid.
1295 bSecondMoments - [in] true to calculate length second moments.
1296 bProductMoments - [in] true to calculate length product moments.
1297 Returns:
1298 True if successful.
1299 */
1300 bool LengthMassProperties(
1301 ON_MassProperties& mp,
1302 bool bLength = true,
1303 bool bFirstMoments = true,
1304 bool bSecondMoments = true,
1305 bool bProductMoments = true,
1306 double rel_tol = 1.0e-6,
1307 double abs_tol = 1.0e-6
1308 ) const;
1309
1310 /*
1311 Description:
1312 Calculate area mass properties of a curve. The curve should
1313 be planar.
1314 Parameters:
1315 base_point - [in]
1316 A point on the plane that contians the curve. To get
1317 the best results, the point should be in the near the
1318 curve's centroid.
1319
1320 When computing the area, area centroid, or area first
1321 moments of a planar area whose boundary is defined by
1322 several curves, pass the same base_point and plane_normal
1323 to each call to AreaMassProperties. The base_point must
1324 be in the plane of the curves.
1325
1326 When computing the area second moments or area product
1327 moments of a planar area whose boundary is defined by several
1328 curves, you MUST pass the entire area's centroid as the
1329 base_point and the input mp parameter must contain the
1330 results of a previous call to
1331 AreaMassProperties(mp,true,true,false,false,base_point).
1332 In particular, in this case, you need to make two sets of
1333 calls; use first set to calculate the area centroid and
1334 the second set calculate the second moments and product
1335 moments.
1336 plane_normal - [in]
1337 nonzero unit normal to the plane of integration. If a closed
1338 curve has counter clock-wise orientation with respect to
1339 this normal, the area will be positive. If the a closed curve
1340 has clock-wise orientation with respect to this normal, the
1341 area will be negative.
1342 mp - [out]
1343 bArea - [in] true to calculate volume
1344 bFirstMoments - [in] true to calculate area first moments,
1345 area, and area centroid.
1346 bSecondMoments - [in] true to calculate area second moments.
1347 bProductMoments - [in] true to calculate area product moments.
1348 Returns:
1349 True if successful.
1350 */
1351 bool AreaMassProperties(
1352 ON_3dPoint base_point,
1353 ON_3dVector plane_normal,
1354 ON_MassProperties& mp,
1355 bool bArea = true,
1356 bool bFirstMoments = true,
1357 bool bSecondMoments = true,
1358 bool bProductMoments = true,
1359 double rel_tol = 1.0e-6,
1360 double abs_tol = 1.0e-6
1361 ) const;
1362
1363 /*
1364 Description:
1365 Mesh a curve into line segments.
1366 Parameters:
1367 mp - [in]
1368 Parameters that determine how the curve will be
1369 approximated by a polyline.
1370 polyline - [in]
1371 If not NULL, the polyline approximation will be appended
1372 to this polyline.
1373 bSkipFirstPoint - [in]
1374 If true, the starting point of the approximation
1375 will not be added to the returned polyline. This
1376 parameter is useful when getting a polyline approximation
1377 of a sequence of contiguous curves.
1378 domain - [in]
1379 If not NULL, the polyline approximation will be restricted
1380 to this domain.
1381 Returns:
1382 A pointer to the polyline approximation.
1383 */
1384 class ON_PolylineCurve* MeshCurve(
1386 ON_PolylineCurve* polyline,
1387 bool bSkipFirstPoint,
1388 const ON_Interval* domain
1389 ) const;
1390
1391 // The non-const version of MeshCurve() exists because a version of the
1392 // SDK was shipped with the "const" tag missing. The non-const
1393 // version does not modify this.
1394 class ON_PolylineCurve* MeshCurve(
1396 ON_PolylineCurve* polyline,
1397 bool bSkipFirstPoint,
1398 const ON_Interval* domain
1399 );
1400
1401 /*
1402 Description:
1403 Lookup a parameter in the m_t array, optionally using a built in snap tolerance to
1404 snap a parameter value to an element of m_t.
1405 This function is used by some types derived from ON_Curve to snap parameter values
1406 Parameters:
1407 t - [in] parameter
1408 index -[out] index into m_t such that
1409 if function returns false then
1410
1411 @table
1412 value condition
1413 -1 t<m_t[0] or m_t is empty
1414 0<=i<=m_t.Count()-2 m_t[i] < t < m_t[i+1]
1415 m_t.Count()-1 t>m_t[ m_t.Count()-1]
1416
1417 if the function returns true then t is equal to, or is closest to and
1418 within tolerance of m_t[index].
1419
1420 bEnableSnap-[in] enable snapping
1421 m_t -[in] Array of parameter values to snap to
1422 RelTol -[in] tolerance used in snapping
1423
1424 Returns:
1425 true if the t is exactly equal to (bEnableSnap==false), or within tolerance of
1426 (bEnableSnap==true) m_t[index].
1427 */
1428 protected:
1429 bool ParameterSearch( double t, int& index, bool bEnableSnap, const ON_SimpleArray<double>& m_t,
1430 double RelTol=ON_SQRT_EPSILON) const;
1431
1432protected:
1433 // Runtime only - ignored by Read()/Write()
1434 ON_CurveTree* CurveTreeHelper();
1435 ON_CurveTree* m_ctree;
1436};
1437
1438#if defined(ON_DLL_TEMPLATE)
1439// This stuff is here because of a limitation in the way Microsoft
1440// handles templates and DLLs. See Microsoft's knowledge base
1441// article ID Q168958 for details.
1442#pragma warning( push )
1443#pragma warning( disable : 4231 )
1444ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_Curve*>;
1445#pragma warning( pop )
1446#endif
1447
1449{
1450public:
1451 ON_CurveArray( int = 0 );
1452 ~ON_CurveArray(); // deletes any non-NULL curves
1453
1454 bool Write( ON_BinaryArchive& ) const;
1455 bool Read( ON_BinaryArchive& );
1456
1457 void Destroy(); // deletes curves, sets pointers to NULL, sets count to zero
1458
1459 bool Duplicate( ON_CurveArray& ) const; // operator= copies the pointer values
1460 // duplicate copies the curves themselves
1461
1462 /*
1463 Description:
1464 Get tight bounding box of the bezier.
1465 Parameters:
1466 tight_bbox - [in/out] tight bounding box
1467 bGrowBox -[in] (default=false)
1468 If true and the input tight_bbox is valid, then returned
1469 tight_bbox is the union of the input tight_bbox and the
1470 tight bounding box of the bezier curve.
1471 xform -[in] (default=NULL)
1472 If not NULL, the tight bounding box of the transformed
1473 bezier is calculated. The bezier curve is not modified.
1474 Returns:
1475 True if the returned tight_bbox is set to a valid
1476 bounding box.
1477 */
1478 bool GetTightBoundingBox(
1479 ON_BoundingBox& tight_bbox,
1480 int bGrowBox = false,
1481 const ON_Xform* xform = 0
1482 ) const;
1483};
1484
1485/*
1486Description:
1487 Trim a curve.
1488Parameters:
1489 curve - [in] curve to trim (not modified)
1490 trim_parameters - [in] trimming parameters
1491 If curve is open, then trim_parameters must be an increasing
1492 interval.If curve is closed, and trim_parameters ins a
1493 decreasing interval, then the portion of the curve across the
1494 start/end is returned.
1495Returns:
1496 trimmed curve or NULL if input is invalid.
1497*/
1498ON_DECL
1500 const ON_Curve& curve,
1501 ON_Interval trim_parameters
1502 );
1503
1504/*
1505Description:
1506 Move ends of curves to a common point. Neither curve can be closed or an ON_CurveProxy.
1507 If one is an arc or polycurve with arc at end to change, and the other is not,
1508 then the arc is left unchanged and the other curve is moved to the arc endpoint.
1509 Otherwise, both are moved to the midpoint of the segment between the ends.
1510Parameters:
1511 Crv0 - [in] first curve to modify.
1512 [out] with one endpoint possibly changed.
1513 end0 - [in] if 0, change start of Crv0. Otherwise change end.
1514 Crv1 - [in] second curve to modify.
1515 [out] with one endpoint possibly changed.
1516 end1 - [in] if 0, change start of Crv1. Otherwise change end.
1517Returns:
1518 true if the endpoints match. Falsse otherwise,
1519*/
1520ON_DECL
1522 ON_Curve& Crv0,
1523 int end0,
1524 ON_Curve& Crv1,
1525 int end1
1526 );
1527
1528/*
1529Description:
1530 Join all contiguous curves of an array of ON_Curves.
1531Parameters:
1532 InCurves - [in] Array of curves to be joined (not modified)
1533 OutCurves - [out] Resulting joined curves and copies of curves that were not joined to anything
1534 are appended.
1535 join_tol - [in] Distance tolerance used to decide if endpoints are close enough
1536 bPreserveDirection - [in] If true, curve endpoints will be compared to curve startpoints.
1537 If false, all start and endpoints will be compared, and copies of input
1538 curves may be reversed in output.
1539 key - [out] if key is not null, InCurves[i] was joined into OutCurves[key[i]].
1540Returns:
1541 Number of curves added to Outcurves
1542Remarks:
1543 Closed curves are copied to OutCurves.
1544 Curves that cannot be joined to others are copied to OutCurves. When curves are joined, the results
1545 are ON_PolyCurves. All members of InCurves must have same dimension, at most 3.
1546 */
1547ON_DECL
1549 ON_SimpleArray<ON_Curve*>& OutCurves,
1550 double join_tol,
1551 bool bPreserveDirection = false,
1552 ON_SimpleArray<int>* key = 0
1553 );
1554
1555
1556/*
1557Description:
1558 Sort a list of lines so they are geometrically continuous.
1559Parameters:
1560 line_count - [in] number of lines
1561 line_list - [in] array of lines
1562 index - [out] The input index[] is an array of line_count unused integers.
1563 The returned index[] is a permutation of {0,1,...,line_count-1}
1564 so that the list of lines is in end-to-end order.
1565 bReverse - [out] The input bReverse[] is an array of line_count unused bools.
1566 If the returned value of bReverse[j] is true, then
1567 line_list[index[j]] needs to be reversed.
1568Returns:
1569 True if successful, false if not.
1570*/
1571ON_DECL
1572bool ON_SortLines(
1573 int line_count,
1574 const ON_Line* line_list,
1575 int* index,
1576 bool* bReverse
1577 );
1578
1579/*
1580Description:
1581 Sort a list of lines so they are geometrically continuous.
1582Parameters:
1583 line_list - [in] array of lines
1584 index - [out] The input index[] is an array of line_count unused integers.
1585 The returned index[] is a permutation of {0,1,...,line_count-1}
1586 so that the list of lines is in end-to-end order.
1587 bReverse - [out] The input bReverse[] is an array of line_count unused bools.
1588 If the returned value of bReverse[j] is true, then
1589 line_list[index[j]] needs to be reversed.
1590Returns:
1591 True if successful, false if not.
1592*/
1593ON_DECL
1594bool ON_SortLines(
1595 const ON_SimpleArray<ON_Line>& line_list,
1596 int* index,
1597 bool* bReverse
1598 );
1599
1600/*
1601Description:
1602 Sort a list of open curves so end of a curve matches the start of the next curve.
1603Parameters:
1604 curve_count - [in] number of curves
1605 curve_list - [in] array of curve pointers
1606 index - [out] The input index[] is an array of curve_count unused integers.
1607 The returned index[] is a permutation of {0,1,...,curve_count-1}
1608 so that the list of curves is in end-to-end order.
1609 bReverse - [out] The input bReverse[] is an array of curve_count unused bools.
1610 If the returned value of bReverse[j] is true, then
1611 curve_list[index[j]] needs to be reversed.
1612Returns:
1613 True if successful, false if not.
1614*/
1615ON_DECL
1616bool ON_SortCurves(
1617 int curve_count,
1618 const ON_Curve* const* curve_list,
1619 int* index,
1620 bool* bReverse
1621 );
1622
1623/*
1624Description:
1625 Sort a list of curves so end of a curve matches the start of the next curve.
1626Parameters:
1627 curve - [in] array of curves to sort. The curves themselves are not modified.
1628 index - [out] The input index[] is an array of curve_count unused integers.
1629 The returned index[] is a permutation of {0,1,...,curve_count-1}
1630 so that the list of curves is in end-to-end order.
1631 bReverse - [out] The input bReverse[] is an array of curve_count unused bools.
1632 If the returned value of bReverse[j] is true, then
1633 curve[index[j]] needs to be reversed.
1634Returns:
1635 True if successful, false if not.
1636*/
1637ON_DECL
1638bool ON_SortCurves(
1639 const ON_SimpleArray<const ON_Curve*>& curves,
1640 ON_SimpleArray<int>& index,
1641 ON_SimpleArray<bool>& bReverse
1642 );
1643
1644/*
1645Description:
1646 Sort a list of curves so end of a curve matches the start of the next curve.
1647Parameters:
1648 curve_count - [in] number of curves
1649 curve - [in] array of curve pointers
1650 index - [out] The input index[] is an array of curve_count unused integers.
1651 The returned index[] is a permutation of {0,1,...,curve_count-1}
1652 so that the list of curves is in end-to-end order.
1653 bReverse - [out] The input bReverse[] is an array of curve_count unused bools.
1654 If the returned value of bReverse[j] is true, then
1655 curve[index[j]] needs to be reversed.
1656Returns:
1657 True if successful, false if not.
1658*/
1659ON_DECL
1660bool ON_SortCurves(
1661 const ON_SimpleArray<ON_Curve*>& curves,
1662 ON_SimpleArray<int>& index,
1663 ON_SimpleArray<bool>& bReverse
1664 );
1665
1666/*
1667Description:
1668 Determine the orientaion (counterclockwise or clockwise) of a closed
1669 planar curve.
1670Paramters:
1671 curve - [in] simple (no self intersections) closed planar curve
1672 xform - [in] Transformation to map the curve to the xy plane. If the
1673 curve is parallel to the xy plane, you may pass NULL.
1674Returns:
1675 +1: The curve's orientation is counter clockwise in the xy plane.
1676 -1: The curve's orientation is clockwise in the xy plane.
1677 0: Unable to compute the curve's orientation.
1678*/
1679ON_DECL
1680int ON_ClosedCurveOrientation( const ON_Curve& curve, const ON_Xform* xform );
1681
1682#endif
Copies the current selection to the clipboard.
Definition Duplicate.js:12
Definition opennurbs_point.h:403
Definition opennurbs_point.h:931
Definition opennurbs_arc.h:34
Definition opennurbs_archive.h:152
Definition opennurbs_bounding_box.h:25
Definition opennurbs_curve.h:1449
Definition opennurbs_curve.h:88
ON_OBJECT_DECLARE(ON_Curve)
virtual ON_BOOL32 Evaluate(double t, int der_count, int v_stride, double *v, int side=0, int *hint=0) const =0
virtual int Degree() const =0
ON_CurveTree * m_ctree
Definition opennurbs_curve.h:1435
ON_CurveTree * CurveTreeHelper()
virtual ON_BOOL32 Reverse()=0
virtual int SpanCount() const =0
virtual ON_BOOL32 GetSpanVector(double *knots) const =0
virtual ON_Interval Domain() const =0
virtual ON_BOOL32 IsInPlane(const ON_Plane &test_plane, double tolerance=ON_ZERO_TOLERANCE) const =0
Definition opennurbs_ellipse.h:23
Definition opennurbs_geometry.h:36
virtual bool GetTightBoundingBox(ON_BoundingBox &tight_bbox, int bGrowBox=false, const ON_Xform *xform=0) const
Definition opennurbs_geometry.cpp:98
virtual bool EvaluatePoint(const class ON_ObjRef &objref, ON_3dPoint &P) const
Definition opennurbs_geometry.cpp:247
ON_Geometry & operator=(const ON_Geometry &)
Definition opennurbs_geometry.cpp:26
Definition opennurbs_point.h:46
Definition opennurbs_line.h:20
Definition opennurbs_massprop.h:25
Definition opennurbs_curve.h:37
int m_reserved1
Definition opennurbs_curve.h:52
double m_max_ang_radians
Definition opennurbs_curve.h:57
double m_reserved3
Definition opennurbs_curve.h:83
double m_tolerance
Definition opennurbs_curve.h:73
ON_MeshCurveParameters()
Definition opennurbs_mesh.cpp:603
int m_main_seg_count
Definition opennurbs_curve.h:49
int m_reserved2
Definition opennurbs_curve.h:53
double m_max_aspect
Definition opennurbs_curve.h:68
double m_max_chr
Definition opennurbs_curve.h:61
int m_sub_seg_count
Definition opennurbs_curve.h:50
double m_min_edge_length
Definition opennurbs_curve.h:77
double m_reserved4
Definition opennurbs_curve.h:84
double m_max_edge_length
Definition opennurbs_curve.h:81
Definition opennurbs_nurbscurve.h:27
Definition opennurbs_objref.h:167
virtual unsigned int SizeOf() const
Definition opennurbs_object.cpp:1677
virtual ON::object_type ObjectType() const
Definition opennurbs_object.cpp:1616
virtual void DestroyRuntimeCache(bool bDelete=true)
Definition opennurbs_object.cpp:1757
Definition opennurbs_plane.h:20
Definition opennurbs_polylinecurve.h:21
ON_BOOL32 Write(ON_BinaryArchive &binary_archive) const
Definition opennurbs_polylinecurve.cpp:175
ON_BOOL32 Read(ON_BinaryArchive &binary_archive)
Definition opennurbs_polylinecurve.cpp:186
bool GetTightBoundingBox(ON_BoundingBox &tight_bbox, int bGrowBox=false, const ON_Xform *xform=0) const
Definition opennurbs_bezier.cpp:816
Definition opennurbs_array.h:46
Definition opennurbs_surface.h:58
Definition opennurbs_xform.h:28
Trims an entity to another entity or trims both entities if this.trimBoth is true.
Definition Trim.js:12
ON_DECL ON_Curve * ON_TrimCurve(const ON_Curve &curve, ON_Interval trim_parameters)
Definition opennurbs_curve.cpp:2530
ON_DECL bool ON_ForceMatchCurveEnds(ON_Curve &Crv0, int end0, ON_Curve &Crv1, int end1)
Definition opennurbs_curve.cpp:1899
ON_DECL int ON_ClosedCurveOrientation(const ON_Curve &curve, const ON_Xform *xform)
Definition opennurbs_brep.cpp:6722
ON_DECL bool ON_SortCurves(int curve_count, const ON_Curve *const *curve_list, int *index, bool *bReverse)
Definition opennurbs_curve.cpp:3401
ON_DECL int ON_JoinCurves(const ON_SimpleArray< const ON_Curve * > &InCurves, ON_SimpleArray< ON_Curve * > &OutCurves, double join_tol, bool bPreserveDirection=false, ON_SimpleArray< int > *key=0)
Definition opennurbs_curve.cpp:2886
ON_DECL bool ON_SortLines(int line_count, const ON_Line *line_list, int *index, bool *bReverse)
Definition opennurbs_curve.cpp:3292
#define ON_ZERO_TOLERANCE
Definition opennurbs_defines.h:238
#define ON_DECL
Definition opennurbs_defines.h:92
#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