1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomValidators_BodyShapes.cpp
4 // Created: 21 December 2015
5 // Author: Dmitry Bobylev
7 #include "GeomValidators_BodyShapes.h"
9 #include <ModelAPI_AttributeSelectionList.h>
10 #include <ModelAPI_Object.h>
11 #include <ModelAPI_ResultConstruction.h>
13 bool GeomValidators_BodyShapes::isValid(const AttributePtr& theAttribute,
14 const std::list<std::string>& theArguments,
15 std::string& theError) const
17 std::string anAttributeType = theAttribute->attributeType();
18 if(anAttributeType == ModelAPI_AttributeSelection::typeId()) {
19 AttributeSelectionPtr anAttrSelection =
20 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
21 ResultPtr aContext = anAttrSelection->context();
23 theError = "Error: Context is empty.";
27 ResultConstructionPtr aResultConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
28 if(aResultConstruction.get()) {
29 theError = "Error: Result construction selected.";
32 } else if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
33 AttributeSelectionListPtr anAttrSelectionList =
34 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
36 // All objects should not be result constructions.
37 for(int anIndex = 0, aSize = anAttrSelectionList->size(); anIndex < aSize; ++anIndex) {
38 AttributeSelectionPtr anAttrSelection = anAttrSelectionList->value(anIndex);
39 if(!isValid(anAttrSelection, theArguments, theError)) {
44 theError = "Error: Attribute \"" + anAttributeType + "\" does not supported by this validator.";