Point Cloud Library (PCL) 1.12.1
opennurbs_evaluate_nurbs.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_EVALUATE_NURBS_INC_)
18#define ON_EVALUATE_NURBS_INC_
19
20ON_DECL
21bool ON_IncreaseBezierDegree(
22 int, // dimension
23 ON_BOOL32, // true if Bezier is rational
24 int, // order (>=2)
25 int, // cv_stride (>=dim+1)
26 double* // cv[(order+1)*cv_stride] array
27 );
28
29ON_DECL
30bool ON_RemoveBezierSingAt0( // input bezier is rational with 0/0 at start
31 int, // dimension
32 int, // order (>=2)
33 int, // cv_stride (>=dim+1)
34 double* // cv[order*cv_stride] array
35 );
36
37ON_DECL
38bool ON_RemoveBezierSingAt1( // input bezier is rational with 0/0 at end
39 int, // dimension
40 int, // order (>=2)
41 int, // cv_stride (>=dim+1)
42 double* // cv[order*cv_stride] array
43 );
44
45ON_DECL
46double ON_EvaluateBernsteinBasis( // returns (i choose d)*(1-t)^(d-i)*t^i
47 int, // degree,
48 int, // 0 <= i <= degree
49 double // t
50 );
51
52ON_DECL
53void ON_EvaluatedeCasteljau(
54 int, // dim
55 int, // order
56 int, // side <= 0 return left side of bezier in cv array
57 // > 0 return right side of bezier in cv array
58 int, // cv_stride
59 double*, // cv
60 double // t 0 <= t <= 1
61 );
62
63ON_DECL
64bool ON_EvaluateBezier(
65 int, // dimension
66 ON_BOOL32, // true if Bezier is rational
67 int, // order (>=2)
68 int, // cv_stride >= (is_rat)?dim+1:dim
69 const double*, // cv[order*cv_stride] array
70 double, double, // t0,t1 = domain of bezier
71 int, // number of derivatives to compute (>=0)
72 double, // evaluation parameter
73 int, // v_stride (>=dimension)
74 double* // v[(der_count+1)*v_stride] array
75 );
76
77ON_DECL
78bool ON_EvaluateNurbsBasis(
79 int, // order (>=1)
80 const double*, // knot[] array of 2*(order-1) knots
81 double, // evaluation parameter
82 double* // basis_values[] array of length order*order
83 );
84
85ON_DECL
86bool ON_EvaluateNurbsBasisDerivatives(
87 int, // order (>=1)
88 const double*, // knot[] array of 2*(order-1) knots
89 int, // number of derivatives
90 double* // basis_values[] array of length order*order
91 );
92
93
94
95
96/*
97int dim, // dimension
98 ON_BOOL32 is_rat, // true if NURBS is rational
99 int order, // order
100 const double* knot, // knot[] array of (2*order-2) doubles
101 int cv_stride, // cv_stride >= (is_rat)?dim+1:dim
102 const double* cv, // cv[order*cv_stride] array
103 int der_count, // number of derivatives to compute
104 double t, // evaluation parameter
105 int v_stride, // v_stride (>=dimension)
106 double* v // v[(der_count+1)*v_stride] array
107 )
108 int, // dimension
109 ON_BOOL32, // true if NURBS is rational
110 int, // order
111 const double*, // knot[] array of (2*order-2) doubles
112 int, // cv_stride
113 const double*, // cv[] array of order*cv_stride doubles
114 int, // number of derivatives to compute (>=0)
115 double, // evaluation parameter
116 int, // answer_stride (>=dimension)
117 double* // answer[] array of length (ndir+1)*answer_stride
118*/
119
120
121ON_DECL
122
123/*
124Description:
125 Evaluate a NURBS curve span.
126Parameters:
127 dim - [in]
128 dimension (> 0).
129 is_rat - [in]
130 true or false.
131 order - [in]
132 order=degree+1 (order>=2)
133 knot - [in] NURBS knot vector.
134 NURBS knot vector with 2*(order-1) knots, knot[order-2] != knot[order-1]
135 cv_stride - [in]
136 cv - [in]
137 For 0 <= i < order the i-th control vertex is
138
139 cv[n],...,cv[n+(is_rat?dim:dim+1)],
140
141 where n = i*cv_stride. If is_rat is true the cv is
142 in homogeneous form.
143 der_count - [in]
144 number of derivatives to evaluate (>=0)
145 t - [in]
146 evaluation parameter
147 v_stride - [in]
148 v - [out]
149 An array of length v_stride*(der_count+1). The evaluation
150 results are returned in this array.
151
152 P = v[0],...,v[m_dim-1]
153 Dt = v[v_stride],...
154 Dtt = v[2*v_stride],...
155 ...
156
157 In general, Dt^i returned in v[n],...,v[n+m_dim-1], where
158
159 n = v_stride*i.
160
161Returns:
162 True if successful.
163See Also:
164 ON_NurbsCurve::Evaluate
165 ON_EvaluateNurbsSurfaceSpan
166 ON_EvaluateNurbsCageSpan
167*/
168bool ON_EvaluateNurbsSpan(
169 int dim,
170 int is_rat,
171 int order,
172 const double* knot,
173 int cv_stride,
174 const double* cv,
175 int der_count,
176 double t,
177 int v_stride,
178 double* v
179 );
180
181/*
182Description:
183 Evaluate a NURBS surface bispan.
184Parameters:
185 dim - [in] >0
186 is_rat - [in] true of false
187 order0 - [in] >= 2
188 order1 - [in] >= 2
189 knot0 - [in]
190 NURBS knot vector with 2*(order0-1) knots, knot0[order0-2] != knot0[order0-1]
191 knot1 - [in]
192 NURBS knot vector with 2*(order1-1) knots, knot1[order1-2] != knot1[order1-1]
193 cv_stride0 - [in]
194 cv_stride1 - [in]
195 cv - [in]
196 For 0 <= i < order0 and 0 <= j < order1, the (i,j) control vertex is
197
198 cv[n],...,cv[n+(is_rat?dim:dim+1)],
199
200 where n = i*cv_stride0 + j*cv_stride1. If is_rat is true the cv is
201 in homogeneous form.
202
203 der_count - [in] (>=0)
204 s - [in]
205 t - [in] (s,t) is the evaluation parameter
206 v_stride - [in] (>=dim)
207 v - [out] An array of length v_stride*(der_count+1)*(der_count+2)/2.
208 The evaluation results are stored in this array.
209
210 P = v[0],...,v[m_dim-1]
211 Ds = v[v_stride],...
212 Dt = v[2*v_stride],...
213 Dss = v[3*v_stride],...
214 Dst = v[4*v_stride],...
215 Dtt = v[5*v_stride],...
216
217 In general, Ds^i Dt^j is returned in v[n],...,v[n+m_dim-1], where
218
219 n = v_stride*( (i+j)*(i+j+1)/2 + j).
220
221Returns:
222 True if succcessful.
223See Also:
224 ON_NurbsSurface::Evaluate
225 ON_EvaluateNurbsSpan
226 ON_EvaluateNurbsCageSpan
227*/
228ON_DECL
229bool ON_EvaluateNurbsSurfaceSpan(
230 int dim,
231 int is_rat,
232 int order0,
233 int order1,
234 const double* knot0,
235 const double* knot1,
236 int cv_stride0,
237 int cv_stride1,
238 const double* cv,
239 int der_count,
240 double s,
241 double t,
242 int v_stride,
243 double* v
244 );
245
246
247
248/*
249Description:
250 Evaluate a NURBS cage trispan.
251Parameters:
252 dim - [in] >0
253 is_rat - [in] true of false
254 order0 - [in] >= 2
255 order1 - [in] >= 2
256 order2 - [in] >= 2
257 knot0 - [in]
258 NURBS knot vector with 2*(order0-1) knots, knot0[order0-2] != knot0[order0-1]
259 knot1 - [in]
260 NURBS knot vector with 2*(order1-1) knots, knot1[order1-2] != knot1[order1-1]
261 knot2 - [in]
262 NURBS knot vector with 2*(order1-1) knots, knot2[order2-2] != knot2[order2-1]
263 cv_stride0 - [in]
264 cv_stride1 - [in]
265 cv_stride2 - [in]
266 cv - [in]
267 For 0 <= i < order0, 0 <= j < order1, and 0 <= k < order2,
268 the (i,j,k)-th control vertex is
269
270 cv[n],...,cv[n+(is_rat?dim:dim+1)],
271
272 where n = i*cv_stride0 + j*cv_stride1 *k*cv_stride2.
273 If is_rat is true the cv is in homogeneous form.
274
275 der_count - [in] (>=0)
276 r - [in]
277 s - [in]
278 t - [in] (r,s,t) is the evaluation parameter
279 v_stride - [in] (>=dim)
280 v - [out] An array of length v_stride*(der_count+1)*(der_count+2)*(der_count+3)/6.
281 The evaluation results are stored in this array.
282
283 P = v[0],...,v[m_dim-1]
284 Dr = v[v_stride],...
285 Ds = v[2*v_stride],...
286 Dt = v[3*v_stride],...
287 Drr = v[4*v_stride],...
288 Drs = v[5*v_stride],...
289 Drt = v[6*v_stride],...
290 Dss = v[7*v_stride],...
291 Dst = v[8*v_stride],...
292 Dtt = v[9*v_stride],...
293
294 In general, Dr^i Ds^j Dt^k is returned in v[n],...,v[n+dim-1], where
295
296 d = (i+j+k)
297 n = v_stride*( d*(d+1)*(d+2)/6 + (j+k)*(j+k+1)/2 + k)
298
299Returns:
300 True if succcessful.
301See Also:
302 ON_NurbsCage::Evaluate
303 ON_EvaluateNurbsSpan
304 ON_EvaluateNurbsSurfaceSpan
305*/
306ON_DECL
307bool ON_EvaluateNurbsCageSpan(
308 int dim,
309 int is_rat,
310 int order0, int order1, int order2,
311 const double* knot0,
312 const double* knot1,
313 const double* knot2,
314 int cv_stride0, int cv_stride1, int cv_stride2,
315 const double* cv,
316 int der_count,
317 double t0, double t1, double t2,
318 int v_stride,
319 double* v
320 );
321
322
323ON_DECL
324bool ON_EvaluateNurbsDeBoor( // for expert users only - no support available
325 int, // cv_dim ( dim+1 for rational cvs )
326 int, // order (>=2)
327 int, // cv_stride (>=cv_dim)
328 double*, // cv array - values changed to result of applying De Boor's algorithm
329 const double*, // knot array
330 int, // side,
331 // -1 return left side of B-spline span in cv array
332 // +1 return right side of B-spline span in cv array
333 // -2 return left side of B-spline span in cv array
334 // Ignore values of knots[0,...,order-3] and assume
335 // left end of span has a fully multiple knot with
336 // value "mult_k".
337 // +2 return right side of B-spline span in cv array
338 // Ignore values of knots[order,...,2*order-2] and
339 // assume right end of span has a fully multiple
340 // knot with value "mult_k".
341 double, // mult_k - used when side is +2 or -2. See above for usage.
342 double // t
343 // If side < 0, then the cv's for the portion of the NURB span to
344 // the LEFT of t are computed. If side > 0, then the cv's for the
345 // portion the span to the RIGHT of t are computed. The following
346 // table summarizes the restrictions on t:
347 //
348 // value of side condition t must satisfy
349 // -2 mult_k < t and mult_k < knots[order-1]
350 // -1 knots[order-2] < t
351 // +1 t < knots[order-1]
352 // +2 t < mult_k and knots[order-2] < mult_k
353 );
354
355
356ON_DECL
357bool ON_EvaluateNurbsBlossom(int, // cvdim,
358 int, // order,
359 int, // cv_stride,
360 const double*, //CV, size cv_stride*order
361 const double*, //knot, nondecreasing, size 2*(order-1)
362 // knot[order-2] != knot[order-1]
363 const double*, //t, input parameters size order-1
364 double* // P
365
366 // DeBoor algorithm with different input at each step.
367 // returns false for bad input.
368 );
369
370
371ON_DECL
372void ON_ConvertNurbSpanToBezier(
373 int, // cvdim (dim+1 for rational curves)
374 int, // order,
375 int, // cvstride (>=cvdim)
376 double*, // cv array - input has NURBS cvs, output has Bezier cvs
377 const double*, // (2*order-2) knots for the NURBS span
378 double, // t0, NURBS span parameter of start point
379 double // t1, NURBS span parameter of end point
380 );
381#endif