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