MCPcopy Create free account
hub / github.com/ImageEngine/cortex / fromOSL

Method fromOSL

src/IECore/Ramp.cpp:341–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339
340template<typename X, typename Y>
341void Ramp<X,Y>::fromOSL( const std::string &basis, const std::vector<X> &positions, const std::vector<Y> &values, const std::string &identifier )
342{
343 points.clear();
344 size_t n = std::min( positions.size(), values.size() );
345
346 if( basis == "bezier" )
347 {
348 for( size_t i = 0; i < n; i += 3 )
349 {
350 points.insert( Point( positions[i], values[i] ) );
351 }
352
353 interpolation = RampInterpolation::MonotoneCubic;
354
355 std::vector<X> testPositions;
356 std::vector<Y> testValues;
357 std::string testBasis;
358 toOSL( testBasis, testPositions, testValues );
359 if( !( testPositions == positions && testValues == values ) )
360 {
361 IECore::msg( IECore::MessageHandler::Warning, "Ramp", "While loading shader parameter " + identifier + " found bezier curve that cannot be represented in Gaffer. Using most similar MonotoneCubic curve instead." );
362 }
363 return;
364 }
365 else
366 {
367 for( size_t i = 0; i < n; ++i )
368 {
369 points.insert( Point( positions[i], values[i] ) );
370 }
371 }
372
373 if( basis == "bspline" )
374 {
375 interpolation = RampInterpolation::BSpline;
376 }
377 else if( basis == "linear" )
378 {
379 interpolation = RampInterpolation::Linear;
380 }
381 else if( basis == "constant" )
382 {
383 interpolation = RampInterpolation::Constant;
384 }
385 else if( basis == "monotonecubic" )
386 {
387 // 3delight actually supports monotonecubic, so it's possible we could see an input
388 // directly using this interpolation.
389 interpolation = RampInterpolation::MonotoneCubic;
390 }
391 else
392 {
393 interpolation = RampInterpolation::CatmullRom;
394 }
395
396 trimEndPoints( points );
397
398}

Callers 1

Calls 4

trimEndPointsFunction · 0.85
insertMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected