29 template<
class T,
class KnotVectorType>
inline
32 const KnotVectorType & knots,
40 "coefs.rows(): " << coefs.rows() <<
", knots.size(): " << knots.size() <<
", deg: " << deg ) ;
42 result.resize( coefs.cols(), u.cols() ) ;
47 for (
index_t j=0; j< u.cols(); j++ )
50 GISMO_ASSERT( (u(0,j)>knots[deg]-(T)(1e-4) ) && (u(0,j) < *(knots.end()-deg-1)+(T)(1e-4) ),
51 "Parametric point "<< u(0,j) <<
" outside knot domain ["
52 << knots[deg]<<
","<<*(knots.end()-deg-1) <<
"].");
54 ind = (knots.iFind( u(0,j) ) - knots.begin()) - deg;
57 points = coefs.middleRows( ind, deg+1 );
59 for (
int r=0; r< deg; r++ )
61 for (
int i=deg; i>r; i-- )
64 tmp= ( u(0,j) - knots[k] ) / (knots[k+deg-r]-knots[k]);
65 points.row(i) = (T(1)-tmp)*points.row(i-1) + tmp* points.row(i) ;
67 result.col(j)= points.row(deg);
74 template<
class T,
class KnotVectorType>
inline
77 const KnotVectorType & knots,
85 "coefs.rows(): " << coefs.rows() <<
", knots.size(): " << knots.size() <<
", deg: " << deg ) ;
89 result.resize( coefs.cols(), u.cols() ) ;
94 for (
index_t j=0; j< u.cols(); j++ )
97 GISMO_ASSERT( (u(0,j)>knots[deg]-(T)(1e-4) ) && (u(0,j) < *(knots.end()-deg-2)+(T)(1e-4) ),
98 "Parametric point "<< u(0,j) <<
" outside knot domain ["
99 << knots[deg]<<
","<<*(knots.end()-deg-2) <<
"].");
101 ind = knots.findspan( u(0,j) ) - deg - 1;
106 for (
int r=ind; r< deg+ind+1; r++ )
107 points.row(r-ind) = ( T(deg+1) / (knots[r+deg+2]-knots[r+1]) )
108 * ( coefs.row(r+1) - coefs.row(r) );
110 for (
int r=0; r< deg; r++ )
112 for (
int i=deg; i>r; i-- )
115 tmp= ( u(0,j) - knots[k] ) / (knots[k+deg+1-r]-knots[k]);
116 points.row(i) = (T(1)-tmp)*points.row(i-1) + tmp* points.row(i) ;
118 result.col(j)= points.row(deg);
128 template<
short_t d,
typename T,
typename KnotVectorType,
typename Mat>
131 const gsMatrix<T>& u,
132 const gsTensorBSplineBasis<d, T>& base,
139 result.resize( coefs.cols(), u.cols() ) ;
141 gsMatrix<index_t> ind;
144 base.eval_into(u, B);
145 base.active_into(u, ind);
151 for (
index_t j=0; j< u.cols() ; j++ )
153 result(0, j) = coefs(ind(0, j)) * B(0, j);
154 for (
index_t i = 1; i < ind.rows(); ++i )
155 result(0, j) += coefs(ind(i, j)) * B(i, j);
164 template<
short_t d,
typename T,
typename KnotVectorType,
typename Mat>
166 void gsTensorDeriv_into(
const gsMatrix<T>& u,
167 const gsTensorBSplineBasis<d, T>& base,
171 const unsigned nPts = u.cols();
172 const unsigned nDer = d;
174 result.setZero(d, nPts);
176 gsMatrix<index_t> ind;
178 base.deriv_into(u, deriv);
179 base.active_into(u, ind);
186 for (
unsigned j = 0; j < nPts; ++j)
187 for (
unsigned k = 0; k < nDer; ++k)
188 for (
index_t i = 0; i < ind.rows(); i++)
189 result(k, j) += coefs(ind(i, j)) * deriv(k + i * nDer, j);
197 template<
short_t d,
typename T,
typename KnotVectorType,
typename Mat>
199 void gsTensorDeriv2_into(
const gsMatrix<T>& u,
200 const gsTensorBSplineBasis<d, T>& base,
204 const unsigned nPts = u.cols();
205 const unsigned n2der = (d * (d + 1)) / 2;
207 result.setZero(n2der, nPts);
209 gsMatrix<index_t> ind;
212 base.deriv2_into(u, deriv2);
213 base.active_into(u, ind);
215 for (
unsigned j = 0; j < nPts; j++)
216 for (
unsigned k = 0; k < n2der; k++)
217 for (
index_t i = 0; i < ind.rows(); i++)
218 result(k, j) += coefs(ind(i, j)) * deriv2(k + i * n2der, j);
225 template<
short_t d,
typename T,
typename KnotVectorType,
typename Mat>
227 void gsTensorDeboor_v2(
228 const gsMatrix<T>& u,
229 const gsTensorBSplineBasis<d, T>& base,
246 result.resize(coefs.cols(), u.cols());
247 gsVector<index_t, d> size_of_tmp_coefs(d);
249 unsigned nmb_of_tmp_coefs = 1;
250 for (
unsigned dim = 0; dim < d; dim++)
252 const KnotVectorType& kv = base.knots(dim);
253 size_of_tmp_coefs(dim) = kv.
degree() + 1;
254 nmb_of_tmp_coefs *= size_of_tmp_coefs(dim);
257 Mat tmp_coefs(nmb_of_tmp_coefs, coefs.cols());
261 for (
index_t i = 0; i < u.cols(); i++)
274 std::vector<bool> is_last(d,
false);
276 for (
short_t dim = 0; dim < d; dim++)
278 const KnotVectorType& kv = base.knots(dim);
280 if ( u(dim, i) == kv.last() )
288 gsVector<index_t, d> low, upp;
289 base.active_cwise(u.col(i), low, upp);
308 gsVector<index_t, d> coefs_position(low);
310 gsVector<index_t, d> zero(d);
314 gsVector<index_t, d> tmp_coefs_position(zero);
317 gsVector<index_t, d> tmp_coefs_str(d);
318 bspline::buildCoeffsStrides<d>(size_of_tmp_coefs, tmp_coefs_str);
320 gsVector<index_t, d> tmp_coefs_last(d);
321 bspline::getLastIndexLocal<d>(size_of_tmp_coefs, tmp_coefs_last);
334 unsigned flat_index = base.index(coefs_position);
335 unsigned tmp_coefs_index = bspline::getIndex<d>(tmp_coefs_str,
338 tmp_coefs.row(tmp_coefs_index) = coefs.row(flat_index);
341 nextCubePoint<gsVector<index_t, d> >(tmp_coefs_position, zero,
343 }
while(
nextCubePoint<gsVector<index_t, d> >(coefs_position, low, upp));
355 gsVector<index_t, d> start(d);
357 gsVector<index_t, d> end(size_of_tmp_coefs);
358 for (
short_t dim = 0; dim < d; dim++)
361 for (
short_t dim = 0; dim < d; dim++)
365 start(dim) = end(dim);
369 const KnotVectorType& kv = base.knots(dim);
371 gismo::gsTensorInsertKnotDegreeTimes<d, T, KnotVectorType, Mat>
372 (kv, tmp_coefs, size_of_tmp_coefs, u(dim, i), dim,
382 index_t flat_index = bspline::getIndex<d>(tmp_coefs_str,
392 result.col(i) = tmp_coefs.row(flat_index).transpose();
bool nextCubePoint(Vec &cur, const Vec &end)
Iterate in lexigographic order through the points of the integer lattice contained in the cube [0...
Definition: gsCombinatorics.h:327
#define short_t
Definition: gsConfig.h:35
void gsDeboorDeriv(const gsMatrix< T > &u, const KnotVectorType &knots, int deg, const gsMatrix< T > &coefs, gsMatrix< T > &result)
Definition: gsDeboor.hpp:75
Boehm's algorithm for knot insertion.
#define index_t
Definition: gsConfig.h:32
void gsDeboor(const gsMatrix< T > &u, const KnotVectorType &knots, int deg, const gsMatrix< T > &coefs, gsMatrix< T > &result)
Definition: gsDeboor.hpp:30
Provides combinatorial unitilies.
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
This is the main header file that collects wrappers of Eigen for linear algebra.
int degree() const
Returns the degree of the knot vector.
Definition: gsKnotVector.hpp:700