53 #ifndef ACG_KNOTVECTORT_HH 54 #define ACG_KNOTVECTORT_HH 77 template<
typename Scalar >
96 void setType(KnotvectorType _type);
98 void createKnots(
unsigned int _splineDeg,
unsigned int _dim);
100 inline std::vector< Scalar >& getKnotvector() {
return knots_;}
101 inline const std::vector< Scalar >& getKnotvector()
const {
return knots_; }
103 inline unsigned int size()
const {
return knots_.size();}
105 inline Scalar getKnot(
unsigned int _index)
const {
106 assert(_index < knots_.size());
107 return knots_.at(_index);
110 void setKnotvector(
const std::vector< Scalar >& _knots);
112 void resize(
unsigned int _size) {knots_.resize(_size);}
114 void insertKnot(
unsigned int _index,
const Scalar _knot);
116 void addKnot(Scalar _knot);
118 inline void setKnot(
unsigned int _index, Scalar _knot) {
119 assert(_index < knots_.size());
120 knots_.at(_index) = _knot;
123 void deleteKnot(
unsigned int _index);
131 assert (_index < knots_.size());
132 return knots_[_index];
139 inline const Scalar &
operator()(
unsigned int _index)
const {
140 assert (_index < knots_.size());
141 return knots_[_index];
144 void clear() {knots_.clear();};
151 void request_selections() { request_prop( ref_count_selections_, selections_);}
154 void release_selections() { release_prop( ref_count_selections_, selections_);}
157 bool selections_available()
const {
return bool(ref_count_selections_);}
160 unsigned char& selection(
unsigned int _i) {
161 assert(_i < selections_.size());
162 assert(selections_available());
163 return selections_[_i];
165 const unsigned char& selection(
unsigned int _i)
const {
166 assert(_i < selections_.size());
167 assert(selections_available());
168 return selections_[_i];
172 void select(
unsigned int _pIdx) { selection(_pIdx) = 1; };
173 void deselect(
unsigned int _pIdx) { selection(_pIdx) = 0; };
175 bool selected(
unsigned int _pIdx)
const {
return (selection(_pIdx) == 1); };
180 template <
class PropT>
181 void request_prop(
unsigned int& _ref_count, PropT& _prop);
183 template <
class PropT>
184 void release_prop(
unsigned int& _ref_count, PropT& _prop);
189 std::vector<unsigned char> selections_;
192 unsigned int ref_count_selections_;
196 std::vector<Scalar> knots_;
198 KnotvectorType knotvectorType_;
200 void createUniformInterpolatingKnots(
unsigned int _splineDeg,
unsigned int _dim);
202 void createUniformKnots(
unsigned int _splineDeg,
unsigned int _dim);
204 unsigned int num_control_points_;
205 unsigned int spline_degree_;
212 template<
typename Scalar >
213 inline std::ostream& operator<<(std::ostream& _stream, const KnotvectorT< Scalar >& _knotvector) {
216 for (
unsigned int i = 0; i < knotvector.size(); i++)
217 _stream << knotvector(i) <<
" ";
223 template<
typename Scalar >
226 unsigned int size(0);
228 _knotvector.resize(size);
229 for (
unsigned int i = 0; i < size; i++)
230 _is >> _knotvector(i);
239 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_KNOTVECTORT_C) 240 #define ACG_KNOTVECTORT_TEMPLATES 241 #include "KnotvectorT_impl.hh" 244 #endif // ACG_KNOTVECTORT_HH defined std::istream & operator>>(std::istream &is, Matrix4x4T< Scalar > &m)
read the space-separated components of a vector from a stream */
Namespace providing different geometric functions concerning angles.
Scalar & operator()(unsigned int _index)
returns a reference to the _index'th knot
const Scalar & operator()(unsigned int _index) const
returns a const reference to the _index'th knot
~KnotvectorT()
Destructor.
KnotvectorT()
Constructor.