Salome HOME
Added CPP High API for FeaturesPlugin_Pipe
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_Boolean.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesAPI_Boolean.cpp
4 // Created:     07 June 2016
5 // Author:      Dmitry Bobylev
6
7 #include "FeaturesAPI_Boolean.h"
8
9 #include <ModelHighAPI_Integer.h>
10 #include <ModelHighAPI_Selection.h>
11 #include <ModelHighAPI_Tools.h>
12
13 //==================================================================================================
14 FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr<ModelAPI_Feature>& theFeature)
15 : ModelHighAPI_Interface(theFeature)
16 {
17   initialize();
18 }
19
20 //==================================================================================================
21 FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr<ModelAPI_Feature>& theFeature,
22                                          const ModelHighAPI_Integer& theBoolType,
23                                          const std::list<ModelHighAPI_Selection>& theMainObjects,
24                                          const std::list<ModelHighAPI_Selection>& theToolObjects)
25 : ModelHighAPI_Interface(theFeature)
26 {
27   if(initialize()) {
28     fillAttribute(theBoolType, myboolType);
29     fillAttribute(theMainObjects, mymainObjects);
30     fillAttribute(theToolObjects, mytoolObjects);
31
32     execute();
33   }
34 }
35
36 //==================================================================================================
37 FeaturesAPI_Boolean::~FeaturesAPI_Boolean()
38 {
39
40 }
41
42 //==================================================================================================
43 void FeaturesAPI_Boolean::setBoolType(const ModelHighAPI_Integer& theBoolType)
44 {
45   fillAttribute(theBoolType, myboolType);
46
47   execute();
48 }
49
50 //==================================================================================================
51 void FeaturesAPI_Boolean::setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects)
52 {
53   fillAttribute(theMainObjects, mymainObjects);
54
55   execute();
56 }
57
58 //==================================================================================================
59 void FeaturesAPI_Boolean::setToolObjects(const std::list<ModelHighAPI_Selection>& theToolObjects)
60 {
61   fillAttribute(theToolObjects, mytoolObjects);
62
63   execute();
64 }
65
66 // TODO(spo): make add* as static functions of the class
67 //==================================================================================================
68 BooleanPtr addCut(const std::shared_ptr<ModelAPI_Document>& thePart,
69                   const std::list<ModelHighAPI_Selection>& theMainObjects,
70                   const std::list<ModelHighAPI_Selection>& theToolObjects)
71 {
72   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
73   return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
74                                             FeaturesPlugin_Boolean::BOOL_CUT,
75                                             theMainObjects,
76                                             theToolObjects));
77 }
78
79 //==================================================================================================
80 BooleanPtr addFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
81                    const std::list<ModelHighAPI_Selection>& theObjects)
82 {
83   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
84   std::list<ModelHighAPI_Selection> aToolObjects;
85   return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
86                                             FeaturesPlugin_Boolean::BOOL_FUSE,
87                                             theObjects,
88                                             aToolObjects));
89 }
90
91 //==================================================================================================
92 BooleanPtr addFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
93                    const std::list<ModelHighAPI_Selection>& theMainObjects,
94                    const std::list<ModelHighAPI_Selection>& theToolObjects)
95 {
96   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
97   return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
98                                             FeaturesPlugin_Boolean::BOOL_FUSE,
99                                             theMainObjects,
100                                             theToolObjects));
101 }
102
103 //==================================================================================================
104 BooleanPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
105                      const std::list<ModelHighAPI_Selection>& theMainObjects,
106                      const std::list<ModelHighAPI_Selection>& theToolObjects)
107 {
108   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
109   return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
110                                             FeaturesPlugin_Boolean::BOOL_COMMON,
111                                             theMainObjects,
112                                             theToolObjects));
113 }