00001 #ifndef OPENTISSUE_CORE_SPLINE_SPLINE_MAKE_PERIODIC_H 00002 #define OPENTISSUE_CORE_SPLINE_SPLINE_MAKE_PERIODIC_H 00003 // 00004 // OpenTissue Template Library 00005 // - A generic toolbox for physics-based modeling and simulation. 00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen. 00007 // 00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php 00009 // 00010 00011 #include <OpenTissue/configuration.h> 00012 00013 #include <OpenTissue/core/spline/spline_compute_knot_span.h> 00014 #include <OpenTissue/core/spline/spline_compute_nonzero_basis.h> 00015 00016 namespace OpenTissue 00017 { 00018 namespace spline 00019 { 00020 namespace detail 00021 { 00032 template<typename knot_container, typename point_container> 00033 inline void compute_closed_periodic(int const k, knot_container & U, point_container & P) 00034 { 00035 typedef typename knot_container::value_type T; 00036 00037 int const n = P.size()-1; 00038 int const d = k-1; 00039 int const knot_num = n+2*d+2; 00040 00041 //--- Add the new knot-values and controlpoints. 00042 for (int i = 0; i < d; ++i) 00043 { 00044 P.push_back(P[i]); 00045 } 00046 00047 int j = 1; 00048 for (int i = n+2; i < knot_num; ++i) 00049 { 00050 T val = U[i-1] + (U[j] - U[j-1]); 00051 U.push_back(val); 00052 ++j; 00053 } 00054 00055 } 00056 } // namespace detail 00057 00068 template<typename spline_type> 00069 inline spline_type make_periodic(spline_type const & spline) 00070 { 00071 spline_type S; 00072 S = spline; 00073 detail::compute_closed_periodic( S.get_order(), S.get_knot_container(), S.get_control_container() ); 00074 return S; 00075 } 00076 00077 } // namespace spline 00078 } // namespace OpenTissue 00079 00080 //OPENTISSUE_CORE_SPLINE_SPLINE_MAKE_PERIODIC_H 00081 #endif