opennurbs_polycurve.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 ////////////////////////////////////////////////////////////////
18 //
19 // Definition of poly curve (composite curve)
20 //
21 ////////////////////////////////////////////////////////////////
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 */
36 class ON_CLASS ON_PolyCurve : public ON_Curve
37 {
38  ON_OBJECT_DECLARE(ON_PolyCurve);
39 
40 public:
41  ON_PolyCurve() ON_NOEXCEPT;
42  virtual ~ON_PolyCurve();
43  ON_PolyCurve(const ON_PolyCurve&);
45 
46 #if defined(ON_HAS_RVALUEREF)
47  // rvalue copy constructor
48  ON_PolyCurve( ON_PolyCurve&& ) ON_NOEXCEPT;
49 
50  // The rvalue assignment operator calls ON_Object::operator=(ON_Object&&)
51  // which could throw exceptions. See the implementation of
52  // ON_Object::operator=(ON_Object&&) for details.
54 #endif
55 
56 public:
57  // virtual ON_Object::DestroyRuntimeCache override
58  void DestroyRuntimeCache( bool bDelete = true ) override;
59 
60  ON_PolyCurve( int ); // int = initial capacity - use when a good estimate
61  // of the number of segments is known.
62 
63  void Destroy();
64 
65 
66  void EmergencyDestroy(); // call if memory used by ON_PolyCurve becomes invalid
67 
68 
69  /////////////////////////////////////////////////////////////////
70  // ON_Object overrides
71 
72  // virtual ON_Object::SizeOf override
73  unsigned int SizeOf() const override;
74 
75  // virtual ON_Object::DataCRC override
76  ON__UINT32 DataCRC(ON__UINT32 current_remainder) const override;
77 
78  bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
79 
80  /*
81  Description:
82  Tests an object to see if its data members are correctly
83  initialized.
84  Parameters:
85  bAllowGaps - [in]
86  If true, gaps are allowed between polycurve segments.
87  If false, gaps are not allowed between polycurve segments.
88  text_log - [in] if the object is not valid and text_log
89  is not nullptr, then a brief englis description of the
90  reason the object is not valid is appened to the log.
91  The information appended to text_log is suitable for
92  low-level debugging purposes by programmers and is
93  not intended to be useful as a high level user
94  interface tool.
95  Returns:
96  @untitled table
97  true object is valid
98  false object is invalid, uninitialized, etc.
99  Remarks:
100  Overrides virtual ON_Object::IsValid
101  */
102  bool IsValid( bool bAllowGaps, ON_TextLog* text_log ) const;
103 
104 
105  void Dump( ON_TextLog& ) const override; // for debugging
106 
107  bool Write(
108  ON_BinaryArchive& // open binary file
109  ) const override;
110 
111  bool Read(
112  ON_BinaryArchive& // open binary file
113  ) override;
114 
115  /////////////////////////////////////////////////////////////////
116  // ON_Geometry overrides
117 
118  int Dimension() const override;
119 
120  // virtual ON_Geometry GetBBox override
121  bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
122 
123  // virtual ON_Geometry GetTightBoundingBox override
124  bool GetTightBoundingBox( class ON_BoundingBox& tight_bbox, bool bGrowBox = false, const class ON_Xform* xform = nullptr ) const override;
125 
126  bool Transform(
127  const ON_Xform&
128  ) override;
129 
130  // virtual ON_Geometry::IsDeformable() override
131  bool IsDeformable() const override;
132 
133  // virtual ON_Geometry::MakeDeformable() override
134  bool MakeDeformable() override;
135 
136  bool SwapCoordinates(
137  int, int // indices of coords to swap
138  ) override;
139 
140 
141 
142  // virtual ON_Geometry override
143  bool EvaluatePoint( const class ON_ObjRef& objref, ON_3dPoint& P ) const override;
144 
145  /////////////////////////////////////////////////////////////////
146  // ON_Curve overrides
147 
148  ON_Curve* DuplicateCurve() const override;
149 
150  ON_Interval Domain() const override;
151 
152  // Description:
153  // virtual ON_Curve::SetDomain override.
154  // Set the domain of the curve
155  // Parameters:
156  // t0 - [in]
157  // t1 - [in] new domain will be [t0,t1]
158  // Returns:
159  // true if successful.
160  bool SetDomain(
161  double t0,
162  double t1
163  ) override;
164 
165  bool ChangeDimension(
166  int desired_dimension
167  ) override;
168 
169  /*
170  Description:
171  If this curve is closed, then modify it so that
172  the start/end point is at curve parameter t.
173  Parameters:
174  t - [in] curve parameter of new start/end point. The
175  returned curves domain will start at t.
176  Returns:
177  true if successful.
178  Remarks:
179  Overrides virtual ON_Curve::ChangeClosedCurveSeam
180  */
181  bool ChangeClosedCurveSeam(
182  double t
183  ) override;
184 
185  int SpanCount() const override; // number of smooth spans in curve
186 
187  bool GetSpanVector( // span "knots"
188  double* // array of length SpanCount() + 1
189  ) const override; //
190 
191  int Degree( // returns maximum algebraic degree of any span
192  // ( or a good estimate if curve spans are not algebraic )
193  ) const override;
194 
195  bool IsLinear( // true if curve locus is a line segment between
196  // between specified points
197  double = ON_ZERO_TOLERANCE // tolerance to use when checking linearity
198  ) const override;
199 
200  /*
201  Description:
202  Several types of ON_Curve can have the form of a polyline including
203  a degree 1 ON_NurbsCurve, an ON_PolylineCurve, and an ON_PolyCurve
204  all of whose segments are some form of polyline. IsPolyline tests
205  a curve to see if it can be represented as a polyline.
206  Parameters:
207  pline_points - [out] if not nullptr and true is returned, then the
208  points of the polyline form are returned here.
209  t - [out] if not nullptr and true is returned, then the parameters of
210  the polyline points are returned here.
211  Returns:
212  @untitled table
213  0 curve is not some form of a polyline
214  >=2 number of points in polyline form
215  */
216  int IsPolyline(
217  ON_SimpleArray<ON_3dPoint>* pline_points = nullptr,
218  ON_SimpleArray<double>* pline_t = nullptr
219  ) const override;
220 
221  bool IsArc( // ON_Arc.m_angle > 0 if curve locus is an arc between
222  // specified points
223  const ON_Plane* = nullptr, // if not nullptr, test is performed in this plane
224  ON_Arc* = nullptr, // if not nullptr and true is returned, then arc parameters
225  // are filled in
226  double = ON_ZERO_TOLERANCE // tolerance to use when checking
227  ) const override;
228 
229  bool IsPlanar(
230  ON_Plane* = nullptr, // if not nullptr and true is returned, then plane parameters
231  // are filled in
232  double = ON_ZERO_TOLERANCE // tolerance to use when checking
233  ) const override;
234 
235  bool IsInPlane(
236  const ON_Plane&, // plane to test
237  double = ON_ZERO_TOLERANCE // tolerance to use when checking
238  ) const override;
239 
240  bool IsClosed( // true if curve is closed (either curve has
241  void // clamped end knots and euclidean location of start
242  ) const override; // CV = euclidean location of end CV, or curve is
243  // periodic.)
244 
245  bool IsPeriodic( // true if curve is a single periodic segment
246  void
247  ) const override;
248 
249  /*
250  Description:
251  Search for a derivatitive, tangent, or curvature discontinuity.
252  Parameters:
253  c - [in] type of continity to test for. If ON::continuity::C1_continuous
254  t0 - [in] search begins at t0
255  t1 - [in] (t0 < t1) search ends at t1
256  t - [out] if a discontinuity is found, the *t reports the
257  parameter at the discontinuity.
258  hint - [in/out] if GetNextDiscontinuity will be called repeatedly,
259  passing a "hint" with initial value *hint=0 will increase the speed
260  of the search.
261  dtype - [out] if not nullptr, *dtype reports the kind of discontinuity
262  found at *t. A value of 1 means the first derivative or unit tangent
263  was discontinuous. A value of 2 means the second derivative or
264  curvature was discontinuous.
265  cos_angle_tolerance - [in] default = cos(1 degree) Used only when
266  c is ON::continuity::G1_continuous or ON::continuity::G2_continuous. If the cosine
267  of the angle between two tangent vectors
268  is <= cos_angle_tolerance, then a G1 discontinuity is reported.
269  curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when
270  c is ON::continuity::G2_continuous or ON::continuity::Gsmooth_continuous.
271  ON::continuity::G2_continuous:
272  If K0 and K1 are curvatures evaluated
273  from above and below and |K0 - K1| > curvature_tolerance,
274  then a curvature discontinuity is reported.
275  ON::continuity::Gsmooth_continuous:
276  If K0 and K1 are curvatures evaluated from above and below
277  and the angle between K0 and K1 is at least twice angle tolerance
278  or ||K0| - |K1|| > (max(|K0|,|K1|) > curvature_tolerance,
279  then a curvature discontinuity is reported.
280  Returns:
281  true if a discontinuity was found on the interior of the interval (t0,t1).
282  Remarks:
283  Overrides ON_Curve::GetNextDiscontinuity.
284  */
285  bool GetNextDiscontinuity(
286  ON::continuity c,
287  double t0,
288  double t1,
289  double* t,
290  int* hint=nullptr,
291  int* dtype=nullptr,
292  double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
293  double curvature_tolerance=ON_SQRT_EPSILON
294  ) const override;
295 
296  /*
297  Description:
298  Test continuity at a curve parameter value.
299  Parameters:
300  c - [in] continuity to test for
301  t - [in] parameter to test
302  hint - [in] evaluation hint
303  point_tolerance - [in] if the distance between two points is
304  greater than point_tolerance, then the curve is not C0.
305  d1_tolerance - [in] if the difference between two first derivatives is
306  greater than d1_tolerance, then the curve is not C1.
307  d2_tolerance - [in] if the difference between two second derivatives is
308  greater than d2_tolerance, then the curve is not C2.
309  cos_angle_tolerance - [in] default = cos(1 degree) Used only when
310  c is ON::continuity::G1_continuous or ON::continuity::G2_continuous. If the cosine
311  of the angle between two tangent vectors
312  is <= cos_angle_tolerance, then a G1 discontinuity is reported.
313  curvature_tolerance - [in] (default = ON_SQRT_EPSILON) Used only when
314  c is ON::continuity::G2_continuous or ON::continuity::Gsmooth_continuous.
315  ON::continuity::G2_continuous:
316  If K0 and K1 are curvatures evaluated
317  from above and below and |K0 - K1| > curvature_tolerance,
318  then a curvature discontinuity is reported.
319  ON::continuity::Gsmooth_continuous:
320  If K0 and K1 are curvatures evaluated from above and below
321  and the angle between K0 and K1 is at least twice angle tolerance
322  or ||K0| - |K1|| > (max(|K0|,|K1|) > curvature_tolerance,
323  then a curvature discontinuity is reported.
324  Returns:
325  true if the curve has at least the c type continuity at the parameter t.
326  Remarks:
327  Overrides ON_Curve::IsContinuous.
328  */
329  bool IsContinuous(
330  ON::continuity c,
331  double t,
332  int* hint = nullptr,
333  double point_tolerance=ON_ZERO_TOLERANCE,
334  double d1_tolerance=ON_ZERO_TOLERANCE,
335  double d2_tolerance=ON_ZERO_TOLERANCE,
336  double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
337  double curvature_tolerance=ON_SQRT_EPSILON
338  ) const override;
339 
340  bool Reverse() override; // reverse parameterizatrion
341  // Domain changes from [a,b] to [-b,-a]
342 
343  /*
344  Description:
345  Force the curve to start at a specified point.
346  Parameters:
347  start_point - [in]
348  Returns:
349  true if successful.
350  Remarks:
351  Some start points cannot be moved. Be sure to check return
352  code.
353  See Also:
354  ON_Curve::SetEndPoint
355  ON_Curve::PointAtStart
356  ON_Curve::PointAtEnd
357  */
358  // virtual
359  bool SetStartPoint(
360  ON_3dPoint start_point
361  ) override;
362 
363  /*
364  Description:
365  Force the curve to end at a specified point.
366  Parameters:
367  end_point - [in]
368  Returns:
369  true if successful.
370  Remarks:
371  Some end points cannot be moved. Be sure to check return
372  code.
373  See Also:
374  ON_Curve::SetStartPoint
375  ON_Curve::PointAtStart
376  ON_Curve::PointAtEnd
377  */
378  //virtual
379  bool SetEndPoint(
380  ON_3dPoint end_point
381  ) override;
382 
383  bool Evaluate( // returns false if unable to evaluate
384  double, // evaluation parameter
385  int, // number of derivatives (>=0)
386  int, // array stride (>=Dimension())
387  double*, // array of length stride*(ndir+1)
388  int = 0, // optional - determines which side to evaluate from
389  // 0 = default
390  // < 0 to evaluate from below,
391  // > 0 to evaluate from above
392  int* = 0 // optional - evaluation hint (int) used to speed
393  // repeated evaluations
394  ) const override;
395 
396 
397  // Description:
398  // virtual ON_Curve::Trim override.
399  // Removes portions of the curve outside the specified interval.
400  // Parameters:
401  // domain - [in] interval of the curve to keep. Portions of the
402  // curve before curve(domain[0]) and after curve(domain[1]) are
403  // removed.
404  // Returns:
405  // true if successful.
406  bool Trim(
407  const ON_Interval& domain
408  ) override;
409 
410  // Description:
411  // Where possible, analytically extends curve to include domain.
412  // Parameters:
413  // domain - [in] if domain is not included in curve domain,
414  // curve will be extended so that its domain includes domain.
415  // Will not work if curve is closed. Original curve is identical
416  // to the restriction of the resulting curve to the original curve domain,
417  // Returns:
418  // true if successful.
419  bool Extend(
420  const ON_Interval& domain
421  ) override;
422 
423  // Description:
424  // virtual ON_Curve::Split override.
425  // Divide the curve at the specified parameter. The parameter
426  // must be in the interior of the curve's domain. The pointers
427  // passed to Split must either be nullptr or point to an ON_Curve
428  // object of the same of the same type. If the pointer is nullptr,
429  // then a curve will be created in Split(). You may pass "this"
430  // as one of the pointers to Split().
431  // Parameters:
432  // t - [in] parameter in interval Domain().
433  // left_side - [out] left portion of curve
434  // right_side - [out] right portion of curve
435  // Example:
436  // For example, if crv were an ON_NurbsCurve, then
437  //
438  // ON_NurbsCurve right_side;
439  // crv.Split( crv.Domain().Mid() &crv, &right_side );
440  //
441  // would split crv at the parametric midpoint, put the left side
442  // in crv, and return the right side in right_side.
443  bool Split(
444  double t, // t = curve parameter to split curve at
445  ON_Curve*& left_side, // left portion returned here
446  ON_Curve*& right_side // right portion returned here
447  ) const override;
448 
449  int GetNurbForm( // returns 0: unable to create NURBS representation
450  // with desired accuracy.
451  // 1: success - returned NURBS parameterization
452  // matches the curve's to wthe desired accuracy
453  // 2: success - returned NURBS point locus matches
454  // the curve's to the desired accuracy but, on
455  // the interior of the curve's domain, the
456  // curve's parameterization and the NURBS
457  // parameterization may not match to the
458  // desired accuracy.
459  ON_NurbsCurve&,
460  double = 0.0,
461  const ON_Interval* = nullptr // OPTIONAL subdomain of polycurve
462  ) const override;
463 
464  int HasNurbForm( // returns 0: unable to create NURBS representation
465  // with desired accuracy.
466  // 1: success - returned NURBS parameterization
467  // matches the curve's to wthe desired accuracy
468  // 2: success - returned NURBS point locus matches
469  // the curve's to the desired accuracy but, on
470  // the interior of the curve's domain, the
471  // curve's parameterization and the NURBS
472  // parameterization may not match to the
473  // desired accuracy.
474  ) const override;
475 
476  // virtual ON_Curve::GetCurveParameterFromNurbFormParameter override
478  double, // nurbs_t
479  double* // curve_t
480  ) const override;
481 
482  // virtual ON_Curve::GetNurbFormParameterFromCurveParameter override
484  double, // curve_t
485  double* // nurbs_t
486  ) const override;
487 
488  /////////////////////////////////////////////////////////////////
489  // Interface
490 
491  int Count() const; // number of segment curves
492 
493  // These operator[] functions return nullptr if index is out of range
494  ON_Curve* operator[](int) const;
495 
496  /*
497  Description:
498  Returns a pointer to a segment curve.
499  Parameters:
500  segment_index - [in] 0 based index (0 <= segment_index < Count() )
501  Returns:
502  A pointer to the segment curve. Returns nullptr if segment_index < 0
503  or segment_index >= Count().
504  */
505  ON_Curve* SegmentCurve(
506  int segment_index
507  ) const;
508 
509  /*
510  Description:
511  Converts a polycurve parameter to a segment curve parameter.
512  Parameters:
513  polycurve_parameter - [in]
514  Returns:
515  Segment curve evaluation parameter or ON_UNSET_VALUE if the
516  segment curve parameter cannot be computed.
517  See Also:
518  ON_PolyCurve::PolyCurveParameter
519  */
520  double SegmentCurveParameter(
521  double polycurve_parameter
522  ) const;
523 
524  /*
525  Description:
526  Converts a segment curve parameter to a polycurve parameter.
527  Parameters:
528  segment_index - [in]
529  segmentcurve_parameter - [in]
530  Returns:
531  Polycurve evaluation parameter or ON_UNSET_VALUE if the
532  polycurve curve parameter cannot be computed.
533  See Also:
534  ON_PolyCurve::SegmentCurveParameter
535  */
536  double PolyCurveParameter(
537  int segment_index,
538  double segmentcurve_parameter
539  ) const;
540 
541  /*
542  Description:
543  Returns the polycurve subdomain assigned to a segment curve.
544  Parameters:
545  segment_index - [in] 0 based index (0 <= segment_index < Count() )
546  Returns:
547  The polycurve subdomain assigned to a segment curve.
548  Returns ([ON_UNSET_VALUE,ON_UNSET_VALUE) if segment_index < 0
549  or segment_index >= Count().
550  */
551  ON_Interval SegmentDomain(
552  int segment_index
553  ) const;
554 
555  /*
556  Description:
557  Find the segment used for evaluation at polycurve_parameter.
558  Parameters:
559  polycurve_parameter - [in]
560  Returns:
561  index of the segment used for evaluation at polycurve_parameter.
562  If polycurve_parameter < Domain.Min(), then 0 is returned.
563  If polycurve_parameter > Domain.Max(), then Count()-1 is returned.
564  */
565  int SegmentIndex(
566  double polycurve_parameter
567  ) const;
568 
569  /*
570  Description:
571  Find the segments with support on sub_domain.
572  Parameters:
573  sub_domain - [in] increasing interval
574  segment_index0 - [out]
575  segment_index1 - [out] segments with index i where
576  *segment_index0 <= i < *segment_index1 are the segments
577  with support on the sub_domain
578  Returns:
579  number of segments with support on sub_domain.
580  */
581  int SegmentIndex(
582  ON_Interval sub_domain,
583  int* segment_index0,
584  int* segment_index1
585  ) const;
586 
587  ON_Curve* FirstSegmentCurve() const; // returns nullptr if count = 0
588 
589  ON_Curve* LastSegmentCurve() const; // returns nullptr if count = 0
590 
591  /*
592  Description:
593  Search the curve for gaps between the sub curve segments.
594  Parameters:
595  segment_index0 - [in]
596  The search for gaps starts at with the comparing
597  the end of segment[segment_index0] and the start of
598  segment[segment_index0+1].
599  Returns:
600  0:
601  No gaps were found.
602  i > segment_index0:
603  The end of polycuve segment[i-1] is not coincident
604  with the start of polycurve segment[i].
605  */
606  int FindNextGap( int segment_index0 ) const;
607 
608  /*
609  Description:
610  Determine if there is a gap between the end of
611  segment[segment_index] and the start of segment[segment_index+1].
612  Parameters:
613  segment_index - [in]
614  >= 0
615  Returns:
616  true:
617  segment_index was valid and there is a gap between
618  the end of segment[segment_index] and the start of
619  segment[segment_index+1].
620  */
621  bool HasGapAt( int segment_index ) const;
622 
623  ON_DEPRECATED_MSG("Replace calls to HasGap() with FindNextGap(0)")
624  int HasGap() const;
625 
626  /*
627  Description:
628  Modify the one or both locations at the end of
629  segment[gap_index-1] and the start of segment[gap_index]
630  so they are coindicent.
631  Parameters:
632  gap_index - [in] 1 <= gap_index < Count()
633  If the locations at the end of segment[gap_index-1] and
634  the start of segment[gap_index] are not identical, then
635  an attempt is made to modify the segments so these
636  locations are closer.
637  ends_to_modify - [in]
638  0: (suggested)
639  The code will decide what segments to modify.
640  1:
641  modify the end location of segment[gap_index-1]
642  2:
643  modify the start location of segment[gap_index]
644  Returns:
645  True if a modification was performed and HasGap(gap_index-1)
646  returns 0 after the modification.
647  False if no modification was preformed because there
648  was no gap or because one could not be performed.
649  Remarks:
650  Note that passing the return value from FindNextGap() will
651  close the gap found by FindNextGap().
652  */
653  bool CloseGap( int gap_index, int segments_to_modify );
654 
655  /*
656  Description:
657  Searches for and closes all gaps that can be found.
658  Returns:
659  Number of gaps that were closed.
660  */
661  int CloseGaps();
662 
663  void Reserve( int ); // make sure capacity is at least the specified count
664 
665  // ON_Curve pointers added with Prepend(), Append(), PrependAndMatch(), AppendANdMatch(),and Insert() are deleted
666  // by ~ON_PolyCurve(). Use ON_CurveProxy( ON_Curve*) if you want
667  // the original curve segment to survive ~ON_PolyCurve().
668  bool Prepend( ON_Curve* ); // Prepend curve.
669  bool Append( ON_Curve* ); // Append curve.
670  bool Insert(
671  int, // segment_index,
672  ON_Curve*
673  );
674 
675  //PrependAndMatch() and AppendAndMatch() return false if this->IsCLosed() or
676  //this->Count() > 0 and curve is closed
677  bool PrependAndMatch(ON_Curve*); //Prepend and match end of curve to start of polycurve
678  bool AppendAndMatch(ON_Curve*); //Append and match start of curve to end of polycurve
679 
680  bool Remove(); // delete last segment and reduce count by 1
681  bool Remove( int ); // delete specified segment and reduce count by 1
682 
683  //////////
684  // Use the HarvestSegment() function when you want to prevent a
685  // segment from being destroyed by ~ON_PolyCurve(). HarvestSegment()
686  // replaces the polycurve segment with a nullptr. Count() and parameter
687  // information remains unchanged.
688  ON_Curve* HarvestSegment( int );
689 
690  /*
691  Returns:
692  True if a curve in the m_segment[] array is an ON_PolyCurve.
693  */
694  bool IsNested() const;
695 
696  /*
697  Description:
698  Removes the nested of polycurves. The result will have not
699  have an ON_PolyCurve as a segment but will have identical
700  locus and parameterization.
701  Returns:
702  True if a nested polycurve was removed. False
703  if no nested polycurves were found.
704  */
705  bool RemoveNesting();
706 
707  ON_DEPRECATED_MSG("Use RemoveNesting(). RemoveNestingEx() will be removed in the next release.")
708  bool RemoveNestingEx();
709 
710  /*
711  Returns:
712  True if the domains of the curves in the m_segment[] array exactly
713  match the domains of the segments specified in the m_t[] array.
714  Put another way, returns true if SegmentDomain(i) = SegmentCurve(i).Domain()
715  for every segment index.
716  */
717  bool HasSynchronizedSegmentDomains() const;
718 
719  /*
720  Description:
721  Sets the domain of the curve int the m_segment[] array to exactly
722  match the domain defined in the m_t[] array. This is not required,
723  but can simplify some coding situations.
724  Returns:
725  True if at least one segment was reparameterized. False if no
726  changes were made.
727  */
728  bool SynchronizeSegmentDomains();
729 
730 
731 
732 
733  //////////
734  // Expert user function
735  // Sets the m_segment[index] to crv.
736  void SetSegment(int index, ON_Curve* crv);
737 
738  //////////
739  /*
740  Description:
741  Expert user function to set the m_t[] array.
742  Parameters:
743  t - [in] increasing array of SegmentCount()+1 parameters.
744  Returns
745  True if successful.
746  */
747  bool SetParameterization( const double* t );
748 
749 /*
750  Description:
751  Lookup a parameter in the m_t array, optionally using a built in snap tolerance to
752  snap a parameter value to an element of m_t.
753  Parameters:
754  t - [in] parameter
755  index -[out] index into m_t such that if the function returns true then t is equal
756  to, or is within tolerance of m_t[index].
757  if function returns false then the value of index is
758 
759  @table
760  condition value of index
761  t<m_t[0] or m_t is empty -1
762  m_t[i] < t < m_t[i+1] i for 0<=i<=m_t.Count()-2
763  t>m_t[ m_t.Count()-1] m_t.Count()-1
764 
765  bEnableSnap -[in] if true use tolerance when comparing to m_t values
766  Returns
767  true if the t is exactly equal to, or within tolerance of
768  (only if bEnableSnap==true) m_t[index].
769 */
770  bool ParameterSearch(double t, int& index, bool bEnableSnap) const;
771 
772  /*
773  Returns:
774  Reference to m_segment.
775  */
776  const ON_CurveArray& SegmentCurves() const;
777 
778  /*
779  Returns:
780  Reference to m_t.
781  */
782  const ON_SimpleArray<double>& SegmentParameters() const;
783 
784  /////////////////////////////////////////////////////////////////
785  // Implementation
786 private:
787  // The curves in this array are deleted by ~ON_PolyCurve().
788  // Use ON_CurveProxy classes if you don't want ON_PolyCurve()
789  // to destroy the curve.
790 
791  ON_CurveArray m_segment; // array of pointers to curves
792  // all have the same dimension
793  // and are contiguous to tolerance
794 
795  ON_SimpleArray<double> m_t; // ON_PolyCurve segment parameterizations
796 };
797 
798 
799 #endif
virtual bool IsClosed() const
Test a curve to see if it is closed.
Definition: opennurbs_curve.h:1168
virtual int SpanCount() const =0
Get number of nonempty smooth (c-infinity) spans in curve
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
Test continuity at a curve parameter value.
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
Search for a derivatitive, tangent, or curvature discontinuity.
virtual int Dimension() const
Dimension of the object.
An ON_Arc is a subcurve of 3d circle.
Definition: opennurbs_arc.h:33
virtual bool GetBBox(double *boxmin, double *boxmax, bool bGrowBox=false) const
This is the virtual function that actually calculates axis aligned bounding boxes.
bool ParameterSearch(double t, int &index, bool bEnableSnap, const ON_SimpleArray< double > &m_t, double RelTol=ON_SQRT_EPSILON) const
Lookup a parameter in the m_t array, optionally using a built in snap tolerance to snap a parameter v...
virtual bool IsArc(const ON_Plane *plane=nullptr, ON_Arc *arc=nullptr, double tolerance=ON_ZERO_TOLERANCE) const
Test a curve to see if the locus if its points is an arc or circle.
virtual bool SetStartPoint(ON_3dPoint start_point)
Force the curve to start at a specified point.
virtual int HasNurbForm() const
Does a NURBS curve representation of this curve.
virtual bool GetSpanVector(double *knots) const =0
Get number of parameters of "knots".
virtual bool MakeDeformable()
If possible, converts the object into a form that can be accuratly modified with "squishy" transforma...
virtual bool Reverse()=0
Reverse the direction of the curve.
virtual bool Extend(const ON_Interval &domain)
Pure virtual function. Default returns false. Where possible, analytically extends curve to include d...
ON_Curve is a pure virtual class for curve objects
Definition: opennurbs_curve.h:93
virtual int GetNurbForm(ON_NurbsCurve &nurbs_curve, double tolerance=0.0, const ON_Interval *subdomain=nullptr) const
Get a NURBS curve representation of this curve.
virtual int Degree() const =0
Returns maximum algebraic degree of any span or a good estimate if curve spans are not algebraic...
virtual bool IsPlanar(ON_Plane *plane=nullptr, double tolerance=ON_ZERO_TOLERANCE) const
Test a curve to see if it is planar.
virtual bool SwapCoordinates(int i, int j)
Swaps object coordinate values with indices i and j.
virtual bool GetNurbFormParameterFromCurveParameter(double curve_t, double *nurbs_t) const
Convert a curve parameter to a NURBS curve parameter.
virtual ON_Curve * DuplicateCurve() const
Get a duplicate of the curve.
virtual bool ChangeDimension(int desired_dimension)
Change the dimension of a curve.
bool EvaluatePoint(const class ON_ObjRef &objref, ON_3dPoint &P) const override
virtual ON_Geometry override
virtual bool IsInPlane(const ON_Plane &test_plane, double tolerance=ON_ZERO_TOLERANCE) const =0
Test a curve to see if it lies in a specific plane.
bool Transform(const ON_Xform &xform) override
overrides virtual ON_Geometry::Transform(). ON_Curve::Transform() calls ON_Geometry::Transform(xform)...
virtual int IsPolyline(ON_SimpleArray< ON_3dPoint > *pline_points=nullptr, ON_SimpleArray< double > *pline_t=nullptr) const
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.
virtual bool ChangeClosedCurveSeam(double t)
If this curve is closed, then modify it so that the start/end point is at curve parameter t...
Definition: opennurbs_bounding_box.h:25
Definition: opennurbs_xform.h:28
An ON_PolyCurve is an ON_Curve represented by a sequence of contiguous ON_Curve segments. A valid polycurve is represented by an array m_segment of Count()>=1 curve objects and a strictly increasing array m_t of Count()+1 parameter values. The i-th curve segment, when considered as part of the polycurve, is affinely reparamaterized from m_t[i] to m_t[i+1], i.e., m_segment[i].Domain()[0] is mapped to m_t[i] and m_segment[i].Domain()[1] is mapped to m_t[i+1].
Definition: opennurbs_polycurve.h:35
bool GetTightBoundingBox(class ON_BoundingBox &tight_bbox, bool bGrowBox=false, const class ON_Xform *xform=nullptr) const override
virtual ON_Geometry GetTightBoundingBox override
virtual void Dump(ON_TextLog &) const
Creates a text dump of the object.
void EmergencyDestroy()
Sets m_user_data_list = 0.
virtual bool IsDeformable() const
ON_Curve & operator=(const ON_Curve &)
virtual bool IsPeriodic() const
Test a curve to see if it is periodic.
bool SetDomain(ON_Interval domain)
Set the domain of the curve.
virtual bool GetCurveParameterFromNurbFormParameter(double nurbs_t, double *curve_t) const
Convert a NURBS curve parameter to a curve parameter
virtual bool Trim(const ON_Interval &domain)
Removes portions of the curve outside the specified interval.
virtual bool SetEndPoint(ON_3dPoint end_point)
Force the curve to end at a specified point.
virtual bool Evaluate(double t, int der_count, int v_stride, double *v, int side=0, int *hint=0) const =0
This evaluator actually does all the work. The other ON_Curve evaluation tools call this virtual func...
Definition: opennurbs_nurbscurve.h:26
Definition: opennurbs_textlog.h:20
Definition: opennurbs_archive.h:1783
virtual bool Read(ON_BinaryArchive &binary_archive)
Low level archive writing tool used by ON_BinaryArchive::ReadObject().
Definition: opennurbs_objref.h:163
Definition: opennurbs_point.h:460
bool IsValid(class ON_TextLog *text_log=nullptr) const override
Tests an object to see if its data members are correctly initialized.
virtual bool Write(ON_BinaryArchive &binary_archive) const
Low level archive writing tool used by ON_BinaryArchive::WriteObject().
virtual ON__UINT32 DataCRC(ON__UINT32 current_remainder) const
Returns a CRC calculated from the information that defines the object. This CRC can be used as a quic...
Definition: opennurbs_plane.h:20
void DestroyRuntimeCache(bool bDelete=true) override
virtual ON_Object::DestroyRuntimeCache override
unsigned int SizeOf() const override
virtual ON_Object::SizeOf override
virtual bool IsLinear(double tolerance=ON_ZERO_TOLERANCE) const
Test a curve to see if the locus if its points is a line segment.
Definition: opennurbs_point.h:46
virtual ON_Interval Domain() const =0
virtual bool Split(double t, ON_Curve *&left_side, ON_Curve *&right_side) const
Splits (divides) the curve at the specified parameter. The parameter must be in the interior of the c...