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 <Events_InfoMessage.h>
11 #include <ModelAPI_AttributeSelectionList.h>
12 #include <ModelAPI_Object.h>
13 #include <ModelAPI_ResultConstruction.h>
15 bool GeomValidators_BodyShapes::isValid(const AttributePtr& theAttribute,
16 const std::list<std::string>& theArguments,
17 Events_InfoMessage& theError) const
19 std::string anAttributeType = theAttribute->attributeType();
20 if(anAttributeType == ModelAPI_AttributeSelection::typeId()) {
21 AttributeSelectionPtr anAttrSelection =
22 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
23 ResultPtr aContext = anAttrSelection->context();
25 theError = "Error: Context is empty.";
29 ResultConstructionPtr aResultConstruction =
30 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
31 if(aResultConstruction.get()) {
32 theError = "Error: Result construction selected.";
35 } else if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
36 AttributeSelectionListPtr anAttrSelectionList =
37 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
39 // All objects should not be result constructions.
40 for(int anIndex = 0, aSize = anAttrSelectionList->size(); anIndex < aSize; ++anIndex) {
41 AttributeSelectionPtr anAttrSelection = anAttrSelectionList->value(anIndex);
42 if(!isValid(anAttrSelection, theArguments, theError)) {
47 theError = "Error: Attribute \"%1\" does not supported by this validator.";
48 theError.arg(anAttributeType);