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 FeaturePtr& theFeature,
13 const std::list<std::string>& theArguments,
14 const ObjectPtr& theObject,
15 const AttributePtr& theAttribute,
16 const GeomShapePtr& theShape) const
18 std::string aCurrentAttributeId = theAttribute->id();
19 // get all feature attributes
20 std::list<AttributePtr> anAttrs =
21 theFeature->data()->attributes(ModelAPI_AttributeSelection::type());
22 if (anAttrs.size() > 0 && theShape.get() != NULL) {
23 std::list<AttributePtr>::iterator anAttr = anAttrs.begin();
24 for(; anAttr != anAttrs.end(); anAttr++) {
25 AttributePtr anAttribute = *anAttr;
26 // take into concideration only other attributes
27 if (anAttribute.get() != NULL && anAttribute->id() != aCurrentAttributeId) {
28 AttributeSelectionPtr aSelectionAttribute =
29 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(anAttribute);
30 // the shape of the attribute should be not the same
31 if (aSelectionAttribute.get() != NULL && theShape->isEqual(aSelectionAttribute->value())) {