- ModelAPI_AttributeSelectionList>(anAttr->second);
- for(int a = aRef->size() - 1; a >= 0; a--) {
- aReferenced.push_back(aRef->value(a)->context());
+ ModelAPI_AttributeSelectionList>(anAttr);
+ for(int a = 0, aSize = aRef->size(); a < aSize; ++a) {
+ FeaturePtr aRefFeat = aRef->value(a)->contextFeature();
+ if (aRefFeat.get()) { // reference to all results of the referenced feature
+ const std::list<ResultPtr>& allRes = aRefFeat->results();
+ std::list<ResultPtr>::const_iterator aRefRes = allRes.cbegin();
+ for (; aRefRes != allRes.cend(); aRefRes++) {
+ aReferenced.push_back(*aRefRes);
+ }
+ } else {
+ aReferenced.push_back(aRef->value(a)->context());
+ }