| 399 | |
| 400 | template<typename X, typename Y> |
| 401 | void Ramp<X,Y>::toOSL( std::string &basis, std::vector<X> &positions, std::vector<Y> &values ) const |
| 402 | { |
| 403 | PointContainer storage; |
| 404 | const PointContainer *currentPoints = &points; |
| 405 | |
| 406 | if( interpolation == RampInterpolation::MonotoneCubic ) |
| 407 | { |
| 408 | monotoneCubicCVsToBezierCurve< Ramp<X,Y> >( points, storage ); |
| 409 | currentPoints = &storage; |
| 410 | basis = "bezier"; |
| 411 | } |
| 412 | else if( interpolation == RampInterpolation::BSpline ) |
| 413 | { |
| 414 | basis = "bspline"; |
| 415 | } |
| 416 | else if( interpolation == RampInterpolation::Linear ) |
| 417 | { |
| 418 | basis = "linear"; |
| 419 | } |
| 420 | else if( interpolation == RampInterpolation::Constant ) |
| 421 | { |
| 422 | // Also, "To maintain consistency", "constant splines ignore the first and the two last |
| 423 | // data values." |
| 424 | basis = "constant"; |
| 425 | } |
| 426 | else |
| 427 | { |
| 428 | basis = "catmull-rom"; |
| 429 | } |
| 430 | auto [ duplicateStartPoints, duplicateEndPoints ] = getOSLEndPointDuplication( interpolation ); |
| 431 | |
| 432 | positions.reserve( currentPoints->size() ); |
| 433 | values.reserve( currentPoints->size() + duplicateStartPoints + duplicateEndPoints ); |
| 434 | |
| 435 | if( currentPoints->size() ) |
| 436 | { |
| 437 | for( size_t i = 0; i < duplicateStartPoints; i++ ) |
| 438 | { |
| 439 | positions.push_back( currentPoints->begin()->first ); |
| 440 | values.push_back( currentPoints->begin()->second ); |
| 441 | } |
| 442 | } |
| 443 | for( auto &it : *currentPoints ) |
| 444 | { |
| 445 | positions.push_back( it.first ); |
| 446 | values.push_back( it.second ); |
| 447 | } |
| 448 | if( currentPoints->size() ) |
| 449 | { |
| 450 | for( size_t i = 0; i < duplicateEndPoints; i++ ) |
| 451 | { |
| 452 | positions.push_back( currentPoints->rbegin()->first ); |
| 453 | values.push_back( currentPoints->rbegin()->second ); |
| 454 | } |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | template<typename X, typename Y> |
no test coverage detected