00001 /* $NoKeywords: $ */ 00002 /* 00003 // 00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved. 00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert 00006 // McNeel & Associates. 00007 // 00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. 00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF 00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED. 00011 // 00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>. 00013 // 00015 */ 00016 00017 #if !defined(ON_EVALUATE_NURBS_INC_) 00018 #define ON_EVALUATE_NURBS_INC_ 00019 00020 ON_DECL 00021 bool ON_IncreaseBezierDegree( 00022 int, // dimension 00023 ON_BOOL32, // true if Bezier is rational 00024 int, // order (>=2) 00025 int, // cv_stride (>=dim+1) 00026 double* // cv[(order+1)*cv_stride] array 00027 ); 00028 00029 ON_DECL 00030 bool ON_RemoveBezierSingAt0( // input bezier is rational with 0/0 at start 00031 int, // dimension 00032 int, // order (>=2) 00033 int, // cv_stride (>=dim+1) 00034 double* // cv[order*cv_stride] array 00035 ); 00036 00037 ON_DECL 00038 bool ON_RemoveBezierSingAt1( // input bezier is rational with 0/0 at end 00039 int, // dimension 00040 int, // order (>=2) 00041 int, // cv_stride (>=dim+1) 00042 double* // cv[order*cv_stride] array 00043 ); 00044 00045 ON_DECL 00046 double ON_EvaluateBernsteinBasis( // returns (i choose d)*(1-t)^(d-i)*t^i 00047 int, // degree, 00048 int, // 0 <= i <= degree 00049 double // t 00050 ); 00051 00052 ON_DECL 00053 void ON_EvaluatedeCasteljau( 00054 int, // dim 00055 int, // order 00056 int, // side <= 0 return left side of bezier in cv array 00057 // > 0 return right side of bezier in cv array 00058 int, // cv_stride 00059 double*, // cv 00060 double // t 0 <= t <= 1 00061 ); 00062 00063 ON_DECL 00064 bool ON_EvaluateBezier( 00065 int, // dimension 00066 ON_BOOL32, // true if Bezier is rational 00067 int, // order (>=2) 00068 int, // cv_stride >= (is_rat)?dim+1:dim 00069 const double*, // cv[order*cv_stride] array 00070 double, double, // t0,t1 = domain of bezier 00071 int, // number of derivatives to compute (>=0) 00072 double, // evaluation parameter 00073 int, // v_stride (>=dimension) 00074 double* // v[(der_count+1)*v_stride] array 00075 ); 00076 00077 ON_DECL 00078 bool ON_EvaluateNurbsBasis( 00079 int, // order (>=1) 00080 const double*, // knot[] array of 2*(order-1) knots 00081 double, // evaluation parameter 00082 double* // basis_values[] array of length order*order 00083 ); 00084 00085 ON_DECL 00086 bool ON_EvaluateNurbsBasisDerivatives( 00087 int, // order (>=1) 00088 const double*, // knot[] array of 2*(order-1) knots 00089 int, // number of derivatives 00090 double* // basis_values[] array of length order*order 00091 ); 00092 00093 00094 00095 00096 /* 00097 int dim, // dimension 00098 ON_BOOL32 is_rat, // true if NURBS is rational 00099 int order, // order 00100 const double* knot, // knot[] array of (2*order-2) doubles 00101 int cv_stride, // cv_stride >= (is_rat)?dim+1:dim 00102 const double* cv, // cv[order*cv_stride] array 00103 int der_count, // number of derivatives to compute 00104 double t, // evaluation parameter 00105 int v_stride, // v_stride (>=dimension) 00106 double* v // v[(der_count+1)*v_stride] array 00107 ) 00108 int, // dimension 00109 ON_BOOL32, // true if NURBS is rational 00110 int, // order 00111 const double*, // knot[] array of (2*order-2) doubles 00112 int, // cv_stride 00113 const double*, // cv[] array of order*cv_stride doubles 00114 int, // number of derivatives to compute (>=0) 00115 double, // evaluation parameter 00116 int, // answer_stride (>=dimension) 00117 double* // answer[] array of length (ndir+1)*answer_stride 00118 */ 00119 00120 00121 ON_DECL 00122 00123 /* 00124 Description: 00125 Evaluate a NURBS curve span. 00126 Parameters: 00127 dim - [in] 00128 dimension (> 0). 00129 is_rat - [in] 00130 true or false. 00131 order - [in] 00132 order=degree+1 (order>=2) 00133 knot - [in] NURBS knot vector. 00134 NURBS knot vector with 2*(order-1) knots, knot[order-2] != knot[order-1] 00135 cv_stride - [in] 00136 cv - [in] 00137 For 0 <= i < order the i-th control vertex is 00138 00139 cv[n],...,cv[n+(is_rat?dim:dim+1)], 00140 00141 where n = i*cv_stride. If is_rat is true the cv is 00142 in homogeneous form. 00143 der_count - [in] 00144 number of derivatives to evaluate (>=0) 00145 t - [in] 00146 evaluation parameter 00147 v_stride - [in] 00148 v - [out] 00149 An array of length v_stride*(der_count+1). The evaluation 00150 results are returned in this array. 00151 00152 P = v[0],...,v[m_dim-1] 00153 Dt = v[v_stride],... 00154 Dtt = v[2*v_stride],... 00155 ... 00156 00157 In general, Dt^i returned in v[n],...,v[n+m_dim-1], where 00158 00159 n = v_stride*i. 00160 00161 Returns: 00162 True if successful. 00163 See Also: 00164 ON_NurbsCurve::Evaluate 00165 ON_EvaluateNurbsSurfaceSpan 00166 ON_EvaluateNurbsCageSpan 00167 */ 00168 bool ON_EvaluateNurbsSpan( 00169 int dim, 00170 int is_rat, 00171 int order, 00172 const double* knot, 00173 int cv_stride, 00174 const double* cv, 00175 int der_count, 00176 double t, 00177 int v_stride, 00178 double* v 00179 ); 00180 00181 /* 00182 Description: 00183 Evaluate a NURBS surface bispan. 00184 Parameters: 00185 dim - [in] >0 00186 is_rat - [in] true of false 00187 order0 - [in] >= 2 00188 order1 - [in] >= 2 00189 knot0 - [in] 00190 NURBS knot vector with 2*(order0-1) knots, knot0[order0-2] != knot0[order0-1] 00191 knot1 - [in] 00192 NURBS knot vector with 2*(order1-1) knots, knot1[order1-2] != knot1[order1-1] 00193 cv_stride0 - [in] 00194 cv_stride1 - [in] 00195 cv - [in] 00196 For 0 <= i < order0 and 0 <= j < order1, the (i,j) control vertex is 00197 00198 cv[n],...,cv[n+(is_rat?dim:dim+1)], 00199 00200 where n = i*cv_stride0 + j*cv_stride1. If is_rat is true the cv is 00201 in homogeneous form. 00202 00203 der_count - [in] (>=0) 00204 s - [in] 00205 t - [in] (s,t) is the evaluation parameter 00206 v_stride - [in] (>=dim) 00207 v - [out] An array of length v_stride*(der_count+1)*(der_count+2)/2. 00208 The evaluation results are stored in this array. 00209 00210 P = v[0],...,v[m_dim-1] 00211 Ds = v[v_stride],... 00212 Dt = v[2*v_stride],... 00213 Dss = v[3*v_stride],... 00214 Dst = v[4*v_stride],... 00215 Dtt = v[5*v_stride],... 00216 00217 In general, Ds^i Dt^j is returned in v[n],...,v[n+m_dim-1], where 00218 00219 n = v_stride*( (i+j)*(i+j+1)/2 + j). 00220 00221 Returns: 00222 True if succcessful. 00223 See Also: 00224 ON_NurbsSurface::Evaluate 00225 ON_EvaluateNurbsSpan 00226 ON_EvaluateNurbsCageSpan 00227 */ 00228 ON_DECL 00229 bool ON_EvaluateNurbsSurfaceSpan( 00230 int dim, 00231 int is_rat, 00232 int order0, 00233 int order1, 00234 const double* knot0, 00235 const double* knot1, 00236 int cv_stride0, 00237 int cv_stride1, 00238 const double* cv, 00239 int der_count, 00240 double s, 00241 double t, 00242 int v_stride, 00243 double* v 00244 ); 00245 00246 00247 00248 /* 00249 Description: 00250 Evaluate a NURBS cage trispan. 00251 Parameters: 00252 dim - [in] >0 00253 is_rat - [in] true of false 00254 order0 - [in] >= 2 00255 order1 - [in] >= 2 00256 order2 - [in] >= 2 00257 knot0 - [in] 00258 NURBS knot vector with 2*(order0-1) knots, knot0[order0-2] != knot0[order0-1] 00259 knot1 - [in] 00260 NURBS knot vector with 2*(order1-1) knots, knot1[order1-2] != knot1[order1-1] 00261 knot2 - [in] 00262 NURBS knot vector with 2*(order1-1) knots, knot2[order2-2] != knot2[order2-1] 00263 cv_stride0 - [in] 00264 cv_stride1 - [in] 00265 cv_stride2 - [in] 00266 cv - [in] 00267 For 0 <= i < order0, 0 <= j < order1, and 0 <= k < order2, 00268 the (i,j,k)-th control vertex is 00269 00270 cv[n],...,cv[n+(is_rat?dim:dim+1)], 00271 00272 where n = i*cv_stride0 + j*cv_stride1 *k*cv_stride2. 00273 If is_rat is true the cv is in homogeneous form. 00274 00275 der_count - [in] (>=0) 00276 r - [in] 00277 s - [in] 00278 t - [in] (r,s,t) is the evaluation parameter 00279 v_stride - [in] (>=dim) 00280 v - [out] An array of length v_stride*(der_count+1)*(der_count+2)*(der_count+3)/6. 00281 The evaluation results are stored in this array. 00282 00283 P = v[0],...,v[m_dim-1] 00284 Dr = v[v_stride],... 00285 Ds = v[2*v_stride],... 00286 Dt = v[3*v_stride],... 00287 Drr = v[4*v_stride],... 00288 Drs = v[5*v_stride],... 00289 Drt = v[6*v_stride],... 00290 Dss = v[7*v_stride],... 00291 Dst = v[8*v_stride],... 00292 Dtt = v[9*v_stride],... 00293 00294 In general, Dr^i Ds^j Dt^k is returned in v[n],...,v[n+dim-1], where 00295 00296 d = (i+j+k) 00297 n = v_stride*( d*(d+1)*(d+2)/6 + (j+k)*(j+k+1)/2 + k) 00298 00299 Returns: 00300 True if succcessful. 00301 See Also: 00302 ON_NurbsCage::Evaluate 00303 ON_EvaluateNurbsSpan 00304 ON_EvaluateNurbsSurfaceSpan 00305 */ 00306 ON_DECL 00307 bool ON_EvaluateNurbsCageSpan( 00308 int dim, 00309 int is_rat, 00310 int order0, int order1, int order2, 00311 const double* knot0, 00312 const double* knot1, 00313 const double* knot2, 00314 int cv_stride0, int cv_stride1, int cv_stride2, 00315 const double* cv, 00316 int der_count, 00317 double t0, double t1, double t2, 00318 int v_stride, 00319 double* v 00320 ); 00321 00322 00323 ON_DECL 00324 bool ON_EvaluateNurbsDeBoor( // for expert users only - no support available 00325 int, // cv_dim ( dim+1 for rational cvs ) 00326 int, // order (>=2) 00327 int, // cv_stride (>=cv_dim) 00328 double*, // cv array - values changed to result of applying De Boor's algorithm 00329 const double*, // knot array 00330 int, // side, 00331 // -1 return left side of B-spline span in cv array 00332 // +1 return right side of B-spline span in cv array 00333 // -2 return left side of B-spline span in cv array 00334 // Ignore values of knots[0,...,order-3] and assume 00335 // left end of span has a fully multiple knot with 00336 // value "mult_k". 00337 // +2 return right side of B-spline span in cv array 00338 // Ignore values of knots[order,...,2*order-2] and 00339 // assume right end of span has a fully multiple 00340 // knot with value "mult_k". 00341 double, // mult_k - used when side is +2 or -2. See above for usage. 00342 double // t 00343 // If side < 0, then the cv's for the portion of the NURB span to 00344 // the LEFT of t are computed. If side > 0, then the cv's for the 00345 // portion the span to the RIGHT of t are computed. The following 00346 // table summarizes the restrictions on t: 00347 // 00348 // value of side condition t must satisfy 00349 // -2 mult_k < t and mult_k < knots[order-1] 00350 // -1 knots[order-2] < t 00351 // +1 t < knots[order-1] 00352 // +2 t < mult_k and knots[order-2] < mult_k 00353 ); 00354 00355 00356 ON_DECL 00357 bool ON_EvaluateNurbsBlossom(int, // cvdim, 00358 int, // order, 00359 int, // cv_stride, 00360 const double*, //CV, size cv_stride*order 00361 const double*, //knot, nondecreasing, size 2*(order-1) 00362 // knot[order-2] != knot[order-1] 00363 const double*, //t, input parameters size order-1 00364 double* // P 00365 00366 // DeBoor algorithm with different input at each step. 00367 // returns false for bad input. 00368 ); 00369 00370 00371 ON_DECL 00372 void ON_ConvertNurbSpanToBezier( 00373 int, // cvdim (dim+1 for rational curves) 00374 int, // order, 00375 int, // cvstride (>=cvdim) 00376 double*, // cv array - input has NURBS cvs, output has Bezier cvs 00377 const double*, // (2*order-2) knots for the NURBS span 00378 double, // t0, NURBS span parameter of start point 00379 double // t1, NURBS span parameter of end point 00380 ); 00381 #endif