59 #ifndef ACG_KNOTVECTORT_HH
60 #define ACG_KNOTVECTORT_HH
83 template<
typename Scalar >
102 void setType(KnotvectorType _type);
104 void createKnots(
unsigned int _splineDeg,
unsigned int _dim);
106 inline std::vector< Scalar >& getKnotvector() {
return knots_;}
107 inline const std::vector< Scalar >& getKnotvector()
const {
return knots_; }
109 inline unsigned int size()
const {
return knots_.size();}
111 inline Scalar getKnot(
unsigned int _index)
const {
112 assert(_index < knots_.size());
113 return knots_.at(_index);
116 void setKnotvector(
const std::vector< Scalar >& _knots);
118 void resize(
unsigned int _size) {knots_.resize(_size);}
120 void insertKnot(
unsigned int _index,
const Scalar _knot);
122 void addKnot(Scalar _knot);
124 inline void setKnot(
unsigned int _index, Scalar _knot) {
125 assert(_index < knots_.size());
126 knots_.at(_index) = _knot;
129 void deleteKnot(
unsigned int _index);
137 assert (_index < knots_.size());
138 return knots_[_index];
145 inline const Scalar &
operator()(
unsigned int _index)
const {
146 assert (_index < knots_.size());
147 return knots_[_index];
150 void clear() {knots_.clear();};
157 void request_selections() { request_prop( ref_count_selections_, selections_);}
160 void release_selections() { release_prop( ref_count_selections_, selections_);}
163 bool selections_available()
const {
return bool(ref_count_selections_);}
166 unsigned char& selection(
unsigned int _i) {
167 assert(_i < selections_.size());
168 assert(selections_available());
169 return selections_[_i];
171 const unsigned char& selection(
unsigned int _i)
const {
172 assert(_i < selections_.size());
173 assert(selections_available());
174 return selections_[_i];
178 void select(
unsigned int _pIdx) { selection(_pIdx) = 1; };
179 void deselect(
unsigned int _pIdx) { selection(_pIdx) = 0; };
181 bool selected(
unsigned int _pIdx)
const {
return (selection(_pIdx) == 1); };
186 template <
class PropT>
187 void request_prop(
unsigned int& _ref_count, PropT& _prop);
189 template <
class PropT>
190 void release_prop(
unsigned int& _ref_count, PropT& _prop);
195 std::vector<unsigned char> selections_;
198 unsigned int ref_count_selections_;
202 std::vector<Scalar> knots_;
204 KnotvectorType knotvectorType_;
206 void createUniformInterpolatingKnots(
unsigned int _splineDeg,
unsigned int _dim);
208 void createUniformKnots(
unsigned int _splineDeg,
unsigned int _dim);
210 unsigned int num_control_points_;
211 unsigned int spline_degree_;
218 template<
typename Scalar >
219 inline std::ostream& operator<<(std::ostream& _stream, const KnotvectorT< Scalar >& _knotvector) {
221 KnotvectorT< Scalar > knotvector = _knotvector;
222 for (
unsigned int i = 0; i < knotvector.size(); i++)
223 _stream << knotvector(i) <<
" ";
229 template<
typename Scalar >
230 inline std::istream&
operator>>(std::istream& _is, KnotvectorT< Scalar >& _knotvector) {
232 unsigned int size(0);
234 _knotvector.resize(size);
235 for (
unsigned int i = 0; i < size; i++)
236 _is >> _knotvector(i);
245 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_KNOTVECTORT_C)
246 #define ACG_KNOTVECTORT_TEMPLATES
247 #include "KnotvectorT.cc"
250 #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.
~KnotvectorT()
Destructor.
Scalar & operator()(unsigned int _index)
returns a reference to the _index'th knot
KnotvectorT()
Constructor.
const Scalar & operator()(unsigned int _index) const
returns a const reference to the _index'th knot