opennurbs_arccurve.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 #if !defined(ON_GEOMETRY_CURVE_ARC_INC_)
18 #define ON_GEOMETRY_CURVE_ARC_INC_
19 
20 
21 /*
22 Description:
23  ON_ArcCurve is used to represent arcs and circles.
24  ON_ArcCurve.IsCircle() returns true if the curve
25  is a complete circle.
26 Remarks:
27  - An ON_ArcCurve is a subcurve of a circle, with a
28  constant speed parameterization. The parameterization is
29  an affine linear reparameterzation of the underlying arc
30  m_arc onto the domain m_t.
31  - A valid ON_ArcCurve has Radius()>0 and 0<AngleRadians()<=2*PI
32  and a strictly increasing Domain().
33 */
34 class ON_CLASS ON_ArcCurve : public ON_Curve
35 {
36  ON_OBJECT_DECLARE(ON_ArcCurve);
37 
38 public:
39  ON_ArcCurve() ON_NOEXCEPT;
40  virtual ~ON_ArcCurve();
41  ON_ArcCurve(const ON_ArcCurve&);
43 
44 #if defined(ON_HAS_RVALUEREF)
45  // rvalue copy constructor
46  ON_ArcCurve( ON_ArcCurve&& ) ON_NOEXCEPT;
47 
48  // The rvalue assignment operator calls ON_Object::operator=(ON_Object&&)
49  // which could throw exceptions. See the implementation of
50  // ON_Object::operator=(ON_Object&&) for details.
52 #endif
53 
54  // virtual ON_Object::SizeOf override
55  unsigned int SizeOf() const override;
56 
57  // virtual ON_Object::DataCRC override
58  ON__UINT32 DataCRC(ON__UINT32 current_remainder) const override;
59 
60  /*
61  Description:
62  Create an arc curve with domain (0,arc.Length()).
63  */
64  ON_ArcCurve(
65  const ON_Arc& arc
66  );
67 
68  /*
69  Description:
70  Create an arc curve with domain (t0,t1)
71  */
73  const ON_Arc& arc,
74  double t0,
75  double t1
76  );
77 
78  /*
79  Description:
80  Creates a curve that is a complete circle with
81  domain (0,circle.Length()).
82  */
84  const ON_Circle& circle
85  );
86 
87  /*
88  Description:
89  Creates a curve that is a complete circle with domain (t0,t1).
90  */
92  const ON_Circle& circle,
93  double t0,
94  double t1
95  );
96 
97  /*
98  Description:
99  Create an arc curve with domain (0,arc.Length()).
100  */
101  ON_ArcCurve& operator=(const ON_Arc& arc);
102 
103  /*
104  Description:
105  Creates a curve that is a complete circle with
106  domain (0,circle.Length()).
107  */
108  ON_ArcCurve& operator=(const ON_Circle& circle);
109 
110  /////////////////////////////////////////////////////////////////
111  // ON_Object overrides
112 
113  bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
114 
115  void Dump( ON_TextLog& ) const override;
116 
117  bool Write(
118  ON_BinaryArchive& // open binary file
119  ) const override;
120 
121  bool Read(
122  ON_BinaryArchive& // open binary file
123  ) override;
124 
125  /////////////////////////////////////////////////////////////////
126  // ON_Geometry overrides
127 
128  int Dimension() const override;
129 
130  // virtual ON_Geometry GetBBox override
131  bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
132 
133  // virtual ON_Geometry GetTightBoundingBox override
134  bool GetTightBoundingBox( class ON_BoundingBox& tight_bbox, bool bGrowBox = false, const class ON_Xform* xform = nullptr ) const override;
135 
136  bool Transform(
137  const ON_Xform&
138  ) override;
139 
140  /////////////////////////////////////////////////////////////////
141  // ON_Curve overrides
142 
143  // Description:
144  // virtual ON_Curve::SetDomain override.
145  // Set the domain of the curve
146  // Parameters:
147  // t0 - [in]
148  // t1 - [in] new domain will be [t0,t1]
149  // Returns:
150  // true if successful.
151  bool SetDomain(
152  double t0,
153  double t1
154  ) override;
155 
156  ON_Interval Domain() const override;
157 
158  bool ChangeDimension(
159  int desired_dimension
160  ) override;
161 
162  bool ChangeClosedCurveSeam(
163  double t
164  ) override;
165 
166  int SpanCount() const override; // number of smooth spans in curve
167 
168  bool GetSpanVector( // span "knots"
169  double* // array of length SpanCount() + 1
170  ) const override; //
171 
172  int Degree( // returns maximum algebraic degree of any span
173  // ( or a good estimate if curve spans are not algebraic )
174  ) const override;
175 
176  bool IsLinear( // true if curve locus is a line segment between
177  // between specified points
178  double = ON_ZERO_TOLERANCE // tolerance to use when checking linearity
179  ) const override;
180 
181  bool IsArc( // ON_Arc.m_angle > 0 if curve locus is an arc between
182  // specified points
183  const ON_Plane* = nullptr, // if not nullptr, test is performed in this plane
184  ON_Arc* = nullptr, // if not nullptr and true is returned, then arc parameters
185  // are filled in
186  double = 0.0 // tolerance to use when checking
187  ) const override;
188 
189  bool IsPlanar(
190  ON_Plane* = nullptr, // if not nullptr and true is returned, then plane parameters
191  // are filled in
192  double = 0.0 // tolerance to use when checking
193  ) const override;
194 
195  bool IsInPlane(
196  const ON_Plane&, // plane to test
197  double = 0.0 // tolerance to use when checking
198  ) const override;
199 
200  bool IsClosed( // true if curve is closed (either curve has
201  void // clamped end knots and euclidean location of start
202  ) const override; // CV = euclidean location of end CV, or curve is
203  // periodic.)
204 
205  bool IsPeriodic( // true if curve is a single periodic segment
206  void
207  ) const override;
208 
209  bool IsContinuous(
210  ON::continuity c,
211  double t,
212  int* hint = nullptr,
213  double point_tolerance=ON_ZERO_TOLERANCE,
214  double d1_tolerance=ON_ZERO_TOLERANCE,
215  double d2_tolerance=ON_ZERO_TOLERANCE,
216  double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
217  double curvature_tolerance=ON_SQRT_EPSILON
218  ) const override;
219 
220  bool Reverse() override; // reverse parameterizatrion
221  // Domain changes from [a,b] to [-b,-a]
222 
223  /*
224  Description:
225  Force the curve to start at a specified point.
226  Parameters:
227  start_point - [in]
228  Returns:
229  true if successful.
230  Remarks:
231  Some end points cannot be moved. Be sure to check return
232  code.
233  See Also:
234  ON_Curve::SetEndPoint
235  ON_Curve::PointAtStart
236  ON_Curve::PointAtEnd
237  */
238  bool SetStartPoint(
239  ON_3dPoint start_point
240  ) override;
241 
242  /*
243  Description:
244  Force the curve to end at a specified point.
245  Parameters:
246  end_point - [in]
247  Returns:
248  true if successful.
249  Remarks:
250  Some end points cannot be moved. Be sure to check return
251  code.
252  See Also:
253  ON_Curve::SetStartPoint
254  ON_Curve::PointAtStart
255  ON_Curve::PointAtEnd
256  */
257  bool SetEndPoint(
258  ON_3dPoint end_point
259  ) override;
260 
261  bool Evaluate( // returns false if unable to evaluate
262  double, // evaluation parameter
263  int, // number of derivatives (>=0)
264  int, // array stride (>=Dimension())
265  double*, // array of length stride*(ndir+1)
266  int = 0, // optional - determines which side to evaluate from
267  // 0 = default
268  // < 0 to evaluate from below,
269  // > 0 to evaluate from above
270  int* = 0 // optional - evaluation hint (int) used to speed
271  // repeated evaluations
272  ) const override;
273 
274  bool Trim( const ON_Interval& ) override;
275 
276  // Description:
277  // Where possible, analytically extends curve to include domain.
278  // Parameters:
279  // domain - [in] if domain is not included in curve domain,
280  // curve will be extended so that its domain includes domain.
281  // Will not work if curve is closed. Original curve is identical
282  // to the restriction of the resulting curve to the original curve domain,
283  // Returns:
284  // true if successful.
285  bool Extend(
286  const ON_Interval& domain
287  ) override;
288 
289  /*
290  Description:
291  Splits (divides) the arc at the specified parameter.
292  The parameter must be in the interior of the arc's domain.
293  The ON_Curve pointers passed to ON_ArcCurve::Split must
294  either be nullptr or point to ON_ArcCurve objects.
295  If a pointer is nullptr, then an ON_ArcCurve will be created
296  in Split(). You may pass "this" as left_side or right_side.
297  Parameters:
298  t - [in] parameter to split the curve at in the
299  interval returned by Domain().
300  left_side - [out] left portion of curve returned here.
301  If not nullptr, left_side must point to an ON_ArcCuve.
302  right_side - [out] right portion of curve returned here
303  If not nullptr, right_side must point to an ON_ArcCuve.
304  Remarks:
305  Overrides virtual ON_Curve::Split.
306  */
307  bool Split(
308  double t,
309  ON_Curve*& left_side,
310  ON_Curve*& right_side
311  ) const override;
312 
313 
314  // virtual ON_Curve::GetNurbForm override
315  int GetNurbForm( // returns 0: unable to create NURBS representation
316  // with desired accuracy.
317  // 1: success - returned NURBS parameterization
318  // matches the curve's to wthe desired accuracy
319  // 2: success - returned NURBS point locus matches
320  // the curve's to the desired accuracy but, on
321  // the interior of the curve's domain, the
322  // curve's parameterization and the NURBS
323  // parameterization may not match to the
324  // desired accuracy.
325  ON_NurbsCurve&,
326  double = 0.0,
327  const ON_Interval* = nullptr // OPTIONAL subdomain of arc curve
328  ) const override;
329 
330  // virtual ON_Curve::HasNurbForm override
331  int HasNurbForm( // returns 0: unable to create NURBS representation
332  // with desired accuracy.
333  // 1: success - NURBS parameterization
334  // matches the curve's
335  // 2: success - returned NURBS point locus matches
336  // the curve'sbut, on
337  // the interior of the curve's domain, the
338  // curve's parameterization and the NURBS
339  // parameterization may not match to the
340  // desired accuracy.
341  ) const override;
342 
343  // virtual ON_Curve::GetCurveParameterFromNurbFormParameter override
345  double, // nurbs_t
346  double* // curve_t
347  ) const override;
348 
349  // virtual ON_Curve::GetNurbFormParameterFromCurveParameter override
351  double, // curve_t
352  double* // nurbs_t
353  ) const override;
354 
355 
356  /*
357  Description:
358  Returns true if this arc curve is a complete circle.
359  */
360  bool IsCircle() const;
361 
362  // Returns:
363  // The arc's radius.
364  double Radius() const;
365 
366  // Returns:
367  // The arc's subtended angle in radians.
368  double AngleRadians() const;
369 
370  // Returns:
371  // The arc's subtended angle in degrees.
372  double AngleDegrees() const;
373 
375  /////////////////////////////////////////////////////////////////
376 
377  ON_Arc m_arc = ON_Arc::UnitCircle; // defualt = radius 1 circle in x-y plane
378 
380 
381  // The dimension of a arc curve can be 2 or 3.
382  // (2 so ON_ArcCurve can be used as a trimming curve)
383  int m_dim = 3;
384 };
385 
386 
387 #endif
virtual bool IsClosed() const
Test a curve to see if it is closed.
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.
ON_ArcCurve is used to represent arcs and circles. ON_ArcCurve.IsCircle() returns true if the curve i...
Definition: opennurbs_arccurve.h:34
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.
static const ON_Interval ZeroToTwoPi
Definition: opennurbs_point.h:51
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 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 GetNurbFormParameterFromCurveParameter(double curve_t, double *nurbs_t) const
Convert a curve parameter to a NURBS curve parameter.
ON_Circle is a circle in 3d. The cirle is represented by a radius and an orthonormal frame of the pla...
Definition: opennurbs_circle.h:32
virtual bool ChangeDimension(int desired_dimension)
Change the dimension of a curve.
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 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
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.
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_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
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
static const ON_Arc UnitCircle
Definition: opennurbs_arc.h:44
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...