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