QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_knot.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(OPENNURBS_KNOT_INC_)
17#define OPENNURBS_KNOT_INC_
18
21 double, // start of domain
22 double // end of domain
23 );
24
26double ON_KnotTolerance(
27 int, // order (>=2)
28 int, // cv count
29 const double*, // knot[] array
30 int // knot index
31 );
32
34double ON_SpanTolerance(
35 int, // order (>=2)
36 int, // cv count
37 const double*, // knot[] array
38 int // span index
39 );
40
42int ON_KnotCount( // returns (order + cv_count - 2)
43 int, // order (>=2)
44 int // cv_count (>=order)
45 );
46
49 int, // order (>=2)
50 int, // cv_count (>=order)
51 const double*, // knot[]
52 int // knot_index
53 );
54
57 int, // order (>=2)
58 int, // cv count
59 const double* // knot[] array
60 );
61
64 int, // order (>=2)
65 int, // cv count
66 const double*, // knot[] array
67 double* // s[] array
68 );
69
70/*
71Description:
72 Given an evaluation parameter t in the domain of a NURBS curve,
73 ON_NurbsSpanIndex(order,cv_count,knot,t,0,0) returns the integer
74 i such that (knot[i],...,knot[i+2*degree-1]), and
75 (cv[i],...,cv[i+degree]) are the knots and control points that
76 define the span of the NURBS that are used for evaluation at t.
77Parameters:
78 order - [in] order >= 2
79 cv_count - [in] cv_count >= order
80 knot - [in] valid knot vector
81 t - [in] evaluation parameter
82 side - [in] determines which span is used when t is at a knot
83 value; side = 0 for the default (from above),
84 side = -1 means from below, and
85 side = +1 means from above.
86 hint - [in] Search hint, or 0 if not hint is available.
87Returns:
88 Returns the index described above.
89*/
92 int order,
93 int cv_count,
94 const double* knot,
95 double t,
96 int side,
97 int hint
98 );
99
102 // returns 0: input span_index < 0
103 // cv_count-order: input span_index = cv_count-order
104 // -1: input span_index > cv_count-order;
105 // otherwise next span index
106 int order,
107 int cv_count,
108 const double* knot,
109 int // current span_index
110 );
111
113int ON_GetSpanIndices( // returns span count, which is one less than length of span_indices[]
114 int order,
115 int cv_count,
116 const double* knot,
117 int* // span_indices[cv_count-order+2].
118 //Indices of knots at end of group of mult knots
119 //at start of span, and knot at start of group of mult knots
120 //at end of spline.
121 );
122
124double ON_SuperfluousKnot(
125 int order,
126 int cv_count,
127 const double* knot,
128 int // 0 = first superfluous knot
129 // 1 = last superfluous knot
130 );
131
134 int order,
135 int cv_count,
136 const double* knot
137 );
138
141 int order,
142 int cv_count,
143 const double* knot,
144 int = 2 // 0 = check left end, 1 = check right end, 2 = check both
145 );
146
149 int order,
150 int cv_count,
151 const double* knot
152 );
153
155// returns true if all knots have multiplicity = degree
158 int order,
159 int cv_count,
160 const double* knot
161 );
162
163
165ON::knot_style ON_KnotVectorStyle(
166 int order,
167 int cv_count,
168 const double* knot
169 );
170
171/*
172Description:
173 Set the domain of a knot vector.
174Parameters:
175 order - [in] order >= 2
176 cv_count - [in] cv_count >= order
177 knot - [in/out] input existing knots and returns knots with new domain.
178 t0 - [in]
179 t1 - [in] New domain will be the interval (t0,t1).
180Returns:
181 True if input is valid and the returned knot vector
182 has the requested domain. False if the input is
183 invalid, in which case the input knot vector is not
184 changed.
185*/
188 int order,
189 int cv_count,
190 double* knot,
191 double t0,
192 double t1
193 );
194
197 int, // order (>=2)
198 int, // cv count
199 const double*, // knot[] array
200 double*, double*
201 );
202
205 int, // order (>=2)
206 int, // cv count
207 double* // knot[] array
208 );
209
211int ON_CompareKnotVector( // returns
212 // -1: first < second
213 // 0: first == second
214 // +1: first > second
215 // first knot vector
216 int, // order (>=2)
217 int, // cv count
218 const double*, // knot[] array
219 // second knot vector
220 int, // order (>=2)
221 int, // cv count
222 const double* // knot[] array
223 );
224
227 int, // order (>=2)
228 int, // cv count
229 const double*, // knot[] array
230 ON_TextLog* text_log = NULL
231 );
232
235 // Sets inital/final order-2 knots to values in
236 // knot[order-2]/knot[cv_count-1].
237 int, // order (>=2)
238 int, // cv count
239 double*, // knot[] array
240 int // 0 = clamp left end, 1 = right end, 2 = clamp both ends
241 );
242
245 // Sets inital and final order-2 knots to values
246 // that make the knot vector periodic
247 int, // order (>=2)
248 int, // cv count
249 double* // knot[] array
250 );
251
252 /*
253 Description:
254 Fill in knot values for a clamped uniform knot
255 vector.
256 Parameters:
257 order - [in] (>=2) order (degree+1) of the NURBS
258 cv_count - [in] (>=order) total number of control points
259 in the NURBS.
260 knot - [in/out] Input is an array with room for
261 ON_KnotCount(order,cv_count) doubles. Output is
262 a clamped uniform knot vector with domain
263 (0, (1+cv_count-order)*delta).
264 delta - [in] (>0, default=1.0) spacing between knots.
265 Returns:
266 true if successful
267 See Also:
268 ON_NurbsCurve::MakeClampedUniformKnotVector
269*/
272 int order,
273 int cv_count,
274 double* knot,
275 double delta = 1.0
276 );
277
278/*
279 Description:
280 Fill in knot values for a clamped uniform knot
281 vector.
282 Parameters:
283 order - [in] (>=2) order (degree+1) of the NURBS
284 cv_count - [in] (>=order) total number of control points
285 in the NURBS.
286 knot - [in/out] Input is an array with room for
287 ON_KnotCount(order,cv_count) doubles. Output is
288 a periodic uniform knot vector with domain
289 (0, (1+cv_count-order)*delta).
290 delta - [in] (>0, default=1.0) spacing between knots.
291 Returns:
292 true if successful
293 See Also:
294 ON_NurbsCurve::MakePeriodicUniformKnotVector
295*/
298 int order,
299 int cv_count,
300 double* knot,
301 double delta = 1.0
302 );
303
305double ON_GrevilleAbcissa( // get Greville abcissae from knots
306 int, // order (>=2)
307 const double* // knot[] array (length = order-1)
308 );
309
311bool ON_GetGrevilleAbcissae( // get Greville abcissae from knots
312 int, // order (>=2)
313 int, // cv count
314 const double*, // knot[] array
315 bool, // true for periodic case
316 double* // g[] array has length cv_count in non-periodic case
317 // and cv_count-order+1 in periodic case
318 );
319
321bool ON_GetGrevilleKnotVector( // get knots from Greville abcissa
322 int, // g[] array stride (>=1)
323 const double*, // g[] array
324 // if not periodic, length = cv_count
325 // if periodic, length = cv_count-order+2
326 bool, // true for periodic knots
327 int, // order (>=2)
328 int, // cv_count (>=order)
329 double* // knot[cv_count+order-2]
330 );
331
334 int, // cv_dim ( = dim+1 for rational cvs )
335 int, // order (>=2)
336 int, // cv_count,
337 int, // cv_stride,
338 double*, // cv[] NULL or array of order many cvs
339 double*, // knot[] array with room for at least knot_multiplicity new knots
340 int // end 0 = clamp start, 1 = clamp end, 2 = clamp both ends
341 );
342
343/*
344Returns:
345 Number of knots added.
346*/
348int ON_InsertKnot(
349 double, // knot_value,
350 int, // knot_multiplicity, (1 to order-1 including multiplicity of any existing knots)
351 int, // cv_dim ( = dim+1 for rational cvs )
352 int, // order (>=2)
353 int, // cv_count,
354 int, // cv_stride (>=cv_dim)
355 double*, // cv[] NULL or cv array with room for at least knot_multiplicity new cvs
356 double*, // knot[] knot array with room for at least knot_multiplicity new knots
357 int* // hint, optional hint about where to search for span to add knots to
358 // pass NULL if no hint is available
359 );
360
361/*
362Description:
363 Reparameterize a rational Bezier curve.
364Parameters:
365 c - [in]
366 reparameterization constant (generally speaking, c should be > 0).
367 The control points are adjusted so that
368 output_bezier(t) = input_bezier(lambda(t)), where
369 lambda(t) = c*t/( (c-1)*t + 1 ).
370 Note that lambda(0) = 0, lambda(1) = 1, lambda'(t) > 0,
371 lambda'(0) = c and lambda'(1) = 1/c.
372 dim - [in]
373 order - [in]
374 cvstride - [in] (>= dim+1)
375 cv - [in/out] homogeneous rational control points
376Returns:
377 The cv values are changed so that
378 output_bezier(t) = input_bezier(lambda(t)).
379*/
381 double c,
382 int dim,
383 int order,
384 int cvstride,
385 double* cv
386 );
387
388/*
389Description:
390 Use a combination of scaling and reparameterization to set two rational
391 Bezier weights to specified values.
392Parameters:
393 dim - [in]
394 order - [in]
395 cvstride - [in] ( >= dim+1)
396 cv - [in/out] homogeneous rational control points
397 i0 - [in]
398 w0 - [in]
399 i1 - [in]
400 w1 - [in]
401 The i0-th cv will have weight w0 and the i1-th cv will have weight w1.
402 If v0 and v1 are the cv's input weights, then v0, v1, w0 and w1 must
403 all be nonzero, and w0*v0 and w1*v1 must have the same sign.
404Returns:
405 true if successful
406Remarks:
407 The equations
408 s * r^i0 = w0/v0
409 s * r^i1 = w1/v1
410 determine the scaling and reparameterization necessary to change v0,v1 to
411 w0,w1.
412
413 If the input Bezier has control vertices {B_0, ..., B_d}, then the
414 output Bezier has control vertices {s*B_0, ... s*r^i * B_i, ..., s*r^d * B_d}.
415*/
417 int dim, int order, int cvstride, double* cv,
418 int i0, double w0,
419 int i1, double w1
420 );
421
422/*
423Description:
424 Reparameterize a rational NURBS curve.
425Parameters:
426 c - [in]
427 reparameterization constant (generally speaking, c should be > 0).
428 The control points and knots are adjusted so that
429 output_nurbs(t) = input_nurbs(lambda(t)), where
430 lambda(t) = c*t/( (c-1)*t + 1 ).
431 Note that lambda(0) = 0, lambda(1) = 1, lambda'(t) > 0,
432 lambda'(0) = c and lambda'(1) = 1/c.
433 dim - [in]
434 order - [in]
435 cvstride - [in] (>=dim+1)
436 cv - [in/out] homogeneous rational control points
437 knot - [in/out]
438 NURBS curve knots
439Returns:
440 The cv values are changed so that
441 output_bezier(t) = input_bezier(lambda(t)).
442See Also:
443 ON_ChangeRationalNurbsCurveEndWeights
444*/
447 double c,
448 int dim,
449 int order,
450 int cv_count,
451 int cvstride,
452 double* cv,
453 double* knot
454 );
455
456/*
457Description:
458 Use a combination of scaling and reparameterization to set the end
459 weights to the specified values. This
460Parameters:
461 dim - [in]
462 order - [in]
463 cvstride - [in] (>=dim+1)
464 cv - [in/out] homogeneous rational control points
465 knot - [in/out] (output knot vector will be clamped and internal
466 knots may be shifted.)
467 w0 - [in]
468 w1 - [in]
469 The first cv will have weight w0 and the last cv will have weight w1.
470 If v0 and v1 are the cv's input weights, then v0, v1, w0 and w1 must
471 all be nonzero, and w0*v0 and w1*v1 must have the same sign.
472Returns:
473 true if successful
474See Also:
475 ON_ReparameterizeRationalNurbsCurve
476*/
479 int dim,
480 int order,
481 int cv_count,
482 int cvstride,
483 double* cv,
484 double* knot,
485 double w0,
486 double w1
487 );
488
489#endif
Definition opennurbs_textlog.h:20
#define ON_DECL
Definition opennurbs_defines.h:92
ON_DECL double ON_GrevilleAbcissa(int, const double *)
Definition opennurbs_knot.cpp:912
ON_DECL bool ON_MakePeriodicUniformKnotVector(int order, int cv_count, double *knot, double delta=1.0)
Definition opennurbs_knot.cpp:889
ON_DECL bool ON_GetKnotVectorSpanVector(int, int, const double *, double *)
Definition opennurbs_knot.cpp:143
ON_DECL bool ON_SetKnotVectorDomain(int order, int cv_count, double *knot, double t0, double t1)
Definition opennurbs_knot.cpp:540
ON_DECL int ON_KnotCount(int, int)
Definition opennurbs_knot.cpp:80
ON_DECL double ON_SuperfluousKnot(int order, int cv_count, const double *knot, int)
Definition opennurbs_knot.cpp:329
ON_DECL double ON_KnotTolerance(int, int, const double *, int)
Definition opennurbs_knot.cpp:38
ON_DECL bool ON_KnotVectorHasBezierSpans(int order, int cv_count, const double *knot)
Definition opennurbs_knot.cpp:457
ON_DECL bool ON_MakeKnotVectorPeriodic(int, int, double *)
Definition opennurbs_knot.cpp:797
ON_DECL bool ON_ChangeRationalNurbsCurveEndWeights(int dim, int order, int cv_count, int cvstride, double *cv, double *knot, double w0, double w1)
Definition opennurbs_nurbscurve.cpp:3419
ON_DECL int ON_KnotMultiplicity(int, int, const double *, int)
Definition opennurbs_knot.cpp:90
ON_DECL bool ON_GetKnotVectorDomain(int, int, const double *, double *, double *)
Definition opennurbs_knot.cpp:576
ON_DECL bool ON_GetGrevilleAbcissae(int, int, const double *, bool, double *)
Definition opennurbs_knot.cpp:938
ON_DECL bool ON_ReverseKnotVector(int, int, double *)
Definition opennurbs_knot.cpp:597
ON_DECL ON::knot_style ON_KnotVectorStyle(int order, int cv_count, const double *knot)
Definition opennurbs_knot.cpp:482
ON_DECL bool ON_GetGrevilleKnotVector(int, const double *, bool, int, int, double *)
Definition opennurbs_knot.cpp:980
ON_DECL int ON_KnotVectorSpanCount(int, int, const double *)
Definition opennurbs_knot.cpp:116
ON_DECL bool ON_IsKnotVectorPeriodic(int order, int cv_count, const double *knot)
Definition opennurbs_knot.cpp:356
ON_DECL bool ON_IsKnotVectorClamped(int order, int cv_count, const double *knot, int=2)
Definition opennurbs_knot.cpp:401
ON_DECL bool ON_IsKnotVectorUniform(int order, int cv_count, const double *knot)
Definition opennurbs_knot.cpp:419
ON_DECL int ON_NurbsSpanIndex(int order, int cv_count, const double *knot, double t, int side, int hint)
Definition opennurbs_knot.cpp:175
ON_DECL bool ON_ReparameterizeRationalNurbsCurve(double c, int dim, int order, int cv_count, int cvstride, double *cv, double *knot)
Definition opennurbs_nurbscurve.cpp:3322
ON_DECL bool ON_IsValidKnotVector(int, int, const double *, ON_TextLog *text_log=NULL)
Definition opennurbs_knot.cpp:678
ON_DECL bool ON_ClampKnotVector(int, int, double *, int)
Definition opennurbs_knot.cpp:766
bool ON_ReparameterizeRationalBezierCurve(double c, int dim, int order, int cvstride, double *cv)
Definition opennurbs_bezier.cpp:2825
ON_DECL int ON_GetSpanIndices(int order, int cv_count, const double *knot, int *)
Definition opennurbs_knot.cpp:289
ON_DECL int ON_NextNurbsSpanIndex(int order, int cv_count, const double *knot, int)
Definition opennurbs_knot.cpp:225
ON_DECL int ON_InsertKnot(double, int, int, int, int, int, double *, double *, int *)
Definition opennurbs_knot.cpp:1221
ON_DECL bool ON_MakeClampedUniformKnotVector(int order, int cv_count, double *knot, double delta=1.0)
Definition opennurbs_knot.cpp:854
ON_DECL double ON_DomainTolerance(double, double)
Definition opennurbs_knot.cpp:23
ON_DECL int ON_CompareKnotVector(int, int, const double *, int, int, const double *)
Definition opennurbs_knot.cpp:621
ON_DECL double ON_SpanTolerance(int, int, const double *, int)
Definition opennurbs_knot.cpp:69
bool ON_ChangeRationalBezierCurveWeights(int dim, int order, int cvstride, double *cv, int i0, double w0, int i1, double w1)
Definition opennurbs_bezier.cpp:2908
#define NULL
Definition opennurbs_system.h:256