| 52 | |
| 53 | template<typename T> |
| 54 | std::string rampRepr( object x ) |
| 55 | { |
| 56 | std::stringstream s; |
| 57 | const std::string name = extract<std::string>( x.attr( "__class__").attr( "__name__" ) ); |
| 58 | s << "IECore." << name << "( "; |
| 59 | const T ramp = extract<T>( x ); |
| 60 | s << "("; |
| 61 | int i = 0; |
| 62 | int l = ramp.points.size(); |
| 63 | typename T::PointContainer::const_iterator it; |
| 64 | for( it = ramp.points.begin(); it != ramp.points.end(); it++, i++ ) |
| 65 | { |
| 66 | // TODO - without this const_cast I get a link error because the const version of repr<Color3f> |
| 67 | // hasn't been defined |
| 68 | s << " ( " << it->first << ", " << IECorePython::repr( const_cast<typename T::YType&>( it->second ) ) << " )"; |
| 69 | if( i!=l-1 ) |
| 70 | { |
| 71 | s << ","; |
| 72 | } |
| 73 | } |
| 74 | s << "), "; |
| 75 | const std::string interpStr = extract<std::string>( object( ramp.interpolation ).attr( "__str__")() ); |
| 76 | s << "IECore.RampInterpolation." << interpStr; |
| 77 | s << ")"; |
| 78 | return s.str(); |
| 79 | } |
| 80 | |
| 81 | template<typename T> |
| 82 | T *rampConstruct( object o, const RampInterpolation &interpolation ) |