Point Cloud Library (PCL)  1.14.1-dev
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 Details:
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 
32  A valid ON_ArcCurve has Radius()>0 and 0<AngleRadians()<=2*PI
33  and a strictly increasing Domain().
34 */
35 class ON_CLASS ON_ArcCurve : public ON_Curve
36 {
37  ON_OBJECT_DECLARE(ON_ArcCurve);
38 
39 public:
42  virtual ~ON_ArcCurve();
43 
44  // virtual ON_Object::SizeOf override
45  unsigned int SizeOf() const;
46 
47  // virtual ON_Object::DataCRC override
48  ON__UINT32 DataCRC(ON__UINT32 current_remainder) const;
49 
50  /*
51  Description:
52  Create an arc curve with domain (0,arc.Length()).
53  */
55  const ON_Arc& arc
56  );
57 
58  /*
59  Description:
60  Create an arc curve with domain (t0,t1)
61  */
63  const ON_Arc& arc,
64  double t0,
65  double t1
66  );
67 
68  /*
69  Description:
70  Creates a curve that is a complete circle with
71  domain (0,circle.Length()).
72  */
74  const ON_Circle& circle
75  );
76 
77  /*
78  Description:
79  Creates a curve that is a complete circle with domain (t0,t1).
80  */
82  const ON_Circle& circle,
83  double t0,
84  double t1
85  );
86 
87 
89 
90  /*
91  Description:
92  Create an arc curve with domain (0,arc.Length()).
93  */
95 
96  /*
97  Description:
98  Creates a curve that is a complete circle with
99  domain (0,circle.Length()).
100  */
101  ON_ArcCurve& operator=(const ON_Circle& circle);
102 
103  /////////////////////////////////////////////////////////////////
104  // ON_Object overrides
105 
106  /*
107  Description:
108  A valid ON_ArcCurve has Radius()>0 and 0<AngleRadians()<=2*PI
109  and a strictly increasing Domain().
110  Parameters:
111  text_log - [in] if the object is not valid and text_log
112  is not NULL, then a brief englis description of the
113  reason the object is not valid is appened to the log.
114  The information appended to text_log is suitable for
115  low-level debugging purposes by programmers and is
116  not intended to be useful as a high level user
117  interface tool.
118  Returns:
119  @untitled table
120  true object is valid
121  false object is invalid, uninitialized, etc.
122  Remarks:
123  Overrides virtual ON_Object::IsValid
124  */
125  ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
126 
127  void Dump( ON_TextLog& ) const;
128 
129  ON_BOOL32 Write(
130  ON_BinaryArchive& // open binary file
131  ) const;
132 
133  ON_BOOL32 Read(
134  ON_BinaryArchive& // open binary file
135  );
136 
137  /////////////////////////////////////////////////////////////////
138  // ON_Geometry overrides
139 
140  int Dimension() const;
141 
142  ON_BOOL32 GetBBox( // returns true if successful
143  double*, // minimum
144  double*, // maximum
145  ON_BOOL32 = false // true means grow box
146  ) const;
147 
148  /*
149  Description:
150  Get tight bounding box of the arc.
151  Parameters:
152  tight_bbox - [in/out] tight bounding box
153  bGrowBox -[in] (default=false)
154  If true and the input tight_bbox is valid, then returned
155  tight_bbox is the union of the input tight_bbox and the
156  arc's tight bounding box.
157  xform -[in] (default=NULL)
158  If not NULL, the tight bounding box of the transformed
159  arc is calculated. The arc is not modified.
160  Returns:
161  True if the returned tight_bbox is set to a valid
162  bounding box.
163  */
165  ON_BoundingBox& tight_bbox,
166  int bGrowBox = false,
167  const ON_Xform* xform = 0
168  ) const;
169 
170 
171  ON_BOOL32 Transform(
172  const ON_Xform&
173  );
174 
175  /////////////////////////////////////////////////////////////////
176  // ON_Curve overrides
177 
178  // Description:
179  // virtual ON_Curve::SetDomain override.
180  // Set the domain of the curve
181  // Parameters:
182  // t0 - [in]
183  // t1 - [in] new domain will be [t0,t1]
184  // Returns:
185  // true if successful.
186  ON_BOOL32 SetDomain(
187  double t0,
188  double t1
189  );
190 
192 
194  int desired_dimension
195  );
196 
198  double t
199  );
200 
201  int SpanCount() const; // number of smooth spans in curve
202 
203  ON_BOOL32 GetSpanVector( // span "knots"
204  double* // array of length SpanCount() + 1
205  ) const; //
206 
207  int Degree( // returns maximum algebraic degree of any span
208  // ( or a good estimate if curve spans are not algebraic )
209  ) const;
210 
211  ON_BOOL32 IsLinear( // true if curve locus is a line segment between
212  // between specified points
213  double = ON_ZERO_TOLERANCE // tolerance to use when checking linearity
214  ) const;
215 
216  ON_BOOL32 IsArc( // ON_Arc.m_angle > 0 if curve locus is an arc between
217  // specified points
218  const ON_Plane* = NULL, // if not NULL, test is performed in this plane
219  ON_Arc* = NULL, // if not NULL and true is returned, then arc parameters
220  // are filled in
221  double = 0.0 // tolerance to use when checking
222  ) const;
223 
224  ON_BOOL32 IsPlanar(
225  ON_Plane* = NULL, // if not NULL and true is returned, then plane parameters
226  // are filled in
227  double = 0.0 // tolerance to use when checking
228  ) const;
229 
230  ON_BOOL32 IsInPlane(
231  const ON_Plane&, // plane to test
232  double = 0.0 // tolerance to use when checking
233  ) const;
234 
235  ON_BOOL32 IsClosed( // true if curve is closed (either curve has
236  void // clamped end knots and euclidean location of start
237  ) const; // CV = euclidean location of end CV, or curve is
238  // periodic.)
239 
240  ON_BOOL32 IsPeriodic( // true if curve is a single periodic segment
241  void
242  ) const;
243 
245  ON::continuity c,
246  double t,
247  int* hint = NULL,
248  double point_tolerance=ON_ZERO_TOLERANCE,
249  double d1_tolerance=ON_ZERO_TOLERANCE,
250  double d2_tolerance=ON_ZERO_TOLERANCE,
251  double cos_angle_tolerance=ON_DEFAULT_ANGLE_TOLERANCE_COSINE,
252  double curvature_tolerance=ON_SQRT_EPSILON
253  ) const;
254 
255  ON_BOOL32 Reverse(); // reverse parameterizatrion
256  // Domain changes from [a,b] to [-b,-a]
257 
258  /*
259  Description:
260  Force the curve to start at a specified point.
261  Parameters:
262  start_point - [in]
263  Returns:
264  true if successful.
265  Remarks:
266  Some end points cannot be moved. Be sure to check return
267  code.
268  See Also:
269  ON_Curve::SetEndPoint
270  ON_Curve::PointAtStart
271  ON_Curve::PointAtEnd
272  */
273  ON_BOOL32 SetStartPoint(
274  ON_3dPoint start_point
275  );
276 
277  /*
278  Description:
279  Force the curve to end at a specified point.
280  Parameters:
281  end_point - [in]
282  Returns:
283  true if successful.
284  Remarks:
285  Some end points cannot be moved. Be sure to check return
286  code.
287  See Also:
288  ON_Curve::SetStartPoint
289  ON_Curve::PointAtStart
290  ON_Curve::PointAtEnd
291  */
292  ON_BOOL32 SetEndPoint(
293  ON_3dPoint end_point
294  );
295 
296  ON_BOOL32 Evaluate( // returns false if unable to evaluate
297  double, // evaluation parameter
298  int, // number of derivatives (>=0)
299  int, // array stride (>=Dimension())
300  double*, // array of length stride*(ndir+1)
301  int = 0, // optional - determines which side to evaluate from
302  // 0 = default
303  // < 0 to evaluate from below,
304  // > 0 to evaluate from above
305  int* = 0 // optional - evaluation hint (int) used to speed
306  // repeated evaluations
307  ) const;
308 
309  ON_BOOL32 Trim( const ON_Interval& );
310 
311  // Description:
312  // Where possible, analytically extends curve to include domain.
313  // Parameters:
314  // domain - [in] if domain is not included in curve domain,
315  // curve will be extended so that its domain includes domain.
316  // Will not work if curve is closed. Original curve is identical
317  // to the restriction of the resulting curve to the original curve domain,
318  // Returns:
319  // true if successful.
320  bool Extend(
321  const ON_Interval& domain
322  );
323 
324  /*
325  Description:
326  Splits (divides) the arc at the specified parameter.
327  The parameter must be in the interior of the arc's domain.
328  The ON_Curve pointers passed to ON_ArcCurve::Split must
329  either be NULL or point to ON_ArcCurve objects.
330  If a pointer is NULL, then an ON_ArcCurve will be created
331  in Split(). You may pass "this" as left_side or right_side.
332  Parameters:
333  t - [in] parameter to split the curve at in the
334  interval returned by Domain().
335  left_side - [out] left portion of curve returned here.
336  If not NULL, left_side must point to an ON_ArcCuve.
337  right_side - [out] right portion of curve returned here
338  If not NULL, right_side must point to an ON_ArcCuve.
339  Remarks:
340  Overrides virtual ON_Curve::Split.
341  */
342  virtual
343  ON_BOOL32 Split(
344  double t,
345  ON_Curve*& left_side,
346  ON_Curve*& right_side
347  ) const;
348 
349  // virtual ON_Curve::GetNurbForm override
350  int GetNurbForm( // returns 0: unable to create NURBS representation
351  // with desired accuracy.
352  // 1: success - returned NURBS parameterization
353  // matches the curve's to wthe desired accuracy
354  // 2: success - returned NURBS point locus matches
355  // the curve's to the desired accuracy but, on
356  // the interior of the curve's domain, the
357  // curve's parameterization and the NURBS
358  // parameterization may not match to the
359  // desired accuracy.
360  ON_NurbsCurve&,
361  double = 0.0,
362  const ON_Interval* = NULL // OPTIONAL subdomain of arc curve
363  ) const;
364 
365  // virtual ON_Curve::HasNurbForm override
366  int HasNurbForm( // returns 0: unable to create NURBS representation
367  // with desired accuracy.
368  // 1: success - NURBS parameterization
369  // matches the curve's
370  // 2: success - returned NURBS point locus matches
371  // the curve'sbut, on
372  // the interior of the curve's domain, the
373  // curve's parameterization and the NURBS
374  // parameterization may not match to the
375  // desired accuracy.
376  ) const;
377 
378  // virtual ON_Curve::GetCurveParameterFromNurbFormParameter override
380  double, // nurbs_t
381  double* // curve_t
382  ) const;
383 
384  // virtual ON_Curve::GetNurbFormParameterFromCurveParameter override
386  double, // curve_t
387  double* // nurbs_t
388  ) const;
389 
390 
391  /*
392  Description:
393  Returns true if this arc curve is a complete circle.
394  */
395  bool IsCircle() const;
396 
397  // Returns:
398  // The arc's radius.
399  double Radius() const;
400 
401  // Returns:
402  // The arc's subtended angle in radians.
403  double AngleRadians() const;
404 
405  // Returns:
406  // The arc's subtended angle in degrees.
407  double AngleDegrees() const;
408 
409 
410  /////////////////////////////////////////////////////////////////
411 
413 
414  // evaluation domain (always increasing)
415  // ( m_t[i] corresponds to m_arc.m_angle[i] )
417 
418  // The dimension of a arc curve can be 2 or 3.
419  // (2 so ON_ArcCurve can be used as a trimming curve)
420  int m_dim;
421 
422 };
423 
424 
425 #endif
ON_BOOL32 IsClosed(void) const
ON__UINT32 DataCRC(ON__UINT32 current_remainder) const
ON_BOOL32 IsPeriodic(void) const
bool Extend(const ON_Interval &domain)
int Degree() const
virtual ON_BOOL32 Split(double t, ON_Curve *&left_side, ON_Curve *&right_side) const
bool GetTightBoundingBox(ON_BoundingBox &tight_bbox, int bGrowBox=false, const ON_Xform *xform=0) const
ON_BOOL32 IsInPlane(const ON_Plane &, double=0.0) const
ON_ArcCurve(const ON_Circle &circle, double t0, double t1)
ON_ArcCurve(const ON_Arc &arc)
ON_ArcCurve & operator=(const ON_ArcCurve &)
virtual ~ON_ArcCurve()
ON_ArcCurve & operator=(const ON_Arc &arc)
int HasNurbForm() const
ON_BOOL32 GetNurbFormParameterFromCurveParameter(double, double *) const
ON_BOOL32 Trim(const ON_Interval &)
ON_BOOL32 Reverse()
ON_BOOL32 IsArc(const ON_Plane *=NULL, ON_Arc *=NULL, double=0.0) const
ON_BOOL32 Evaluate(double, int, int, double *, int=0, int *=0) const
void Dump(ON_TextLog &) const
ON_BOOL32 SetEndPoint(ON_3dPoint end_point)
bool ChangeDimension(int desired_dimension)
ON_BOOL32 GetSpanVector(double *) const
ON_ArcCurve(const ON_ArcCurve &)
ON_BOOL32 Transform(const ON_Xform &)
ON_Interval m_t
bool IsCircle() const
int SpanCount() const
ON_BOOL32 SetStartPoint(ON_3dPoint start_point)
ON_BOOL32 Read(ON_BinaryArchive &)
ON_BOOL32 GetCurveParameterFromNurbFormParameter(double, double *) const
ON_BOOL32 Write(ON_BinaryArchive &) const
int GetNurbForm(ON_NurbsCurve &, double=0.0, const ON_Interval *=NULL) const
ON_BOOL32 ChangeClosedCurveSeam(double t)
ON_BOOL32 SetDomain(double t0, double t1)
ON_BOOL32 IsPlanar(ON_Plane *=NULL, double=0.0) const
unsigned int SizeOf() const
double AngleRadians() const
int Dimension() const
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=ON_DEFAULT_ANGLE_TOLERANCE_COSINE, double curvature_tolerance=ON_SQRT_EPSILON) const
double AngleDegrees() const
ON_BOOL32 IsValid(ON_TextLog *text_log=NULL) const
ON_BOOL32 GetBBox(double *, double *, ON_BOOL32=false) const
double Radius() const
ON_BOOL32 IsLinear(double=ON_ZERO_TOLERANCE) const
ON_ArcCurve(const ON_Circle &circle)
ON_ArcCurve(const ON_Arc &arc, double t0, double t1)
ON_Interval Domain() const
ON_ArcCurve & operator=(const ON_Circle &circle)