+ else {
+ //FeaturePtr aFeature = ModelAPI_Feature::feature(thePrs->object());
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(thePrs->object());
+ if (aFeature.get()) {
+ // Use feature as a reference to all its results
+ myPresentedObject = aFeature;
+ AttributePtr anAttr = attribute();
+ std::string aType = anAttr->attributeType();
+
+ // Check that results of Feature is acceptable by filters for selection attribute
+ if (aType == ModelAPI_AttributeSelection::typeId()) {
+ AttributeSelectionPtr aSelectAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(anAttr);
+ aSelectAttr->setValue(myPresentedObject, GeomShapePtr(), true);
+ GeomShapePtr aShape = aSelectAttr->value();
+ if (!aShape.get() && aSelectAttr->contextFeature().get() &&
+ aSelectAttr->contextFeature()->firstResult().get()) {
+ aShape = aSelectAttr->contextFeature()->firstResult()->shape();
+ }
+ if (aShape.get()) {
+ const TopoDS_Shape aTDShape = aShape->impl<TopoDS_Shape>();
+ Handle(AIS_InteractiveObject) anIO = myWorkshop->selection()->getIO(thePrs);
+ anOwner = new StdSelect_BRepOwner(aTDShape, anIO);
+ }
+ else
+ aValid = false;
+ //aSelectAttr->setValue(ObjectPtr(), GeomShapePtr(), true);
+ }
+ else {
+ ResultPtr aResult = aFeature->firstResult();
+ if (aResult.get()) {
+ GeomShapePtr aShapePtr = ModelAPI_Tools::shape(aResult);
+ if (aShapePtr.get()) {
+ const TopoDS_Shape aTDShape = aShapePtr->impl<TopoDS_Shape>();
+ AISObjectPtr aIOPtr = myWorkshop->findPresentation(aResult);
+ if (aIOPtr.get()) {
+ Handle(AIS_InteractiveObject) anIO = aIOPtr->impl<Handle(AIS_InteractiveObject)>();
+ anOwner = new StdSelect_BRepOwner(aTDShape, anIO);
+ }
+ }
+ }
+ aValid = !anOwner.IsNull(); // only results with a shape can be filtered
+ }
+ } else
+ aValid = false; // only results with a shape can be filtered
+ }