39 class gsNurbs :
public gsGeoTraits<1,T>::GeometryBase
54 typedef memory::shared_ptr< gsNurbs >
Ptr;
57 typedef memory::unique_ptr< gsNurbs >
uPtr;
66 Base(basis, coefs) { }
77 Base( new
Basis(KV, & pcoefs->rightCols(1) ), pcoefs)
93 std::ostream &
print(std::ostream &os)
const
94 { os <<
"NURBS curve "<<
"of degree "<< this->
basis().degree()
95 <<
" over knots "<< this->
basis().knots() <<
",\n";
96 os <<
"weights: ["<< this->
weights().transpose()<<
" ]\n ";
97 os <<
"with control points "<< this->
m_coefs <<
".\n";
116 const KnotVectorType &
knots()
const {
return this->
basis().knots(); }
128 void isCompatible( gsGeometry<T> * other )
132 void makeCompatible( gsGeometry<T> * other )
137 void merge( gsGeometry<T> * otherG )
142 "gsNurbs: cannot merge curves in different spaces ( R^"
143 << this->
geoDim() <<
", R^" << otherG->geoDim() <<
" ).");
147 GISMO_ASSERT( other!=NULL,
"Can only merge with B-spline curves.");
148 other= other->clone().release();
153 const int mDeg =
this ->basis().degree();
154 const int oDeg = other->basis().degree();
155 const int deg = math::max(mDeg,oDeg);
157 other->gsNurbs::degreeElevate( deg - oDeg );
158 this ->gsNurbs::degreeElevate( deg - mDeg );
163 gsMatrix<T> mValue =
this ->eval(
this ->
support().col(1));
164 gsMatrix<T> oValue = other->eval(other->support().col(0));
168 KnotVectorType& mKnots =
this ->basis().knots();
169 KnotVectorType& oKnots = other->basis().knots();
170 T lastKnot = mKnots.last();
175 mKnots.remove(lastKnot);
178 oKnots.addConstant(lastKnot-oKnots.first());
179 mKnots.append( oKnots.begin()+deg+1, oKnots.end());
183 int skip = continuous ? 1 : 0;
184 this->
m_coefs.conservativeResize( n + other->coefsSize() -skip, gsEigen::NoChange ) ;
186 this->
m_coefs.block( n,0,other->coefsSize()-skip,other->geoDim() ) =
187 other->m_coefs.block( 1,0,other->coefsSize()-skip,other->geoDim() ) ;
190 this->
weights().conservativeResize( n + other->coefsSize() -skip, gsEigen::NoChange ) ;
192 this->
weights().block( n,0,other->coefsSize()-skip,1 ) =
193 other->weights().block( 1,0,other->coefsSize()-skip, 1 ) ;
void gsBoehm(KnotVectorType &knots, Mat &coefs, T val, int r=1, bool update_knots=true)
Performs insertion of multiple knot on "knots" and coefficients "coefs".
Definition: gsBoehm.hpp:29
Knot vector for B-splines.
Abstract base class representing a geometry map.
Definition: gsGeometry.h:92
gsMatrix< T > m_coefs
Coefficient matrix of size coefsSize() x geoDim()
Definition: gsGeometry.h:624
Represents a NURBS basis with one parameter.
A NURBS function of one argument, with arbitrary target dimension.
Definition: gsNurbs.h:39
bool gsAllCloseAbsolute(const matrix_t1 &a, const matrix_t2 &b, const typename matrix_t1::Scalar &tol)
tests if the difference between two matrices is bounded by tol in norm
Definition: gsMath.h:465
const KnotVectorType & knots() const
Returns a (const )reference to the knot vector.
Definition: gsNurbs.h:116
gsBasis< T > * m_basis
Pointer to the basis of this geometry.
Definition: gsGeometry.h:627
Class that creates a rational counterpart for a given basis.
Definition: gsRationalBasis.h:47
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsNurbs.h:93
const gsMatrix< T > & weights() const
Returns the weights of the rational basis.
Definition: gsNurbs.h:125
short_t degree(const short_t &i) const
Returns the degree wrt direction i.
Definition: gsGeometry.hpp:333
Boehm's algorithm for knot insertion.
void gsBoehmRefine(KnotVectorType &knots, Mat &coefs, int p, ValIt valBegin, ValIt valEnd, bool update_knots=true)
Definition: gsBoehm.hpp:163
memory::shared_ptr< gsNurbs > Ptr
Shared pointer for gsNurbs.
Definition: gsNurbs.h:54
S give(S &x)
Definition: gsMemory.h:266
Provides declaration of Geometry abstract interface.
gsNurbs(const gsKnotVector< T > &KV, const gsMatrix< T > *pcoefs)
Construct B-Spline by a knot vector, degree and projective coefficient matrix.
Definition: gsNurbs.h:76
index_t coefsSize() const
Return the number of coefficients (control points)
Definition: gsGeometry.h:371
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
virtual void insertKnot(T knot, index_t dir, index_t i=1)
Inserts knot knot at direction dir, i times.
Definition: gsGeometry.hpp:430
gsNurbs(const gsKnotVector< T > &KV, gsMatrix< T > w, gsMatrix< T > coefs)
Construct B-Spline by a knot vector, degree, weights and coefficient matrix.
Definition: gsNurbs.h:69
void insertKnots(It inBegin, It inEnd)
Insert the knots in the range [inBegin,inEnd) without changing the curve.
Definition: gsNurbs.h:210
T & weight(int i)
Access to i-th weight.
Definition: gsNurbs.h:119
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
gsNurbs()
Default empty constructor.
Definition: gsNurbs.h:62
T domainEnd() const
Returns the starting value of the domain of the basis.
Definition: gsNurbs.h:110
void insertKnot(T knot, int i=1)
Insert the given new knot (multiplicity i) without changing the curve.
Definition: gsNurbs.h:199
A univariate NURBS basis.
Definition: gsNurbsBasis.h:39
gsMatrix< T > support() const
Returns the range of parameters (same as parameterRange())
Definition: gsGeometry.hpp:193
T Scalar_t
Coefficient type.
Definition: gsNurbs.h:48
Class for representing a knot vector.
Definition: gsKnotVector.h:79
This is the main header file that collects wrappers of Eigen for linear algebra.
const T weight(int i) const
Const access to i-th weight.
Definition: gsNurbs.h:122
T domainStart() const
Returns the starting value of the domain of the basis.
Definition: gsNurbs.h:107
gsNurbs(const Basis &basis, const gsMatrix< T > &coefs)
Construct NURBS by NURBS basis functions and coefficient matrix.
Definition: gsNurbs.h:65
KnotVectorType & knots()
Returns a reference to the knot vector.
Definition: gsNurbs.h:113
virtual const gsBasis< T > & basis() const =0
Returns a const reference to the basis of the geometry.
short_t geoDim() const
Dimension n of the absent physical space.
Definition: gsGeometry.h:292
memory::unique_ptr< gsNurbs > uPtr
Unique pointer for gsNurbs.
Definition: gsNurbs.h:57
gsMatrix< T > & coefs()
Definition: gsGeometry.h:340