1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomValidators_Tools.cpp
4 // Created: 06 Aug 2014
5 // Author: Vitaly Smetannikov
7 #include "GeomValidators_Tools.h"
9 #include "ModelAPI_AttributeRefAttr.h"
10 #include "ModelAPI_AttributeSelection.h"
11 #include "ModelAPI_AttributeReference.h"
13 #include <TopoDS_Iterator.hxx>
15 namespace GeomValidators_Tools {
17 ObjectPtr getObject(const AttributePtr& theAttribute)
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();
27 if (anAttrType == ModelAPI_AttributeSelection::typeId()) {
28 AttributeSelectionPtr anAttr =
29 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
31 anObject = anAttr->context();
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();