Salome HOME
13e95ace0ffc8bbb0be3a5178414575bced770c8
[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 #include <ModelAPI_ResultConstruction.h>
12
13 bool GeomValidators_BodyShapes::isValid(const AttributePtr& theAttribute,
14                                         const std::list<std::string>& theArguments,
15                                         std::string& theError) const
16 {
17   std::string anAttributeType = theAttribute->attributeType();
18   if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
19     AttributeSelectionListPtr aSelectionListAttr = 
20                       std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
21     // all context objects should not be sketch entities
22     for(int anIndex = 0, aSize = aSelectionListAttr->size(); anIndex < aSize; ++anIndex) {
23       AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(anIndex);
24       ResultPtr aContext = aSelectAttr->context();
25       if(!aContext.get()) {
26         theError = "Error: Context is empty.";
27         return false;
28       }
29
30       ResultConstructionPtr aResultConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
31       if(aResultConstruction.get()) {
32         theError = "Error: Result construction selected.";
33         return false;
34       }
35     }
36   }
37
38   return true;
39 }