88    typedef std::vector<T>      knotContainer;
 
   89    typedef std::vector<mult_t> multContainer;
 
   97    typedef typename std::vector<T>::const_iterator 
iterator;
 
   98    typedef std::reverse_iterator<iterator> reverse_iterator;
 
  103    typedef std::reverse_iterator<uiterator> reverse_uiterator;
 
  108    typedef std::reverse_iterator<smart_iterator>  reverse_smart_iterator;
 
  113    typedef reverse_iterator const_reverse_iterator;
 
  122    reverse_iterator       
rbegin()  
const;    
 
  124    reverse_iterator       
rend()    
const;
 
  141    reverse_uiterator      
urbegin() 
const;
 
  143    reverse_uiterator      
urend()   
const;
 
  150    reverse_smart_iterator 
rsbegin() 
const;
 
  152    reverse_smart_iterator 
rsend()   
const;
 
  178    void insert(T knot, mult_t mult = 1 );
 
  183    template<
typename iterType>
 
  184    void insert( iterType ibeg, iterType iend )
 
  189        knotContainer temp(m_repKnots.size()+(iend-ibeg) );
 
  190        std::merge( 
begin(), 
end(), ibeg, iend, temp.begin() );
 
  192        m_repKnots.swap(temp);
 
 
  207    void remove( 
const T knot, mult_t mult = 1 );
 
  221    mult_t 
multLast()
 const { 
return m_multSum.back() - m_multSum.end()[-2]; }
 
  242    inline size_t size()
 const { 
return m_repKnots.size(); }
 
  245    inline size_t uSize()
 const { 
return m_multSum.size(); }
 
  250        GISMO_ASSERT( 
static_cast<size_t>(i) < m_repKnots.size(),
 
  251                      "Index "<<i<<
" not in the knot vector.");
 
  252        return m_repKnots[i];
 
 
  259                              "Unique index "<<i<<
" not in the knot vector.");
 
 
  275        return knotContainer(this->
ubegin(),this->
uend());
 
 
  282    operator const knotContainer& () 
const {
return m_repKnots;}
 
  285    const T * 
data()
 const {
return m_repKnots.data(); }
 
  326    std::ostream &
print(std::ostream &os = 
gsInfo ) 
const;
 
  331    typedef typename knotContainer::iterator nonConstIterator    ;
 
  332    typedef typename multContainer::iterator nonConstMultIterator;
 
  337        GISMO_ASSERT( 
size() > 
static_cast<size_t>(2*m_deg+1), 
"Not enough knots.");
 
  338        return begin() + m_deg;
 
 
  344        GISMO_ASSERT( 
size() > 
static_cast<size_t>(2*m_deg+1), 
"Not enough knots.");
 
  345        return end() - (m_deg + 1);
 
 
  351    { 
return sbegin() + m_deg; }
 
 
  356    { 
return send() - (m_deg + 1); }
 
 
  386    void trimLeft (
const mult_t numKnots);
 
  396        it += math::min( (
size_t)m_deg, 
size() );
 
  397        return std::distance( 
uiterator(*
this,0,0), it.uIterator() );
 
 
  410    static bool isConsistent(
const knotContainer & repKnots,
 
  411                             const multContainer & multSums);
 
  416        return (m_repKnots == other.m_repKnots) &&
 
  417               (m_multSum  == other.m_multSum ) &&
 
  418               (m_deg == other.m_deg);
 
 
  424    void rebuildMultSum();
 
  429    knotContainer m_repKnots;
 
  432    multContainer m_multSum;
 
  461                  mult_t mult_interior=1,
 
  470    template<
typename iterType>
 
  473        insert(begOfKnots,endOfKnots);
 
 
  488                      unsigned mult_interior,
 
  497                      unsigned mult_interior = 1,
 
 
  508                    T grading = 0.5, 
unsigned mult_interior = 1)
 
 
  515                    T grading, 
