| 211 | } |
| 212 | |
| 213 | Expected<std::vector<float>> findPartialLens( const CurvePoints& cp, float * outCurveLen ) |
| 214 | { |
| 215 | MR_TIMER; |
| 216 | if ( cp.size() < 2 ) |
| 217 | { |
| 218 | assert( false ); |
| 219 | return unexpected( "Curve is too short" ); |
| 220 | } |
| 221 | |
| 222 | std::vector<float> lens; |
| 223 | lens.reserve( cp.size() ); |
| 224 | lens.push_back( 0 ); |
| 225 | for ( int i = 0; i + 1 < cp.size(); ++i ) |
| 226 | lens.push_back( lens.back() + distance( cp[i].pos, cp[i+1].pos ) ); |
| 227 | assert( lens.size() == cp.size() ); |
| 228 | if ( outCurveLen ) |
| 229 | *outCurveLen = lens.back(); |
| 230 | if ( lens.back() <= 0 ) |
| 231 | return unexpected( "curve has zero length" ); |
| 232 | |
| 233 | return lens; |
| 234 | } |
| 235 | |
| 236 | CurvePoint getCurvePoint( const CurvePoints& cp, const std::vector<float> & lens, float p ) |
| 237 | { |
no test coverage detected