29 template<
short_t d,
class T>
33 GISMO_ASSERT( checkVectorPtrCast<Basis_t>(bb),
"Invalid vector of basis pointers.");
34 GISMO_ENSURE( d == bb.size(),
"Wrong d in the constructor of gsTensorBSplineBasis." );
39 template<
short_t d,
class T>
40 gsTensorBSplineBasis<d,T>::gsTensorBSplineBasis(std::vector<gsBasis<T>*> & bb )
43 GISMO_ENSURE( d == bb.size(),
"Wrong d in the constructor of gsTensorBSplineBasis." );
48 template<
short_t d,
class T>
49 void gsTensorBSplineBasis<d,T>::
54 for (
index_t j = 0; j < u.cols(); ++j)
58 low[i] = component(i).firstActive( u(i,j) );
59 upp[i] = low[i] + component(i).degree();
64 template<
short_t d,
class T>
67 const std::vector< std::vector<T> >& refineKnots)
69 GISMO_ASSERT( refineKnots.size() == d,
"refineKnots vector has wrong size" );
73 for (
unsigned i = 0; i < d; ++i)
75 this->component(i).refine_withTransfer( B[i], refineKnots[i] );
78 tensorCombineTransferMatrices<d, T>( B, transfer );
81 template<
short_t d,
class T>
85 GISMO_ASSERT( refineKnots.size() == d,
"refineKnots vector has wrong size" );
87 for (
unsigned j = 0; j < d; ++j)
89 strides[j]=this->stride(j);
91 for (
unsigned i = 0; i < d; ++i)
93 if(refineKnots[i].size()>0)
96 refineKnots[i].begin(), refineKnots[i].end(),
true);
98 for (
index_t j = i+1; j<strides.rows(); ++j)
99 strides[j]=this->stride(j);
105 template<
short_t d,
class T>
110 "Number of rows of refinement boxes must equal dimension of parameter space.");
112 "Refinement boxes must have even number of columns.");
114 const T tol = 0.000000001;
117 for(
int di = 0; di < this->dim(); di++)
121 KnotVectorType kold_di = Self_t::component(di).knots();
124 std::vector<bool> flagInsertKt( kold_di.size(),
false);
131 for(
size_t i=1; i < kold_di.size(); i++ )
132 if( kold_di[i]-kold_di[i-1] > tol)
134 const T midpt = (kold_di[i] + kold_di[i-1])/(T)(2);
135 for(
index_t j=0; j < boxes.cols(); j+=2 )
138 flagInsertKt[i] = boxes(di,j) < midpt && midpt < boxes(di,j+1);
144 for(
size_t i=1; i < kold_di.size(); i++ )
145 if( flagInsertKt[i] )
147 T midpt = (kold_di[i] + kold_di[i-1])/(T)(2);
148 Self_t::component(di).insertKnot( midpt );
164 template<
short_t d,
class T>
168 GISMO_ASSERT( u.rows() ==
static_cast<index_t>(d),
"Invalid point dimension: "<<u.rows()<<
", expected "<< d);
170 unsigned firstAct[d];
175 for (
unsigned i = 0; i < d; ++i)
177 size[i] = component(i).numActive();
181 result.resize( numAct, u.cols() );
184 for (
index_t j = 0; j < u.cols(); ++j)
187 for (
short_t i = 0; i < d; ++i)
189 firstAct[i] = component(i).firstActive( u(i,j) );
197 index_t gidx = firstAct[d-1] + v(d-1);
198 for (
short_t i=d-2; i>=0; --i )
199 gidx = gidx * this->size(i) + firstAct[i] + v(i);
212 template<
short_t d,
class T>
217 typedef gsTensorBSplineBasis<d,T> Object;
219 GSXML_COMMON_FUNCTIONS(Object);
220 static std::string tag () {
return "Basis"; }
221 static std::string type () {
return "TensorBSplineBasis"+
to_string(d); }
223 static Object *
get (gsXmlNode * node)
228 && ( !strcmp(node->first_attribute(
"type")->value(),
229 internal::gsXml<Object>::type().c_str() ) ),
230 "Something is wrong with the XML data: There should be a node with a "
231 <<internal::gsXml<Object>::type().c_str()<<
" Basis.");
236 && ( !strcmp(node->first_attribute(
"type")->value(),
237 internal::gsXml<Object>::type().c_str())
238 || !strcmp(node->first_attribute(
"type")->value(),
"BSplineBasis") ),
239 "Something is wrong with the XML data: There should be a node with a "
240 <<internal::gsXml<Object>::type().c_str()<<
" Basis.");
243 return getTensorBasisFromXml<Object >( node );
246 static gsXmlNode * put (
const Object & obj,
249 return putTensorBasisToXml<Object >(obj,data);
Knot vector for B-splines.
std::vector< Base * > castVectorPtr(std::vector< Derived * > pVec)
Casts a vector of pointers.
Definition: gsMemory.h:344
#define short_t
Definition: gsConfig.h:35
Boehm's algorithm for knot insertion.
#define index_t
Definition: gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
gsTensorBSplineBasis()
Default constructor.
Definition: gsTensorBSplineBasis.h:74
void gsTensorBoehmRefine(KnotVectorType &knots, Mat &coefs, int direction, gsVector< unsigned > str, ValIt valBegin, ValIt valEnd, bool update_knots=true)
Definition: gsBoehm.hpp:372
A tensor product B-spline basis.
Definition: gsTensorBSplineBasis.h:36
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
Provides implementation of generic XML functions.
std::string to_string(const unsigned &i)
Helper to convert small unsigned to string.
Definition: gsXml.cpp:74
bool nextLexicographic(Vec &cur, const Vec &size)
Iterates through a tensor lattice with the given size. Updates cur and returns true if another entry ...
Definition: gsCombinatorics.h:196
Provides declaration of input/output XML utilities struct.
Provides declaration of TensorBSplineBasis abstract interface.