Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_SPLINE_SPLINE_NUBS_H
00002 #define OPENTISSUE_CORE_SPLINE_SPLINE_NUBS_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <stdexcept>
00013
00014 namespace OpenTissue
00015 {
00016 namespace spline
00017 {
00039 template<typename U, typename P>
00040 class NUBSpline
00041 {
00042 public:
00043
00044 typedef U knot_container;
00045 typedef P point_container;
00046
00047 protected:
00048
00049 U m_U;
00050 P m_P;
00051 size_t m_k;
00052
00053 public:
00054
00055 NUBSpline()
00056 : m_k(0u)
00057 {}
00058
00062 NUBSpline(
00063 size_t const order
00064 , U const & knots
00065 , P const & controls
00066 )
00067 {
00068
00069 if(order<= 0u)
00070 throw std::invalid_argument("order must be greater than zero");
00071
00072 if(knots.size() <= 0u)
00073 throw std::invalid_argument("knots was empty");
00074
00075 if(controls.size() <= 0u)
00076 throw std::invalid_argument("controls was empty");
00077
00078 if( (knots.size() - controls.size()) != order)
00079 throw std::invalid_argument("Incorrect specification, n = m - k, was not fulfilled! ");
00080
00081 this->m_U = knots;
00082 this->m_P = controls;
00083 this->m_k = order;
00084 }
00085
00086 virtual ~NUBSpline() { }
00087
00088 public:
00089
00109 U & get_knot_container() { return this->m_U; }
00110 U const & get_knot_container() const { return this->m_U; }
00111
00128 P & get_control_container() { return this->m_P; }
00129 P const & get_control_container() const { return this->m_P; }
00130
00131 size_t const get_dimension() const
00132 {
00133 if(this->m_P.size() == 0u)
00134 return 0u;
00135 return this->m_P[0].size();
00136 }
00137
00138 size_t const & get_order() const { return this->m_k; }
00139
00140 };
00141
00142 }
00143 }
00144
00145
00146 #endif