unsigned mult_interior = 1)
 
  520        m_repKnots.reserve( 2*(m_deg+1) + interior*mult_interior );
 
  521        m_multSum .reserve(interior+2);
 
  523        const T h = (u1-u0) / (T)(interior+1);
 
  525        m_repKnots.insert(m_repKnots.begin(), m_deg+1, u0);
 
  526        m_multSum .push_back(m_deg+1);
 
  528        for ( 
unsigned i=1; i<=interior; i++ )
 
  530            m_repKnots.insert(m_repKnots.end(), mult_interior,
 
  531                              math::pow(T(i)*h, 1.0/grading) );
 
  532            m_multSum .push_back( mult_interior + m_multSum.back() );
 
  534        m_repKnots.insert(m_repKnots.end(), m_deg+1, u1);
 
  535        m_multSum .push_back( m_deg+1 + m_multSum.back() );
 
 
  591                   std::vector<T>& result) 
const;
 
  599                       std::vector<T>& result) 
const;
 
  624    void insert( 
const knotContainer &knots, 
int mult = 1 )
 
  626        for( 
int i = 0; i < mult; ++i)
 
  627            insert( knots.begin(), knots.end() ); 
 
 
  646    template<
typename iterType>
 
  651        input.insert(input.begin(), 
begin, 
end); 
 
  652        std::sort(input.begin(), input.end());
 
  654        knotContainer newKnots;
 
  655        T segmentsPerSpan = knotsPerSpan + 1;
 
  659        for( 
typename multContainer::const_iterator it= input.begin();
 
  662            for( mult_t k = 1; k <= knotsPerSpan; ++k )
 
  664                spanBegin =*(this->
ubegin()+*it);
 
  665                spanEnd  =*(this->
ubegin()+*it+1);
 
  666                newKnot = ( (segmentsPerSpan-(T)(k)) * spanBegin + (T)(k) * spanEnd ) / segmentsPerSpan;
 
  667                newKnots.push_back( newKnot );
 
  670        insert(newKnots.begin(), newKnots.end());
 
 
  695                     unsigned mult_interior = 1)
 
 
  724        return m_repKnots.front();
 
 
  731        return m_repKnots.back();
 
 
  741    void refineSpans( 
const std::vector<unsigned> & spanIndices, mult_t knotsPerSpan = 1)
 
  743        multContainer transformedIndices;
 
  744        transformedIndices.reserve(spanIndices.size());
 
  745        for( std::vector<unsigned>::const_iterator it = spanIndices.begin();
 
  746             it != spanIndices.end();
 
  748            transformedIndices.push_back(
static_cast<mult_t
>(*it));
 
  750        return refineSpans( transformedIndices, knotsPerSpan );
 
 
  755    void refineSpans( 
const multContainer & spanIndices, mult_t knotsPerSpan = 1);
 
  762        m_repKnots.reserve(
size()+2*i);
 
  763        m_repKnots.insert(m_repKnots.begin(), i, m_repKnots.front() );
 
  764        m_repKnots.insert(m_repKnots.end()  , i, m_repKnots.back()  );
 
  767        std::transform(m_multSum.begin(), m_multSum.end(), m_multSum.begin(),
 
  768                       GS_BIND2ND(std::plus<mult_t>(), i) );
 
  769        m_multSum.back() += i;
 
 
  787                    if ( itr.multiplicity() > m_deg )
 
  788                        remove( itr, itr.multiplicity() - m_deg );
 
 
  801    template<
typename iterType>
 
  810    const knotContainer& 
get() const 
 
 
  819    inline bool has(T knot)
 const 
  821        return std::binary_search( 
ubegin(), 
uend(), knot);
 
 
  830        return (
ubegin() + i).multiplicity();
 
 
  837        return (
ubegin()+i).firstAppearance();
 
 
  846        return (
ubegin()+i).lastAppearance();
 
 
  855        return (
ubegin()+i).multSum();
 
 
  861        return ! ((*this)==other);
 
 
  865    inline T 
at (
const size_t & i)
 const 
  867        return m_repKnots.at(i);
 
 
  875            if( math::abs(*uit - (*uit-(T)(1)) - df) > tol )
 
 
  884        const int dp1 = m_deg + 1;
 
 
  908                                   mult_t mult = 1) 
