1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomValidators_Finite.cpp
4 // Created: 27 Aug 2015
5 // Author: Natalia ERMOLAEVA
7 #include <GeomValidators_Finite.h>
9 #include <Events_InfoMessage.h>
11 #include <ModelAPI_AttributeSelectionList.h>
12 #include <ModelAPI_ResultConstruction.h>
14 bool GeomValidators_Finite::isValid(const AttributePtr& theAttribute,
15 const std::list<std::string>& theArguments,
16 Events_InfoMessage& theError) const
20 const std::string anAttributeType = theAttribute->attributeType();
22 if(anAttributeType == ModelAPI_AttributeSelection::typeId()) {
23 AttributeSelectionPtr aSelectionAttr =
24 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
25 ResultPtr aResult = aSelectionAttr->context();
26 ResultConstructionPtr aConstruction =
27 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aResult);
28 if (aConstruction.get() && aConstruction->isInfinite()) {
30 theError = "Infinite result is selected.";
32 } else if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
33 AttributeSelectionListPtr aSelectionListAttr =
34 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
35 for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize; i++) {
36 AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
37 ResultPtr aResult = aSelectAttr->context();
38 if (aResult.get() && aResult->groupName() == ModelAPI_ResultConstruction::group()) {
39 ResultConstructionPtr aConstruction =
40 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aResult);
41 if (aConstruction.get() && aConstruction->isInfinite()) {
43 theError = "Infinite result is selected.";