1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModelAPI_ShapeValidator.cpp
5 // Author: Natalia ERMOLAEVA
7 #include "ModelAPI_ShapeValidator.h"
9 #include <ModelAPI_AttributeSelection.h>
10 #include "ModelAPI_Object.h"
12 bool ModelAPI_ShapeValidator::isValid(const AttributePtr& theAttribute,
13 const std::list<std::string>& theArguments) const
15 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
16 AttributeSelectionPtr aSelectionAttribute =
17 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
18 GeomShapePtr aShape = aSelectionAttribute->value();
20 std::string aCurrentAttributeId = theAttribute->id();
21 // get all feature attributes
22 std::list<AttributePtr> anAttrs =
23 aFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
24 if (anAttrs.size() > 0 && aShape.get() != NULL) {
25 std::list<AttributePtr>::iterator anAttr = anAttrs.begin();
26 for(; anAttr != anAttrs.end(); anAttr++) {
27 AttributePtr anAttribute = *anAttr;
28 // take into concideration only other attributes
29 if (anAttribute.get() != NULL && anAttribute->id() != aCurrentAttributeId) {
30 AttributeSelectionPtr aSelectionAttribute =
31 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(anAttribute);
32 // the shape of the attribute should be not the same
33 if (aSelectionAttribute.get() != NULL && aShape->isEqual(aSelectionAttribute->value())) {