QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_linecurve.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#if !defined(ON_GEOMETRY_CURVE_LINE_INC_)
17#define ON_GEOMETRY_CURVE_LINE_INC_
18
19class ON_LineCurve;
21{
23
24public:
26 ON_LineCurve(const ON_2dPoint&,const ON_2dPoint&); // creates a 2d line curve
27 ON_LineCurve(const ON_3dPoint&,const ON_3dPoint&); // creates a 3d line curve
28 ON_LineCurve(const ON_Line&);
29 ON_LineCurve(const ON_Line&,
30 double,double // domain
31 );
33
34 virtual ~ON_LineCurve();
35
38
40 // ON_Object overrides
41
42 // virtual ON_Object::SizeOf override
43 unsigned int SizeOf() const;
44
45 // virtual ON_Object::DataCRC override
46 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const;
47
48 /*
49 Description:
50 Tests an object to see if its data members are correctly
51 initialized.
52 Parameters:
53 text_log - [in] if the object is not valid and text_log
54 is not NULL, then a brief englis description of the
55 reason the object is not valid is appened to the log.
56 The information appended to text_log is suitable for
57 low-level debugging purposes by programmers and is
58 not intended to be useful as a high level user
59 interface tool.
60 Returns:
61 @untitled table
62 true object is valid
63 false object is invalid, uninitialized, etc.
64 Remarks:
65 Overrides virtual ON_Object::IsValid
66 */
67 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
68
69 void Dump( ON_TextLog& ) const; // for debugging
70
72 ON_BinaryArchive& // open binary file
73 ) const;
74
76 ON_BinaryArchive& // open binary file
77 );
78
80 // ON_Geometry overrides
81
82 int Dimension() const;
83
84 ON_BOOL32 GetBBox( // returns true if successful
85 double*, // minimum
86 double*, // maximum
87 ON_BOOL32 = false // true means grow box
88 ) const;
89
90 /*
91 Description:
92 Get tight bounding box of the line.
93 Parameters:
94 tight_bbox - [in/out] tight bounding box
95 bGrowBox -[in] (default=false)
96 If true and the input tight_bbox is valid, then returned
97 tight_bbox is the union of the input tight_bbox and the
98 line's tight bounding box.
99 xform -[in] (default=NULL)
100 If not NULL, the tight bounding box of the transformed
101 line is calculated. The line is not modified.
102 Returns:
103 True if the returned tight_bbox is set to a valid
104 bounding box.
105 */
107 ON_BoundingBox& tight_bbox,
108 int bGrowBox = false,
109 const ON_Xform* xform = 0
110 ) const;
111
113 const ON_Xform&
114 );
115
116 // virtual ON_Geometry::IsDeformable() override
117 bool IsDeformable() const;
118
119 // virtual ON_Geometry::MakeDeformable() override
120 bool MakeDeformable();
121
123 int, int // indices of coords to swap
124 );
125
126 // virtual ON_Geometry override
127 bool Morph( const ON_SpaceMorph& morph );
128
129 // virtual ON_Geometry override
130 bool IsMorphable() const;
131
133 // ON_Curve overrides
134
135 ON_Interval Domain() const;
136
137 // Description:
138 // Set the domain of the curve
139 // Parameters:
140 // t0 - [in]
141 // t1 - [in] new domain will be [t0,t1]
142 // Returns:
143 // true if successful.
145 double t0,
146 double t1
147 );
148
149 bool ChangeDimension(
150 int desired_dimension
151 );
152
153 int SpanCount() const; // number of smooth spans in curve
154
155 ON_BOOL32 GetSpanVector( // span "knots"
156 double* // array of length SpanCount() + 1
157 ) const; //
158
159 int Degree( // returns maximum algebraic degree of any span
160 // ( or a good estimate if curve spans are not algebraic )
161 ) const;
162
163 ON_BOOL32 IsLinear( // true if curve locus is a line segment between
164 // between specified points
165 double = ON_ZERO_TOLERANCE // tolerance to use when checking linearity
166 ) const;
167
168 /*
169 Description:
170 Several types of ON_Curve can have the form of a polyline including
171 a degree 1 ON_NurbsCurve, an ON_PolylineCurve, and an ON_PolyCurve
172 all of whose segments are some form of polyline. IsPolyline tests
173 a curve to see if it can be represented as a polyline.
174 Parameters:
175 pline_points - [out] if not NULL and true is returned, then the
176 points of the polyline form are returned here.
177 t - [out] if not NULL and true is returned, then the parameters of
178 the polyline points are returned here.
179 Returns:
180 @untitled table
181 0 curve is not some form of a polyline
182 >=2 number of points in polyline form
183 */
184 virtual
185 int IsPolyline(
186 ON_SimpleArray<ON_3dPoint>* pline_points = NULL,
188 ) const;
189
190 ON_BOOL32 IsArc( // ON_Arc.m_angle > 0 if curve locus is an arc between
191 // specified points
192 const ON_Plane* = NULL, // if not NULL, test is performed in this plane
193 ON_Arc* = NULL, // if not NULL and true is returned, then arc parameters
194 // are filled in
195 double = ON_ZERO_TOLERANCE // tolerance to use when checking
196 ) const;
197
199 ON_Plane* = NULL, // if not NULL and true is returned, then plane parameters
200 // are filled in
201 double = ON_ZERO_TOLERANCE // tolerance to use when checking
202 ) const;
203
205 const ON_Plane&, // plane to test
206 double = ON_ZERO_TOLERANCE // tolerance to use when checking
207 ) const;
208
209 ON_BOOL32 IsClosed( // true if curve is closed (either curve has
210 void // clamped end knots and euclidean location of start
211 ) const; // CV = euclidean location of end CV, or curve is
212 // periodic.)
213
214 ON_BOOL32 IsPeriodic( // true if curve is a single periodic segment
215 void
216 ) const;
217
218 /*
219 Description:
220 Force the curve to start at a specified point.
221 Parameters:
222 start_point - [in]
223 Returns:
224 true if successful.
225 Remarks:
226 Some end points cannot be moved. Be sure to check return
227 code.
228 See Also:
229 ON_Curve::SetEndPoint
230 ON_Curve::PointAtStart
231 ON_Curve::PointAtEnd
232 */
234 ON_3dPoint start_point
235 );
236
237 /*
238 Description:
239 Force the curve to end at a specified point.
240 Parameters:
241 end_point - [in]
242 Returns:
243 true if successful.
244 Remarks:
245 Some end points cannot be moved. Be sure to check return
246 code.
247 See Also:
248 ON_Curve::SetStartPoint
249 ON_Curve::PointAtStart
250 ON_Curve::PointAtEnd
251 */
253 ON_3dPoint end_point
254 );
255
256 ON_BOOL32 Reverse(); // reverse parameterizatrion
257 // Domain changes from [a,b] to [-b,-a]
258
259 ON_BOOL32 Evaluate( // returns false if unable to evaluate
260 double, // evaluation parameter
261 int, // number of derivatives (>=0)
262 int, // array stride (>=Dimension())
263 double*, // array of length stride*(ndir+1)
264 int = 0, // optional - determines which side to evaluate from
265 // 0 = default
266 // < 0 to evaluate from below,
267 // > 0 to evaluate from above
268 int* = 0 // optional - evaluation hint (int) used to speed
269 // repeated evaluations
270 ) const;
271
273 // Find parameter of the point on a curve that is closest to test_point.
274 // If the maximum_distance parameter is > 0, then only points whose distance
275 // to the given point is <= maximum_distance will be returned. Using a
276 // positive value of maximum_distance can substantially speed up the search.
277 // If the sub_domain parameter is not NULL, then the search is restricted
278 // to the specified portion of the curve.
279 //
280 // true if returned if the search is successful. false is returned if
281 // the search fails.
282 bool GetClosestPoint( const ON_3dPoint&, // test_point
283 double*, // parameter of local closest point returned here
284 double = 0.0, // maximum_distance
285 const ON_Interval* = NULL // sub_domain
286 ) const;
287
289 // Find parameter of the point on a curve that is locally closest to
290 // the test_point. The search for a local close point starts at
291 // seed_parameter. If the sub_domain parameter is not NULL, then
292 // the search is restricted to the specified portion of the curve.
293 //
294 // true if returned if the search is successful. false is returned if
295 // the search fails.
296 ON_BOOL32 GetLocalClosestPoint( const ON_3dPoint&, // test_point
297 double, // seed_parameter
298 double*, // parameter of local closest point returned here
299 const ON_Interval* = NULL // sub_domain
300 ) const;
301
302 // virtual ON_Curve override
303 int IntersectSelf(
305 double intersection_tolerance = 0.0,
306 const ON_Interval* curve_domain = 0
307 ) const;
308
309 // Description:
310 // virtual ON_Curve::GetLength override.
311 // Get the length of the line.
312 // Parameters:
313 // length - [out] length returned here.
314 // t - [out] parameter such that the length of the curve
315 // from its start to t is arc_length.
316 // fractional_tolerance - [in] desired fractional precision.
317 // fabs(("exact" length from start to t) - arc_length)/arc_length <= fractional_tolerance
318 // sub_domain - [in] If not NULL, the calculation is performed on
319 // the specified sub-domain of the curve.
320 // Returns:
321 // true if returned if the length calculation is successful.
323 double* length,
324 double fractional_tolerance = 1.0e-8,
325 const ON_Interval* sub_domain = NULL
326 ) const;
327
328 /*
329 Description:
330 Used to quickly find short curves.
331 Parameters:
332 tolerance - [in] (>=0)
333 sub_domain - [in] If not NULL, the test is performed
334 on the interval that is the intersection of
335 sub_domain with Domain().
336 Returns:
337 True if the length of the curve is <= tolerance.
338 Remarks:
339 Faster than calling Length() and testing the
340 result.
341 */
342 bool IsShort(
343 double tolerance,
344 const ON_Interval* sub_domain = NULL
345 ) const;
346
347 // Description:
348 // virtual ON_Curve::GetNormalizedArcLengthPoint override.
349 // Get the parameter of the point on the line that is a
350 // prescribed distance from the start of the line
351 // Parameters:
352 // s - [in] normalized arc length parameter. E.g., 0 = start
353 // of curve, 1/2 = midpoint of curve, 1 = end of curve.
354 // t - [out] parameter such that the length of the line
355 // from its start to t is arc_length.
356 // fractional_tolerance - [in] desired fractional precision.
357 // fabs(("exact" length from start to t) - arc_length)/arc_length <= fractional_tolerance
358 // sub_domain - [in] If not NULL, the calculation is performed on
359 // the specified sub-domain of the curve.
360 // Returns:
361 // true if successful
363 double s,
364 double* t,
365 double fractional_tolerance = 1.0e-8,
366 const ON_Interval* sub_domain = NULL
367 ) const;
368
369 /*
370 Description:
371 virtual ON_Curve::GetNormalizedArcLengthPoints override.
372 Get the parameter of the point on the curve that is a
373 prescribed arc length from the start of the curve.
374 Parameters:
375 count - [in] number of parameters in s.
376 s - [in] array of normalized arc length parameters. E.g., 0 = start
377 of curve, 1/2 = midpoint of curve, 1 = end of curve.
378 t - [out] array of curve parameters such that the length of the
379 curve from its start to t[i] is s[i]*curve_length.
380 absolute_tolerance - [in] if absolute_tolerance > 0, then the difference
381 between (s[i+1]-s[i])*curve_length and the length of the curve
382 segment from t[i] to t[i+1] will be <= absolute_tolerance.
383 fractional_tolerance - [in] desired fractional precision for each segment.
384 fabs("true" length - actual length)/(actual length) <= fractional_tolerance
385 sub_domain - [in] If not NULL, the calculation is performed on
386 the specified sub-domain of the curve. A 0.0 s value corresponds to
387 sub_domain->Min() and a 1.0 s value corresponds to sub_domain->Max().
388 Returns:
389 true if successful
390 */
392 int count,
393 const double* s,
394 double* t,
395 double absolute_tolerance = 0.0,
396 double fractional_tolerance = 1.0e-8,
397 const ON_Interval* sub_domain = NULL
398 ) const;
399
400 // Description:
401 // virtual ON_Curve::Trim override.
402 // Removes portions of the curve outside the specified interval.
403 // Parameters:
404 // domain - [in] interval of the curve to keep. Portions of the
405 // curve before curve(domain[0]) and after curve(domain[1]) are
406 // removed.
407 // Returns:
408 // true if successful.
410 const ON_Interval& domain
411 );
412
413 // Description:
414 // Where possible, analytically extends curve to include domain.
415 // Parameters:
416 // domain - [in] if domain is not included in curve domain,
417 // curve will be extended so that its domain includes domain.
418 // Original curve is identical
419 // to the restriction of the resulting curve to the original curve domain,
420 // Returns:
421 // true if successful.
422 bool Extend(
423 const ON_Interval& domain
424 );
425
426 // Description:
427 // virtual ON_Curve::Split override.
428 // Divide the curve at the specified parameter. The parameter
429 // must be in the interior of the curve's domain. The pointers
430 // passed to Split must either be NULL or point to an ON_Curve
431 // object of the same of the same type. If the pointer is NULL,
432 // then a curve will be created in Split(). You may pass "this"
433 // as one of the pointers to Split().
434 // Parameters:
435 // t - [in] parameter in interval Domain().
436 // left_side - [out] left portion of curve
437 // right_side - [out] right portion of curve
438 // Example:
439 // For example, if crv were an ON_NurbsCurve, then
440 //
441 // ON_NurbsCurve right_side;
442 // crv.Split( crv.Domain().Mid() &crv, &right_side );
443 //
444 // would split crv at the parametric midpoint, put the left side
445 // in crv, and return the right side in right_side.
447 double t, // t = curve parameter to split curve at
448 ON_Curve*& left_side, // left portion returned here
449 ON_Curve*& right_side // right portion returned here
450 ) const;
451
452 // Description:
453 // virtual ON_Curve::GetNurbForm override.
454 // Get a NURBS curve representation of this curve.
455 // Parameters:
456 // nurbs_curve - [out] NURBS representation returned here
457 // tolerance - [in] tolerance to use when creating NURBS
458 // representation.
459 // subdomain - [in] if not NULL, then the NURBS representation
460 // for this portion of the curve is returned.
461 // Returns:
462 // 0 unable to create NURBS representation
463 // with desired accuracy.
464 // 1 success - returned NURBS parameterization
465 // matches the curve's to wthe desired accuracy
466 // 2 success - returned NURBS point locus matches
467 // the curve's to the desired accuracy but, on
468 // the interior of the curve's domain, the
469 // curve's parameterization and the NURBS
470 // parameterization may not match to the
471 // desired accuracy.
472 int GetNurbForm(
474 double = 0.0,
475 const ON_Interval* = NULL
476 ) const;
477
478 // Description:
479 // virtual ON_Curve::HasNurbForm override.
480 // Does a NURBS curve representation of this curve exist.
481 // Parameters:
482 // Returns:
483 // 0 unable to create NURBS representation
484 // with desired accuracy.
485 // 1 success - returned NURBS parameterization
486 // matches the curve's to wthe desired accuracy
487 // 2 success - returned NURBS point locus matches
488 // the curve's to the desired accuracy but, on
489 // the interior of the curve's domain, the
490 // curve's parameterization and the NURBS
491 // parameterization may not match to the
492 // desired accuracy.
493 int HasNurbForm(
494 ) const;
495
496 // Description:
497 // virtual ON_Curve::GetCurveParameterFromNurbFormParameter override.
498 // Convert a NURBS curve parameter to a curve parameter
499 //
500 // Parameters:
501 // nurbs_t - [in] nurbs form parameter
502 // curve_t - [out] curve parameter
503 //
504 // Remarks:
505 // If GetNurbForm returns 2, this function converts the curve
506 // parameter to the NURBS curve parameter.
507 //
508 // See Also:
509 // ON_Curve::GetNurbForm, ON_Curve::GetNurbFormParameterFromCurveParameter
510 virtual
512 double nurbs_t,
513 double* curve_t
514 ) const;
515
516 // Description:
517 // virtual ON_Curve::GetNurbFormParameterFromCurveParameter override.
518 // Convert a curve parameter to a NURBS curve parameter.
519 //
520 // Parameters:
521 // curve_t - [in] curve parameter
522 // nurbs_t - [out] nurbs form parameter
523 //
524 // Remarks:
525 // If GetNurbForm returns 2, this function converts the curve
526 // parameter to the NURBS curve parameter.
527 //
528 // See Also:
529 // ON_Curve::GetNurbForm, ON_Curve::GetCurveParameterFromNurbFormParameter
530 virtual
532 double curve_t,
533 double* nurbs_t
534 ) const;
535
537 // Interface
538
540 ON_Interval m_t; // domain
541 int m_dim; // 2 or 3 (2 so ON_LineCurve can be uses as a trimming curve)
542};
543
544
545#endif
@ Transform
Definition RSMetaType.h:67
Definition opennurbs_point.h:253
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:88
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 GetNormalizedArcLengthPoint(double s, double *t, double fractional_tolerance=1.0e-8, const ON_Interval *sub_domain=NULL) const
Definition opennurbs_curve.cpp:2489
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 int IntersectSelf(ON_SimpleArray< ON_X_EVENT > &x, double intersection_tolerance=0.0, const ON_Interval *curve_domain=0) const
Definition opennurbs_basic.cpp:343
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
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
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
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_linecurve.h:21
ON_Interval m_t
Definition opennurbs_linecurve.h:540
ON_OBJECT_DECLARE(ON_LineCurve)
int m_dim
Definition opennurbs_linecurve.h:541
ON_Line m_line
Definition opennurbs_linecurve.h:539
Definition opennurbs_line.h:20
Definition opennurbs_nurbscurve.h:27
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_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
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