]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/PartSet/PartSet_Validators.cpp
Salome HOME
Multiple objects and tools for Boolean operations.
[modules/shaper.git] / src / PartSet / PartSet_Validators.cpp
index e31b1b2b50257a04d870bc72860e4fac5953b839..1e0f79b2f75dfc882b3ab6b4470234d8e7a93345 100644 (file)
@@ -216,7 +216,7 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
       }
     }
   }
-  else if (anAttrType == ModelAPI_AttributeRefAttr::typeId()) {
+  else if (anAttrType == ModelAPI_AttributeSelection::typeId()) {
     AttributeSelectionPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
     ResultPtr aContext = anAttr->context();
     GeomShapePtr aShape = anAttr->value();
@@ -258,6 +258,32 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
       }
     }
   }
+  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);
+            for(int j = 0; j < aRefSelList->size(); j++) {
+              std::shared_ptr<ModelAPI_AttributeSelection> aRefSel = aRefSelList->value(j);
+              if(aCurSel->context() == aRefSel->context()) {
+                if(aCurSel->value().get() == NULL || aRefSel->value().get() == NULL
+                  || aCurSel->value()->isEqual(aRefSel->value())) {
+                    return false;
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
   return !featureHasReferences(theAttribute);
 }