| 643 | } |
| 644 | |
| 645 | void ImageReader::channelsToRead( vector<string> &names ) |
| 646 | { |
| 647 | vector<string> allNames; |
| 648 | channelNames( allNames ); |
| 649 | |
| 650 | ConstStringVectorParameterPtr p = channelNamesParameter(); |
| 651 | const StringVectorData *d = static_cast<const StringVectorData *>( p->getValue() ); |
| 652 | |
| 653 | // give all channels when no list is provided |
| 654 | if (!d->readable().size()) |
| 655 | { |
| 656 | names = allNames; |
| 657 | return; |
| 658 | } |
| 659 | |
| 660 | // otherwise, copy in the requested names from the parameter set. |
| 661 | // this is intersection(A, D) |
| 662 | names.clear(); |
| 663 | for (vector<string>::const_iterator it = d->readable().begin(); it != d->readable().end(); it++) |
| 664 | { |
| 665 | if (find(allNames.begin(), allNames.end(), *it) != allNames.end()) |
| 666 | { |
| 667 | names.push_back(*it); |
| 668 | } |
| 669 | } |
| 670 | } |
| 671 | |
| 672 | StringVectorParameter *ImageReader::channelNamesParameter() |
| 673 | { |