Salome HOME
Merge branch 'python_parametric_api' of https://git.salome-platform.org/git/modules...
[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 #include <TopoDS_Iterator.hxx>
14
15 namespace GeomValidators_Tools {
16
17   ObjectPtr getObject(const AttributePtr& theAttribute)
18   {
19     ObjectPtr anObject;
20     std::string anAttrType = theAttribute->attributeType();
21     if (anAttrType == ModelAPI_AttributeRefAttr::typeId()) {
22       AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
23       if (anAttr != NULL && anAttr->isObject())
24         anObject = anAttr->object();
25     }
26     if (anAttrType == ModelAPI_AttributeSelection::typeId()) {
27       AttributeSelectionPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
28       if (anAttr != NULL)
29         anObject = anAttr->context();
30     }
31     if (anAttrType == ModelAPI_AttributeReference::typeId()) {
32       AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
33       if (anAttr.get() != NULL)
34         anObject = anAttr->value();
35     }
36     return anObject;
37   }
38
39 }