+ else if (anAttrType == ModelAPI_AttributeReference::typeId()) {
+ AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
+ ObjectPtr anObject = anAttr->value();
+ // Check selection attributes
+ anAttrs = aFeature->data()->attributes(ModelAPI_AttributeReference::typeId());
+ if (anAttrs.size() > 0) {
+ std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+ for(; anAttr != anAttrs.end(); anAttr++) {
+ if ((*anAttr).get() && (*anAttr)->id() != theAttribute->id()) {
+ std::shared_ptr<ModelAPI_AttributeReference> aRef =
+ std::dynamic_pointer_cast<ModelAPI_AttributeReference>(*anAttr);
+ // check the object is already presented
+ if (aRef->value() == anObject) {
+ theError = errorMessage(EqualObjects, anObject.get() ? anObject->data()->name() : "",
+ theAttribute->id(), aRef->id());
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ }
+ else if(anAttrType == ModelAPI_AttributeSelectionList::typeId()) {
+ std::shared_ptr<ModelAPI_AttributeSelectionList> aCurSelList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ anAttrs = aFeature->data()->attributes(ModelAPI_AttributeSelectionList::typeId());
+ if(anAttrs.size() > 0) {
+ std::list<std::shared_ptr<ModelAPI_Attribute>>::iterator anAttrItr = anAttrs.begin();
+ for(; anAttrItr != anAttrs.end(); anAttrItr++){
+ if ((*anAttrItr).get() && (*anAttrItr)->id() != theAttribute->id()){
+ std::shared_ptr<ModelAPI_AttributeSelectionList> aRefSelList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*anAttrItr);
+ for(int i = 0; i < aCurSelList->size(); i++) {
+ std::shared_ptr<ModelAPI_AttributeSelection> aCurSel = aCurSelList->value(i);
+ ResultPtr aCurSelContext = aCurSel->context();
+ ResultCompSolidPtr aCurSelCompSolidPtr = ModelAPI_Tools::compSolidOwner(aCurSelContext);
+ std::shared_ptr<GeomAPI_Shape> aCurSelCompSolid;
+ if(aCurSelCompSolidPtr.get()) {
+ aCurSelCompSolid = aCurSelCompSolidPtr->shape();
+ }
+ for(int j = 0; j < aRefSelList->size(); j++) {
+ std::shared_ptr<ModelAPI_AttributeSelection> aRefSel = aRefSelList->value(j);
+ ResultPtr aRefSelContext = aRefSel->context();
+ ResultCompSolidPtr aRefSelCompSolidPtr = ModelAPI_Tools::compSolidOwner(aRefSelContext);
+ std::shared_ptr<GeomAPI_Shape> aRefSelCompSolid;
+ if(aRefSelCompSolidPtr.get()) {
+ aRefSelCompSolid = aRefSelCompSolidPtr->shape();
+ }
+ if ((aCurSelCompSolid.get() && aCurSelCompSolid->isEqual(aRefSel->value()))
+ || (aRefSelCompSolid.get() && aRefSelCompSolid->isEqual(aCurSel->value()))) {
+ theError = errorMessage(EqualShapes, "", theAttribute->id(),
+ aRefSel->id());
+ return false;
+ }
+ if(aCurSelContext == aRefSelContext) {
+ if (aCurSel->value().get() == NULL || aRefSel->value().get() == NULL) {
+ theError = errorMessage(EmptyShapes, "", theAttribute->id(),
+ aRefSel->id());
+ return false;
+ }
+ if (aCurSel->value()->isEqual(aRefSel->value())) {
+ theError = errorMessage(EqualShapes, "", theAttribute->id(),
+ aRefSel->id());
+ return false;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (anAttrType == ModelAPI_AttributeRefList::typeId()) {
+ std::shared_ptr<ModelAPI_AttributeRefList> aCurSelList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
+ anAttrs = aFeature->data()->attributes(ModelAPI_AttributeRefList::typeId());
+ if (anAttrs.size() > 0) {
+ std::list<std::shared_ptr<ModelAPI_Attribute>>::iterator anAttrItr = anAttrs.begin();
+ for (; anAttrItr != anAttrs.end(); anAttrItr++){
+ if ((*anAttrItr).get() && (*anAttrItr)->id() != theAttribute->id()){
+ std::shared_ptr<ModelAPI_AttributeRefList> aRefSelList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*anAttrItr);
+ for (int i = 0; i < aCurSelList->size(); i++) {
+ ObjectPtr aCurSelObject = aCurSelList->object(i);
+ for (int j = 0; j < aRefSelList->size(); j++) {
+ if (aCurSelObject == aRefSelList->object(j)) {
+ theError = errorMessage(EqualObjects,
+ aCurSelObject.get() ? aCurSelObject->data()->name() : "",
+ theAttribute->id(), aCurSelList->id());
+ return false;
+ }
+ }
+ }
+ }