1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: FeaturesAPI_Extrusion.cpp
4 // Created: 09 June 2016
5 // Author: Dmitry Bobylev
7 #include "FeaturesAPI_ExtrusionBoolean.h"
9 #include <ModelHighAPI_Double.h>
10 #include <ModelHighAPI_Tools.h>
12 //==================================================================================================
13 FeaturesAPI_ExtrusionBoolean::FeaturesAPI_ExtrusionBoolean(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
18 //==================================================================================================
19 FeaturesAPI_ExtrusionBoolean::~FeaturesAPI_ExtrusionBoolean()
23 //==================================================================================================
24 void FeaturesAPI_ExtrusionBoolean::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
26 fillAttribute(theBaseObjects, mybaseObjects);
31 //==================================================================================================
32 void FeaturesAPI_ExtrusionBoolean::setDirection(const ModelHighAPI_Selection& theDirection)
34 fillAttribute(theDirection, mydirection);
39 //==================================================================================================
40 void FeaturesAPI_ExtrusionBoolean::setSizes(const ModelHighAPI_Double& theToSize,
41 const ModelHighAPI_Double& theFromSize)
43 fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
44 fillAttribute(theToSize, mytoSize);
45 fillAttribute(theFromSize, myfromSize);
50 //==================================================================================================
51 void FeaturesAPI_ExtrusionBoolean::setSize(const ModelHighAPI_Double& theSize)
53 fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
54 fillAttribute(theSize, mytoSize);
55 fillAttribute(ModelHighAPI_Double(), myfromSize);
60 //==================================================================================================
61 void FeaturesAPI_ExtrusionBoolean::setPlanesAndOffsets(const ModelHighAPI_Selection& theToObject,
62 const ModelHighAPI_Double& theToOffset,
63 const ModelHighAPI_Selection& theFromObject,
64 const ModelHighAPI_Double& theFromOffset)
66 fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod);
67 fillAttribute(theToObject, mytoObject);
68 fillAttribute(theToOffset, mytoOffset);
69 fillAttribute(theFromObject, myfromObject);
70 fillAttribute(theFromOffset, myfromOffset);
75 //==================================================================================================
76 void FeaturesAPI_ExtrusionBoolean::setBooleanObjects(const std::list<ModelHighAPI_Selection>& theBooleanObjects)
78 fillAttribute(theBooleanObjects, mybooleanObjects);
83 //==================================================================================================
84 FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(const std::shared_ptr<ModelAPI_Feature>& theFeature)
85 : FeaturesAPI_ExtrusionBoolean(theFeature)
90 //==================================================================================================
91 FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(const std::shared_ptr<ModelAPI_Feature>& theFeature,
92 const std::list<ModelHighAPI_Selection>& theBaseObjects,
93 const ModelHighAPI_Double& theSize,
94 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
95 : FeaturesAPI_ExtrusionBoolean(theFeature)
98 fillAttribute(theBaseObjects, mybaseObjects);
99 fillAttribute(theSize, mytoSize);
100 fillAttribute(ModelHighAPI_Double(), myfromSize);
101 setBooleanObjects(theBooleanObjects);
105 //==================================================================================================
106 FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(const std::shared_ptr<ModelAPI_Feature>& theFeature,
107 const std::list<ModelHighAPI_Selection>& theBaseObjects,
108 const ModelHighAPI_Selection& theDirection,
109 const ModelHighAPI_Double& theSize,
110 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
111 : FeaturesAPI_ExtrusionBoolean(theFeature)
114 fillAttribute(theBaseObjects, mybaseObjects);
115 fillAttribute(theDirection, mydirection);
116 fillAttribute(theSize, mytoSize);
117 fillAttribute(ModelHighAPI_Double(), myfromSize);
118 setBooleanObjects(theBooleanObjects);
122 //==================================================================================================
123 FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(const std::shared_ptr<ModelAPI_Feature>& theFeature,
124 const std::list<ModelHighAPI_Selection>& theBaseObjects,
125 const ModelHighAPI_Double& theToSize,
126 const ModelHighAPI_Double& theFromSize,
127 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
128 : FeaturesAPI_ExtrusionBoolean(theFeature)
131 fillAttribute(theBaseObjects, mybaseObjects);
132 fillAttribute(theToSize, mytoSize);
133 fillAttribute(theFromSize, myfromSize);
134 setBooleanObjects(theBooleanObjects);
138 //==================================================================================================
139 FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(const std::shared_ptr<ModelAPI_Feature>& theFeature,
140 const std::list<ModelHighAPI_Selection>& theBaseObjects,
141 const ModelHighAPI_Selection& theDirection,
142 const ModelHighAPI_Double& theToSize,
143 const ModelHighAPI_Double& theFromSize,
144 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
145 : FeaturesAPI_ExtrusionBoolean(theFeature)
148 fillAttribute(theBaseObjects, mybaseObjects);
149 fillAttribute(theDirection, mydirection);
150 fillAttribute(theToSize, mytoSize);
151 fillAttribute(theFromSize, myfromSize);
152 setBooleanObjects(theBooleanObjects);
156 //==================================================================================================
157 FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(const std::shared_ptr<ModelAPI_Feature>& theFeature,
158 const std::list<ModelHighAPI_Selection>& theBaseObjects,
159 const ModelHighAPI_Selection& theToObject,
160 const ModelHighAPI_Double& theToOffset,
161 const ModelHighAPI_Selection& theFromObject,
162 const ModelHighAPI_Double& theFromOffset,
163 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
164 : FeaturesAPI_ExtrusionBoolean(theFeature)
167 fillAttribute(theBaseObjects, mybaseObjects);
168 fillAttribute(theToObject, mytoObject);
169 fillAttribute(theToOffset, mytoOffset);
170 fillAttribute(theFromObject, myfromObject);
171 fillAttribute(theFromOffset, myfromOffset);
172 setBooleanObjects(theBooleanObjects);
176 //==================================================================================================
177 FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(const std::shared_ptr<ModelAPI_Feature>& theFeature,
178 const std::list<ModelHighAPI_Selection>& theBaseObjects,
179 const ModelHighAPI_Selection& theDirection,
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 : FeaturesAPI_ExtrusionBoolean(theFeature)
188 fillAttribute(theBaseObjects, mybaseObjects);
189 fillAttribute(theDirection, mydirection);
190 fillAttribute(theToObject, mytoObject);
191 fillAttribute(theToOffset, mytoOffset);
192 fillAttribute(theFromObject, myfromObject);
193 fillAttribute(theFromOffset, myfromOffset);
194 setBooleanObjects(theBooleanObjects);
198 // TODO(spo): make add* as static functions of the class
199 //==================================================================================================
200 ExtrusionCutPtr addExtrusionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
201 const std::list<ModelHighAPI_Selection>& theBaseObjects,
202 const ModelHighAPI_Double& theSize,
203 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
205 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionCut::ID());
206 return ExtrusionCutPtr(new FeaturesAPI_ExtrusionCut(aFeature, theBaseObjects, theSize, theBooleanObjects));
209 //==================================================================================================
210 ExtrusionCutPtr addExtrusionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
211 const std::list<ModelHighAPI_Selection>& theBaseObjects,
212 const ModelHighAPI_Selection& theDirection,
213 const ModelHighAPI_Double& theSize,
214 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
216 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionCut::ID());
217 return ExtrusionCutPtr(new FeaturesAPI_ExtrusionCut(aFeature, theBaseObjects, theDirection, theSize, theBooleanObjects));
220 //==================================================================================================
221 ExtrusionCutPtr addExtrusionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
222 const std::list<ModelHighAPI_Selection>& theBaseObjects,
223 const ModelHighAPI_Double& theToSize,
224 const ModelHighAPI_Double& theFromSize,
225 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
227 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionCut::ID());
228 return ExtrusionCutPtr(new FeaturesAPI_ExtrusionCut(aFeature, theBaseObjects, theToSize, theFromSize, theBooleanObjects));
231 //==================================================================================================
232 ExtrusionCutPtr addExtrusionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
233 const std::list<ModelHighAPI_Selection>& theBaseObjects,
234 const ModelHighAPI_Selection& theDirection,
235 const ModelHighAPI_Double& theToSize,
236 const ModelHighAPI_Double& theFromSize,
237 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
239 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionCut::ID());
240 return ExtrusionCutPtr(new FeaturesAPI_ExtrusionCut(aFeature,
248 //==================================================================================================
249 ExtrusionCutPtr addExtrusionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
250 const std::list<ModelHighAPI_Selection>& theBaseObjects,
251 const ModelHighAPI_Selection& theToObject,
252 const ModelHighAPI_Double& theToOffset,
253 const ModelHighAPI_Selection& theFromObject,
254 const ModelHighAPI_Double& theFromOffset,
255 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
257 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionCut::ID());
258 return ExtrusionCutPtr(new FeaturesAPI_ExtrusionCut(aFeature,
267 //==================================================================================================
268 ExtrusionCutPtr addExtrusionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
269 const std::list<ModelHighAPI_Selection>& theBaseObjects,
270 const ModelHighAPI_Selection& theDirection,
271 const ModelHighAPI_Selection& theToObject,
272 const ModelHighAPI_Double& theToOffset,
273 const ModelHighAPI_Selection& theFromObject,
274 const ModelHighAPI_Double& theFromOffset,
275 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
277 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionCut::ID());
278 return ExtrusionCutPtr(new FeaturesAPI_ExtrusionCut(aFeature,
289 //==================================================================================================
290 FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature)
291 : FeaturesAPI_ExtrusionBoolean(theFeature)
296 //==================================================================================================
297 FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
298 const std::list<ModelHighAPI_Selection>& theBaseObjects,
299 const ModelHighAPI_Double& theSize,
300 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
301 : FeaturesAPI_ExtrusionBoolean(theFeature)
304 fillAttribute(theBaseObjects, mybaseObjects);
305 fillAttribute(theSize, mytoSize);
306 fillAttribute(ModelHighAPI_Double(), myfromSize);
307 setBooleanObjects(theBooleanObjects);
311 //==================================================================================================
312 FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
313 const std::list<ModelHighAPI_Selection>& theBaseObjects,
314 const ModelHighAPI_Selection& theDirection,
315 const ModelHighAPI_Double& theSize,
316 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
317 : FeaturesAPI_ExtrusionBoolean(theFeature)
320 fillAttribute(theBaseObjects, mybaseObjects);
321 fillAttribute(theDirection, mydirection);
322 fillAttribute(theSize, mytoSize);
323 fillAttribute(ModelHighAPI_Double(), myfromSize);
324 setBooleanObjects(theBooleanObjects);
328 //==================================================================================================
329 FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
330 const std::list<ModelHighAPI_Selection>& theBaseObjects,
331 const ModelHighAPI_Double& theToSize,
332 const ModelHighAPI_Double& theFromSize,
333 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
334 : FeaturesAPI_ExtrusionBoolean(theFeature)
337 fillAttribute(theBaseObjects, mybaseObjects);
338 fillAttribute(theToSize, mytoSize);
339 fillAttribute(theFromSize, myfromSize);
340 setBooleanObjects(theBooleanObjects);
344 //==================================================================================================
345 FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
346 const std::list<ModelHighAPI_Selection>& theBaseObjects,
347 const ModelHighAPI_Selection& theDirection,
348 const ModelHighAPI_Double& theToSize,
349 const ModelHighAPI_Double& theFromSize,
350 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
351 : FeaturesAPI_ExtrusionBoolean(theFeature)
354 fillAttribute(theBaseObjects, mybaseObjects);
355 fillAttribute(theDirection, mydirection);
356 fillAttribute(theToSize, mytoSize);
357 fillAttribute(theFromSize, myfromSize);
358 setBooleanObjects(theBooleanObjects);
362 //==================================================================================================
363 FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
364 const std::list<ModelHighAPI_Selection>& theBaseObjects,
365 const ModelHighAPI_Selection& theToObject,
366 const ModelHighAPI_Double& theToOffset,
367 const ModelHighAPI_Selection& theFromObject,
368 const ModelHighAPI_Double& theFromOffset,
369 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
370 : FeaturesAPI_ExtrusionBoolean(theFeature)
373 fillAttribute(theBaseObjects, mybaseObjects);
374 fillAttribute(theToObject, mytoObject);
375 fillAttribute(theToOffset, mytoOffset);
376 fillAttribute(theFromObject, myfromObject);
377 fillAttribute(theFromOffset, myfromOffset);
378 setBooleanObjects(theBooleanObjects);
382 //==================================================================================================
383 FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(const std::shared_ptr<ModelAPI_Feature>& theFeature,
384 const std::list<ModelHighAPI_Selection>& theBaseObjects,
385 const ModelHighAPI_Selection& theDirection,
386 const ModelHighAPI_Selection& theToObject,
387 const ModelHighAPI_Double& theToOffset,
388 const ModelHighAPI_Selection& theFromObject,
389 const ModelHighAPI_Double& theFromOffset,
390 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
391 : FeaturesAPI_ExtrusionBoolean(theFeature)
394 fillAttribute(theBaseObjects, mybaseObjects);
395 fillAttribute(theDirection, mydirection);
396 fillAttribute(theToObject, mytoObject);
397 fillAttribute(theToOffset, mytoOffset);
398 fillAttribute(theFromObject, myfromObject);
399 fillAttribute(theFromOffset, myfromOffset);
400 setBooleanObjects(theBooleanObjects);
404 // TODO(spo): make add* as static functions of the class
405 //==================================================================================================
406 ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
407 const std::list<ModelHighAPI_Selection>& theBaseObjects,
408 const ModelHighAPI_Double& theSize,
409 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
411 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionFuse::ID());
412 return ExtrusionFusePtr(new FeaturesAPI_ExtrusionFuse(aFeature, theBaseObjects, theSize, theBooleanObjects));
415 //==================================================================================================
416 ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
417 const std::list<ModelHighAPI_Selection>& theBaseObjects,
418 const ModelHighAPI_Selection& theDirection,
419 const ModelHighAPI_Double& theSize,
420 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
422 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionFuse::ID());
423 return ExtrusionFusePtr(new FeaturesAPI_ExtrusionFuse(aFeature, theBaseObjects, theDirection, theSize, theBooleanObjects));
426 //==================================================================================================
427 ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
428 const std::list<ModelHighAPI_Selection>& theBaseObjects,
429 const ModelHighAPI_Double& theToSize,
430 const ModelHighAPI_Double& theFromSize,
431 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
433 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionFuse::ID());
434 return ExtrusionFusePtr(new FeaturesAPI_ExtrusionFuse(aFeature, theBaseObjects, theToSize, theFromSize, theBooleanObjects));
437 //==================================================================================================
438 ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
439 const std::list<ModelHighAPI_Selection>& theBaseObjects,
440 const ModelHighAPI_Selection& theDirection,
441 const ModelHighAPI_Double& theToSize,
442 const ModelHighAPI_Double& theFromSize,
443 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
445 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionFuse::ID());
446 return ExtrusionFusePtr(new FeaturesAPI_ExtrusionFuse(aFeature,
454 //==================================================================================================
455 ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
456 const std::list<ModelHighAPI_Selection>& theBaseObjects,
457 const ModelHighAPI_Selection& theToObject,
458 const ModelHighAPI_Double& theToOffset,
459 const ModelHighAPI_Selection& theFromObject,
460 const ModelHighAPI_Double& theFromOffset,
461 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
463 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionFuse::ID());
464 return ExtrusionFusePtr(new FeaturesAPI_ExtrusionFuse(aFeature,
473 //==================================================================================================
474 ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
475 const std::list<ModelHighAPI_Selection>& theBaseObjects,
476 const ModelHighAPI_Selection& theDirection,
477 const ModelHighAPI_Selection& theToObject,
478 const ModelHighAPI_Double& theToOffset,
479 const ModelHighAPI_Selection& theFromObject,
480 const ModelHighAPI_Double& theFromOffset,
481 const std::list<ModelHighAPI_Selection>& theBooleanObjects)
483 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesPlugin_ExtrusionFuse::ID());
484 return ExtrusionFusePtr(new FeaturesAPI_ExtrusionFuse(aFeature,