| 381 | } |
| 382 | |
| 383 | bool ImagePrimitive::channelValid( const IECore::Data *data, std::string *reason ) const |
| 384 | { |
| 385 | if( !data ) |
| 386 | { |
| 387 | if( reason ) |
| 388 | { |
| 389 | *reason = "Channel has no data."; |
| 390 | } |
| 391 | return false; |
| 392 | } |
| 393 | |
| 394 | if( !trait<TypeTraits::IsNumericVectorTypedData>( data ) ) |
| 395 | { |
| 396 | if( reason ) |
| 397 | { |
| 398 | *reason = "Channel data has inappropriate type."; |
| 399 | } |
| 400 | return false; |
| 401 | } |
| 402 | |
| 403 | size_t size = IECore::size( data ); |
| 404 | size_t numPixels = channelSize(); |
| 405 | if( size!=numPixels ) |
| 406 | { |
| 407 | if( reason ) |
| 408 | { |
| 409 | *reason = str( format( "Channel has wrong size (%d but should be %d)." ) % size % numPixels ); |
| 410 | } |
| 411 | return false; |
| 412 | } |
| 413 | |
| 414 | return true; |
| 415 | } |
| 416 | |
| 417 | bool ImagePrimitive::channelValid( const std::string &name, std::string *reason ) const |
| 418 | { |