This repository has been archived by the owner on May 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
opennurbs_curve.h
1471 lines (1349 loc) · 49.4 KB
/
opennurbs_curve.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* $NoKeywords: $ */
/*
//
// Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
// McNeel & Associates.
//
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
// MERCHANTABILITY ARE HEREBY DISCLAIMED.
//
// For complete openNURBS copyright information see <http://www.opennurbs.org>.
//
////////////////////////////////////////////////////////////////
*/
////////////////////////////////////////////////////////////////
//
// Definition of virtual parametric curve
//
////////////////////////////////////////////////////////////////
#if !defined(OPENNURBS_CURVE_INC_)
#define OPENNURBS_CURVE_INC_
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
class ON_CLASS ON_MeshCurveParameters
{
public:
ON_MeshCurveParameters();
// If main_seg_count <= 0, then both these parameters are ignored.
// If main_seg_count > 0, then sub_seg_count must be >= 1. In this
// case the curve will be broken into main_seg_count equally spaced
// chords. If needed, each of these chords can be split into as many
// sub_seg_count sub-parts if the subdivision is necessary for the
// mesh to meet the other meshing constraints. In particular, if
// sub_seg_count = 0, then the curve is broken into main_seg_count
// pieces and no further testing is performed.
int m_main_seg_count;
int m_sub_seg_count;
int m_reserved1;
int m_reserved2;
// Maximum angle (in radians) between unit tangents at adjacent
// vertices.
double m_max_ang_radians;
// Maximum permitted value of
// distance chord midpoint to curve) / (length of chord)
double m_max_chr;
// If max_aspect < 1.0, the parameter is ignored.
// If 1 <= max_aspect < sqrt(2), it is treated as if
// max_aspect = sqrt(2).
// This parameter controls the maximum permitted value of
// (length of longest chord) / (length of shortest chord)
double m_max_aspect;
// If tolerance = 0, the parameter is ignored.
// This parameter controls the maximum permitted value of the
// distance from the curve to the mesh.
double m_tolerance;
// If m_min_edge_length = 0, the parameter is ignored.
// This parameter controls the minimum permitted edge length.
double m_min_edge_length;
// If max_edge_length = 0, the parameter is ignored.
// This parameter controls the maximum permitted edge length.
double m_max_edge_length;
double m_reserved3;
double m_reserved4;
};
/*
Description:
ON_Curve is a pure virtual class for curve objects
- Any class derived from ON_Curve should have a
ON_OBJECT_DECLARE(ON_...);
at the beginning of its class definition and a
ON_OBJECT_IMPLEMENT( ON_..., ON_Curve );
in a .cpp file.
Example:
- See the definition of ON_NurbsCurve for an example.
*/
class ON_CLASS ON_Curve : public ON_Geometry
{
ON_OBJECT_DECLARE(ON_Curve);
public:
ON_Curve() ON_NOEXCEPT;
virtual ~ON_Curve();
ON_Curve(const ON_Curve&);
ON_Curve& operator=(const ON_Curve&);
#if defined(ON_HAS_RVALUEREF)
// rvalue copy constructor
ON_Curve( ON_Curve&& ) ON_NOEXCEPT;
// The rvalue assignment operator calls ON_Object::operator=(ON_Object&&)
// which could throw exceptions. See the implementation of
// ON_Object::operator=(ON_Object&&) for details.
ON_Curve& operator=( ON_Curve&& );
#endif
public:
// virtual ON_Object::DestroyRuntimeCache override
void DestroyRuntimeCache( bool bDelete = true ) override;
// virtual ON_Object::SizeOf override
unsigned int SizeOf() const override;
// virtual ON_Geometry override
bool EvaluatePoint( const class ON_ObjRef& objref, ON_3dPoint& P ) const override;
/*
Description:
Get a duplicate of the curve.
Returns:
A duplicate of the curve.
Remarks:
The caller must delete the returned curve.
For non-ON_CurveProxy objects, this simply duplicates the curve using
ON_Object::Duplicate.
For ON_CurveProxy objects, this duplicates the actual proxy curve
geometry and, if necessary, trims and reverse the result to that
the returned curve's parameterization and locus match the proxy curve's.
*/
virtual
ON_Curve* DuplicateCurve() const;
// Description:
// overrides virtual ON_Object::ObjectType.
// Returns:
// ON::curve_object
ON::object_type ObjectType() const override;
// virtual ON_Geometry GetTightBoundingBox override
bool GetTightBoundingBox( class ON_BoundingBox& tight_bbox, bool bGrowBox = false, const class ON_Xform* xform = nullptr ) const override;
/*
Description:
overrides virtual ON_Geometry::Transform().
ON_Curve::Transform() calls ON_Geometry::Transform(xform),
which calls ON_Object::TransformUserData(xform), and then
calls this->DestroyCurveTree().
Parameters:
xform - [in] transformation to apply to object.
Remarks:
Classes derived from ON_Curve should call
ON_Curve::Transform() to handle user data
transformations and curve tree destruction
and then transform their definition.
*/
bool Transform(
const ON_Xform& xform
) override;
////////////////////////////////////////////////////////////////////
// curve interface
// Description:
// Gets domain of the curve
// Parameters:
// t0 - [out]
// t1 - [out] domain is [*t0, *t1]
// Returns:
// true if successful.
bool GetDomain( double* t0, double* t1 ) const;
// Returns:
// domain of the curve.
virtual
ON_Interval Domain() const = 0;
/*
Description:
Set the domain of the curve.
Parameters:
domain - [in] increasing interval
Returns:
true if successful.
*/
bool SetDomain( ON_Interval domain );
// Description:
// Set the domain of the curve
// Parameters:
// t0 - [in]
// t1 - [in] new domain will be [t0,t1]
// Returns:
// true if successful.
virtual
bool SetDomain(
double t0,
double t1
);
/*
Description:
If this curve is closed, then modify it so that
the start/end point is at curve parameter t.
Parameters:
t - [in] curve parameter of new start/end point. The
returned curves domain will start at t.
min_dist - [in] Do not change if Crv(t) is within min_dist of the original seam
Returns:
true if successful, and seam was moved.
*/
bool ChangeClosedCurveSeam(
double t,
double min_dist
);
/*
Description:
If this curve is closed, then modify it so that
the start/end point is at curve parameter t.
Parameters:
t - [in] curve parameter of new start/end point. The
returned curves domain will start at t.
Returns:
true if successful.
*/
virtual
bool ChangeClosedCurveSeam(
double t
);
/*
Description:
Change the dimension of a curve.
Parameters:
desired_dimension - [in]
Returns:
true if the curve's dimension was already desired_dimension
or if the curve's dimension was successfully changed to
desired_dimension.
*/
virtual
bool ChangeDimension(
int desired_dimension
);
// Description:
// Get number of nonempty smooth (c-infinity) spans in curve
// Returns:
// Number of nonempty smooth (c-infinity) spans.
virtual
int SpanCount() const = 0;
// Description:
// Get number of parameters of "knots".
// Parameters:
// knots - [out] an array of length SpanCount()+1 is filled in
// with the parameters where the curve is not smooth (C-infinity).
// Returns:
// true if successful
virtual
bool GetSpanVector(
double* knots
) const = 0; //
//////////
// If t is in the domain of the curve, GetSpanVectorIndex() returns the
// span vector index "i" such that span_vector[i] <= t <= span_vector[i+1].
// The "side" parameter determines which span is selected when t is at the
// end of a span.
virtual
bool GetSpanVectorIndex(
double t , // [IN] t = evaluation parameter
int side, // [IN] side 0 = default, -1 = from below, +1 = from above
int* span_vector_index, // [OUT] span vector index
ON_Interval* span_domain // [OUT] domain of the span containing "t"
) const;
// Description:
// Returns maximum algebraic degree of any span
// or a good estimate if curve spans are not algebraic.
// Returns:
// degree
virtual
int Degree() const = 0;
// Description:
// Returns maximum algebraic degree of any span
// or a good estimate if curve spans are not algebraic.
// Returns:
// degree
virtual
bool GetParameterTolerance( // returns tminus < tplus: parameters tminus <= s <= tplus
double t, // [IN] t = parameter in domain
double* tminus, // [OUT] tminus
double* tplus // [OUT] tplus
) const;
// Description:
// Test a curve to see if the locus if its points is a line segment.
// Parameters:
// tolerance - [in] // tolerance to use when checking linearity
// Returns:
// true if the ends of the curve are farther than tolerance apart
// and the maximum distance from any point on the curve to
// the line segment connecting the curve's ends is <= tolerance.
virtual
bool IsLinear(
double tolerance = ON_ZERO_TOLERANCE
) const;
/*
Description:
Several types of ON_Curve can have the form of a polyline including
a degree 1 ON_NurbsCurve, an ON_PolylineCurve, and an ON_PolyCurve
all of whose segments are some form of polyline. IsPolyline tests
a curve to see if it can be represented as a polyline.
Parameters:
pline_points - [out] if not nullptr and true is returned, then the
points of the polyline form are returned here.
t - [out] if not nullptr and true is returned, then the parameters of
the polyline points are returned here.
Returns:
@untitled table
0 curve is not some form of a polyline
>=2 number of points in polyline form
*/
virtual
int IsPolyline(
ON_SimpleArray<ON_3dPoint>* pline_points = nullptr,
ON_SimpleArray<double>* pline_t = nullptr
) const;
// Description:
// Test a curve to see if the locus if its points is an arc or circle.
// Parameters:
// plane - [in] if not nullptr, test is performed in this plane
// arc - [out] if not nullptr and true is returned, then arc parameters
// are filled in
// tolerance - [in] tolerance to use when checking
// Returns:
// ON_Arc.m_angle > 0 if curve locus is an arc between
// specified points. If ON_Arc.m_angle is 2.0*ON_PI, then the curve
// is a circle.
virtual
bool IsArc(
const ON_Plane* plane = nullptr,
ON_Arc* arc = nullptr,
double tolerance = ON_ZERO_TOLERANCE
) const;
/*
Description:
Parameters:
t - [in] curve parameter
plane - [in]
if not nullptr, test is performed in this plane
arc - [out]
if not nullptr and true is returned, then arc parameters
are filled in
tolerance - [in]
tolerance to use when checking
t0 - [out]
if not nullptr, and then *t0 is set to the parameter
at the start of the G2 curve segment that was
tested.
t1 - [out]
if not nullptr, and then *t0 is set to the parameter
at the start of the G2 curve segment that was
tested.
Returns:
True if the paramter t is on a arc segment of the curve.
*/
bool IsArcAt(
double t,
const ON_Plane* plane = 0,
ON_Arc* arc = 0,
double tolerance = ON_ZERO_TOLERANCE,
double* t0 = 0,
double* t1 = 0
) const;
virtual
bool IsEllipse(
const ON_Plane* plane = nullptr,
ON_Ellipse* ellipse = nullptr,
double tolerance = ON_ZERO_TOLERANCE
) const;
// Description:
// Test a curve to see if it is planar.
// Parameters:
// plane - [out] if not nullptr and true is returned,
// the plane parameters are filled in.
// tolerance - [in] tolerance to use when checking
// Returns:
// true if there is a plane such that the maximum distance from
// the curve to the plane is <= tolerance.
virtual
bool IsPlanar(
ON_Plane* plane = nullptr,
double tolerance = ON_ZERO_TOLERANCE
) const;
// Description:
// Test a curve to see if it lies in a specific plane.
// Parameters:
// test_plane - [in]
// tolerance - [in] tolerance to use when checking
// Returns:
// true if the maximum distance from the curve to the
// test_plane is <= tolerance.
virtual
bool IsInPlane(
const ON_Plane& test_plane,
double tolerance = ON_ZERO_TOLERANCE
) const = 0;
/*
Description:
Decide if it makes sense to close off this curve by moving
the endpoint to the start based on start-end gap size and length
of curve as approximated by chord defined by 6 points.
Parameters:
tolerance - [in] maximum allowable distance between start and end.
if start - end gap is greater than tolerance, returns false
min_abs_size - [in] if greater than 0.0 and none of the interior sampled
points are at least min_abs_size from start, returns false.
min_rel_size - [in] if greater than 1.0 and chord length is less than
min_rel_size*gap, returns false.
Returns:
true if start and end points are close enough based on above conditions.
*/
bool IsClosable(
double tolerance,
double min_abs_size = 0.0,
double min_rel_size = 10.0
) const;
// Description:
// Test a curve to see if it is closed.
// Returns:
// true if the curve is closed.
virtual
bool IsClosed() const;
// Description:
// Test a curve to see if it is periodic.
// Returns:
// true if the curve is closed and at least C2 at the start/end.
virtual
bool IsPeriodic() const;
/*
Description:
Search for a derivatitive, tangent, or curvature
discontinuity.
Parameters:
c - [in] type of continity to test for.
t0 - [in] Search begins at t0. If there is a discontinuity
at t0, it will be ignored. This makes it
possible to repeatedly call GetNextDiscontinuity
and step through the discontinuities.
t1 - [in] (t0 != t1) If there is a discontinuity at t1 is
will be ingored unless c is a locus discontinuity
type and t1 is at the start or end of the curve.
t - [out] if a discontinuity is found, then *t reports the
parameter at the discontinuity.
hint - [in/out] if GetNextDiscontinuity will be called
repeatedly, passing a "hint" with initial value *hint=0
will increase the speed of the search.
dtype - [out] if not nullptr, *dtype reports the kind of
discontinuity found at *t. A value of 1 means the first
derivative or unit tangent was discontinuous. A value
of 2 means the second derivative or curvature was
discontinuous. A value of 0 means teh curve is not
closed, a locus discontinuity test was applied, and
t1 is at the start of end of the curve.
If 'c', the type of continuity to test for
is ON::continuity::Gsmooth_continuous and the curvature changes
from curved to 0 or 0 to curved and there is no
tangency kink dtype is returns 3
cos_angle_tolerance - [in] default = cos(1 degree) Used only
when c is ON::continuity::G1_continuous or ON::continuity::G2_continuous. If the
cosine of the angle between two tangent vectors is
<= cos_angle_tolerance, then a G1 discontinuity is reported.
curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used
only when c is ON::continuity::G2_continuous. If K0 and K1 are
curvatures evaluated from above and below and
|K0 - K1| > curvature_tolerance, then a curvature
discontinuity is reported.
Returns:
Parametric continuity tests c = (C0_continuous, ..., G2_continuous):
true if a parametric discontinuity was found strictly
between t0 and t1. Note well that all curves are
parametrically continuous at the ends of their domains.
Locus continuity tests c = (C0_locus_continuous, ...,G2_locus_continuous):
true if a locus discontinuity was found strictly between
t0 and t1 or at t1 is the at the end of a curve.
Note well that all open curves (IsClosed()=false) are locus
discontinuous at the ends of their domains. All closed
curves (IsClosed()=true) are at least C0_locus_continuous at
the ends of their domains.
*/
virtual
bool GetNextDiscontinuity(
ON::continuity c,
double t0,
double t1,
double* t,
int* hint=nullptr,
int* dtype=nullptr,
double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
double curvature_tolerance=ON_SQRT_EPSILON
) const;
/*
Description:
Test continuity at a curve parameter value.
Parameters:
c - [in] type of continuity to test for. Read ON::continuity
comments for details.
t - [in] parameter to test
hint - [in] evaluation hint
point_tolerance - [in] if the distance between two points is
greater than point_tolerance, then the curve is not C0.
d1_tolerance - [in] if the difference between two first derivatives is
greater than d1_tolerance, then the curve is not C1.
d2_tolerance - [in] if the difference between two second derivatives is
greater than d2_tolerance, then the curve is not C2.
cos_angle_tolerance - [in] default = cos(1 degree) Used only when
c is ON::continuity::G1_continuous or ON::continuity::G2_continuous. If the cosine
of the angle between two tangent vectors
is <= cos_angle_tolerance, then a G1 discontinuity is reported.
curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when
c is ON::continuity::G2_continuous or ON::continuity::Gsmooth_continuous.
ON::continuity::G2_continuous:
If K0 and K1 are curvatures evaluated
from above and below and |K0 - K1| > curvature_tolerance,
then a curvature discontinuity is reported.
ON::continuity::Gsmooth_continuous:
If K0 and K1 are curvatures evaluated from above and below
and the angle between K0 and K1 is at least twice angle tolerance
or ||K0| - |K1|| > (max(|K0|,|K1|) > curvature_tolerance,
then a curvature discontinuity is reported.
Returns:
true if the curve has at least the c type continuity at
the parameter t.
*/
virtual
bool IsContinuous(
ON::continuity c,
double t,
int* hint = nullptr,
double point_tolerance=ON_ZERO_TOLERANCE,
double d1_tolerance=ON_ZERO_TOLERANCE,
double d2_tolerance=ON_ZERO_TOLERANCE,
double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
double curvature_tolerance=ON_SQRT_EPSILON
) const;
// Description:
// Reverse the direction of the curve.
// Returns:
// true if curve was reversed.
// Remarks:
// If reveresed, the domain changes from [a,b] to [-b,-a]
virtual
bool Reverse()=0;
/*
Description:
Force the curve to start at a specified point.
Parameters:
start_point - [in]
Returns:
true if successful.
Remarks:
Some end points cannot be moved. Be sure to check return
code.
ON_Curve::SetStartPoint() returns true if start_point is the same as the start of the curve,
false otherwise.
See Also:
ON_Curve::SetEndPoint
ON_Curve::PointAtStart
ON_Curve::PointAtEnd
*/
virtual
bool SetStartPoint(
ON_3dPoint start_point
);
/*
Description:
Force the curve to end at a specified point.
Parameters:
end_point - [in]
Returns:
true if successful.
Remarks:
Some end points cannot be moved. Be sure to check return
code.
ON_Curve::SetEndPoint() returns true if end_point is the same as the end of the curve,
false otherwise.
See Also:
ON_Curve::SetStartPoint
ON_Curve::PointAtStart
ON_Curve::PointAtEnd
*/
virtual
bool SetEndPoint(
ON_3dPoint end_point
);
// Description:
// Evaluate point at a parameter.
// Parameters:
// t - [in] evaluation parameter
// Returns:
// Point (location of curve at the parameter t).
// Remarks:
// No error handling.
// See Also:
// ON_Curve::EvPoint
// ON_Curve::PointAtStart
// ON_Curve::PointAtEnd
ON_3dPoint PointAt(
double t
) const;
// Description:
// Evaluate point at the start of the curve.
// Parameters:
// t - [in] evaluation parameter
// Returns:
// Point (location of the start of the curve.)
// Remarks:
// No error handling.
// See Also:
// ON_Curve::PointAt
ON_3dPoint PointAtStart() const;
// Description:
// Evaluate point at the end of the curve.
// Parameters:
// t - [in] evaluation parameter
// Returns:
// Point (location of the end of the curve.)
// Remarks:
// No error handling.
// See Also:
// ON_Curve::PointAt
ON_3dPoint PointAtEnd() const;
// Description:
// Evaluate first derivative at a parameter.
// Parameters:
// t - [in] evaluation parameter
// Returns:
// First derivative of the curve at the parameter t.
// Remarks:
// No error handling.
// See Also:
// ON_Curve::Ev1Der
ON_3dVector DerivativeAt(
double t
) const;
// Description:
// Evaluate unit tangent vector at a parameter.
// Parameters:
// t - [in] evaluation parameter
// Returns:
// Unit tangent vector of the curve at the parameter t.
// Remarks:
// No error handling.
// See Also:
// ON_Curve::EvTangent
ON_3dVector TangentAt(
double t
) const;
// Description:
// Evaluate the curvature vector at a parameter.
// Parameters:
// t - [in] evaluation parameter
// Returns:
// curvature vector of the curve at the parameter t.
// Remarks:
// No error handling.
// See Also:
// ON_Curve::EvCurvature
ON_3dVector CurvatureAt(
double t
) const;
// Description:
// Return a 3d frame at a parameter.
// Parameters:
// t - [in] evaluation parameter
// plane - [out] the frame is returned here
// Returns:
// true if successful
// See Also:
// ON_Curve::PointAt, ON_Curve::TangentAt,
// ON_Curve::Ev1Der, Ev2Der
bool FrameAt( double t, ON_Plane& plane) const;
// Description:
// Evaluate point at a parameter with error checking.
// Parameters:
// t - [in] evaluation parameter
// point - [out] value of curve at t
// side - [in] optional - determines which side to evaluate from
// =0 default
// <0 to evaluate from below,
// >0 to evaluate from above
// hint - [in/out] optional evaluation hint used to speed repeated evaluations
// Returns:
// false if unable to evaluate.
// See Also:
// ON_Curve::PointAt
// ON_Curve::EvTangent
// ON_Curve::Evaluate
bool EvPoint(
double t,
ON_3dPoint& point,
int side = 0,
int* hint = 0
) const;
// Description:
// Evaluate first derivative at a parameter with error checking.
// Parameters:
// t - [in] evaluation parameter
// point - [out] value of curve at t
// first_derivative - [out] value of first derivative at t
// side - [in] optional - determines which side to evaluate from
// =0 default
// <0 to evaluate from below,
// >0 to evaluate from above
// hint - [in/out] optional evaluation hint used to speed repeated evaluations
// Returns:
// false if unable to evaluate.
// See Also:
// ON_Curve::EvPoint
// ON_Curve::Ev2Der
// ON_Curve::EvTangent
// ON_Curve::Evaluate
bool Ev1Der(
double t,
ON_3dPoint& point,
ON_3dVector& first_derivative,
int side = 0,
int* hint = 0
) const;
// Description:
// Evaluate second derivative at a parameter with error checking.
// Parameters:
// t - [in] evaluation parameter
// point - [out] value of curve at t
// first_derivative - [out] value of first derivative at t
// second_derivative - [out] value of second derivative at t
// side - [in] optional - determines which side to evaluate from
// =0 default
// <0 to evaluate from below,
// >0 to evaluate from above
// hint - [in/out] optional evaluation hint used to speed repeated evaluations
// Returns:
// false if unable to evaluate.
// See Also:
// ON_Curve::Ev1Der
// ON_Curve::EvCurvature
// ON_Curve::Evaluate
bool Ev2Der(
double t,
ON_3dPoint& point,
ON_3dVector& first_derivative,
ON_3dVector& second_derivative,
int side = 0,
int* hint = 0
) const;
/*
Description:
Evaluate unit tangent at a parameter with error checking.
Parameters:
t - [in] evaluation parameter
point - [out] value of curve at t
tangent - [out] value of unit tangent
side - [in] optional - determines which side to evaluate from
=0 default
<0 to evaluate from below,
>0 to evaluate from above
hint - [in/out] optional evaluation hint used to speed repeated evaluations
Returns:
false if unable to evaluate.
See Also:
ON_Curve::TangentAt
ON_Curve::Ev1Der
*/
bool EvTangent(
double t,
ON_3dPoint& point,
ON_3dVector& tangent,
int side = 0,
int* hint = 0
) const;
/*
Description:
Evaluate unit tangent and curvature at a parameter with error checking.
Parameters:
t - [in] evaluation parameter
point - [out] value of curve at t
tangent - [out] value of unit tangent
kappa - [out] value of curvature vector
side - [in] optional - determines which side to evaluate from
=0 default
<0 to evaluate from below,
>0 to evaluate from above
hint - [in/out] optional evaluation hint used to speed repeated evaluations
Returns:
false if unable to evaluate.
See Also:
ON_Curve::CurvatureAt
ON_Curve::Ev2Der
ON_EvCurvature
*/
bool EvCurvature(
double t,
ON_3dPoint& point,
ON_3dVector& tangent,
ON_3dVector& kappa,
int side = 0,
int* hint = 0
) const;
/*
Description:
This evaluator actually does all the work. The other ON_Curve
evaluation tools call this virtual function.
Parameters:
t - [in] evaluation parameter ( usually in Domain() ).
der_count - [in] (>=0) number of derivatives to evaluate
v_stride - [in] (>=Dimension()) stride to use for the v[] array
v - [out] array of length (der_count+1)*v_stride
curve(t) is returned in (v[0],...,v[m_dim-1]),
curve'(t) is retuned in (v[v_stride],...,v[v_stride+m_dim-1]),
curve"(t) is retuned in (v[2*v_stride],...,v[2*v_stride+m_dim-1]),
etc.
side - [in] optional - determines which side to evaluate from
=0 default
<0 to evaluate from below,
>0 to evaluate from above
hint - [in/out] optional evaluation hint used to speed repeated evaluations
Returns:
false if unable to evaluate.
See Also:
ON_Curve::EvPoint
ON_Curve::Ev1Der
ON_Curve::Ev2Der
*/
virtual
bool Evaluate(
double t,
int der_count,
int v_stride,
double* v,
int side = 0,
int* hint = 0
) const = 0;
/*
Parameters:
min_length -[in]
minimum length of a linear span
tolerance -[in]
distance tolerance to use when checking linearity.
Returns
true if the span is a non-degenrate line. This means:
- dimension = 2 or 3
- The length of the the line segment from the span's initial
point to the span's control point is >= min_length.
- The maximum distance from the line segment to the span
is <= tolerance and the span increases monotonically
in the direction of the line segment.
*/
bool FirstSpanIsLinear(
double min_length,
double tolerance
) const;
bool LastSpanIsLinear(
double min_length,
double tolerance
) const;
bool FirstSpanIsLinear(
double min_length,
double tolerance,
ON_Line* span_line
) const;
bool LastSpanIsLinear(
double min_length,
double tolerance,
ON_Line* span_line
) const;
// Description:
// Removes portions of the curve outside the specified interval.
// Parameters:
// domain - [in] interval of the curve to keep. Portions of the
// curve before curve(domain[0]) and after curve(domain[1]) are
// removed.
// Returns:
// true if successful.
virtual
bool Trim(
const ON_Interval& domain
);
// Description:
// Pure virtual function. Default returns false.
// Where possible, analytically extends curve to include domain.
// Parameters:
// domain - [in] if domain is not included in curve domain,
// curve will be extended so that its domain includes domain.
// Will not work if curve is closed. Original curve is identical
// to the restriction of the resulting curve to the original curve domain,
// Returns:
// true if successful.
virtual
bool Extend(
const ON_Interval& domain
);
/*
Description:
Splits (divides) the curve at the specified parameter.
The parameter must be in the interior of the curve's domain.
The pointers passed to Split must either be nullptr or point to
an ON_Curve object of the same type. If the pointer is nullptr,
then a curve will be created in Split(). You may pass "this"
as left_side or right_side.
Parameters:
t - [in] parameter to split the curve at in the
interval returned by Domain().
left_side - [out] left portion of curve returned here
right_side - [out] right portion of curve returned here
Returns:
true - The curve was split into two pieces.
false - The curve could not be split. For example if the parameter is
too close to an endpoint.
Example:
For example, if crv were an ON_NurbsCurve, then
ON_NurbsCurve right_side;
crv.Split( crv.Domain().Mid() &crv, &right_side );
would split crv at the parametric midpoint, put the left side
in crv, and return the right side in right_side.
*/
virtual
bool Split(
double t,
ON_Curve*& left_side,
ON_Curve*& right_side
) const;
/*
Description:
Get a NURBS curve representation of this curve.
Parameters:
nurbs_curve - [out] NURBS representation returned here
tolerance - [in] tolerance to use when creating NURBS
representation.
subdomain - [in] if not nullptr, then the NURBS representation
for this portion of the curve is returned.
Returns:
0 unable to create NURBS representation