13 #ifndef eli_geom_curve_length_hpp
14 #define eli_geom_curve_length_hpp
16 #include "eli/code_eli.hpp"
30 template <
typename curve__>
35 typename curve__::data_type
operator()(
const typename curve__::data_type &t)
37 return pcurve->fp(t).norm();
42 template<
template<
typename,
unsigned short,
typename>
class curve__,
typename data__,
unsigned short dim__,
typename tol__>
48 typedef typename piecewise_type::data_type data_type;
50 typename piecewise_type::segment_collection_type::const_iterator it;
54 length(seg_len, it->second, tol);
58 template<
template<
typename,
unsigned short,
typename>
class curve__,
typename data__,
unsigned short dim__,
typename tol__>
66 typedef typename piecewise_type::data_type data_type;
75 typename piecewise_type::segment_collection_type::const_iterator it, it0, it1;
76 data_type tt0, tt1, seg_len;
83 length(len, it0->second, tt0, tt1, tol);
86 length(seg_len, it0->second, tt0, 1, tol);
88 length(seg_len, it1->second, 0, tt1, tol);
93 for (++it; it!=it1; ++it)
95 length(seg_len, it->second, tol);
100 template<
typename curve__>
101 void length(
typename curve__::data_type &len,
const curve__ &c,
const typename curve__::data_type &tol)
103 length(len, c, static_cast<typename curve__::data_type>(0.0), static_cast<typename curve__::data_type>(1.0), tol);
105 template<
typename curve__>
106 void length(
typename curve__::data_type &len,
const curve__ &c,
const typename curve__::data_type &t0,
const typename curve__::data_type &t1,
const typename curve__::data_type &tol)
123 len=quad(f, t0, t1, ap);
130 data_type length_adaptive_subdivision()
const
134 return internal_length_adaptive_subdivision(SMALL_POS_FLOAT, 0);
137 data_type internal_length_adaptive_subdivision(
const data_type &tol,
const index_type &depth)
const
139 data_type L1, Lc, Lp, err;
140 index_type i, n(this->degree()), depth_max(20);
146 Lp+=dist(b[i], b[i+1]);
147 L1=(2*Lc+(n-1)*Lp)/(n+1);
152 err=std::abs(Lp-Lc)/(1<<(2*depth));
155 if ( (err>tol) && (depth<depth_max) )
157 beziern_curve bc_l, bc_r;
160 split(bc_l, bc_r, 0.5);
163 L1=bc_l.internal_length_adaptive_subdivision(tol/2, depth+1)+bc_r.internal_length_adaptive_subdivision(tol/2, depth+1);
curve__::data_type operator()(const typename curve__::data_type &t)
Definition: length.hpp:35
Definition: length.hpp:31
data__ data_type
Definition: piecewise.hpp:276
data__ tolerance
Definition: simpson.hpp:33
Definition: piecewise.hpp:244
Definition: simpson.hpp:30
const curve__ * pcurve
Definition: length.hpp:33
void length(typename piecewise< curve__, data__, dim__, tol__ >::data_type &len, const piecewise< curve__, data__, dim__, tol__ > &pc, const typename piecewise< curve__, data__, dim__, tol__ >::data_type &tol)
Definition: length.hpp:43
segment_collection_type segments
Definition: piecewise.hpp:1858
void find_segment(typename segment_collection_type::const_iterator &it, const index_type &index) const
Definition: piecewise.hpp:2013
Definition: simpson.hpp:27