Salome HOME
Issue #1343 Improvement of Extrusion and Revolution operations: extrusion cut.
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_CompositeBoolean.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        FeaturesPlugin_CompositeBoolean.cpp
4 // Created:     11 June 2015
5 // Author:      Dmitry Bobylev
6
7 #include "FeaturesPlugin_CompositeBoolean.h"
8
9 #include <ModelAPI_AttributeSelectionList.h>
10 #include <ModelAPI_AttributeReference.h>
11 #include <ModelAPI_ResultBody.h>
12 #include <ModelAPI_ResultConstruction.h>
13 #include <ModelAPI_Session.h>
14 #include <ModelAPI_Tools.h>
15 #include <ModelAPI_Validator.h>
16
17 #include <GeomAlgoAPI_CompoundBuilder.h>
18 #include <GeomAlgoAPI_MakeShapeList.h>
19 #include <GeomAlgoAPI_MakeSweep.h>
20 #include <GeomAlgoAPI_PaveFiller.h>
21 #include <GeomAlgoAPI_Prism.h>
22 #include <GeomAlgoAPI_Revolution.h>
23 #include <GeomAlgoAPI_ShapeTools.h>
24 #include <GeomAPI_ShapeExplorer.h>
25
26 #include <map>
27 #include <sstream>
28
29 //=================================================================================================
30 void FeaturesPlugin_CompositeBoolean::initAttributes()
31 {
32   AttributeSelectionListPtr aSelection = 
33     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
34     LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
35
36   data()->addAttribute(SKETCH_OBJECT_ID(), ModelAPI_AttributeReference::typeId());
37   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
38                                                                SKETCH_OBJECT_ID());
39
40   // Boolean works with solids always.
41   data()->addAttribute(BOOLEAN_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
42   aSelection = data()->selectionList(BOOLEAN_OBJECTS_ID());
43   aSelection->setSelectionType("SOLID");
44
45   initMakeSolidsAttributes();
46
47   data()->addAttribute(SKETCH_SELECTION_ID(), ModelAPI_AttributeSelection::typeId());
48   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SKETCH_SELECTION_ID());
49 }
50
51 //=================================================================================================
52 std::shared_ptr<ModelAPI_Feature> FeaturesPlugin_CompositeBoolean::addFeature(std::string theID)
53 {
54   std::shared_ptr<ModelAPI_Feature> aNew = document()->addFeature(theID, false);
55   if (aNew) {
56     data()->reference(SKETCH_OBJECT_ID())->setValue(aNew);
57   }
58   // set as current also after it becomes sub to set correctly enabled for other sketch subs
59   document()->setCurrentFeature(aNew, false);
60   return aNew;
61 }
62
63 //=================================================================================================
64 int FeaturesPlugin_CompositeBoolean::numberOfSubs(bool forTree) const
65 {
66   ObjectPtr aObj = data()->reference(SKETCH_OBJECT_ID())->value();
67   return aObj.get()? 1 : 0;
68 }
69
70 //=================================================================================================
71 std::shared_ptr<ModelAPI_Feature> FeaturesPlugin_CompositeBoolean::subFeature(const int theIndex, bool forTree)
72 {
73   if (theIndex == 0)
74     return std::dynamic_pointer_cast<ModelAPI_Feature>(data()->reference(SKETCH_OBJECT_ID())->value());
75   return std::shared_ptr<ModelAPI_Feature>();
76 }
77
78 //=================================================================================================
79 int FeaturesPlugin_CompositeBoolean::subFeatureId(const int theIndex) const
80 {
81   if (theIndex == 0) {
82     FeaturePtr aFeature = 
83       std::dynamic_pointer_cast<ModelAPI_Feature>(data()->reference(SKETCH_OBJECT_ID())->value());
84     if (aFeature.get())
85       return aFeature->data()->featureId();
86   }
87   return -1;
88 }
89
90 //=================================================================================================
91 bool FeaturesPlugin_CompositeBoolean::isSub(ObjectPtr theObject) const
92 {
93   // check is this feature of result
94   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
95   if (!aFeature)
96     return false;
97  
98   ObjectPtr aSub = data()->reference(SKETCH_OBJECT_ID())->value();
99   return aSub == theObject;
100 }
101
102 //=================================================================================================
103 void FeaturesPlugin_CompositeBoolean::removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature)
104 {
105   AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID());
106   if (aFacesSelectionList.get() && aFacesSelectionList->size() > 0)
107     aFacesSelectionList->clear();
108 }
109
110 //=================================================================================================
111 void FeaturesPlugin_CompositeBoolean::erase()
112 {
113   if (data().get() && data()->isValid()) { // on abort of sketch of this composite it may be invalid
114     FeaturePtr aSketch =
115       std::dynamic_pointer_cast<ModelAPI_Feature>(data()->reference(SKETCH_OBJECT_ID())->value());
116     if (aSketch.get() && aSketch->data()->isValid()) {
117       document()->removeFeature(aSketch);
118     }
119   }
120   ModelAPI_CompositeFeature::erase();
121 }
122
123
124 //=================================================================================================
125 void FeaturesPlugin_CompositeBoolean::execute()
126 {
127   /// feature extrusion does not have the next attribute
128   AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID());
129   if (aFacesSelectionList.get() && !aFacesSelectionList->isInitialized()) {
130     AttributeReferencePtr aSketchAttr = reference(SKETCH_OBJECT_ID());
131     if (aSketchAttr.get() && aSketchAttr->isInitialized())
132       setSketchObjectToList();
133   }
134
135   // Getting faces to create solids.
136   std::shared_ptr<ModelAPI_Feature> aSketchFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(
137                                                      reference(SKETCH_OBJECT_ID())->value());
138   if(!aSketchFeature || aSketchFeature->results().empty()) {
139     return;
140   }
141   ResultPtr aSketchRes = aSketchFeature->results().front();
142   ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSketchRes);
143   if(!aConstruction.get()) {
144     return;
145   }
146   selection(SKETCH_SELECTION_ID())->setValue(aSketchRes, std::shared_ptr<GeomAPI_Shape>());
147   int aSketchFacesNum = aConstruction->facesNum();
148   if(aSketchFacesNum == 0) {
149     return;
150   }
151   ListOfShape aFacesList;
152   for(int aFaceIndex = 0; aFaceIndex < aSketchFacesNum; aFaceIndex++) {
153     std::shared_ptr<GeomAPI_Shape> aFace = std::dynamic_pointer_cast<GeomAPI_Shape>(aConstruction->face(aFaceIndex));
154     aFacesList.push_back(aFace);
155   }
156
157   // Searching faces with common edges.
158   ListOfShape aShells;
159   ListOfShape aFreeFaces;
160   std::shared_ptr<GeomAPI_Shape> aFacesCompound = GeomAlgoAPI_CompoundBuilder::compound(aFacesList);
161   GeomAlgoAPI_ShapeTools::combineShapes(aFacesCompound, GeomAPI_Shape::SHELL, aShells, aFreeFaces);
162   aShells.insert(aShells.end(), aFreeFaces.begin(), aFreeFaces.end());
163
164   // Pass shells/faces to solids creation function.
165   ListOfShape aTools;
166   ListOfMakeShape aSolidsAlgos;
167   makeSolids(aShells, aTools, aSolidsAlgos);
168   if(aTools.empty()) {
169     return;
170   }
171
172   // Getting objects for boolean operation.
173   ListOfShape anObjects;
174   std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape> aCompSolidsObjects;
175   AttributeSelectionListPtr anObjectsSelList = selectionList(BOOLEAN_OBJECTS_ID());
176   if(anObjectsSelList->size() == 0) {
177     return;
178   }
179   for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
180     AttributeSelectionPtr anObjectAttr = anObjectsSelList->value(anObjectsIndex);
181     std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();
182     if(!anObject.get()) {
183       return;
184     }
185     ResultPtr aContext = anObjectAttr->context();
186     ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
187     if(aResCompSolidPtr.get()) {
188       std::shared_ptr<GeomAPI_Shape> aContextShape = aResCompSolidPtr->shape();
189       std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator anIt = aCompSolidsObjects.begin();
190       for(; anIt != aCompSolidsObjects.end(); anIt++) {
191         if(anIt->first->isEqual(aContextShape)) {
192           aCompSolidsObjects[anIt->first].push_back(anObject);
193           break;
194         }
195       }
196       if(anIt == aCompSolidsObjects.end()) {
197         aCompSolidsObjects[aContextShape].push_back(anObject);
198       }
199     } else {
200       anObjects.push_back(anObject);
201     }
202   }
203
204   // Cut from each object solids.
205   int aResultIndex = 0;
206
207   switch(myBooleanOperationType) {
208     case GeomAlgoAPI_Boolean::BOOL_CUT:
209     case GeomAlgoAPI_Boolean::BOOL_COMMON:{
210       // Cut each object with all tools
211       for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++) {
212         std::shared_ptr<GeomAPI_Shape> anObject = *anObjectsIt;
213         ListOfShape aListWithObject;
214         aListWithObject.push_back(anObject);
215         GeomAlgoAPI_Boolean aBoolAlgo(aListWithObject, aTools, myBooleanOperationType);
216
217         // Checking that the algorithm worked properly.
218         if(!aBoolAlgo.isDone() || aBoolAlgo.shape()->isNull() || !aBoolAlgo.isValid()) {
219           setError("Error: Boolean algorithm failed.");
220           return;
221         }
222
223         if(GeomAlgoAPI_ShapeTools::volume(aBoolAlgo.shape()) > 1.e-7) {
224           std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
225           loadNamingDS(aResultBody, aShells, aSolidsAlgos, anObject, aTools, aBoolAlgo.shape(),
226                        aBoolAlgo, *aBoolAlgo.mapOfSubShapes().get());
227           setResult(aResultBody, aResultIndex);
228           aResultIndex++;
229         }
230       }
231
232       // Compsolids handling
233       for(std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator anIt = aCompSolidsObjects.begin();
234         anIt != aCompSolidsObjects.end(); anIt++) {
235         std::shared_ptr<GeomAPI_Shape> aCompSolid = anIt->first;
236         ListOfShape& aUsedInOperationSolids = anIt->second;
237
238         // Collecting solids from compsolids which will not be modified in boolean operation.
239         ListOfShape aNotUsedSolids;
240         for(GeomAPI_ShapeExplorer anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
241           std::shared_ptr<GeomAPI_Shape> aSolidInCompSolid = anExp.current();
242           ListOfShape::iterator anIt = aUsedInOperationSolids.begin();
243           for(; anIt != aUsedInOperationSolids.end(); anIt++) {
244             if(aSolidInCompSolid->isEqual(*anIt)) {
245               break;
246             }
247           }
248           if(anIt == aUsedInOperationSolids.end()) {
249             aNotUsedSolids.push_back(aSolidInCompSolid);
250           }
251         }
252
253         std::shared_ptr<GeomAlgoAPI_Boolean> aBoolAlgo(new GeomAlgoAPI_Boolean(aUsedInOperationSolids, aTools, myBooleanOperationType));
254
255         // Checking that the algorithm worked properly.
256         if(!aBoolAlgo->isDone() || aBoolAlgo->shape()->isNull() || !aBoolAlgo->isValid()) {
257           setError("Error: Boolean algorithm failed.");
258           return;
259         }
260
261         GeomAlgoAPI_MakeShapeList aMakeShapeList;
262         aMakeShapeList.appendAlgo(aBoolAlgo);
263         GeomAPI_DataMapOfShapeShape aMapOfShapes;
264         aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes());
265
266         // Add result to not used solids from compsolid.
267         ListOfShape aShapesToAdd = aNotUsedSolids;
268         aShapesToAdd.push_back(aBoolAlgo->shape());
269         std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
270         if(!aFillerAlgo->isDone()) {
271           std::string aFeatureError = "Error: PaveFiller algorithm failed.";
272           setError(aFeatureError);
273           return;
274         }
275
276         aMakeShapeList.appendAlgo(aFillerAlgo);
277         aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
278
279         if(GeomAlgoAPI_ShapeTools::volume(aFillerAlgo->shape()) > 1.e-7) {
280           std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
281           loadNamingDS(aResultBody, aShells, aSolidsAlgos, aCompSolid, aTools, aFillerAlgo->shape(), aMakeShapeList, aMapOfShapes);
282           setResult(aResultBody, aResultIndex);
283           aResultIndex++;
284         }
285       }
286       break;
287     }
288     case GeomAlgoAPI_Boolean::BOOL_FUSE: {
289       // Collecting all solids which will be fused.
290       ListOfShape aSolidsToFuse;
291       aSolidsToFuse.insert(aSolidsToFuse.end(), anObjects.begin(), anObjects.end());
292       aSolidsToFuse.insert(aSolidsToFuse.end(), aTools.begin(), aTools.end());
293
294       // Collecting solids from compsolids which will not be modified in boolean operation.
295       ListOfShape aNotUsedSolids;
296       for(std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator anIt = aCompSolidsObjects.begin();
297         anIt != aCompSolidsObjects.end(); anIt++) {
298         std::shared_ptr<GeomAPI_Shape> aCompSolid = anIt->first;
299         ListOfShape& aUsedInOperationSolids = anIt->second;
300         aSolidsToFuse.insert(aSolidsToFuse.end(), aUsedInOperationSolids.begin(), aUsedInOperationSolids.end());
301
302         // Collect solids from compsolid which will not be modified in boolean operation.
303         for(GeomAPI_ShapeExplorer anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
304           std::shared_ptr<GeomAPI_Shape> aSolidInCompSolid = anExp.current();
305           ListOfShape::iterator anIt = aUsedInOperationSolids.begin();
306           for(; anIt != aUsedInOperationSolids.end(); anIt++) {
307             if(aSolidInCompSolid->isEqual(*anIt)) {
308               break;
309             }
310           }
311           if(anIt == aUsedInOperationSolids.end()) {
312             aNotUsedSolids.push_back(aSolidInCompSolid);
313           }
314         }
315       }
316
317       ListOfShape anOriginalSolids = aSolidsToFuse;
318       anOriginalSolids.insert(anOriginalSolids.end(), aNotUsedSolids.begin(), aNotUsedSolids.end());
319       GeomAlgoAPI_MakeShapeList aMakeShapeList;
320       GeomAPI_DataMapOfShapeShape aMapOfShapes;
321
322       // If we have compsolids then cut with not used solids all others.
323       if(!aNotUsedSolids.empty()) {
324         aSolidsToFuse.clear();
325         for(ListOfShape::iterator anIt = anOriginalSolids.begin(); anIt != anOriginalSolids.end(); anIt++) {
326           ListOfShape aOneObjectList;
327           aOneObjectList.push_back(*anIt);
328           std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(aOneObjectList, aNotUsedSolids, GeomAlgoAPI_Boolean::BOOL_CUT));
329
330           if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-7) {
331             aSolidsToFuse.push_back(aCutAlgo->shape());
332             aMakeShapeList.appendAlgo(aCutAlgo);
333             aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
334           }
335         }
336       }
337
338       anObjects.clear();
339       anObjects.push_back(aSolidsToFuse.back());
340       aSolidsToFuse.pop_back();
341       aTools = aSolidsToFuse;
342
343       // Fuse all objects and all tools.
344       std::shared_ptr<GeomAlgoAPI_Boolean> aFuseAlgo(new GeomAlgoAPI_Boolean(anObjects, aTools, myBooleanOperationType));
345
346       // Checking that the algorithm worked properly.
347       if(!aFuseAlgo->isDone() || aFuseAlgo->shape()->isNull() || !aFuseAlgo->isValid()) {
348         static const std::string aFeatureError = "Error: Boolean algorithm failed.";
349         setError(aFeatureError);
350         return;
351       }
352
353       std::shared_ptr<GeomAPI_Shape> aShape = aFuseAlgo->shape();
354       aMakeShapeList.appendAlgo(aFuseAlgo);
355       aMapOfShapes.merge(aFuseAlgo->mapOfSubShapes());
356
357       // Add result to not used solids from compsolid (if we have any).
358       if(!aNotUsedSolids.empty()) {
359         aNotUsedSolids.push_back(aShape);
360         std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(new GeomAlgoAPI_PaveFiller(aNotUsedSolids, true));
361         if(!aFillerAlgo->isDone()) {
362           std::string aFeatureError = "Error: PaveFiller algorithm failed.";
363           setError(aFeatureError);
364           return;
365         }
366         if(aFillerAlgo->shape()->isNull()) {
367           static const std::string aShapeError = "Error: Resulting shape is Null.";
368           setError(aShapeError);
369           return;
370         }
371         if(!aFillerAlgo->isValid()) {
372           std::string aFeatureError = "Error: Resulting shape is not valid.";
373           setError(aFeatureError);
374           return;
375         }
376
377         aShape = aFillerAlgo->shape();
378         aMakeShapeList.appendAlgo(aFillerAlgo);
379         aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
380       }
381
382       std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data(), aResultIndex);
383       loadNamingDS(aResultBody, aShells, aSolidsAlgos, anOriginalSolids.front(), anOriginalSolids, aShape, aMakeShapeList, aMapOfShapes);
384       setResult(aResultBody, aResultIndex);
385       aResultIndex++;
386       break;
387     }
388     default: {
389       setError("Error: Wrong type of boolean operation.");
390       return;
391     }
392   }
393
394   // Remove the rest results if there were produced in the previous pass.
395   removeResults(aResultIndex);
396 }
397
398 //=================================================================================================
399 void FeaturesPlugin_CompositeBoolean::loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
400                                                    const ListOfShape& theShells,
401                                                    ListOfMakeShape& theSolidsAlgos,
402                                                    const std::shared_ptr<GeomAPI_Shape> theBaseShape,
403                                                    const ListOfShape& theTools,
404                                                    const std::shared_ptr<GeomAPI_Shape> theResultShape,
405                                                    GeomAlgoAPI_MakeShape& theMakeShape,
406                                                    GeomAPI_DataMapOfShapeShape& theMapOfShapes)
407 {
408   //load result
409   if(theBaseShape->isEqual(theResultShape)) {
410     theResultBody->store(theResultShape);
411   } else {
412     const int aGenTag = 1;
413     const int aModTag = 2;
414     const int aDelTag = 3;
415     const int aSubsolidsTag=4; /// sub solids will be placed at labels 6, 7, etc. if result is compound of solids
416     int aToTag = 5000; // may be many labels, starting from this index
417     int aFromTag = 10000; // may be many labels, starting from this index or last aToTag index
418     const std::string aGenName = "Generated";
419     const std::string aModName = "Modified";
420     const std::string aLatName = "LateralFace";
421     const std::string aFromName = "FromFace";
422     const std::string aToName = "ToFace";
423
424     theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
425
426     ListOfShape::const_iterator aShellsIter = theShells.begin();
427     ListOfMakeShape::const_iterator aSolidsAlgosIter = theSolidsAlgos.begin();
428     for(; aShellsIter != theShells.end() && aSolidsAlgosIter != theSolidsAlgos.end(); aShellsIter++, aSolidsAlgosIter++) {
429       //Insert lateral face : Face from Edge
430       std::shared_ptr<GeomAlgoAPI_MakeShape> aSolidAlgo = std::dynamic_pointer_cast<GeomAlgoAPI_MakeShape>(*aSolidsAlgosIter);
431       if(aSolidAlgo.get()) {
432         std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = aSolidAlgo->mapOfSubShapes();
433         theResultBody->loadAndOrientGeneratedShapes(aSolidAlgo.get(), *aShellsIter, GeomAPI_Shape::EDGE, aGenTag,
434                                                     aLatName, *aSubShapes.get());
435
436
437         std::shared_ptr<GeomAlgoAPI_MakeSweep> aSweepAlgo = std::dynamic_pointer_cast<GeomAlgoAPI_MakeSweep>(aSolidAlgo);
438         if(aSweepAlgo.get()) {
439           //Insert to faces
440           int aToFaceIndex = 1;
441           const ListOfShape& aToFaces = aSweepAlgo->toShapes();
442           for(ListOfShape::const_iterator anIt = aToFaces.cbegin(); anIt != aToFaces.cend(); anIt++) {
443             std::shared_ptr<GeomAPI_Shape> aToFace = *anIt;
444             if(aSubShapes->isBound(aToFace)) {
445               aToFace = aSubShapes->find(aToFace);
446             }
447             std::ostringstream aStr;
448             aStr << aToName << "_" << aToFaceIndex++;
449             theResultBody->generated(aToFace, aStr.str(), aToTag++);
450           }
451
452           //Insert from faces
453           int aFromFaceIndex = 1;
454           const ListOfShape& aFromFaces = aSweepAlgo->fromShapes();
455           if (aFromTag < aToTag) aFromTag = aToTag;
456           for(ListOfShape::const_iterator anIt = aFromFaces.cbegin(); anIt != aFromFaces.cend(); anIt++) {
457             std::shared_ptr<GeomAPI_Shape> aFromFace = *anIt;
458             if(aSubShapes->isBound(aFromFace)) {
459               aFromFace = aSubShapes->find(aFromFace);
460             }
461             std::ostringstream aStr;
462             aStr << aFromName << "_" << aFromFaceIndex++;
463             theResultBody->generated(aFromFace, aStr.str(), aFromTag++);
464           }
465         }
466       }
467     }
468
469     theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
470                                                aModTag, aModName, theMapOfShapes);
471     theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, aDelTag);
472
473     for(ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) {
474       theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE,
475                                                  aModTag, aModName, theMapOfShapes);
476       theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDelTag);
477     }
478   }
479 }
480
481 //=================================================================================================
482 void FeaturesPlugin_CompositeBoolean::setSketchObjectToList()
483 {
484   std::shared_ptr<ModelAPI_Feature> aSketchFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(
485                                                        reference(SKETCH_OBJECT_ID())->value());
486
487   if(aSketchFeature.get() && !aSketchFeature->results().empty()) {
488     ResultPtr aSketchRes = aSketchFeature->results().front();
489     ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSketchRes);
490     if(aConstruction.get()) {
491       AttributeSelectionListPtr aFacesSelectionList = selectionList(LIST_ID());
492       if (aFacesSelectionList.get() && aFacesSelectionList->size() == 0)
493         aFacesSelectionList->append(aSketchRes, std::shared_ptr<GeomAPI_Shape>());
494     }
495   }
496 }