QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_polycurve.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
16
18//
19// Definition of poly curve (composite curve)
20//
22
23#if !defined(OPENNURBS_POLYCURVE_INC_)
24#define OPENNURBS_POLYCURVE_INC_
25
26/*
27 Description:
28 An ON_PolyCurve is an ON_Curve represented by a sequence of
29 contiguous ON_Curve segments. A valid polycurve is represented
30 by an array m_segment of Count()>=1 curve objects and a strictly
31 increasing array m_t of Count()+1 parameter values. The i-th
32 curve segment, when considered as part of the polycurve, is affinely
33 reparamaterized from m_t[i] to m_t[i+1], i.e., m_segment[i].Domain()[0]
34 is mapped to m_t[i] and m_segment[i].Domain()[1] is mapped to m_t[i+1].
35*/
36class ON_PolyCurve;
38{
40
41public:
42 // virtual ON_Object::DestroyRuntimeCache override
43 void DestroyRuntimeCache( bool bDelete = true );
44
45public:
47 ON_PolyCurve( int ); // int = initial capacity - use when a good estimate
48 // of the number of segments is known.
50
51 void Destroy();
52
53 virtual ~ON_PolyCurve();
54
55 void EmergencyDestroy(); // call if memory used by ON_PolyCurve becomes invalid
56
58
60 // ON_Object overrides
61
62 // virtual ON_Object::SizeOf override
63 unsigned int SizeOf() const;
64
65 // virtual ON_Object::DataCRC override
66 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const;
67
68 /*
69 Description:
70 Tests an object to see if its data members are correctly
71 initialized.
72 Parameters:
73 text_log - [in] if the object is not valid and text_log
74 is not NULL, then a brief englis description of the
75 reason the object is not valid is appened to the log.
76 The information appended to text_log is suitable for
77 low-level debugging purposes by programmers and is
78 not intended to be useful as a high level user
79 interface tool.
80 Returns:
81 @untitled table
82 true object is valid
83 false object is invalid, uninitialized, etc.
84 Remarks:
85 Overrides virtual ON_Object::IsValid
86 */
87 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
88
89 /*
90 Description:
91 Tests an object to see if its data members are correctly
92 initialized.
93 Parameters:
94 bAllowGaps - [in]
95 If true, gaps are allowed between polycurve segments.
96 If false, gaps are not allowed between polycurve segments.
97 text_log - [in] if the object is not valid and text_log
98 is not NULL, then a brief englis description of the
99 reason the object is not valid is appened to the log.
100 The information appended to text_log is suitable for
101 low-level debugging purposes by programmers and is
102 not intended to be useful as a high level user
103 interface tool.
104 Returns:
105 @untitled table
106 true object is valid
107 false object is invalid, uninitialized, etc.
108 Remarks:
109 Overrides virtual ON_Object::IsValid
110 */
111 bool IsValid( bool bAllowGaps, ON_TextLog* text_log ) const;
112
113
114 void Dump( ON_TextLog& ) const; // for debugging
115
117 ON_BinaryArchive& // open binary file
118 ) const;
119
121 ON_BinaryArchive& // open binary file
122 );
123
125 // ON_Geometry overrides
126
127 int Dimension() const;
128
129 ON_BOOL32 GetBBox( // returns true if successful
130 double*, // minimum
131 double*, // maximum
132 ON_BOOL32 = false // true means grow box
133 ) const;
134
135 /*
136 Description:
137 Get tight bounding box.
138 Parameters:
139 tight_bbox - [in/out] tight bounding box
140 bGrowBox -[in] (default=false)
141 If true and the input tight_bbox is valid, then returned
142 tight_bbox is the union of the input tight_bbox and the
143 curve's tight bounding box.
144 xform -[in] (default=NULL)
145 If not NULL, the tight bounding box of the transformed
146 curve is calculated. The curve is not modified.
147 Returns:
148 True if a valid tight_bbox is returned.
149 */
151 ON_BoundingBox& tight_bbox,
152 int bGrowBox = false,
153 const ON_Xform* xform = 0
154 ) const;
155
157 const ON_Xform&
158 );
159
160 // virtual ON_Geometry::IsDeformable() override
161 bool IsDeformable() const;
162
163 // virtual ON_Geometry::MakeDeformable() override
164 bool MakeDeformable();
165
167 int, int // indices of coords to swap
168 );
169
170
171 // virtual ON_Geometry override
172 bool Morph( const ON_SpaceMorph& morph );
173
174 // virtual ON_Geometry override
175 bool IsMorphable() const;
176
177 // virtual ON_Geometry override
178 bool EvaluatePoint( const class ON_ObjRef& objref, ON_3dPoint& P ) const;
179
181 // ON_Curve overrides
182
183 ON_Curve* DuplicateCurve() const;
184
185 ON_Interval Domain() const;
186
187 // Description:
188 // virtual ON_Curve::SetDomain override.
189 // Set the domain of the curve
190 // Parameters:
191 // t0 - [in]
192 // t1 - [in] new domain will be [t0,t1]
193 // Returns:
194 // true if successful.
196 double t0,
197 double t1
198 );
199
200 bool ChangeDimension(
201 int desired_dimension
202 );
203
204 /*
205 Description:
206 If this curve is closed, then modify it so that
207 the start/end point is at curve parameter t.
208 Parameters:
209 t - [in] curve parameter of new start/end point. The
210 returned curves domain will start at t.
211 Returns:
212 true if successful.
213 Remarks:
214 Overrides virtual ON_Curve::ChangeClosedCurveSeam
215 */
217 double t
218 );
219
220 int SpanCount() const; // number of smooth spans in curve
221
222 ON_BOOL32 GetSpanVector( // span "knots"
223 double* // array of length SpanCount() + 1
224 ) const; //
225
226 int Degree( // returns maximum algebraic degree of any span
227 // ( or a good estimate if curve spans are not algebraic )
228 ) const;
229
230 ON_BOOL32 IsLinear( // true if curve locus is a line segment between
231 // between specified points
232 double = ON_ZERO_TOLERANCE // tolerance to use when checking linearity
233 ) const;
234
235 /*
236 Description:
237 Several types of ON_Curve can have the form of a polyline including
238 a degree 1 ON_NurbsCurve, an ON_PolylineCurve, and an ON_PolyCurve
239 all of whose segments are some form of polyline. IsPolyline tests
240 a curve to see if it can be represented as a polyline.
241 Parameters:
242 pline_points - [out] if not NULL and true is returned, then the
243 points of the polyline form are returned here.
244 t - [out] if not NULL and true is returned, then the parameters of
245 the polyline points are returned here.
246 Returns:
247 @untitled table
248 0 curve is not some form of a polyline
249 >=2 number of points in polyline form
250 */
251 int IsPolyline(
252 ON_SimpleArray<ON_3dPoint>* pline_points = NULL,
254 ) const;
255
256 ON_BOOL32 IsArc( // ON_Arc.m_angle > 0 if curve locus is an arc between
257 // specified points
258 const ON_Plane* = NULL, // if not NULL, test is performed in this plane
259 ON_Arc* = NULL, // if not NULL and true is returned, then arc parameters
260 // are filled in
261 double = ON_ZERO_TOLERANCE // tolerance to use when checking
262 ) const;
263
265 ON_Plane* = NULL, // if not NULL and true is returned, then plane parameters
266 // are filled in
267 double = ON_ZERO_TOLERANCE // tolerance to use when checking
268 ) const;
269
271 const ON_Plane&, // plane to test
272 double = ON_ZERO_TOLERANCE // tolerance to use when checking
273 ) const;
274
275 ON_BOOL32 IsClosed( // true if curve is closed (either curve has
276 void // clamped end knots and euclidean location of start
277 ) const; // CV = euclidean location of end CV, or curve is
278 // periodic.)
279
280 ON_BOOL32 IsPeriodic( // true if curve is a single periodic segment
281 void
282 ) const;
283
284 /*
285 Description:
286 Search for a derivatitive, tangent, or curvature discontinuity.
287 Parameters:
288 c - [in] type of continity to test for. If ON::C1_continuous
289 t0 - [in] search begins at t0
290 t1 - [in] (t0 < t1) search ends at t1
291 t - [out] if a discontinuity is found, the *t reports the
292 parameter at the discontinuity.
293 hint - [in/out] if GetNextDiscontinuity will be called repeatedly,
294 passing a "hint" with initial value *hint=0 will increase the speed
295 of the search.
296 dtype - [out] if not NULL, *dtype reports the kind of discontinuity
297 found at *t. A value of 1 means the first derivative or unit tangent
298 was discontinuous. A value of 2 means the second derivative or
299 curvature was discontinuous.
300 cos_angle_tolerance - [in] default = cos(1 degree) Used only when
301 c is ON::G1_continuous or ON::G2_continuous. If the cosine
302 of the angle between two tangent vectors
303 is <= cos_angle_tolerance, then a G1 discontinuity is reported.
304 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when
305 c is ON::G2_continuous. If K0 and K1 are curvatures evaluated
306 from above and below and |K0 - K1| > curvature_tolerance,
307 then a curvature discontinuity is reported.
308 Returns:
309 true if a discontinuity was found on the interior of the interval (t0,t1).
310 Remarks:
311 Overrides ON_Curve::GetNextDiscontinuity.
312 */
314 ON::continuity c,
315 double t0,
316 double t1,
317 double* t,
318 int* hint=NULL,
319 int* dtype=NULL,
320 double cos_angle_tolerance=0.99984769515639123915701155881391,
321 double curvature_tolerance=ON_SQRT_EPSILON
322 ) const;
323
324 /*
325 Description:
326 Test continuity at a curve parameter value.
327 Parameters:
328 c - [in] continuity to test for
329 t - [in] parameter to test
330 hint - [in] evaluation hint
331 point_tolerance - [in] if the distance between two points is
332 greater than point_tolerance, then the curve is not C0.
333 d1_tolerance - [in] if the difference between two first derivatives is
334 greater than d1_tolerance, then the curve is not C1.
335 d2_tolerance - [in] if the difference between two second derivatives is
336 greater than d2_tolerance, then the curve is not C2.
337 cos_angle_tolerance - [in] default = cos(1 degree) Used only when
338 c is ON::G1_continuous or ON::G2_continuous. If the cosine
339 of the angle between two tangent vectors
340 is <= cos_angle_tolerance, then a G1 discontinuity is reported.
341 curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when
342 c is ON::G2_continuous. If K0 and K1 are curvatures evaluated
343 from above and below and |K0 - K1| > curvature_tolerance,
344 then a curvature discontinuity is reported.
345 Returns:
346 true if the curve has at least the c type continuity at the parameter t.
347 Remarks:
348 Overrides ON_Curve::IsContinuous.
349 */
350 bool IsContinuous(
351 ON::continuity c,
352 double t,
353 int* hint = NULL,
354 double point_tolerance=ON_ZERO_TOLERANCE,
355 double d1_tolerance=ON_ZERO_TOLERANCE,
356 double d2_tolerance=ON_ZERO_TOLERANCE,
357 double cos_angle_tolerance=0.99984769515639123915701155881391,
358 double curvature_tolerance=ON_SQRT_EPSILON
359 ) const;
360
361 ON_BOOL32 Reverse(); // reverse parameterizatrion
362 // Domain changes from [a,b] to [-b,-a]
363
364 /*
365 Description:
366 Force the curve to start at a specified point.
367 Parameters:
368 start_point - [in]
369 Returns:
370 true if successful.
371 Remarks:
372 Some start points cannot be moved. Be sure to check return
373 code.
374 See Also:
375 ON_Curve::SetEndPoint
376 ON_Curve::PointAtStart
377 ON_Curve::PointAtEnd
378 */
379 // virtual
381 ON_3dPoint start_point
382 );
383
384 /*
385 Description:
386 Force the curve to end at a specified point.
387 Parameters:
388 end_point - [in]
389 Returns:
390 true if successful.
391 Remarks:
392 Some end points cannot be moved. Be sure to check return
393 code.
394 See Also:
395 ON_Curve::SetStartPoint
396 ON_Curve::PointAtStart
397 ON_Curve::PointAtEnd
398 */
399 //virtual
401 ON_3dPoint end_point
402 );
403
404 ON_BOOL32 Evaluate( // returns false if unable to evaluate
405 double, // evaluation parameter
406 int, // number of derivatives (>=0)
407 int, // array stride (>=Dimension())
408 double*, // array of length stride*(ndir+1)
409 int = 0, // optional - determines which side to evaluate from
410 // 0 = default
411 // < 0 to evaluate from below,
412 // > 0 to evaluate from above
413 int* = 0 // optional - evaluation hint (int) used to speed
414 // repeated evaluations
415 ) const;
416
418 // Find parameter of the point on a curve that is closest to test_point.
419 // If the maximum_distance parameter is > 0, then only points whose distance
420 // to the given point is <= maximum_distance will be returned. Using a
421 // positive value of maximum_distance can substantially speed up the search.
422 // If the sub_domain parameter is not NULL, then the search is restricted
423 // to the specified portion of the curve.
424 //
425 // true if returned if the search is successful. false is returned if
426 // the search fails.
427 bool GetClosestPoint( const ON_3dPoint&, // test_point
428 double*, // parameter of local closest point returned here
429 double = 0.0, // maximum_distance
430 const ON_Interval* = NULL // sub_domain
431 ) const;
432
434 // Find parameter of the point on a curve that is locally closest to
435 // the test_point. The search for a local close point starts at
436 // seed_parameter. If the sub_domain parameter is not NULL, then
437 // the search is restricted to the specified portion of the curve.
438 //
439 // true if returned if the search is successful. false is returned if
440 // the search fails.
441 ON_BOOL32 GetLocalClosestPoint( const ON_3dPoint&, // test_point
442 double, // seed_parameter
443 double*, // parameter of local closest point returned here
444 const ON_Interval* = NULL // sub_domain
445 ) const;
446
448 // Length of curve.
449 // true if returned if the length calculation is successful.
450 // false is returned if the length is not calculated.
451 //
452 // The arc length will be computed so that
453 // (returned length - real length)/(real length) <= fractional_tolerance
454 // More simply, if you want N significant figures in the answer, set the
455 // fractional_tolerance to 1.0e-N. For "nice" curves, 1.0e-8 works
456 // fine. For very high degree nurbs and nurbs with bad parameterizations,
457 // use larger values of fractional_tolerance.
458 ON_BOOL32 GetLength( // returns true if length successfully computed
459 double*, // length returned here
460 double = 1.0e-8, // fractional_tolerance
461 const ON_Interval* = NULL // (optional) sub_domain
462 ) const;
463
464 /*
465 Description:
466 Used to quickly find short curves.
467 Parameters:
468 tolerance - [in] (>=0)
469 sub_domain - [in] If not NULL, the test is performed
470 on the interval that is the intersection of
471 sub_domain with Domain().
472 Returns:
473 True if the length of the curve is <= tolerance.
474 Remarks:
475 Faster than calling Length() and testing the
476 result.
477 */
478 bool IsShort(
479 double tolerance,
480 const ON_Interval* sub_domain = NULL
481 ) const;
482
483 /*
484 Description:
485 Looks for segments that are shorter than tolerance
486 that can be removed. If bRemoveShortSegments is true,
487 then the short segments are removed. Does not change the
488 domain, but it will change the relative parameterization.
489 Parameters:
490 tolerance - [in]
491 bRemoveShortSegments - [in] If true, then short segments
492 are removed.
493 Returns:
494 True if removable short segments can were found.
495 False if no removable short segments can were found.
496 */
498 double tolerance,
499 bool bRemoveShortSegments = true
500 );
501
502 /*
503 Description:
504 virtual ON_Curve::GetNormalizedArcLengthPoint override.
505 Get the parameter of the point on the line that is a
506 prescribed distance from the start of the line
507 Parameters:
508 s - [in] normalized arc length parameter. E.g., 0 = start
509 of curve, 1/2 = midpoint of curve, 1 = end of curve.
510 t - [out] parameter such that the length of the line
511 from its start to t is arc_length.
512 fractional_tolerance - [in] desired fractional precision.
513 fabs(("exact" length from start to t) - arc_length)/arc_length <= fractional_tolerance
514 sub_domain - [in] If not NULL, the calculation is performed on
515 the specified sub-domain of the curve.
516 Returns:
517 true if successful
518 */
520 double s,
521 double* t,
522 double fractional_tolerance = 1.0e-8,
523 const ON_Interval* sub_domain = NULL
524 ) const;
525
526 /*
527 Description:
528 virtual ON_Curve::GetNormalizedArcLengthPoints override.
529 Get the parameter of the point on the curve that is a
530 prescribed arc length from the start of the curve.
531 Parameters:
532 count - [in] number of parameters in s.
533 s - [in] array of normalized arc length parameters. E.g., 0 = start
534 of curve, 1/2 = midpoint of curve, 1 = end of curve.
535 t - [out] array of curve parameters such that the length of the
536 curve from its start to t[i] is s[i]*curve_length.
537 absolute_tolerance - [in] if absolute_tolerance > 0, then the difference
538 between (s[i+1]-s[i])*curve_length and the length of the curve
539 segment from t[i] to t[i+1] will be <= absolute_tolerance.
540 fractional_tolerance - [in] desired fractional precision for each segment.
541 fabs("true" length - actual length)/(actual length) <= fractional_tolerance
542 sub_domain - [in] If not NULL, the calculation is performed on
543 the specified sub-domain of the curve. A 0.0 s value corresponds to
544 sub_domain->Min() and a 1.0 s value corresponds to sub_domain->Max().
545 Returns:
546 true if successful
547 */
549 int count,
550 const double* s,
551 double* t,
552 double absolute_tolerance = 0.0,
553 double fractional_tolerance = 1.0e-8,
554 const ON_Interval* sub_domain = NULL
555 ) const;
556
557 // Description:
558 // virtual ON_Curve::Trim override.
559 // Removes portions of the curve outside the specified interval.
560 // Parameters:
561 // domain - [in] interval of the curve to keep. Portions of the
562 // curve before curve(domain[0]) and after curve(domain[1]) are
563 // removed.
564 // Returns:
565 // true if successful.
567 const ON_Interval& domain
568 );
569
570 // Description:
571 // Where possible, analytically extends curve to include domain.
572 // Parameters:
573 // domain - [in] if domain is not included in curve domain,
574 // curve will be extended so that its domain includes domain.
575 // Will not work if curve is closed. Original curve is identical
576 // to the restriction of the resulting curve to the original curve domain,
577 // Returns:
578 // true if successful.
579 bool Extend(
580 const ON_Interval& domain
581 );
582
583 // Description:
584 // virtual ON_Curve::Split override.
585 // Divide the curve at the specified parameter. The parameter
586 // must be in the interior of the curve's domain. The pointers
587 // passed to Split must either be NULL or point to an ON_Curve
588 // object of the same of the same type. If the pointer is NULL,
589 // then a curve will be created in Split(). You may pass "this"
590 // as one of the pointers to Split().
591 // Parameters:
592 // t - [in] parameter in interval Domain().
593 // left_side - [out] left portion of curve
594 // right_side - [out] right portion of curve
595 // Example:
596 // For example, if crv were an ON_NurbsCurve, then
597 //
598 // ON_NurbsCurve right_side;
599 // crv.Split( crv.Domain().Mid() &crv, &right_side );
600 //
601 // would split crv at the parametric midpoint, put the left side
602 // in crv, and return the right side in right_side.
604 double t, // t = curve parameter to split curve at
605 ON_Curve*& left_side, // left portion returned here
606 ON_Curve*& right_side // right portion returned here
607 ) const;
608
609 int GetNurbForm( // returns 0: unable to create NURBS representation
610 // with desired accuracy.
611 // 1: success - returned NURBS parameterization
612 // matches the curve's to wthe desired accuracy
613 // 2: success - returned NURBS point locus matches
614 // the curve's to the desired accuracy but, on
615 // the interior of the curve's domain, the
616 // curve's parameterization and the NURBS
617 // parameterization may not match to the
618 // desired accuracy.
620 double = 0.0,
621 const ON_Interval* = NULL // OPTIONAL subdomain of polycurve
622 ) const;
623
624 int HasNurbForm( // returns 0: unable to create NURBS representation
625 // with desired accuracy.
626 // 1: success - returned NURBS parameterization
627 // matches the curve's to wthe desired accuracy
628 // 2: success - returned NURBS point locus matches
629 // the curve's to the desired accuracy but, on
630 // the interior of the curve's domain, the
631 // curve's parameterization and the NURBS
632 // parameterization may not match to the
633 // desired accuracy.
634 ) const;
635
636 // virtual ON_Curve::GetCurveParameterFromNurbFormParameter override
638 double, // nurbs_t
639 double* // curve_t
640 ) const;
641
642 // virtual ON_Curve::GetNurbFormParameterFromCurveParameter override
644 double, // curve_t
645 double* // nurbs_t
646 ) const;
647
649 // Interface
650
651 int Count() const; // number of segment curves
652
653 // These operator[] functions return NULL if index is out of range
654 ON_Curve* operator[](int) const;
655
656 /*
657 Description:
658 Returns a pointer to a segment curve.
659 Parameters:
660 segment_index - [in] 0 based index (0 <= segment_index < Count() )
661 Returns:
662 A pointer to the segment curve. Returns NULL if segment_index < 0
663 or segment_index >= Count().
664 */
665 ON_Curve* SegmentCurve(
666 int segment_index
667 ) const;
668
669 /*
670 Description:
671 Converts a polycurve parameter to a segment curve parameter.
672 Parameters:
673 polycurve_parameter - [in]
674 Returns:
675 Segment curve evaluation parameter or ON_UNSET_VALUE if the
676 segment curve parameter cannot be computed.
677 See Also:
678 ON_PolyCurve::PolyCurveParameter
679 */
680 double SegmentCurveParameter(
681 double polycurve_parameter
682 ) const;
683
684 /*
685 Description:
686 Converts a segment curve parameter to a polycurve parameter.
687 Parameters:
688 segment_index - [in]
689 segmentcurve_parameter - [in]
690 Returns:
691 Polycurve evaluation parameter or ON_UNSET_VALUE if the
692 polycurve curve parameter cannot be computed.
693 See Also:
694 ON_PolyCurve::SegmentCurveParameter
695 */
696 double PolyCurveParameter(
697 int segment_index,
698 double segmentcurve_parameter
699 ) const;
700
701 /*
702 Description:
703 Returns the polycurve subdomain assigned to a segment curve.
704 Parameters:
705 segment_index - [in] 0 based index (0 <= segment_index < Count() )
706 Returns:
707 The polycurve subdomain assigned to a segment curve.
708 Returns ([ON_UNSET_VALUE,ON_UNSET_VALUE) if segment_index < 0
709 or segment_index >= Count().
710 */
711 ON_Interval SegmentDomain(
712 int segment_index
713 ) const;
714
715 /*
716 Description:
717 Find the segment used for evaluation at polycurve_parameter.
718 Parameters:
719 polycurve_parameter - [in]
720 Returns:
721 index of the segment used for evaluation at polycurve_parameter.
722 If polycurve_parameter < Domain.Min(), then 0 is returned.
723 If polycurve_parameter > Domain.Max(), then Count()-1 is returned.
724 */
725 int SegmentIndex(
726 double polycurve_parameter
727 ) const;
728
729 /*
730 Description:
731 Find the segments with support on sub_domain.
732 Parameters:
733 sub_domain - [in] increasing interval
734 segment_index0 - [out]
735 segment_index1 - [out] segments with index i where
736 *segment_index0 <= i < *segment_index1 are the segments
737 with support on the sub_domain
738 Returns:
739 number of segments with support on sub_domain.
740 */
741 int SegmentIndex(
742 ON_Interval sub_domain,
743 int* segment_index0,
744 int* segment_index1
745 ) const;
746
747 ON_Curve* FirstSegmentCurve() const; // returns NULL if count = 0
748
749 ON_Curve* LastSegmentCurve() const; // returns NULL if count = 0
750
751 /*
752 Description:
753 This is a quick way to see if the curve has
754 gaps between the sub curve segments.
755 The test is fairly severe (ON_ComparePoint).
756 Returns:
757 0: The ends adjacent polycuve segments are coincident.
758 i > 0: The end of polycuve segment (i-1) is not coincident
759 with the start of polycurve segment i.
760 */
761 int HasGap() const;
762
763 void Reserve( int ); // make sure capacity is at least the specified count
764
765 // ON_Curve pointers added with Prepend(), Append(), PrependAndMatch(), AppendANdMatch(),and Insert() are deleted
766 // by ~ON_PolyCurve(). Use ON_CurveProxy( ON_Curve*) if you want
767 // the original curve segment to survive ~ON_PolyCurve().
768 ON_BOOL32 Prepend( ON_Curve* ); // Prepend curve.
769 ON_BOOL32 Append( ON_Curve* ); // Append curve.
770 ON_BOOL32 Insert(
771 int, // segment_index,
772 ON_Curve*
773 );
774
775 //PrependAndMatch() and AppendAndMatch() return false if this->IsCLosed() or
776 //this->Count() > 0 and curve is closed
777 ON_BOOL32 PrependAndMatch(ON_Curve*); //Prepend and match end of curve to start of polycurve
778 ON_BOOL32 AppendAndMatch(ON_Curve*); //Append and match start of curve to end of polycurve
779
780 ON_BOOL32 Remove(); // delete last segment and reduce count by 1
781 ON_BOOL32 Remove( int ); // delete specified segment and reduce count by 1
782
784 // Use the HarvestSegment() function when you want to prevent a
785 // segment from being destroyed by ~ON_PolyCurve(). HarvestSegment()
786 // replaces the polycurve segment with a NULL. Count() and parameter
787 // information remains unchanged.
788 ON_Curve* HarvestSegment( int );
789
790 /*
791 Returns:
792 True if a curve in the m_segment[] array is an ON_PolyCurve.
793 */
794 bool IsNested() const;
795
796 /*
797 Description:
798 Same as RemoveNestingEx().
799 Remarks:
800 RemoveNestingEx was added to avoid breaking the SDK.
801 */
802 void RemoveNesting();
803
804 /*
805 Description:
806 Removes the nested of polycurves. The result will have not
807 have an ON_PolyCurve as a segment but will have identical
808 locus and parameterization.
809 Returns:
810 True if a nested polycurve was removed. False
811 if no nested polycurves were found.
812 */
813 bool RemoveNestingEx();
814
815 /*
816 Returns:
817 True if the domains of the curves in the m_segment[] array exactly
818 match the domains of the segments specified in the m_t[] array.
819 Put another way, returns true if SegmentDomain(i) = SegmentCurve(i).Domain()
820 for every segment index.
821 */
822 bool HasSynchronizedSegmentDomains() const;
823
824 /*
825 Description:
826 Sets the domain of the curve int the m_segment[] array to exactly
827 match the domain defined in the m_t[] array. This is not required,
828 but can simplify some coding situations.
829 Returns:
830 True if at least one segment was reparameterized. False if no
831 changes were made.
832 */
833 bool SynchronizeSegmentDomains();
834
835
836
837
839 // Expert user function
840 // Sets the m_segment[index] to crv.
841 void SetSegment(int index, ON_Curve* crv);
842
844 /*
845 Description:
846 Expert user function to set the m_t[] array.
847 Parameters:
848 t - [in] increasing array of SegmentCount()+1 parameters.
849 Returns
850 True if successful.
851 */
852 bool SetParameterization( const double* t );
853
854/*
855 Description:
856 Lookup a parameter in the m_t array, optionally using a built in snap tolerance to
857 snap a parameter value to an element of m_t.
858 Parameters:
859 t - [in] parameter
860 index -[out] index into m_t such that if the function returns true then t is equal
861 to, or is within tolerance of m_t[index].
862 if function returns false then the value of index is
863
864 @table
865 condition value of index
866 t<m_t[0] or m_t is empty -1
867 m_t[i] < t < m_t[i+1] i for 0<=i<=m_t.Count()-2
868 t>m_t[ m_t.Count()-1] m_t.Count()-1
869
870 bEnableSnap -[in] if true use tolerance when comparing to m_t values
871 Returns
872 true if the t is exactly equal to, or within tolerance of
873 (only if bEnableSnap==true) m_t[index].
874*/
875 bool ParameterSearch(double t, int& index, bool bEnableSnap) const;
876
877 /*
878 Returns:
879 Reference to m_segment.
880 */
881 const ON_CurveArray& SegmentCurves() const;
882
883 /*
884 Returns:
885 Reference to m_t.
886 */
887 const ON_SimpleArray<double>& SegmentParameters() const;
888
890 // Implementation
891private:
892 // The curves in this array are deleted by ~ON_PolyCurve().
893 // Use ON_CurveProxy classes if you don't want ON_PolyCurve()
894 // to destroy the curve.
895
896 ON_CurveArray m_segment; // array of pointers to curves
897 // all have the same dimension
898 // and are contiguous to tolerance
899
900 ON_SimpleArray<double> m_t; // ON_PolyCurve segment parameterizations
901};
902
903
904#endif
@ Transform
Definition RSMetaType.h:67
Definition opennurbs_point.h:403
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
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
void DestroyRuntimeCache(bool bDelete=true)
Definition opennurbs_object.cpp:1761
virtual ON_BOOL32 IsArc(const ON_Plane *plane=NULL, ON_Arc *arc=NULL, double tolerance=ON_ZERO_TOLERANCE) const
Definition opennurbs_curve.cpp:248
bool GetTightBoundingBox(ON_BoundingBox &tight_bbox, int bGrowBox=false, const ON_Xform *xform=0) const
Definition opennurbs_basic.cpp:333
virtual int GetNurbForm(ON_NurbsCurve &nurbs_curve, double tolerance=0.0, const ON_Interval *subdomain=NULL) const
Definition opennurbs_curve.cpp:2625
virtual ON_BOOL32 ChangeClosedCurveSeam(double t)
Definition opennurbs_curve.cpp:117
virtual ON_BOOL32 GetNormalizedArcLengthPoint(double s, double *t, double fractional_tolerance=1.0e-8, const ON_Interval *sub_domain=NULL) const
Definition opennurbs_curve.cpp:2489
virtual ON_Curve * DuplicateCurve() const
Definition opennurbs_curve.cpp:66
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 GetLocalClosestPoint(const ON_3dPoint &test_point, double seed_parameter, double *t, const ON_Interval *sub_domain=0) const
Definition opennurbs_curve.cpp:1209
virtual ON_BOOL32 SetStartPoint(ON_3dPoint start_point)
Definition opennurbs_curve.cpp:779
virtual ON_BOOL32 IsPeriodic() const
Definition opennurbs_curve.cpp:444
virtual ON_BOOL32 Split(double t, ON_Curve *&left_side, ON_Curve *&right_side) const
Definition opennurbs_curve.cpp:2614
bool IsShort(double tolerance, const ON_Interval *sub_domain=NULL) const
Definition opennurbs_curve.cpp:1482
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 GetNormalizedArcLengthPoints(int count, const double *s, double *t, double absolute_tolerance=0.0, double fractional_tolerance=1.0e-8, const ON_Interval *sub_domain=NULL) const
Definition opennurbs_curve.cpp:2500
virtual ON_BOOL32 IsClosed() const
Definition opennurbs_curve.cpp:408
virtual ON_BOOL32 Reverse()=0
virtual ON_BOOL32 GetCurveParameterFromNurbFormParameter(double nurbs_t, double *curve_t) const
Definition opennurbs_curve.cpp:2659
bool SetDomain(ON_Interval domain)
Definition opennurbs_curve.cpp:105
virtual ON_BOOL32 GetLength(double *length, double fractional_tolerance=1.0e-8, const ON_Interval *sub_domain=NULL) const
Definition opennurbs_curve.cpp:1220
virtual ON_BOOL32 SetEndPoint(ON_3dPoint end_point)
Definition opennurbs_curve.cpp:784
virtual int SpanCount() const =0
virtual ON_BOOL32 GetNurbFormParameterFromCurveParameter(double curve_t, double *nurbs_t) const
Definition opennurbs_curve.cpp:2668
virtual ON_BOOL32 GetSpanVector(double *knots) const =0
virtual ON_BOOL32 IsLinear(double tolerance=ON_ZERO_TOLERANCE) const
Definition opennurbs_curve.cpp:184
virtual ON_BOOL32 IsPlanar(ON_Plane *plane=NULL, double tolerance=ON_ZERO_TOLERANCE) const
Definition opennurbs_curve.cpp:317
virtual ON_Interval Domain() const =0
virtual ON_BOOL32 Trim(const ON_Interval &domain)
Definition opennurbs_curve.cpp:2514
bool ParameterSearch(double t, int &index, bool bEnableSnap, const ON_SimpleArray< double > &m_t, double RelTol=ON_SQRT_EPSILON) const
Definition opennurbs_curve.cpp:3226
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
bool EvaluatePoint(const class ON_ObjRef &objref, ON_3dPoint &P) const
Definition opennurbs_curve.cpp:993
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
Definition opennurbs_objref.h:167
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_polycurve.h:38
ON_SimpleArray< double > m_t
Definition opennurbs_polycurve.h:900
ON_CurveArray m_segment
Definition opennurbs_polycurve.h:896
ON_OBJECT_DECLARE(ON_PolyCurve)
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
char s
Definition opennurbs_string.cpp:32
#define NULL
Definition opennurbs_system.h:256
int ON_BOOL32
Definition opennurbs_system.h:362
unsigned int ON__UINT32
Definition opennurbs_system.h:326