Salome HOME
Issue #1860: fix end lines with spaces
[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 =
23         std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
24       if (anAttr != NULL && anAttr->isObject())
25         anObject = anAttr->object();
26     }
27     if (anAttrType == ModelAPI_AttributeSelection::typeId()) {
28       AttributeSelectionPtr anAttr =
29         std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
30       if (anAttr != NULL)
31         anObject = anAttr->context();
32     }
33     if (anAttrType == ModelAPI_AttributeReference::typeId()) {
34       AttributeReferencePtr anAttr =
35         std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
36       if (anAttr.get() != NULL)
37         anObject = anAttr->value();
38     }
39     return anObject;
40   }
41
42 }