Salome HOME
2.17. Improved management of overconstraint situation: Processing added arguments...
[modules/shaper.git] / src / GeomValidators / GeomValidators_BodyShapes.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomValidators_BodyShapes.cpp
4 // Created:     21 December 2015
5 // Author:      Dmitry Bobylev
6
7 #include "GeomValidators_BodyShapes.h"
8
9 #include <ModelAPI_AttributeSelectionList.h>
10 #include <ModelAPI_Object.h>
11
12 bool GeomValidators_BodyShapes::isValid(const AttributePtr& theAttribute,
13                                       const std::list<std::string>& theArguments,
14                                       std::string& theError) const
15 {
16   std::string anAttributeType = theAttribute->attributeType();
17   if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
18     AttributeSelectionListPtr aSelectionListAttr = 
19                       std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
20     // all context objects should not be sketch entities
21     for(int i = 0, aSize = aSelectionListAttr->size(); i < aSize; i++) {
22       AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
23       ObjectPtr anObject = aSelectAttr->context();
24       if (!anObject.get())
25         return false;
26       else {
27         FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
28         std::string aFeatureKind = aFeature->getKind();
29         if(aFeatureKind == "Sketch") {
30           return false;
31         }
32       }
33     }
34   }
35
36   return true;
37 }