| 83 | } |
| 84 | |
| 85 | void ChannelOp::modify( Object * primitive, const CompoundObject * operands ) |
| 86 | { |
| 87 | ImagePrimitive *image = runTimeCast<ImagePrimitive>( primitive ); |
| 88 | |
| 89 | if( image->getDataWindow().isEmpty() ) |
| 90 | { |
| 91 | return; |
| 92 | } |
| 93 | |
| 94 | ChannelVector channels; |
| 95 | |
| 96 | const vector<string> &channelNames = channelNamesParameter()->getTypedValue(); |
| 97 | for( const auto &name : channelNames ) |
| 98 | { |
| 99 | std::string reason; |
| 100 | if( !image->channelValid( name, &reason ) ) |
| 101 | { |
| 102 | throw Exception( str( format( "Channel \"%s\" is invalid: " ) % name ) + reason ); |
| 103 | } |
| 104 | |
| 105 | if( !image->channels[name]->isInstanceOf( FloatVectorData::staticTypeId() ) ) |
| 106 | { |
| 107 | throw Exception( str( format( "Channel \"%s\" is invalid: not a float vector." ) % name ) ); |
| 108 | } |
| 109 | |
| 110 | channels.push_back( boost::static_pointer_cast< FloatVectorData >( image->channels[name] ) ); |
| 111 | } |
| 112 | |
| 113 | modifyChannels( image->getDisplayWindow(), image->getDataWindow(), channels ); |
| 114 | /// \todo Consider cases where the derived class invalidates the channel data (by changing its length) |
| 115 | } |
nothing calls this directly
no test coverage detected