Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_SPLINE_SPLINE_COMPUTE_POINT_ON_SPLINE_H
00002 #define OPENTISSUE_CORE_SPLINE_SPLINE_COMPUTE_POINT_ON_SPLINE_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/spline/spline_compute_knot_span.h>
00013 #include <OpenTissue/core/spline/spline_compute_nonzero_basis.h>
00014
00015 #include <stdexcept>
00016
00017 namespace OpenTissue
00018 {
00019 namespace spline
00020 {
00021 namespace detail
00022 {
00036 template<typename knot_container, typename point_container>
00037 inline void compute_point_on_spline(
00038 typename knot_container::value_type const & u
00039 , int const k
00040 , knot_container const & U
00041 , point_container const & P
00042 , typename point_container::value_type & p
00043 )
00044 {
00045 typedef typename point_container::value_type vector_type;
00046
00047 if(k<1)
00048 throw std::invalid_argument("order must be greater than zero");
00049
00050 if( U.size() != (P.size() + k) )
00051 throw std::invalid_argument("invalid spline specification");
00052
00053 vector_type N;
00054
00055 detail::compute_nonzero_basis(u, k, U, N);
00056
00057
00058 int const i = detail::compute_knot_span(u, k, U);
00059
00060 p.clear();
00061 for(int r=0; r < k; ++r)
00062 {
00063 int j = i-k+1+r;
00064 p += P[j] * N(r);
00065 }
00066 }
00067
00068 }
00069
00070
00080 template<typename spline_type>
00081 inline void compute_point_on_spline(
00082 typename spline_type::knot_container::value_type const & u
00083 , spline_type const & spline
00084 , typename spline_type::point_container::value_type & p
00085 )
00086 {
00087 detail::compute_point_on_spline(
00088 u
00089 , spline.get_order()
00090 , spline.get_knot_container()
00091 , spline.get_control_container()
00092 , p
00093 );
00094 }
00095
00096 }
00097 }
00098
00099
00100 #endif