]> SALOME platform Git repositories - modules/shaper.git/blob - src/FeaturesAPI/FeaturesAPI_RevolutionBoolean.cpp
Salome HOME
Added CPP High API for FeaturesPlugin_RevolutionCut, FeaturesPlugin_RevolutionFuse
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_RevolutionBoolean.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesAPI_RevolutionBoolean.cpp
4 // Created:     09 June 2016
5 // Author:      Dmitry Bobylev
6
7 #include "FeaturesAPI_RevolutionBoolean.h"
8
9 #include <ModelHighAPI_Double.h>
10 #include <ModelHighAPI_Tools.h>
11
12 //==================================================================================================
13 FeaturesAPI_RevolutionBoolean::FeaturesAPI_RevolutionBoolean(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
15 {
16 }
17
18 //==================================================================================================
19 FeaturesAPI_RevolutionBoolean::~FeaturesAPI_RevolutionBoolean()
20 {
21 }
22
23 //==================================================================================================
24 void FeaturesAPI_RevolutionBoolean::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
25 {
26   fillAttribute(theBaseObjects, mybaseObjects);
27
28   execute();
29 }
30
31 //==================================================================================================
32 void FeaturesAPI_RevolutionBoolean::setAxis(const ModelHighAPI_Selection& theAxis)
33 {
34   fillAttribute(theAxis, myaxis);
35
36   execute();
37 }
38
39 //==================================================================================================
40 void FeaturesAPI_RevolutionBoolean::setAngles(const ModelHighAPI_Double& theToAngle,
41                                               const ModelHighAPI_Double& theFromAngle)
42 {
43   fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES(), mycreationMethod);
44   fillAttribute(theToAngle, mytoAngle);
45   fillAttribute(theFromAngle, myfromAngle);
46
47   execute();
48 }
49
50 //==================================================================================================
51 void FeaturesAPI_RevolutionBoolean::setAngle(const ModelHighAPI_Double& theAngle)
52 {
53   fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES(), mycreationMethod);
54   fillAttribute(theAngle, mytoAngle);
55   fillAttribute(ModelHighAPI_Double(), myfromAngle);
56
57   execute();
58 }
59
60 //==================================================================================================
61 void FeaturesAPI_RevolutionBoolean::setPlanesAndOffsets(const ModelHighAPI_Selection& theToObject,
62                                                         const ModelHighAPI_Double& theToOffset,
63                                                         const ModelHighAPI_Selection& theFromObject,
64                                                         const ModelHighAPI_Double& theFromOffset)
65 {
66   fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_PLANES(), mycreationMethod);
67   fillAttribute(theToObject, mytoObject);
68   fillAttribute(theToOffset, mytoOffset);
69   fillAttribute(theFromObject, myfromObject);
70   fillAttribute(theFromOffset, myfromOffset);
71
72   execute();
73 }
74
75 //==================================================================================================
76 void FeaturesAPI_RevolutionBoolean::setBooleanObjects(const std::list<ModelHighAPI_Selection>& theBooleanObjects)
77 {
78   fillAttribute(theBooleanObjects, mybooleanObjects);
79
80   execute();
81 }
82
83 //==================================================================================================
84 FeaturesAPI_RevolutionCut::FeaturesAPI_RevolutionCut(const std::shared_ptr<ModelAPI_Feature>& theFeature)
85 : FeaturesAPI_RevolutionBoolean(theFeature)
86 {
87   initialize();
88 }
89
90 //==================================================================================================
91 FeaturesAPI_RevolutionCut::FeaturesAPI_RevolutionCut(const std::shared_ptr<ModelAPI_Feature>& theFeature,
92                                                      const std::list<ModelHighAPI_Selection>& theBaseObjects,
93                                                      const ModelHighAPI_Selection& theAxis,
94                                                      const ModelHighAPI_Double& theSize,
95                                                      const std::list<ModelHighAPI_Selection>& theBooleanObjects)
96 : FeaturesAPI_RevolutionBoolean(theFeature)
97 {
98   if(initialize()) {
99     fillAttribute(theBaseObjects, mybaseObjects);
100     fillAttribute(theAxis, myaxis);
101     fillAttribute(theSize, mytoAngle);
102     fillAttribute(ModelHighAPI_Double(), myfromAngle);
103     setBooleanObjects(theBooleanObjects);
104   }
105 }
106
107 //==================================================================================================
108 FeaturesAPI_RevolutionCut::FeaturesAPI_RevolutionCut(const std::shared_ptr<ModelAPI_Feature>& theFeature,
109                                                      const std::list<ModelHighAPI_Selection>& theBaseObjects,
110                                                      const ModelHighAPI_Selection& theAxis,
111                                                      const ModelHighAPI_Double& theToAngle,
112                                                      const ModelHighAPI_Double& theFromAngle,
113                                                      const std::list<ModelHighAPI_Selection>& theBooleanObjects)
114 : FeaturesAPI_RevolutionBoolean(theFeature)
115 {
116   if(initialize()) {
117     fillAttribute(theBaseObjects, mybaseObjects);
118     fillAttribute(theAxis, myaxis);
119     fillAttribute(theToAngle, mytoAngle);
120     fillAttribute(theFromAngle, myfromAngle);
121     setBooleanObjects(theBooleanObjects);
122   }
123 }
124
125 //==================================================================================================
126 FeaturesAPI_RevolutionCut::FeaturesAPI_RevolutionCut(const std::shared_ptr<ModelAPI_Feature>& theFeature,
127                                                      const std::list<ModelHighAPI_Selection>& theBaseObjects,
128                                                      const ModelHighAPI_Selection& theAxis,
129                                                      const ModelHighAPI_Selection& theToObject,
130                                                      const ModelHighAPI_Double& theToOffset,
131                                                      const ModelHighAPI_Selection& theFromObject,
132                                                      const ModelHighAPI_Double& theFromOffset,
133                                                      const std::list<ModelHighAPI_Selection>& theBooleanObjects)
134 : FeaturesAPI_RevolutionBoolean(theFeature)
135 {
136   if(initialize()) {
137     fillAttribute(theBaseObjects, mybaseObjects);
138     fillAttribute(theAxis, myaxis);
139     fillAttribute(theToObject, mytoObject);
140     fillAttribute(theToOffset, mytoOffset);
141     fillAttribute(theFromObject, myfromObject);
142     fillAttribute(theFromOffset, myfromOffset);
143     setBooleanObjects(theBooleanObjects);
144   }
145 }
146
147 // TODO(spo): make add* as static functions of the class
148 //==================================================================================================
149 RevolutionCutPtr addRevolutionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
150                                   const std::list<ModelHighAPI_Selection>& theBaseObjects,
151                                   const ModelHighAPI_Selection& theAxis,
152                                   const ModelHighAPI_Double& theSize,
153                                   const std::list<ModelHighAPI_Selection>& theBooleanObjects)
154 {
155   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_RevolutionCut::ID());
156   return RevolutionCutPtr(new FeaturesAPI_RevolutionCut(aFeature, theBaseObjects, theAxis, theSize, theBooleanObjects));
157 }
158
159 //==================================================================================================
160 RevolutionCutPtr addRevolutionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
161                                   const std::list<ModelHighAPI_Selection>& theBaseObjects,
162                                   const ModelHighAPI_Selection& theAxis,
163                                   const ModelHighAPI_Double& theToAngle,
164                                   const ModelHighAPI_Double& theFromAngle,
165                                   const std::list<ModelHighAPI_Selection>& theBooleanObjects)
166 {
167   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_RevolutionCut::ID());
168   return RevolutionCutPtr(new FeaturesAPI_RevolutionCut(aFeature,
169                                                       theBaseObjects,
170                                                       theAxis,
171                                                       theToAngle,
172                                                       theFromAngle,
173                                                       theBooleanObjects));
174 }
175
176 //==================================================================================================
177 RevolutionCutPtr addRevolutionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
178                                   const std::list<ModelHighAPI_Selection>& theBaseObjects,
179                                   const ModelHighAPI_Selection& theAxis,
180                                   const ModelHighAPI_Selection& theToObject,
181                                   const ModelHighAPI_Double& theToOffset,
182                                   const ModelHighAPI_Selection& theFromObject,
183                                   const ModelHighAPI_Double& theFromOffset,
184                                   const std::list<ModelHighAPI_Selection>& theBooleanObjects)
185 {
186   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_RevolutionCut::ID());
187   return RevolutionCutPtr(new FeaturesAPI_RevolutionCut(aFeature,
188                                                       theBaseObjects,
189                                                       theAxis,
190                                                       theToObject,
191                                                       theToOffset,
192                                                       theFromObject,
193                                                       theFromOffset,
194                                                       theBooleanObjects));
195 }
196
197
198 //==================================================================================================
199 FeaturesAPI_RevolutionFuse::FeaturesAPI_RevolutionFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature)
200 : FeaturesAPI_RevolutionBoolean(theFeature)
201 {
202   initialize();
203 }
204
205 //==================================================================================================
206 FeaturesAPI_RevolutionFuse::FeaturesAPI_RevolutionFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
207                                                        const std::list<ModelHighAPI_Selection>& theBaseObjects,
208                                                        const ModelHighAPI_Selection& theAxis,
209                                                        const ModelHighAPI_Double& theSize,
210                                                        const std::list<ModelHighAPI_Selection>& theBooleanObjects)
211 : FeaturesAPI_RevolutionBoolean(theFeature)
212 {
213   if(initialize()) {
214     fillAttribute(theBaseObjects, mybaseObjects);
215     fillAttribute(theAxis, myaxis);
216     fillAttribute(theSize, mytoAngle);
217     fillAttribute(ModelHighAPI_Double(), myfromAngle);
218     setBooleanObjects(theBooleanObjects);
219   }
220 }
221
222 //==================================================================================================
223 FeaturesAPI_RevolutionFuse::FeaturesAPI_RevolutionFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
224                                                        const std::list<ModelHighAPI_Selection>& theBaseObjects,
225                                                        const ModelHighAPI_Selection& theAxis,
226                                                        const ModelHighAPI_Double& theToAngle,
227                                                        const ModelHighAPI_Double& theFromAngle,
228                                                        const std::list<ModelHighAPI_Selection>& theBooleanObjects)
229 : FeaturesAPI_RevolutionBoolean(theFeature)
230 {
231   if(initialize()) {
232     fillAttribute(theBaseObjects, mybaseObjects);
233     fillAttribute(theAxis, myaxis);
234     fillAttribute(theToAngle, mytoAngle);
235     fillAttribute(theFromAngle, myfromAngle);
236     setBooleanObjects(theBooleanObjects);
237   }
238 }
239
240 //==================================================================================================
241 FeaturesAPI_RevolutionFuse::FeaturesAPI_RevolutionFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
242                                                        const std::list<ModelHighAPI_Selection>& theBaseObjects,
243                                                        const ModelHighAPI_Selection& theAxis,
244                                                        const ModelHighAPI_Selection& theToObject,
245                                                        const ModelHighAPI_Double& theToOffset,
246                                                        const ModelHighAPI_Selection& theFromObject,
247                                                        const ModelHighAPI_Double& theFromOffset,
248                                                        const std::list<ModelHighAPI_Selection>& theBooleanObjects)
249 : FeaturesAPI_RevolutionBoolean(theFeature)
250 {
251   if(initialize()) {
252     fillAttribute(theBaseObjects, mybaseObjects);
253     fillAttribute(theAxis, myaxis);
254     fillAttribute(theToObject, mytoObject);
255     fillAttribute(theToOffset, mytoOffset);
256     fillAttribute(theFromObject, myfromObject);
257     fillAttribute(theFromOffset, myfromOffset);
258     setBooleanObjects(theBooleanObjects);
259   }
260 }
261
262 // TODO(spo): make add* as static functions of the class
263 //==================================================================================================
264 RevolutionFusePtr addRevolutionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
265                                     const std::list<ModelHighAPI_Selection>& theBaseObjects,
266                                     const ModelHighAPI_Selection& theAxis,
267                                     const ModelHighAPI_Double& theSize,
268                                     const std::list<ModelHighAPI_Selection>& theBooleanObjects)
269 {
270   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_RevolutionFuse::ID());
271   return RevolutionFusePtr(new FeaturesAPI_RevolutionFuse(aFeature, theBaseObjects, theAxis, theSize, theBooleanObjects));
272 }
273
274 //==================================================================================================
275 RevolutionFusePtr addRevolutionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
276                                     const std::list<ModelHighAPI_Selection>& theBaseObjects,
277                                     const ModelHighAPI_Selection& theAxis,
278                                     const ModelHighAPI_Double& theToAngle,
279                                     const ModelHighAPI_Double& theFromAngle,
280                                     const std::list<ModelHighAPI_Selection>& theBooleanObjects)
281 {
282   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_RevolutionFuse::ID());
283   return RevolutionFusePtr(new FeaturesAPI_RevolutionFuse(aFeature,
284                                                         theBaseObjects,
285                                                         theAxis,
286                                                         theToAngle,
287                                                         theFromAngle,
288                                                         theBooleanObjects));
289 }
290
291 //==================================================================================================
292 RevolutionFusePtr addRevolutionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
293                                     const std::list<ModelHighAPI_Selection>& theBaseObjects,
294                                     const ModelHighAPI_Selection& theAxis,
295                                     const ModelHighAPI_Selection& theToObject,
296                                     const ModelHighAPI_Double& theToOffset,
297                                     const ModelHighAPI_Selection& theFromObject,
298                                     const ModelHighAPI_Double& theFromOffset,
299                                     const std::list<ModelHighAPI_Selection>& theBooleanObjects)
300 {
301   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_RevolutionFuse::ID());
302   return RevolutionFusePtr(new FeaturesAPI_RevolutionFuse(aFeature,
303                                                         theBaseObjects,
304                                                         theAxis,
305                                                         theToObject,
306                                                         theToOffset,
307                                                         theFromObject,
308                                                         theFromOffset,
309                                                         theBooleanObjects));
310 }