Salome HOME
83e65fe47ff2551cc9f7d468bce3f9b730c8d4fd
[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     setBoolType(theBoolType);
29     setMainObjects(theMainObjects);
30     setToolObjects(theToolObjects);
31   }
32 }
33
34 //==================================================================================================
35 FeaturesAPI_Boolean::~FeaturesAPI_Boolean()
36 {
37
38 }
39
40 //==================================================================================================
41 void FeaturesAPI_Boolean::setBoolType(const ModelHighAPI_Integer& theBoolType)
42 {
43   fillAttribute(theBoolType, myboolType);
44
45   execute();
46 }
47
48 //==================================================================================================
49 void FeaturesAPI_Boolean::setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects)
50 {
51   fillAttribute(theMainObjects, mymainObjects);
52
53   execute();
54 }
55
56 //==================================================================================================
57 void FeaturesAPI_Boolean::setToolObjects(const std::list<ModelHighAPI_Selection>& theToolObjects)
58 {
59   fillAttribute(theToolObjects, mytoolObjects);
60
61   execute();
62 }
63
64 // TODO(spo): make add* as static functions of the class
65 //==================================================================================================
66 BooleanPtr addCut(const std::shared_ptr<ModelAPI_Document> & thePart,
67                   const std::list<ModelHighAPI_Selection>& theMainObjects,
68                   const std::list<ModelHighAPI_Selection>& theToolObjects)
69 {
70   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
71   return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
72                                             FeaturesPlugin_Boolean::BOOL_CUT,
73                                             theMainObjects,
74                                             theToolObjects));
75 }
76
77 //==================================================================================================
78 BooleanPtr addFuse(const std::shared_ptr<ModelAPI_Document> & thePart,
79                    const std::list<ModelHighAPI_Selection>& theObjects)
80 {
81   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
82   std::list<ModelHighAPI_Selection> aToolObjects;
83   return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
84                                             FeaturesPlugin_Boolean::BOOL_FUSE,
85                                             theObjects,
86                                             aToolObjects));
87 }
88
89 //==================================================================================================
90 BooleanPtr addFuse(const std::shared_ptr<ModelAPI_Document> & thePart,
91                    const std::list<ModelHighAPI_Selection>& theMainObjects,
92                    const std::list<ModelHighAPI_Selection>& theToolObjects)
93 {
94   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
95   return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
96                                             FeaturesPlugin_Boolean::BOOL_FUSE,
97                                             theMainObjects,
98                                             theToolObjects));
99 }
100
101 //==================================================================================================
102 BooleanPtr addCommon(const std::shared_ptr<ModelAPI_Document> & thePart,
103                      const std::list<ModelHighAPI_Selection>& theMainObjects,
104                      const std::list<ModelHighAPI_Selection>& theToolObjects)
105 {
106   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
107   return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
108                                             FeaturesPlugin_Boolean::BOOL_COMMON,
109                                             theMainObjects,
110                                             theToolObjects));
111 }