| 295 | |
| 296 | template<typename X, typename Y> |
| 297 | IECore::Spline<X,Y> Ramp<X,Y>::evaluator() const |
| 298 | { |
| 299 | using ResultType = IECore::Spline<X,Y>; |
| 300 | ResultType result; |
| 301 | |
| 302 | result.points = points; |
| 303 | |
| 304 | if( interpolation == RampInterpolation::Linear ) |
| 305 | { |
| 306 | result.basis = ResultType::Basis::linear(); |
| 307 | } |
| 308 | else if( interpolation == RampInterpolation::CatmullRom ) |
| 309 | { |
| 310 | result.basis = ResultType::Basis::catmullRom(); |
| 311 | } |
| 312 | else if( interpolation == RampInterpolation::BSpline ) |
| 313 | { |
| 314 | result.basis = ResultType::Basis::bSpline(); |
| 315 | } |
| 316 | else if( interpolation == RampInterpolation::MonotoneCubic ) |
| 317 | { |
| 318 | monotoneCubicCVsToBezierCurve< Ramp<X,Y> >( points, result.points ); |
| 319 | result.basis = ResultType::Basis::bezier(); |
| 320 | } |
| 321 | else if( interpolation == RampInterpolation::Constant ) |
| 322 | { |
| 323 | result.basis = ResultType::Basis::constant(); |
| 324 | } |
| 325 | |
| 326 | int multiplicity = endPointMultiplicity( interpolation ); |
| 327 | |
| 328 | if( multiplicity && result.points.size() ) |
| 329 | { |
| 330 | for( int i = 0; i < multiplicity - 1; ++i ) |
| 331 | { |
| 332 | result.points.insert( *result.points.begin() ); |
| 333 | result.points.insert( *result.points.rbegin() ); |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | return result; |
| 338 | } |
| 339 | |
| 340 | template<typename X, typename Y> |
| 341 | void Ramp<X,Y>::fromOSL( const std::string &basis, const std::vector<X> &positions, const std::vector<Y> &values, const std::string &identifier ) |