1 // Name : ModelHighAPI_Interface.cpp
5 // 17/05/16 - Sergey POKHODENKO - Creation of the file
7 //--------------------------------------------------------------------------------------
8 #include "ModelHighAPI_Interface.h"
9 //--------------------------------------------------------------------------------------
10 #include <Events_InfoMessage.h>
12 #include <ModelAPI_Feature.h>
14 #include "ModelHighAPI_Selection.h"
15 //--------------------------------------------------------------------------------------
16 ModelHighAPI_Interface::ModelHighAPI_Interface(const std::shared_ptr<ModelAPI_Feature> & theFeature)
17 : myFeature(theFeature)
22 ModelHighAPI_Interface::~ModelHighAPI_Interface()
27 //--------------------------------------------------------------------------------------
28 std::shared_ptr<ModelAPI_Feature> ModelHighAPI_Interface::feature() const
33 const std::string& ModelHighAPI_Interface::getKind() const
35 return feature()->getKind();
38 void ModelHighAPI_Interface::execute()
43 std::list<ModelHighAPI_Selection> ModelHighAPI_Interface::result() const
45 // TODO(spo): should I use more common function for the whole model to prepare results?
46 const_cast<ModelHighAPI_Interface*>(this)->execute();
48 std::list<ModelHighAPI_Selection> aSelectionList;
50 std::list<std::shared_ptr<ModelAPI_Result> > aResults = feature()->results();
51 for (auto it = aResults.begin(), end = aResults.end(); it != end; ++it) {
52 aSelectionList.push_back(ModelHighAPI_Selection(*it));
55 return aSelectionList;
58 std::shared_ptr<ModelAPI_Result> ModelHighAPI_Interface::defaultResult() const
60 const_cast<ModelHighAPI_Interface*>(this)->execute();
62 return feature()->lastResult();
65 void ModelHighAPI_Interface::throwException(const std::string & theDescription)
67 Events_InfoMessage("ModelHighAPI_Interface", theDescription).send();
70 const std::string& ModelHighAPI_Interface::attributeGetter(const std::string& theAttrName)
72 return myAttrGetter[theAttrName];