Salome HOME
Fix tests MakeBrick2 & MakeBrick3. Fix Box macro feature.
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Interface.cpp
1 // Name   : ModelHighAPI_Interface.cpp
2 // Purpose: 
3 //
4 // History:
5 // 17/05/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "ModelHighAPI_Interface.h"
9 //--------------------------------------------------------------------------------------
10 #include <Events_Error.h>
11
12 #include <ModelAPI_Feature.h>
13
14 #include "ModelHighAPI_Selection.h"
15 //--------------------------------------------------------------------------------------
16 ModelHighAPI_Interface::ModelHighAPI_Interface(const std::shared_ptr<ModelAPI_Feature> & theFeature)
17 : myFeature(theFeature)
18 {
19
20 }
21
22 ModelHighAPI_Interface::~ModelHighAPI_Interface()
23 {
24
25 }
26
27 //--------------------------------------------------------------------------------------
28 std::shared_ptr<ModelAPI_Feature> ModelHighAPI_Interface::feature() const
29 {
30   return myFeature;
31 }
32
33 const std::string& ModelHighAPI_Interface::getKind() const
34 {
35   return feature()->getKind();
36 }
37
38 void ModelHighAPI_Interface::execute()
39 {
40   feature()->execute();
41 }
42
43 std::list<ModelHighAPI_Selection> ModelHighAPI_Interface::result() const
44 {
45   // TODO(spo): should I use more common function for the whole model to prepare results?
46   const_cast<ModelHighAPI_Interface*>(this)->execute();
47
48   std::list<ModelHighAPI_Selection> aSelectionList;
49
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));
53   }
54
55   return aSelectionList;
56 }
57
58 void ModelHighAPI_Interface::throwException(const std::string & theDescription)
59 {
60   Events_Error::send(theDescription);
61 }