- Handle(TNaming_NamedShape) aName;
- if (myLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
- TopoDS_Shape aShape = aName->Get();
- if (!aShape.IsNull()) {
- boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
- aRes->setImpl(new TopoDS_Shape(aShape));
- return aRes;
+ std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = myAttrs.begin();
+ std::list<ObjectPtr> aReferenced; // not inside of cycle to avoid excess memory menagement
+ for(; anAttr != myAttrs.end(); anAttr++) {
+ std::string aType = anAttr->second->attributeType();
+ if (aType == ModelAPI_AttributeReference::type()) { // reference to object
+ std::shared_ptr<ModelAPI_AttributeReference> aRef = std::dynamic_pointer_cast<
+ ModelAPI_AttributeReference>(anAttr->second);
+ aReferenced.push_back(aRef->value());
+ } else if (aType == ModelAPI_AttributeRefAttr::type()) { // reference to attribute or object
+ std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = std::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(anAttr->second);
+ aReferenced.push_back(aRef->isObject() ? aRef->object() : aRef->attr()->owner());
+ } else if (aType == ModelAPI_AttributeRefList::type()) { // list of references
+ aReferenced = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(anAttr->second)->list();
+ } else if (aType == ModelAPI_AttributeSelection::type()) { // selection attribute
+ std::shared_ptr<ModelAPI_AttributeSelection> aRef = std::dynamic_pointer_cast<
+ ModelAPI_AttributeSelection>(anAttr->second);
+ aReferenced.push_back(aRef->context());
+ } else if (aType == ModelAPI_AttributeSelectionList::type()) { // list of selection attributes
+ std::shared_ptr<ModelAPI_AttributeSelectionList> aRef = std::dynamic_pointer_cast<
+ ModelAPI_AttributeSelectionList>(anAttr->second);
+ for(int a = aRef->size() - 1; a >= 0; a--) {
+ aReferenced.push_back(aRef->value(a)->context());
+ }
+ } else
+ continue; // nothing to do, not reference
+
+ if (!aReferenced.empty()) {
+ theRefs.push_back(std::pair<std::string, std::list<ObjectPtr> >(anAttr->first, aReferenced));
+ aReferenced.clear();