Salome HOME
Resolve batch runtime errors on debian squeeze
[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 AttributePtr& theAttribute,
14                                       const GeomShapePtr& theShape) const
15 {
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())) {
30           return false;
31         }
32       }
33     }
34   }
35   return true;
36 }