Salome HOME
Constriction type for all sketch entities
[modules/shaper.git] / src / ModelAPI / ModelAPI_ShapeValidator.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_ShapeValidator.cpp
4 // Created:     2 Feb 2015
5 // Author:      Natalia ERMOLAEVA
6
7 #include "ModelAPI_ShapeValidator.h"
8
9 #include <ModelAPI_AttributeSelection.h>
10 #include "ModelAPI_Object.h"
11
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
17 {
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())) {
32           return false;
33         }
34       }
35     }
36   }
37   return true;
38 }