const;
 
  911    std::string 
detail() 
const;
 
 
  943std::ostream& operator << (std::ostream& out, 
const gsKnotVector<T> KV )
 
  962static bool isNested(
const gsKnotVector<T> & SubSpace, 
const gsKnotVector<T> & Space)
 
  964    std::vector<T> difference, intersection;
 
  965    std::vector<T> knots1, knots2;
 
  967    std::set_intersection(  SubSpace.ubegin(), SubSpace.uend(),
 
  968                            Space.ubegin(), Space.uend(),
 
  969                            std::back_inserter(intersection) );
 
  971    std::set_difference(    Space.ubegin(), Space.uend(),
 
  972                            intersection.begin(), intersection.end(),
 
  973                            std::back_inserter(difference) );
 
  975    return (difference.size()==0);
 
  978#ifdef GISMO_WITH_PYBIND11 
  983  void pybind11_init_gsKnotVector(pybind11::module &m);
 
  991#ifndef GISMO_BUILD_LIB 
  992#include GISMO_HPP_HEADER(gsKnotVector.hpp) 
  994#ifdef gsKnotVector_EXPORT 
  995#include GISMO_HPP_HEADER(gsKnotVector.hpp) 
  996#undef  EXTERN_CLASS_TEMPLATE 
  997#define EXTERN_CLASS_TEMPLATE CLASS_TEMPLATE_INST 
 1001EXTERN_CLASS_TEMPLATE gsKnotVector<real_t>;
 
