G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsNurbsBasis.h
Go to the documentation of this file.
1
14#pragma once
15
18
20#include <gsNurbs/gsBoehm.h>
21
22
23namespace gismo
24{
25
38template<class T>
39class gsNurbsBasis : public gsRationalBasis<gsBSplineBasis<T> >
40{
41public:
42
43 typedef gsKnotVector<T> KnotVectorType;
44
45 typedef memory::unique_ptr<gsGeometry<T> > gsGeoPtr;
46 typedef memory::unique_ptr<gsBasis<T> > gsBasisPtr;
47
50
53
55
58
59 typedef memory::shared_ptr< gsNurbsBasis > Ptr;
60 typedef memory::unique_ptr< gsNurbsBasis > uPtr;
61
63 static const int Dim = 1;
64
65public:
66
73 gsNurbsBasis(T u0, T u1, unsigned interior, int degree, unsigned mult_interior=1):
74 Base( gsBSplineBasis<T>(u0,u1,interior,degree,mult_interior) )
75 {
76 // if( ! check() )
77 // gsWarn << "Warning: Inconsistent "<< *this<< "\n";
78 }
79
82
85 Base( bs, give(w) ) { }
86
89 Base(new gsBSplineBasis<T>(), give(w))
90 {
91 *this->m_src = give(bs);
92 }
93
96 Base( new gsBSplineBasis<T>(give(KV)) )
97 { }
98
102
104 gsNurbsBasis( const gsNurbsBasis & o) : Base(o) { }
105
106 virtual ~gsNurbsBasis();
107
108public:
109
111 GISMO_CLONE_FUNCTION(gsNurbsBasis)
112
113 gsGeoPtr makeGeometry( gsMatrix<T>coefs ) const;
114
115 static gsBasisPtr create(std::vector<KnotVectorType> cKV, gsMatrix<T> weights);
116 using Base::create;
117
119 std::ostream &print(std::ostream &os) const
120 {
121 os << "NURBS Basis: deg=" << this->degree()
122 << ", size=" << this->size() << ", knot vector:\n";
123 os << this->knots() << ", weights: [ ";
124 os << this->weights().transpose() << " ]";
125 return os;
126 }
127
128 using Base::source;
129
130// ***********************************************
131// Additional members which forward to gsBSplineBasis
132// ***********************************************
133
135 T domainStart() const { return this->source().domainStart(); };
136
138 T domainEnd() const { return this->source().domainEnd(); };
139
141 inline unsigned firstActive(const T & u) const { return this->source().firstActive(u); }
142
147 inline index_t numActive() const { return this->source().numActive(); }
148
151 inline index_t firstActive(const gsMatrix<T,1> & u) const
152 { return this->source().firstActive(u.value()); };
153
154 // /// Returns the knot vector of the basis
155 const KnotVectorType & knots() const { return this->source().knots(); }
156 KnotVectorType & knots() { return this->source().knots(); }
157
159 void insertKnot( T val, int i = 1)
160 {
161 // TO DO: There is also Oslo Algorithm and others
162 gsBoehm( this->knots(), this->weights(), val, i );
163 }
164
166 template <class It>
167 void insertKnots( It begin, It end )
168 {
169 gsBoehmRefine( this->knots(), this->weights(), this->degree(), begin, end);
170 }
171
173 void uniformRefine(int numKnots = 1, int mul=1, int dir = -1)
174 {
175 GISMO_UNUSED(dir);
176 // TO DO ; replace this with global refinemnt by
177 // Lane-Riesenfeld-like Algorithm
178 std::vector<T> newKnots;
179 this->knots().getUniformRefinementKnots(numKnots, newKnots,mul);
180 this->insertKnots( newKnots.begin(), newKnots.end() );
181 }
182
184 void uniform_k_refine(int const & i = 1)
185 {
187 //m_p += i;
188 //m_knots->degreeElevate(i);
189 //m_knots->uniformRefine();
190 };
191
192}; // class gsNurbsBasis
193
194
195} // namespace gismo
196
197
198// *****************************************************************
199#ifndef GISMO_BUILD_LIB
200#include GISMO_HPP_HEADER(gsNurbsBasis.hpp)
201#else
202#ifdef gsNurbsBasis_EXPORT
203#include GISMO_HPP_HEADER(gsNurbsBasis.hpp)
204#undef EXTERN_CLASS_TEMPLATE
205#define EXTERN_CLASS_TEMPLATE CLASS_TEMPLATE_INST
206#endif
207namespace gismo
208{
209EXTERN_CLASS_TEMPLATE gsNurbsBasis<real_t>;
210}
211#endif
212// *****************************************************************
A univariate B-spline basis.
Definition gsBSplineBasis.h:700
virtual gsBasis::uPtr create() const
Create an empty basis of the derived type and return a pointer to it.
Definition gsBasis.hpp:532
Class defining a dummy basis of constant functions. This is used for compatibility reasons.
Definition gsConstantBasis.h:35
Class for representing a knot vector.
Definition gsKnotVector.h:80
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
A univariate NURBS basis.
Definition gsNurbsBasis.h:40
gsNurbsBasis(T u0, T u1, unsigned interior, int degree, unsigned mult_interior=1)
Construct a NURBS basis with unit weights.
Definition gsNurbsBasis.h:73
gsNurbsBasis(gsKnotVector< T > KV, gsMatrix< T > w)
Construct a rational counterpart of B-spline basis given by knots and weights.
Definition gsNurbsBasis.h:100
unsigned firstActive(const T &u) const
Returns the index of the first active (ie. non-zero) basis function at point u.
Definition gsNurbsBasis.h:141
gsNurbsBasis(gsBSplineBasis< T > bs, gsMatrix< T > w)
Construct NURBS basis by a Bspline basis plus weights.
Definition gsNurbsBasis.h:88
void insertKnot(T val, int i=1)
Insert a new knot val with multiplicity i.
Definition gsNurbsBasis.h:159
gsNurbsBasis(gsBSplineBasis< T > *bs, gsMatrix< T > w)
Construct NURBS basis by a Bspline basis pointer (consumed) plus weights.
Definition gsNurbsBasis.h:84
gsNurbsBasis(gsKnotVector< T > KV)
Construct NURBS basis of a knot vector.
Definition gsNurbsBasis.h:95
void insertKnots(It begin, It end)
Insert the new knots given by the range [begin..end).
Definition gsNurbsBasis.h:167
gsNurbs< T > GeometryType
Associated geometry type.
Definition gsNurbsBasis.h:52
void uniform_k_refine(int const &i=1)
Apply k-refinement to the basis i times.
Definition gsNurbsBasis.h:184
gsConstantBasis< T > BoundaryBasisType
Associated Boundary basis type.
Definition gsNurbsBasis.h:57
index_t numActive() const
Number of active basis functions at an arbitrary parameter value.
Definition gsNurbsBasis.h:147
gsNurbsBasis(const gsNurbsBasis &o)
Copy Constructor.
Definition gsNurbsBasis.h:104
T domainEnd() const
Returns the starting value of the domain of the basis.
Definition gsNurbsBasis.h:138
gsGeoPtr makeGeometry(gsMatrix< T >coefs) const
Clone function. Used to make a copy of a derived basis.
Definition gsNurbsBasis.hpp:29
gsBSplineBasis< T > Family_t
The family type.
Definition gsNurbsBasis.h:49
index_t firstActive(const gsMatrix< T, 1 > &u) const
Definition gsNurbsBasis.h:151
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition gsNurbsBasis.h:119
gsNurbsBasis()
Default empty constructor.
Definition gsNurbsBasis.h:81
static const int Dim
Dimension of the parameter domain.
Definition gsNurbsBasis.h:63
T domainStart() const
Returns the starting value of the domain of the basis.
Definition gsNurbsBasis.h:135
void uniformRefine(int numKnots=1, int mul=1, int dir=-1)
Refine the basis uniformly by inserting numKnots new knots per knot span.
Definition gsNurbsBasis.h:173
A NURBS function of one argument, with arbitrary target dimension.
Definition gsNurbs.h:40
Class that creates a rational counterpart for a given basis.
Definition gsRationalBasis.h:48
index_t size() const
Definition gsRationalBasis.h:137
const gsMatrix< T > & weights() const
Returns the weights of the rational basis.
Definition gsRationalBasis.h:300
short_t degree(short_t i=0) const
Definition gsRationalBasis.h:165
const gsBSplineBasis< T > & source() const
Returns the source basis of the rational basis.
Definition gsRationalBasis.h:293
Provides declaration of BSplineBasis class.
Boehm's algorithm for knot insertion.
#define index_t
Definition gsConfig.h:32
#define GISMO_NO_IMPLEMENTATION
Definition gsDebug.h:129
#define GISMO_UNUSED(x)
Definition gsDebug.h:112
Provides forward declarations of types and structs.
Provides declaration of RationalBasis class.
The G+Smo namespace, containing all definitions for the library.
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
S give(S &x)
Definition gsMemory.h:266
void gsBoehmRefine(KnotVectorType &knots, Mat &coefs, int p, ValIt valBegin, ValIt valEnd, bool update_knots=true)
Definition gsBoehm.hpp:163