G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsKnotVector.h
Go to the documentation of this file.
1 
14 #pragma once
15 
17 #include <gsCore/gsDomain.h>
18 
19 #include <gsNurbs/gsKnotIterator.h>
20 
21 namespace gismo
22 {
23 
78 template<typename T>
79 class gsKnotVector : public gsDomain<T>
80 {
81 public: // typedefs
82 
83  // IMPORTANT: mult_t must be a signed type, otherwise the
84  // knotIterator business would not work.
85  typedef index_t mult_t;
86 
87  // container types
88  typedef std::vector<T> knotContainer;
89  typedef std::vector<mult_t> multContainer;
90 
91  // TODO: remove the non-const versions and think about the names.
92  // E.g., reverse_uiterator clashes with urbegin().
93 
96  //typedef const T * iterator;
97  typedef typename std::vector<T>::const_iterator iterator;
98  typedef std::reverse_iterator<iterator> reverse_iterator;
99 
102  typedef internal::gsUKnotIterator<T> uiterator;
103  typedef std::reverse_iterator<uiterator> reverse_uiterator;
104 
107  typedef internal::gsKnotIterator<T> smart_iterator;
108  typedef std::reverse_iterator<smart_iterator> reverse_smart_iterator;
109 
110  //compatibility iterator typedefs
111  typedef uiterator const_uiterator;
112  typedef iterator const_iterator;
113  typedef reverse_iterator const_reverse_iterator;
114 
115 public: // iterator ends
116 
118  iterator begin() const;
120  iterator end() const;
122  reverse_iterator rbegin() const;
124  reverse_iterator rend() const;
125 
129  iterator beginAt(mult_t upos) const;
130 
134  iterator endAt(mult_t upos) const;
135 
137  uiterator ubegin() const;
139  uiterator uend() const;
141  reverse_uiterator urbegin() const;
143  reverse_uiterator urend() const;
144 
146  smart_iterator sbegin() const;
148  smart_iterator send() const;
150  reverse_smart_iterator rsbegin() const;
152  reverse_smart_iterator rsend() const;
153 
154 public: // constructors
155 
157  gsKnotVector() : m_deg(-1)
158  { }
159 
163  explicit gsKnotVector(knotContainer knots, short_t degree = -1 );
164 
166  void swap( gsKnotVector& other );
167 
169  gsAsConstMatrix<T> asMatrix() const {return m_repKnots;}
170 
171 public:
173  gsKnotVector* clone() const;
174 
175 public: // inserting and removing
176 
178  void insert(T knot, mult_t mult = 1 );
179 
183  template<typename iterType>
184  void insert( iterType ibeg, iterType iend )
185  {
186  //size_t numKnots = size() + (iend - ibeg);
187  // GISMO_ENSURE( numKnots < std::numeric_limits<mult_t>::max(),
188  // "Too many knots." );
189  knotContainer temp(m_repKnots.size()+(iend-ibeg) );
190  std::merge( begin(), end(), ibeg, iend, temp.begin() );
191 
192  m_repKnots.swap(temp);
193 
194  rebuildMultSum(); // Possibly sub-optimal but the code is clean.
195 
196  GISMO_ASSERT( check(), "Unsorted knots or invalid multiplicities.");
197  }
198 
199  //TODO: insert with uniqIter and multiplicity.
200 
204  void remove( uiterator uit, mult_t mult = 1 );
205 
207  void remove( const T knot, mult_t mult = 1 );
208 
209  //TODO: remove with two iterators.
210 
211 public: // multiplicities
212 
215  mult_t multiplicity( T u ) const;
216 
218  mult_t multFirst() const { return m_multSum.front(); }
219 
221  mult_t multLast() const { return m_multSum.back() - m_multSum.end()[-2]; }
222 
224  mult_t maxInteriorMultiplicity() const;
225 
227  mult_t minInteriorMultiplicity() const;
228 
231  mult_t multiplicityIndex( mult_t i ) const;
232 
233 public: // modifiers
234 
237  void affineTransformTo( T newBeg, T newEnd );
238 
239 public: // queries
240 
242  inline size_t size() const { return m_repKnots.size(); }
243 
245  inline size_t uSize() const { return m_multSum.size(); }
246 
248  const T& operator[](const mult_t i) const
249  {
250  GISMO_ASSERT( static_cast<size_t>(i) < m_repKnots.size(),
251  "Index "<<i<<" not in the knot vector.");
252  return m_repKnots[i];
253  }
254 
256  const T& operator()(const mult_t i) const
257  {
258  GISMO_ASSERT(i+numLeftGhosts() >=0 && static_cast<size_t>(i+numLeftGhosts()) < uSize(),
259  "Unique index "<<i<<" not in the knot vector.");
260  return *( this->ubegin()+(numLeftGhosts()+i) );
261  }
262 
264  inline T uValue(const size_t & i) const
265  { return this->operator()(i); }
266 
268  inline size_t numElements() const { return (domainUEnd() - domainUBegin()); }
269 
270 public: // getters
271 
273  knotContainer unique () const
274  {
275  return knotContainer(this->ubegin(),this->uend());
276  }
277 
279  multContainer multiplicities() const;
280 
282  operator const knotContainer& () const {return m_repKnots;}
283 
285  const T * data() const {return m_repKnots.data(); }
286 
289  const mult_t * multSumData() const {return m_multSum.data(); }
290 
291 public: // Findspan and value query
292 
297  uiterator uFind( const T u ) const;
298 
303  iterator iFind( const T u ) const;
304 
311  uiterator uUpperBound( const T u ) const;
312 
320  uiterator uLowerBound( const T u ) const;
321 
322 public: // miscellaneous
323 
326  std::ostream &print(std::ostream &os = gsInfo ) const;
327 
329  bool check() const;
330 
331  typedef typename knotContainer::iterator nonConstIterator ;
332  typedef typename multContainer::iterator nonConstMultIterator;
333 
336  {
337  GISMO_ASSERT( size() > static_cast<size_t>(2*m_deg+1), "Not enough knots.");
338  return begin() + m_deg;
339  }
340 
343  {
344  GISMO_ASSERT( size() > static_cast<size_t>(2*m_deg+1), "Not enough knots.");
345  return end() - (m_deg + 1);
346  }
347 
351  { return sbegin() + m_deg; }
352 
356  { return send() - (m_deg + 1); }
357 
360  {
361  return domainSBegin().uIterator();
362  // equivalent:
363  //return ubegin() + domainSBegin().uIndex();
364  }
365 
368  {
369  return domainSEnd().uIterator();
370  // equivalent:
371  //return ubegin() + domainSEnd().uIndex();
372  }
373 
375  inline bool inDomain(const T u) const
376  {
377  return u >= *domainBegin() && u <= *domainEnd();
378  // equivalent:
379  // return u >= m_repKnots[m_deg] && u <= m_repKnots.end()[-m_deg-1];
380  }
381 
383  void erase(const mult_t first, const mult_t last);
384 
386  void trimLeft (const mult_t numKnots);
387 
389  void trimRight(const mult_t numKnots);
390 
394  {
395  smart_iterator it(*this,0,0);
396  it += math::min( (size_t)m_deg, size() );
397  return std::distance( uiterator(*this,0,0), it.uIterator() );
398  }
399 
403  {
404  return std::distance(domainUEnd(), uend()) - 1;
405  }
406 
407 public:
408 
410  static bool isConsistent(const knotContainer & repKnots,
411  const multContainer & multSums);
412 
414  inline bool operator== (const gsKnotVector<T>& other) const
415  {
416  return (m_repKnots == other.m_repKnots) &&
417  (m_multSum == other.m_multSum ) &&
418  (m_deg == other.m_deg);
419  }
420 
421 private: // internals
422 
423  // Creates a vector of multiplicity sums from a scratch and m_repKnots.
424  void rebuildMultSum();
425 
426 private: // members
427 
428  // Knots including repetitions.
429  knotContainer m_repKnots;
430 
431  // m_multSum[i] = cardinality of { knots <= unique knot [i] }.
432  multContainer m_multSum;
433 
434 
435 
436 
437 //=======================================================================//
438 //+++++++ Here follow the functions I would like to get rid of. +++++++++//
439 //=======================================================================//
440 
441 
442 
443 public: // Deprecated functions required by gsKnotVector.
444 
447  {
448  m_deg = degree;
449  }
450 
457  gsKnotVector( T first,
458  T last,
459  unsigned interior,
460  mult_t mult_ends=1,
461  mult_t mult_interior=1,
462  short_t degree = -1 );
463 
470  template<typename iterType>
471  gsKnotVector(short_t deg, const iterType begOfKnots, const iterType endOfKnots)
472  {
473  insert(begOfKnots,endOfKnots);
474  m_deg = (deg == - 1 ? deduceDegree() : deg);
475  }
476 
477 public:
478  // TODO If stays, make it private.
479 
484  void initUniform( T first,
485  T last,
486  unsigned interior,
487  unsigned mult_ends,
488  unsigned mult_interior,
489  short_t degree=-1);
490 
495  void initUniform( unsigned numKnots,
496  unsigned mult_ends,
497  unsigned mult_interior = 1,
498  short_t degree = - 1)
499  {
500  initUniform(0.0, 1.0, numKnots - 2, mult_ends, mult_interior, degree );
501  }
502 
503 
507  void initGraded(unsigned numKnots, int degree,
508  T grading = 0.5, unsigned mult_interior = 1)
509  {
510  initGraded( 0.0, 1.0, numKnots - 2, degree, grading, mult_interior);
511  }
512 
514  void initGraded(T u0, T u1, unsigned interior, int degree,
515  T grading, unsigned mult_interior = 1)
516  {
517  GISMO_ASSERT(u0<u1,"Knot vector must be an interval.");
518 
519  m_deg = degree;
520  m_repKnots.reserve( 2*(m_deg+1) + interior*mult_interior );
521  m_multSum .reserve(interior+2);
522 
523  const T h = (u1-u0) / (T)(interior+1);
524 
525  m_repKnots.insert(m_repKnots.begin(), m_deg+1, u0);
526  m_multSum .push_back(m_deg+1);
527 
528  for ( unsigned i=1; i<=interior; i++ )
529  {
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() );
533  }
534  m_repKnots.insert(m_repKnots.end(), m_deg+1, u1);
535  m_multSum .push_back( m_deg+1 + m_multSum.back() );
536  }
537 
541  {
542  gsMatrix<T> gr( 1,this->size() - m_deg - 1 );
543  this->greville_into(gr);
544  return gr;
545  }
546 
547  // TODO Write properly.
548 
551 /*
552  void makeCompressed(const T tol = 1e-7)
553  {
554  // TO DO: Check and improve, use tmp storage
555  nonConstIterator k = m_repKnots.begin();
556  nonConstMultIterator m = m_multSum .begin();
557  T prev = *k;
558  while( k+1 != end() )
559  {
560  if ( math::abs( *k - *(k+1) ) <= tol )
561  {
562  *m = *(m+1) ;
563  m_repKnots.erase(k+1);//all app.
564  m_multSum.erase(m+1);
565  }
566  else
567  {
568  k++;
569  m++;
570  }
571  }
572  m_repKnots.resize( k - m_repKnots.begin() );
573  m_multSum .resize( m - m_multSum .begin() );
574  }
575 */
576 
577 
578 
583  bool includes(const gsKnotVector<T> & other) const;
584 
590  void difference(const gsKnotVector<T> & other,
591  std::vector<T>& result) const;
592 
598  void symDifference(const gsKnotVector<T> & other,
599  std::vector<T>& result) const;
600 
611  gsKnotVector knotUnion(const gsKnotVector & b) const;
612 
616  gsKnotVector knotIntersection(const gsKnotVector & b) const;
617 
619  void reverse();
620 
624  void insert( const knotContainer &knots, int mult = 1 )
625  {
626  for( int i = 0; i < mult; ++i)
627  insert( knots.begin(), knots.end() ); // inefficient
628  }
629 
632  {
633  m_deg = p;
634  }
635 
638  void supportIndex_into(const mult_t &i, gsMatrix<index_t>& result) const;
639  // TODO: If the function stays, make a unit test from what is in unifiedKnotVector.cpp.
640 
643  void uniformRefine( mult_t numKnots = 1, mult_t mult = 1);
644 
646  template<typename iterType>
647  void refineSpans( iterType begin, iterType end, mult_t knotsPerSpan )
648  {
649  // We sort the input to be on the safe side.
650  multContainer input;
651  input.insert(input.begin(), begin, end); // Pitfall: using std::copy requires reserve or somesuch beforehand.
652  std::sort(input.begin(), input.end());
653 
654  knotContainer newKnots;
655  T segmentsPerSpan = knotsPerSpan + 1;
656  T newKnot;
657  T spanBegin;
658  T spanEnd;
659  for( typename multContainer::const_iterator it= input.begin();
660  it != input.end();
661  ++it )
662  for( mult_t k = 1; k <= knotsPerSpan; ++k )
663  {
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 );
668  }
669 
670  insert(newKnots.begin(), newKnots.end());
671  }
672 
674  void addConstant( T amount );
675 
677  void addConstant( T start, T amount );
678 
679 public: // things required by gsKnotVector
680 
684  gsKnotVector( const knotContainer& uKnots,
685  int degree,
686  int regularity);
687 
691  void initClamped(int degree, unsigned numKnots = 2, unsigned mult_interior = 1);
692 
694  void initClamped(T u0, T u1, int degree, unsigned interior = 0,
695  unsigned mult_interior = 1)
696  {
697  return initUniform(u0, u1, interior, degree + 1, mult_interior, degree );
698  }
699 
701  int degree () const;
702 
703 
706  void greville_into(gsMatrix<T> & result) const;
707 
710  void centers_into(gsMatrix<T> & result) const;
711 
714  int deduceDegree() const;
715 
718  T greville(int i) const;
719 
721  T first () const
722  {
723  GISMO_ASSERT(this->size()>=1, "I need at least one knot.");
724  return m_repKnots.front();
725  }
726 
728  T last () const
729  {
730  GISMO_ASSERT(this->size()>=1, "I need at least one knot.");
731  return m_repKnots.back();
732  }
733 
735  void transform(T c, T d)
736  {
737  affineTransformTo(c,d);
738  }
739 
741  void refineSpans( const std::vector<unsigned> & spanIndices, mult_t knotsPerSpan = 1)
742  {
743  multContainer transformedIndices;
744  transformedIndices.reserve(spanIndices.size());
745  for( std::vector<unsigned>::const_iterator it = spanIndices.begin();
746  it != spanIndices.end();
747  ++it )
748  transformedIndices.push_back(static_cast<mult_t>(*it));
749 
750  return refineSpans( transformedIndices, knotsPerSpan );
751  }
752 
755  void refineSpans( const multContainer & spanIndices, mult_t knotsPerSpan = 1);
756 
759  void degreeIncrease(int const & i = 1)
760  {
761  // update knots
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() );
765 
766  // update multiplicity sum
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;
770 
771  m_deg += i;
772  }
773 
775  void degreeDecrease(int const & i = 1, bool updateInterior = false)
776  {
777  remove( ubegin() , i );
778  remove( uend() - 1, i );
779  m_deg -= i;
780 
781  if (updateInterior)
782  {
783  if ( m_deg <= 0 )
784  initUniform(first(), last(), 0, 1, 0, 0);
785  else
786  for (uiterator itr = ubegin()+1; itr != uend()-1; ++itr)
787  if ( itr.multiplicity() > m_deg )
788  remove( itr, itr.multiplicity() - m_deg );
789  }
790  }
791 
794  void increaseMultiplicity(const mult_t i = 1, bool boundary = false);
795 
798  void reduceMultiplicity(const mult_t i = 1, bool boundary = false);
799 
801  template<typename iterType>
802  void append ( iterType begin, iterType end )
803  {
804  insert( begin, end );
805  }
806 
807  //void _stretchEndKnots()
808 
810  const knotContainer& get() const // to be removed since we have implicit cast
811  {
812  return m_repKnots;
813  }
814 
815 public: // Deprecated functions required by gsCompactKnotVector.
816 
819  inline bool has(T knot) const
820  {
821  return std::binary_search( ubegin(), uend(), knot);
822  // equivalent:
823  // return 0 != multiplicity(knot);
824  }
825 
828  unsigned u_multiplicityIndex(size_t const & i) const
829  {
830  return (ubegin() + i).multiplicity();
831  }
832 
835  inline unsigned firstKnotIndex(const size_t & i) const
836  {
837  return (ubegin()+i).firstAppearance();
838  // equivalent:
839  // return 0 == i ? 0 : m_multSum[i-1];
840  }
841 
844  inline unsigned lastKnotIndex(const size_t & i) const
845  {
846  return (ubegin()+i).lastAppearance();
847  // equivalent:
848  // return m_multSum[i] - 1;
849  }
850 
853  inline unsigned knotsUntilSpan(const size_t & i) const
854  {
855  return (ubegin()+i).multSum();
856  }
857 
859  bool operator != (const gsKnotVector<T>& other) const
860  {
861  return ! ((*this)==other);
862  }
863 
865  inline T at (const size_t & i) const
866  {
867  return m_repKnots.at(i);
868  }
869 
871  bool isUniform(T tol = 1e-9) const
872  {
873  const T df = *(ubegin() + 1) - *ubegin();
874  for( uiterator uit = ubegin() + 1; uit != uend(); ++uit )
875  if( math::abs(*uit - (*uit-(T)(1)) - df) > tol )
876  return false;
877  return true;
878  }
879 
882  bool isOpen() const
883  {
884  const int dp1 = m_deg + 1;
885  return (multFirst() == dp1 &&
886  multLast () == dp1 );
887  // equivalent
888  //return ( ubegin .multiplicity() == dp1 &&
889  // (--uend).multiplicity() == dp1 );
890  // equivalent
891  //return m_multSum.front() == dp1 &&
892  // m_multSum.back() - m_multSum.end()[-2] == dp1;
893  }
894 
896  // \sa gsDomain
897  virtual knotContainer breaks() const
898  {
899  return knotContainer(domainUBegin(), domainUEnd()+1);
900  }
901 
902 public: // others
903 
907  void getUniformRefinementKnots(mult_t knotsPerSpan, knotContainer& result,
908  mult_t mult = 1) const;
909 
911  std::string detail() const;
912 
914  T maxIntervalLength() const;
915 
917  T minIntervalLength() const;
918 
921  void degreeElevate(const short_t & i = 1);
922 
924  void degreeReduce(const short_t & i);
925 
934  std::vector<T> coarsen(index_t knotRemove = 1, index_t knotSkip = 1, mult_t mul = -1);
935 
936 public: // members
937 
938  // TODO remove!
939  short_t m_deg;
940 };
941 
942 template<typename T>
943 std::ostream& operator << (std::ostream& out, const gsKnotVector<T> KV )
944 {
945  KV.print(out);
946  return out;
947 }
948 
949 
950 #ifdef GISMO_WITH_PYBIND11
951 
955  void pybind11_init_gsKnotVector(pybind11::module &m);
956 
957 #endif // GISMO_WITH_PYBIND11
958 
959 } // namespace gismo
960 
961 
962 // *****************************************************************
963 #ifndef GISMO_BUILD_LIB
964 #include GISMO_HPP_HEADER(gsKnotVector.hpp)
965 #else
966 #ifdef gsKnotVector_EXPORT
967 #include GISMO_HPP_HEADER(gsKnotVector.hpp)
968 #undef EXTERN_CLASS_TEMPLATE
969 #define EXTERN_CLASS_TEMPLATE CLASS_TEMPLATE_INST
970 #endif
971 namespace gismo
972 {
973 EXTERN_CLASS_TEMPLATE gsKnotVector<real_t>;
974 //EXTERN_CLASS_TEMPLATE internal::gsXml<gsKnotVector<real_t> >;
975 }
976 #endif
977 // *****************************************************************
Class representing a domain. i.e. a collection of elements (triangles, rectangles, cubes, simplices.
Definition: gsDomain.h:31
const T & operator()(const mult_t i) const
Provides the knot with unique index i.
Definition: gsKnotVector.h:256
reverse_iterator rbegin() const
Returns reverse iterator pointing past the end of the repeated knots.
Definition: gsKnotVector.hpp:147
internal::gsUKnotIterator< T > uiterator
Definition: gsKnotVector.h:102
knotContainer unique() const
Returns unique knots.
Definition: gsKnotVector.h:273
const T * data() const
Returns a pointer to the beginning of the vector of knots.
Definition: gsKnotVector.h:285
static bool isConsistent(const knotContainer &repKnots, const multContainer &multSums)
Sanity check.
Definition: gsKnotVector.hpp:542
gsKnotVector knotIntersection(const gsKnotVector &b) const
Computes the intersection of knot-vectors this and b.
Definition: gsKnotVector.hpp:201
multContainer multiplicities() const
Returns vector of multiplicities of the knots.
Definition: gsKnotVector.hpp:714
void affineTransformTo(T newBeg, T newEnd)
Definition: gsKnotVector.hpp:450
void refineSpans(iterType begin, iterType end, mult_t knotsPerSpan)
Inserts knotsPerSpan knots between each two knots between begin and end.
Definition: gsKnotVector.h:647
unsigned u_multiplicityIndex(size_t const &i) const
Definition: gsKnotVector.h:828
int deduceDegree() const
Definition: gsKnotVector.hpp:706
gsMatrix< T > greville() const
Definition: gsKnotVector.h:540
Abstracgt Base class representing a domain. i.e. a collection of elements (triangles, rectangles, cubes, simplices.
std::string detail() const
Return a string with detailed information on the knot vector.
Definition: gsKnotVector.hpp:800
void trimLeft(const mult_t numKnots)
Removes the left-most numKnots from the knot-vector.
Definition: gsKnotVector.hpp:390
smart_iterator sbegin() const
Returns the smart iterator pointing to the beginning of the repeated knots.
Definition: gsKnotVector.hpp:259
void initClamped(int degree, unsigned numKnots=2, unsigned mult_interior=1)
Definition: gsKnotVector.hpp:693
reverse_uiterator urbegin() const
Returns reverse unique iterator pointing past the end of the unique knots.
Definition: gsKnotVector.hpp:247
T distance(gsMatrix< T > const &A, gsMatrix< T > const &B, index_t i=0, index_t j=0, bool cols=false)
compute a distance between the point number in the set and the point number &lt;j&gt; in the set ; by def...
mult_t maxInteriorMultiplicity() const
Returns the maximum multiplicity in the interior.
Definition: gsKnotVector.hpp:724
#define short_t
Definition: gsConfig.h:35
reverse_uiterator urend() const
Returns reverse unique iterator pointing to the beginning of the unique knots.
Definition: gsKnotVector.hpp:253
smart_iterator domainSEnd() const
Definition: gsKnotVector.h:355
size_t numElements() const
Number of knot intervals inside domain.
Definition: gsKnotVector.h:268
index_t numLeftGhosts() const
Definition: gsKnotVector.h:393
void addConstant(T amount)
Adds amount to all the knots.
Definition: gsKnotVector.hpp:839
void set_degree(short_t p)
Sets the degree to p.
Definition: gsKnotVector.h:631
void trimRight(const mult_t numKnots)
Removes the right-most numKnots from the knot-vector.
Definition: gsKnotVector.hpp:403
bool operator==(const gsKnotVector< T > &other) const
Compare with another knot vector.
Definition: gsKnotVector.h:414
void erase(const mult_t first, const mult_t last)
Removes the knots in the range [first,last)
Definition: gsKnotVector.hpp:376
void insert(iterType ibeg, iterType iend)
Definition: gsKnotVector.h:184
reverse_smart_iterator rsend() const
Returns the reverse smart iterator pointing to the beginning of the repeated knots.
Definition: gsKnotVector.hpp:277
Struct that defines the boundary sides and corners and types of a geometric object.
Definition: gsBoundary.h:55
mult_t multiplicity(T u) const
Definition: gsKnotVector.hpp:421
iterator domainEnd() const
Returns an iterator pointing to the end-knot of the domain.
Definition: gsKnotVector.h:342
void transform(T c, T d)
See affineTransform().
Definition: gsKnotVector.h:735
void centers_into(gsMatrix< T > &result) const
Definition: gsKnotVector.hpp:1025
void supportIndex_into(const mult_t &i, gsMatrix< index_t > &result) const
Definition: gsKnotVector.hpp:1066
gsAsConstMatrix< T > asMatrix() const
Returns the knots as a matrix of size 1 x size()
Definition: gsKnotVector.h:169
uiterator domainUEnd() const
Returns a unique iterator pointing to the ending knot of the domain.
Definition: gsKnotVector.h:367
size_t size() const
Number of knots (including repetitions).
Definition: gsKnotVector.h:242
#define index_t
Definition: gsConfig.h:32
internal::gsKnotIterator< T > smart_iterator
Definition: gsKnotVector.h:107
std::vector< T >::const_iterator iterator
Definition: gsKnotVector.h:97
void greville_into(gsMatrix< T > &result) const
Definition: gsKnotVector.hpp:991
unsigned knotsUntilSpan(const size_t &i) const
Definition: gsKnotVector.h:853
T last() const
Get the last knot.
Definition: gsKnotVector.h:728
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
void insert(T knot, mult_t mult=1)
Inserts knot knot into the knot vector with multiplicity mult.
Definition: gsKnotVector.hpp:325
iterator domainBegin() const
Returns an iterator pointing to the starting knot of the domain.
Definition: gsKnotVector.h:335
void refineSpans(const std::vector< unsigned > &spanIndices, mult_t knotsPerSpan=1)
Because of type compatibility, cf. the other version.
Definition: gsKnotVector.h:741
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
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
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 append(iterType begin, iterType end)
Adds the knots between begin and end to the knot vector.
Definition: gsKnotVector.h:802
const T & operator[](const mult_t i) const
Provides the i-th knot (numbered including repetitions).
Definition: gsKnotVector.h:248
void getUniformRefinementKnots(mult_t knotsPerSpan, knotContainer &result, mult_t mult=1) const
Definition: gsKnotVector.hpp:1048
T minIntervalLength() const
Returns the minimum interval length of the knot sequence.
Definition: gsKnotVector.hpp:527
gsKnotVector(short_t deg, const iterType begOfKnots, const iterType endOfKnots)
Definition: gsKnotVector.h:471
void initUniform(unsigned numKnots, unsigned mult_ends, unsigned mult_interior=1, short_t degree=-1)
Definition: gsKnotVector.h:495
gsKnotVector()
Empty constructor sets the degree to -1 and leaves the knots empty.
Definition: gsKnotVector.h:157
void degreeReduce(const short_t &i)
Converse to degreeElevate.
Definition: gsKnotVector.hpp:944
std::vector< T > coarsen(index_t knotRemove=1, index_t knotSkip=1, mult_t mul=-1)
Definition: gsKnotVector.hpp:952
void initGraded(unsigned numKnots, int degree, T grading=0.5, unsigned mult_interior=1)
Definition: gsKnotVector.h:507
T first() const
Get the first knot.
Definition: gsKnotVector.h:721
const mult_t * multSumData() const
Definition: gsKnotVector.h:289
mult_t minInteriorMultiplicity() const
Returns the minimum multiplicity in the interior.
Definition: gsKnotVector.hpp:733
uiterator domainUBegin() const
Returns a unique iterator pointing to the starting knot of the domain.
Definition: gsKnotVector.h:359
std::ostream & print(std::ostream &os=gsInfo) const
Definition: gsKnotVector.hpp:493
void increaseMultiplicity(const mult_t i=1, bool boundary=false)
Definition: gsKnotVector.hpp:874
void uniformRefine(mult_t numKnots=1, mult_t mult=1)
Definition: gsKnotVector.hpp:820
uiterator ubegin() const
Returns unique iterator pointing to the beginning of the unique knots.
Definition: gsKnotVector.hpp:235
void insert(const knotContainer &knots, int mult=1)
Insert knots into the knot vector.
Definition: gsKnotVector.h:624
index_t numRightGhosts() const
Definition: gsKnotVector.h:402
#define gsInfo
Definition: gsDebug.h:43
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
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
smart_iterator domainSBegin() const
Definition: gsKnotVector.h:350
mult_t multFirst() const
Returns the multiplicity of the first knot.
Definition: gsKnotVector.h:218
virtual knotContainer breaks() const
Returns unique knots of the domain (i.e., including the endpoints of the domain). ...
Definition: gsKnotVector.h:897
Provides forward declarations of types and structs.
T maxIntervalLength() const
Returns the maximum interval length of the knot sequence.
Definition: gsKnotVector.hpp:518
bool check() const
Checks whether the knot vector is in a consistent state.
Definition: gsKnotVector.hpp:536
iterator beginAt(mult_t upos) const
Definition: gsKnotVector.hpp:131
Creates a mapped object or data pointer to a const matrix without copying data.
Definition: gsLinearAlgebra.h:127
void difference(const gsKnotVector< T > &other, std::vector< T > &result) const
Computes the difference between this knot-vector and other.
Definition: gsKnotVector.hpp:159
T uValue(const size_t &i) const
Provides the knot with unique index i.
Definition: gsKnotVector.h:264
uiterator uUpperBound(const T u) const
Returns an iterator pointing to the first knot which compares greater than u.
Definition: gsKnotVector.hpp:763
Provides implementation of knot vector iterators.
gsKnotVector(short_t degree)
Sets the degree and leaves the knots uninitialized.
Definition: gsKnotVector.h:446
void degreeElevate(const short_t &i=1)
Definition: gsKnotVector.hpp:937
uiterator uend() const
Returns unique iterator pointing past the end of the unique knots.
Definition: gsKnotVector.hpp:241
void reduceMultiplicity(const mult_t i=1, bool boundary=false)
Definition: gsKnotVector.hpp:903
void swap(gsKnotVector &other)
Swaps with other knot vector.
Definition: gsKnotVector.hpp:302
void degreeDecrease(int const &i=1, bool updateInterior=false)
Inverse of degreeIncrease.
Definition: gsKnotVector.h:775
iterator end() const
Returns iterator pointing past the end of the repeated knots.
Definition: gsKnotVector.hpp:124
T at(const size_t &i) const
Returns the value of the i - th knot (counted with repetitions).
Definition: gsKnotVector.h:865
unsigned firstKnotIndex(const size_t &i) const
Definition: gsKnotVector.h:835
void reverse()
Better directly use affineTransformTo.
Definition: gsKnotVector.hpp:468
mult_t multLast() const
Returns the multiplicity of the last knot.
Definition: gsKnotVector.h:221
Class for representing a knot vector.
Definition: gsKnotVector.h:79
EIGEN_STRONG_INLINE abs_expr< E > abs(const E &u)
Absolute value.
Definition: gsExpressions.h:4488
mult_t multiplicityIndex(mult_t i) const
Definition: gsKnotVector.hpp:430
iterator begin() const
Returns iterator pointing to the beginning of the repeated knots.
Definition: gsKnotVector.hpp:117
unsigned lastKnotIndex(const size_t &i) const
Definition: gsKnotVector.h:844
size_t uSize() const
Number of unique knots (i.e., without repetitions).
Definition: gsKnotVector.h:245
bool inDomain(const T u) const
Checks, whether the given value is inside the domain.
Definition: gsKnotVector.h:375
bool isOpen() const
Definition: gsKnotVector.h:882
gsKnotVector * clone() const
Returns a pointer to a copy.
Definition: gsKnotVector.hpp:312
reverse_smart_iterator rsbegin() const
Returns the reverse smart iterator pointing past the end of the repeated knots.
Definition: gsKnotVector.hpp:271
void degreeIncrease(int const &i=1)
Definition: gsKnotVector.h:759
smart_iterator send() const
Returns the smart iterator pointing past the end of the repeated knots.
Definition: gsKnotVector.hpp:265
gsKnotVector knotUnion(const gsKnotVector &b) const
Computes the union of knot-vectors this and b.
Definition: gsKnotVector.hpp:187
reverse_iterator rend() const
Returns reverse iterator pointing to the beginning of the repeated knots.
Definition: gsKnotVector.hpp:229
int degree() const
Returns the degree of the knot vector.
Definition: gsKnotVector.hpp:700
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
iterator endAt(mult_t upos) const
Definition: gsKnotVector.hpp:139
bool operator!=(const gsKnotVector< T > &other) const
Compares with another knot vector.
Definition: gsKnotVector.h:859
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
bool has(T knot) const
Definition: gsKnotVector.h:819
bool isUniform(T tol=1e-9) const
Checks whether the knot vector is uniform.
Definition: gsKnotVector.h:871
void initUniform(T first, T last, unsigned interior, unsigned mult_ends, unsigned mult_interior, short_t degree=-1)
Definition: gsKnotVector.hpp:643