Creates a mapped object or data pointer to a const matrix without copying data.
Definition gsAsMatrix.h:141
Class representing a domain. i.e. a collection of elements (triangles, rectangles,...
Definition gsDomain.h:32
Class for representing a knot vector.
Definition gsKnotVector.h:80
bool isOpen() const
Definition gsKnotVector.h:882
bool inDomain(const T u) const
Checks, whether the given value is inside the domain.
Definition gsKnotVector.h:375
reverse_iterator rbegin() const
Returns reverse iterator pointing past the end of the repeated knots.
Definition gsKnotVector.hpp:147
uiterator ubegin() const
Returns unique iterator pointing to the beginning of the unique knots.
Definition gsKnotVector.hpp:235
void greville_into(gsMatrix< T > &result) const
Definition gsKnotVector.hpp:991
bool operator==(const gsKnotVector< T > &other) const
Compare with another knot vector.
Definition gsKnotVector.h:414
void set_degree(short_t p)
Sets the degree to p.
Definition gsKnotVector.h:631
unsigned lastKnotIndex(const size_t &i) const
Definition gsKnotVector.h:844
void reduceMultiplicity(const mult_t i=1, bool boundary=false)
Definition gsKnotVector.hpp:903
bool operator!=(const gsKnotVector< T > &other) const
Compares with another knot vector.
Definition gsKnotVector.h:859
void degreeReduce(const short_t &i)
Converse to degreeElevate.
Definition gsKnotVector.hpp:944
void getUniformRefinementKnots(mult_t knotsPerSpan, knotContainer &result, mult_t mult=1) const
Definition gsKnotVector.hpp:1048
iterator domainBegin() const
Returns an iterator pointing to the starting knot of the domain.
Definition gsKnotVector.h:335
T at(const size_t &i) const
Returns the value of the i - th knot (counted with repetitions).
Definition gsKnotVector.h:865
std::ostream & print(std::ostream &os=gsInfo) const
Definition gsKnotVector.hpp:493
size_t size() const
Number of knots (including repetitions).
Definition gsKnotVector.h:242
mult_t maxInteriorMultiplicity() const
Returns the maximum multiplicity in the interior.
Definition gsKnotVector.hpp:724
void swap(gsKnotVector &other)
Swaps with other knot vector.
Definition gsKnotVector.hpp:302
void initGraded(unsigned numKnots, int degree, T grading=0.5, unsigned mult_interior=1)
Definition gsKnotVector.h:507
iterator begin() const
Returns iterator pointing to the beginning of the repeated knots.
Definition gsKnotVector.hpp:117
bool has(T knot) const
Definition gsKnotVector.h:819
T maxIntervalLength() const
Returns the maximum interval length of the knot sequence.
Definition gsKnotVector.hpp:518
internal::gsKnotIterator< T > smart_iterator
Definition gsKnotVector.h:107
std::vector< T >::const_iterator iterator
Definition gsKnotVector.h:97
void reverse()
Better directly use affineTransformTo.
Definition gsKnotVector.hpp:468
void insert(const knotContainer &knots, int mult=1)
Insert knots into the knot vector.
Definition gsKnotVector.h:624
void initClamped(T u0, T u1, int degree, unsigned interior=0, unsigned mult_interior=1)
Resets the knot vector so that it is uniform and has clamped endknots.
Definition gsKnotVector.h:694
iterator beginAt(mult_t upos) const
Definition gsKnotVector.hpp:131
void append(iterType begin, iterType end)
Adds the knots between begin and end to the knot vector.
Definition gsKnotVector.h:802
smart_iterator domainSEnd() const
Definition gsKnotVector.h:355
T first() const
Get the first knot.
Definition gsKnotVector.h:721
void degreeElevate(const short_t &i=1)
Definition gsKnotVector.hpp:937
void uniformRefine(mult_t numKnots=1, mult_t mult=1)
Definition gsKnotVector.hpp:820
reverse_smart_iterator rsbegin() const
Returns the reverse smart iterator pointing past the end of the repeated knots.
Definition gsKnotVector.hpp:271
const T * data() const
Returns a pointer to the beginning of the vector of knots.
Definition gsKnotVector.h:285
void initClamped(int degree, unsigned numKnots=2, unsigned mult_interior=1)
Definition gsKnotVector.hpp:693
void initUniform(unsigned numKnots, unsigned mult_ends, unsigned mult_interior=1, short_t degree=- 1)
Definition gsKnotVector.h:495
void remove(uiterator uit, mult_t mult=1)
Definition gsKnotVector.hpp:347
void refineSpans(iterType begin, iterType end, mult_t knotsPerSpan)
Inserts knotsPerSpan knots between each two knots between begin and end.
Definition gsKnotVector.h:647
gsKnotVector knotUnion(const gsKnotVector &b) const
Computes the union of knot-vectors this and b.
Definition gsKnotVector.hpp:187
smart_iterator send() const
Returns the smart iterator pointing past the end of the repeated knots.
Definition gsKnotVector.hpp:265
const mult_t * multSumData() const
Definition gsKnotVector.h:289
reverse_smart_iterator rsend() const
Returns the reverse smart iterator pointing to the beginning of the repeated knots.
Definition gsKnotVector.hpp:277
void erase(const mult_t first, const mult_t last)
Removes the knots in the range [first,last)
Definition gsKnotVector.hpp:376
mult_t multiplicityIndex(mult_t i) const
Definition gsKnotVector.hpp:430
knotContainer unique() const
Returns unique knots.
Definition gsKnotVector.h:273
void trimLeft(const mult_t numKnots)
Removes the left-most numKnots from the knot-vector.
Definition gsKnotVector.hpp:390
index_t numRightGhosts() const
Definition gsKnotVector.h:402
void transform(T c, T d)
See affineTransform().
Definition gsKnotVector.h:735
gsKnotVector(short_t degree)
Sets the degree and leaves the knots uninitialized.
Definition gsKnotVector.h:446
const knotContainer & get() const
Get a reference to the underlying std::vector of knots.
Definition gsKnotVector.h:810
bool check() const
Checks whether the knot vector is in a consistent state.
Definition gsKnotVector.hpp:536
int degree() const
Returns the degree of the knot vector.
Definition gsKnotVector.hpp:700
multContainer multiplicities() const
Returns vector of multiplicities of the knots.
Definition gsKnotVector.hpp:714
smart_iterator domainSBegin() const
Definition gsKnotVector.h:350
std::string detail() const
Return a string with detailed information on the knot vector.
Definition gsKnotVector.hpp:800
void supportIndex_into(const mult_t &i, gsMatrix< index_t > &result) const
Definition gsKnotVector.hpp:1066
T last() const
Get the last knot.
Definition gsKnotVector.h:728
gsKnotVector(short_t deg, const iterType begOfKnots, const iterType endOfKnots)
Definition gsKnotVector.h:471
iterator domainEnd() const
Returns an iterator pointing to the end-knot of the domain.
Definition gsKnotVector.h:342
void refineSpans(const std::vector< unsigned > &spanIndices, mult_t knotsPerSpan=1)
Because of type compatibility, cf. the other version.
Definition gsKnotVector.h:741
gsAsConstMatrix< T > asMatrix() const
Returns the knots as a matrix of size 1 x size()
Definition gsKnotVector.h:169
gsKnotVector * clone() const
Returns a pointer to a copy.
Definition gsKnotVector.hpp:312
void degreeIncrease(int const &i=1)
Definition gsKnotVector.h:759
uiterator uend() const
Returns unique iterator pointing past the end of the unique knots.
Definition gsKnotVector.hpp:241
unsigned u_multiplicityIndex(size_t const &i) const
Definition gsKnotVector.h:828
const T & operator[](const mult_t i) const
Provides the i-th knot (numbered including repetitions).
Definition gsKnotVector.h:248
unsigned knotsUntilSpan(const size_t &i) const
Definition gsKnotVector.h:853
bool isUniform(T tol=1e-9) const
Checks whether the knot vector is uniform.
Definition gsKnotVector.h:871
mult_t multFirst() const
Returns the multiplicity of the first knot.
Definition gsKnotVector.h:218
uiterator domainUBegin() const
Returns a unique iterator pointing to the starting knot of the domain.
Definition gsKnotVector.h:359
void insert(T knot, mult_t mult=1)
Inserts knot knot into the knot vector with multiplicity mult.
Definition gsKnotVector.hpp:325
reverse_iterator rend() const
Returns reverse iterator pointing to the beginning of the repeated knots.
Definition gsKnotVector.hpp:229
mult_t multLast() const
Returns the multiplicity of the last knot.
Definition gsKnotVector.h:221
void difference(const gsKnotVector< T > &other, std::vector< T > &result) const
Computes the difference between this knot-vector and other.
Definition gsKnotVector.hpp:159
static bool isConsistent(const knotContainer &repKnots, const multContainer &multSums)
Sanity check.
Definition gsKnotVector.hpp:542
iterator iFind(const T u) const
Returns an iterator to the last occurrence of the knot at the beginning of the knot interval containi...
Definition gsKnotVector.hpp:779
void degreeDecrease(int const &i=1, bool updateInterior=false)
Inverse of degreeIncrease.
Definition gsKnotVector.h:775
void addConstant(T amount)
Adds amount to all the knots.
Definition gsKnotVector.hpp:839
uiterator domainUEnd() const
Returns a unique iterator pointing to the ending knot of the domain.
Definition gsKnotVector.h:367
size_t uSize() const
Number of unique knots (i.e., without repetitions).
Definition gsKnotVector.h:245
const T & operator()(const mult_t i) const
Provides the knot with unique index i.
Definition gsKnotVector.h:256
int deduceDegree() const
Definition gsKnotVector.hpp:706
virtual knotContainer breaks() const
Returns unique knots of the domain (i.e., including the endpoints of the domain).
Definition gsKnotVector.h:897
mult_t multiplicity(T u) const
Definition gsKnotVector.hpp:421
internal::gsUKnotIterator< T > uiterator
Definition gsKnotVector.h:102
void trimRight(const mult_t numKnots)
Removes the right-most numKnots from the knot-vector.
Definition gsKnotVector.hpp:403
mult_t minInteriorMultiplicity() const
Returns the minimum multiplicity in the interior.
Definition gsKnotVector.hpp:733
uiterator uFind(const T u) const
Returns the uiterator pointing to the knot at the beginning of the knot interval containing u....
Definition gsKnotVector.hpp:747
void initGraded(T u0, T u1, unsigned interior, int degree, T grading, unsigned mult_interior=1)
Resets the knot vector so that its knots are graded.
Definition gsKnotVector.h:514
smart_iterator sbegin() const
Returns the smart iterator pointing to the beginning of the repeated knots.
Definition gsKnotVector.hpp:259
T uValue(const size_t &i) const
Provides the knot with unique index i.
Definition gsKnotVector.h:264
void symDifference(const gsKnotVector< T > &other, std::vector< T > &result) const
Computes the symmetric difference between this knot-vector and other.
Definition gsKnotVector.hpp:172
void initUniform(T first, T last, unsigned interior, unsigned mult_ends, unsigned mult_interior, short_t degree=-1)
Definition gsKnotVector.hpp:643
uiterator uLowerBound(const T u) const
Returns a uiterator pointing to the first knot which does not compare less than u.
Definition gsKnotVector.hpp:771
gsKnotVector()
Empty constructor sets the degree to -1 and leaves the knots empty.
Definition gsKnotVector.h:157
iterator end() const
Returns iterator pointing past the end of the repeated knots.
Definition gsKnotVector.hpp:124
void increaseMultiplicity(const mult_t i=1, bool boundary=false)
Definition gsKnotVector.hpp:874
void centers_into(gsMatrix< T > &result) const
Definition gsKnotVector.hpp:1025
T minIntervalLength() const
Returns the minimum interval length of the knot sequence.
Definition gsKnotVector.hpp:527
uiterator uUpperBound(const T u) const
Returns an iterator pointing to the first knot which compares greater than u.
Definition gsKnotVector.hpp:763
void affineTransformTo(T newBeg, T newEnd)
Definition gsKnotVector.hpp:450
std::vector< T > coarsen(index_t knotRemove=1, index_t knotSkip=1, mult_t mul=-1)
Definition gsKnotVector.hpp:952
iterator endAt(mult_t upos) const
Definition gsKnotVector.hpp:139
bool includes(const gsKnotVector< T > &other) const
Returns true if every knot of other (counted with repetitions) is found within this knot-vector....
Definition gsKnotVector.hpp:153
gsMatrix< T > greville() const
Definition gsKnotVector.h:540
reverse_uiterator urend() const
Returns reverse unique iterator pointing to the beginning of the unique knots.
Definition gsKnotVector.hpp:253
unsigned firstKnotIndex(const size_t &i) const
Definition gsKnotVector.h:835
index_t numLeftGhosts() const
Definition gsKnotVector.h:393
size_t numElements() const
Number of knot intervals inside domain.
Definition gsKnotVector.h:268
gsKnotVector knotIntersection(const gsKnotVector &b) const
Computes the intersection of knot-vectors this and b.
Definition gsKnotVector.hpp:201
reverse_uiterator urbegin() const
Returns reverse unique iterator pointing past the end of the unique knots.
Definition gsKnotVector.hpp:247
void insert(iterType ibeg, iterType iend)
Definition gsKnotVector.h:184
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define gsInfo
Definition gsDebug.h:43
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Abstracgt Base class representing a domain. i.e. a collection of elements (triangles,...
Provides forward declarations of types and structs.
Provides implementation of knot vector iterators.
The G+Smo namespace, containing all definitions for the library.
Struct that defines the boundary sides and corners and types of a geometric object.
Definition gsBoundary.h:56