Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom.git into Dev_1.1.0
[modules/shaper.git] / src / GeomValidators / GeomValidators_Tools.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomValidators_Tools.cpp
4 // Created:     06 Aug 2014
5 // Author:      Vitaly Smetannikov
6
7 #include "GeomValidators_Tools.h"
8
9 #include "ModelAPI_AttributeRefAttr.h"
10 #include "ModelAPI_AttributeSelection.h"
11 #include "ModelAPI_AttributeReference.h"
12
13 namespace GeomValidators_Tools {
14
15   ObjectPtr getObject(const AttributePtr& theAttribute)
16   {
17     ObjectPtr anObject;
18     std::string anAttrType = theAttribute->attributeType();
19     if (anAttrType == ModelAPI_AttributeRefAttr::type()) {
20       AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
21       if (anAttr != NULL && anAttr->isObject())
22         anObject = anAttr->object();
23     }
24     if (anAttrType == ModelAPI_AttributeSelection::type()) {
25       AttributeSelectionPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
26       if (anAttr != NULL && anAttr->isInitialized())
27         anObject = anAttr->context();
28     }
29     if (anAttrType == ModelAPI_AttributeReference::type()) {
30       AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
31       if (anAttr.get() != NULL && anAttr->isInitialized())
32         anObject = anAttr->value();
33     }
34     return anObject;
35   }
36 }