59 #ifndef BSPLINESURFACET_HH
60 #define BSPLINESURFACET_HH
67 #include <ACG/Math/VectorT.hh>
69 #include <ObjectTypes/Knotvector/KnotvectorT.hh>
87 template <
class Po
intT>
94 typedef typename Point::value_type Scalar;
95 typedef typename std::vector< std::vector< Point > > ControlNet;
96 typedef typename std::vector< std::vector< unsigned char > > PropertyNet;
103 explicit BSplineSurfaceT(
unsigned int _degm = 3,
unsigned int _degn = 3);
111 void resize(
unsigned int _m,
unsigned int _n);
174 void set_degree(
unsigned int _degm,
unsigned int _degn);
202 return control_net_[_m][_n];
212 return control_net_[_m][_n];
219 inline const Point&
operator()(
unsigned int _m,
unsigned int _n)
const
222 return control_net_[_m][_n];
231 assert ( (0 <= _param[0]) && (_param[0] <
dimm_) && (0 <= _param[1]) &&( _param[1] <
dimn_ ) );
232 return control_net_[_param[0]][_param[1]];
241 assert ( (0 <= _param[0]) && (_param[0] <
dimm_) && (0 <= _param[1]) &&( _param[1] <
dimn_ ) );
242 return control_net_[_param[0]][_param[1]];
251 void get_vector_m(std::vector< Point> & _control_polygon,
unsigned int _m);
258 void get_vector_n(std::vector< Point> & _control_polygon,
unsigned int _n);
265 void add_vector_m(
const std::vector< Point> & _control_polygon);
271 void add_vector_n(
const std::vector< Point> & _control_polygon);
279 void insert_vector_m(
const std::vector< Point> & _control_polygon,
unsigned int _m);
285 void insert_vector_n(
const std::vector< Point> & _control_polygon,
unsigned int _n);
426 unsigned char& controlpoint_selection(
unsigned int _i,
unsigned int _j) {
return cpselections_[_i][_j];}
427 const unsigned char& controlpoint_selection(
unsigned int _i,
unsigned int _j)
const {
return cpselections_[_i][_j];}
432 unsigned char& edge_selection(
unsigned int _i,
unsigned int _j) {
return eselections_[_i][_j];}
433 const unsigned char& edge_selection(
unsigned int _i,
unsigned int _j)
const {
return eselections_[_i][_j];}
447 void select_controlpoint(
unsigned int _iIdx,
unsigned int _jIdx) { controlpoint_selection(_iIdx, _jIdx) = 1; };
448 void deselect_controlpoint(
unsigned int _iIdx,
unsigned int _jIdx) { controlpoint_selection(_iIdx, _jIdx) = 0; };
450 bool controlpoint_selected(
unsigned int _iIdx,
unsigned int _jIdx)
const {
return (controlpoint_selection(_iIdx, _jIdx) == 1); };
455 template <
class PropT>
456 void request_prop(
unsigned int& _ref_count, PropT& _prop);
458 template <
class PropT>
459 void release_prop(
unsigned int& _ref_count, PropT& _prop);
471 ControlNet control_net_;
491 unsigned int ref_count_cpselections_;
492 unsigned int ref_count_eselections_;
500 #if defined(INCLUDE_TEMPLATES) && !defined(BSPLINESURFACE_BSPLINESURFACET_C)
501 #define BSPLINESURFACE_BSPLINESURFACET_TEMPLATES
502 #include "BSplineSurfaceT.cc"
505 #endif // ACG_BSPLINESURFACET_HH defined
int degree_n() const
Returns the spline degree in n direction.
void get_vector_n(std::vector< Point > &_control_polygon, unsigned int _n)
Returns an m ctrPointVector.
void get_vector_m(std::vector< Point > &_control_polygon, unsigned int _m)
Returns an n control point vector.
std::vector< Scalar > & get_knots_n()
get the knotvector in m direction of the bspline surface
Knotvector * get_knotvector_n_ref()
Get a reference to the knotvector in n direction.
void release_edge_selections()
release edge selection property
Point surfacePoint(double _u, double _v)
Evaluates a spline surface at parameters _u and _v.
Namespace providing different geometric functions concerning angles.
void request_edge_selections()
request edge selection property
PropertyNet cpselections_
list of control point properties
unsigned int dimm_
number of control points in m direction
Scalar upperv()
Returns the upper v parameter.
void request_controlpoint_selections()
request control point selection property
const Point & operator()(unsigned int _m, unsigned int _n) const
Returns a const reference to the control point (m, n)
void set_knots_m(std::vector< Scalar > _knots)
Set the knotvector of the bspline surface in m direction.
ACG::Vec2i interval_n(double _t)
Returns the index of the knots v and v+1 such that t in [v, v+1)
unsigned int n_knots_n()
Returns the number of knots in n direction.
void add_vector_m(const std::vector< Point > &_control_polygon)
Adds a control point n-vector.
void delete_vector_m(unsigned int _m)
Deletes an n control point vector.
int degree_m() const
Returns the spline degree in m direction.
ACG::Vec2i interval_m(double _t)
Returns the index of the knots u and u+1 such that t in [u, u+1)
Scalar get_knot_n(int _i)
Get knot i in n direction.
const Point & operator()(Vec2i _param) const
Returns a const reference to the control point (m, n)
void createKnots()
Creates interpolating knotvectors 0...0, 1, 2, ..., n...n.
unsigned int n_control_points_n() const
Returns the number of controlpoints in n direction.
void insert_knot_n(double _t)
Insert a knot i in n direction without changing the surface.
Point & operator()(Vec2i _param)
Returns a reference to the control point (m, n)
Point derivativeSurfacePoint(double _u, double _v, int _derm, int _dern)
Returns the _derm'th derivative of a spline surface.
void release_controlpoint_selections()
release control point selection property
Scalar basisFunction(Knotvector &_knotvector, int _i, int _n, double _t)
A Spline Basis Function.
Point & get_control_point(unsigned int _m, unsigned int _n)
Returns a reference to the control point (m, n)
Scalar lowerv()
Returns the lower v parameter.
void insert_vector_n(const std::vector< Point > &_control_polygon, unsigned int _n)
Inserts an m control point vector.
Knotvector knotvector_m_
Knotvector in m direction.
Knotvector knotvector_n_
Knotvector in n direction.
Scalar get_knot_m(int _i)
Get knot i in m direction.
void delete_vector_n(unsigned int _n)
Deletes an m control point vector.
Knotvector * get_knotvector_m_ref()
Get a reference to the knotvector in m direction.
bool controlpoint_selections_available() const
Check if control point selection property is available.
void reset_control_net()
Clears the control net.
BSplineSurfaceT(unsigned int _degm=3, unsigned int _degn=3)
Constructor.
Scalar derivativeBasisFunction(Knotvector &_knotvector, int _i, int _n, double _t, int _der)
Derivative of a Spline Basis Function.
ACG::Vec2i spann(double _t)
Returns the basis functions which are unequal to zero at parameter v.
unsigned int dimn_
number of control points in n direction
PropertyNet eselections_
list of edge properties
void add_vector_n(const std::vector< Point > &_control_polygon)
Adds a control point m-vector.
Point & operator()(unsigned int _m, unsigned int _n)
Returns a reference to the control point (m, n)
std::vector< Scalar > & get_knots_m()
get the knotvector in m direction of the bspline surface
Knotvector get_knotvector_n()
Get the knotvector in n direction.
ACG::Vec2i spanm(double _t)
Returns the basis functions which are unequal to zero at parameter u.
void surfacePointNormal(Point &_pt, Point &_normal, double _u, double _v)
Evaluates a spline surface at parameters _u and _v.
void resize(unsigned int _m, unsigned int _n)
Resizes the spline struct.
unsigned int degree_n_
Spline degree in n direction.
Knotvector get_knotvector_m()
Get the knotvector in m direction.
void insert_knot_m(double _t)
Insert a knot i in m direction without changing the surface.
unsigned int n_control_points_m() const
Returns the number of controlpoints in m direction.
unsigned int degree_m_
Spline degree in m direction.
void insert_vector_m(const std::vector< Point > &_control_polygon, unsigned int _m)
Inserts an n control point vector.
void set_degree(unsigned int _degm, unsigned int _degn)
Sets the degree of the spline surface.
Scalar upperu()
Returns the upper u parameter.
bool edge_selections_available() const
Check if edge selection property is available.
Point surfacePoint_rec(double _u, double _v)
Evaluates a spline surface at parameters _u and _v.
Point normalSurfacePoint(double _u, double _v)
Returns the normal of a spline surface.
Scalar loweru()
Returns the lower u parameter.
void set_knots_n(std::vector< Scalar > _knots)
Set the knotvector of the bspline surface in n direction.
unsigned int n_knots_m()
Returns the number of knots in m direction.