1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: FeaturesPlugin_Boolean.cpp
4 // Created: 02 Sept 2014
5 // Author: Vitaly SMETANNIKOV
7 #include "FeaturesPlugin_Boolean.h"
9 #include <ModelAPI_Data.h>
10 #include <ModelAPI_Document.h>
11 #include <ModelAPI_AttributeReference.h>
12 #include <ModelAPI_AttributeInteger.h>
13 #include <ModelAPI_ResultCompSolid.h>
14 #include <ModelAPI_ResultBody.h>
15 #include <ModelAPI_AttributeSelectionList.h>
16 #include <ModelAPI_Session.h>
17 #include <ModelAPI_Validator.h>
18 #include <ModelAPI_Tools.h>
20 #include <GeomAlgoAPI_Boolean.h>
21 #include <GeomAlgoAPI_MakeShapeList.h>
22 #include <GeomAlgoAPI_Partition.h>
23 #include <GeomAlgoAPI_PaveFiller.h>
24 #include <GeomAlgoAPI_ShapeTools.h>
25 #include <GeomAPI_ShapeExplorer.h>
26 #include <GeomAPI_ShapeIterator.h>
31 //=================================================================================================
32 FeaturesPlugin_Boolean::FeaturesPlugin_Boolean()
36 //=================================================================================================
37 void FeaturesPlugin_Boolean::initAttributes()
39 data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::typeId());
41 AttributeSelectionListPtr aSelection =
42 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
43 FeaturesPlugin_Boolean::OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
45 aSelection = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
46 FeaturesPlugin_Boolean::TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
48 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), OBJECT_LIST_ID());
49 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TOOL_LIST_ID());
52 //=================================================================================================
53 std::shared_ptr<GeomAPI_Shape> FeaturesPlugin_Boolean::getShape(const std::string& theAttrName)
55 std::shared_ptr<ModelAPI_AttributeReference> aObjRef = std::dynamic_pointer_cast<
56 ModelAPI_AttributeReference>(data()->attribute(theAttrName));
58 std::shared_ptr<ModelAPI_ResultBody> aConstr = std::dynamic_pointer_cast<
59 ModelAPI_ResultBody>(aObjRef->value());
61 return aConstr->shape();
63 return std::shared_ptr<GeomAPI_Shape>();
66 //=================================================================================================
67 void FeaturesPlugin_Boolean::execute()
69 // Getting operation type.
70 std::shared_ptr<ModelAPI_AttributeInteger> aTypeAttr = std::dynamic_pointer_cast<
71 ModelAPI_AttributeInteger>(data()->attribute(FeaturesPlugin_Boolean::TYPE_ID()));
74 OperationType aType = (FeaturesPlugin_Boolean::OperationType)aTypeAttr->value();
76 ListOfShape anObjects, aTools, anEdgesAndFaces;
77 std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape> aCompSolidsObjects;
80 AttributeSelectionListPtr anObjectsSelList =
81 selectionList(FeaturesPlugin_Boolean::OBJECT_LIST_ID());
82 for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
83 AttributeSelectionPtr anObjectAttr = anObjectsSelList->value(anObjectsIndex);
84 std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();
88 ResultPtr aContext = anObjectAttr->context();
89 ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
90 if(aResCompSolidPtr.get()) {
91 std::shared_ptr<GeomAPI_Shape> aContextShape = aResCompSolidPtr->shape();
92 std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator
93 anIt = aCompSolidsObjects.begin();
94 for(; anIt != aCompSolidsObjects.end(); anIt++) {
95 if(anIt->first->isEqual(aContextShape)) {
96 aCompSolidsObjects[anIt->first].push_back(anObject);
100 if(anIt == aCompSolidsObjects.end()) {
101 aCompSolidsObjects[aContextShape].push_back(anObject);
104 if(anObject->shapeType() == GeomAPI_Shape::EDGE ||
105 anObject->shapeType() == GeomAPI_Shape::FACE) {
106 anEdgesAndFaces.push_back(anObject);
108 anObjects.push_back(anObject);
114 AttributeSelectionListPtr aToolsSelList = selectionList(FeaturesPlugin_Boolean::TOOL_LIST_ID());
115 for(int aToolsIndex = 0; aToolsIndex < aToolsSelList->size(); aToolsIndex++) {
116 AttributeSelectionPtr aToolAttr = aToolsSelList->value(aToolsIndex);
117 std::shared_ptr<GeomAPI_Shape> aTool = aToolAttr->value();
121 if(aTool->shapeType() == GeomAPI_Shape::EDGE ||
122 aTool->shapeType() == GeomAPI_Shape::FACE) {
123 anEdgesAndFaces.push_back(aTool);
125 aTools.push_back(aTool);
129 int aResultIndex = 0;
135 if((anObjects.empty() && aCompSolidsObjects.empty()) || aTools.empty()) {
136 std::string aFeatureError = "Error: Not enough objects for boolean operation.";
137 setError(aFeatureError);
141 // For solids cut each object with all tools.
142 for(ListOfShape::iterator
143 anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++) {
144 std::shared_ptr<GeomAPI_Shape> anObject = *anObjectsIt;
145 ListOfShape aListWithObject;
146 aListWithObject.push_back(anObject);
147 GeomAlgoAPI_MakeShape aBoolAlgo;
148 GeomShapePtr aResShape;
153 GeomAlgoAPI_Boolean(aListWithObject, aTools, GeomAlgoAPI_Boolean::BOOL_CUT);
154 aResShape = aBoolAlgo.shape();
159 GeomAlgoAPI_Boolean(aListWithObject, aTools, GeomAlgoAPI_Boolean::BOOL_COMMON);
160 aResShape = aBoolAlgo.shape();
164 aBoolAlgo = GeomAlgoAPI_Partition(aListWithObject, aTools);
165 aResShape = aBoolAlgo.shape();
166 if(aResShape->shapeType() == GeomAPI_Shape::COMPOUND) {
167 int aSubResultsNb = 0;
168 GeomAPI_ShapeIterator anIt(aResShape);
169 for(; anIt.more(); anIt.next()) {
172 if(aSubResultsNb == 1) {
173 anIt.init(aResShape);
175 aResShape = anIt.current();
183 // Checking that the algorithm worked properly.
184 if(!aBoolAlgo.isDone()) {
185 static const std::string aFeatureError = "Error: Boolean algorithm failed.";
186 setError(aFeatureError);
189 if(aResShape->isNull()) {
190 static const std::string aShapeError = "Error: Resulting shape is Null.";
191 setError(aShapeError);
194 if(!aBoolAlgo.isValid()) {
195 std::string aFeatureError = "Error: Resulting shape is not valid.";
196 setError(aFeatureError);
200 if(GeomAlgoAPI_ShapeTools::volume(aResShape) > 1.e-27) {
201 std::shared_ptr<ModelAPI_ResultBody> aResultBody =
202 document()->createBody(data(), aResultIndex);
203 loadNamingDS(aResultBody, anObject, aTools, aResShape,
204 aBoolAlgo, *aBoolAlgo.mapOfSubShapes().get());
205 setResult(aResultBody, aResultIndex);
210 // Compsolids handling
211 for(std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator
212 anIt = aCompSolidsObjects.begin();
213 anIt != aCompSolidsObjects.end(); anIt++) {
214 std::shared_ptr<GeomAPI_Shape> aCompSolid = anIt->first;
215 ListOfShape& aUsedInOperationSolids = anIt->second;
217 // Collecting solids from compsolids which will not be modified in boolean operation.
218 ListOfShape aNotUsedSolids;
219 for(GeomAPI_ShapeExplorer
220 anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
221 std::shared_ptr<GeomAPI_Shape> aSolidInCompSolid = anExp.current();
222 ListOfShape::iterator anIt = aUsedInOperationSolids.begin();
223 for(; anIt != aUsedInOperationSolids.end(); anIt++) {
224 if(aSolidInCompSolid->isEqual(*anIt)) {
228 if(anIt == aUsedInOperationSolids.end()) {
229 aNotUsedSolids.push_back(aSolidInCompSolid);
233 std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
237 aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aUsedInOperationSolids,
239 GeomAlgoAPI_Boolean::BOOL_CUT));
243 aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aUsedInOperationSolids,
245 GeomAlgoAPI_Boolean::BOOL_COMMON));
249 aBoolAlgo.reset(new GeomAlgoAPI_Partition(aUsedInOperationSolids, aTools));
254 // Checking that the algorithm worked properly.
255 if(!aBoolAlgo->isDone()) {
256 static const std::string aFeatureError = "Error: Boolean algorithm failed.";
257 setError(aFeatureError);
260 if(aBoolAlgo->shape()->isNull()) {
261 static const std::string aShapeError = "Error: Resulting shape is Null.";
262 setError(aShapeError);
265 if(!aBoolAlgo->isValid()) {
266 std::string aFeatureError = "Error: Resulting shape is not valid.";
267 setError(aFeatureError);
271 GeomAlgoAPI_MakeShapeList aMakeShapeList;
272 aMakeShapeList.appendAlgo(aBoolAlgo);
273 GeomAPI_DataMapOfShapeShape aMapOfShapes;
274 aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes());
275 GeomShapePtr aResultShape = aBoolAlgo->shape();
277 // Add result to not used solids from compsolid.
278 if(!aNotUsedSolids.empty()) {
279 ListOfShape aShapesToAdd = aNotUsedSolids;
280 aShapesToAdd.push_back(aBoolAlgo->shape());
281 std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
282 new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
283 if(!aFillerAlgo->isDone()) {
284 std::string aFeatureError = "Error: PaveFiller algorithm failed.";
285 setError(aFeatureError);
289 aMakeShapeList.appendAlgo(aFillerAlgo);
290 aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
291 aResultShape = aFillerAlgo->shape();
294 if(GeomAlgoAPI_ShapeTools::volume(aResultShape) > 1.e-27) {
295 std::shared_ptr<ModelAPI_ResultBody> aResultBody =
296 document()->createBody(data(), aResultIndex);
297 loadNamingDS(aResultBody, aCompSolid, aTools, aResultShape, aMakeShapeList, aMapOfShapes);
298 setResult(aResultBody, aResultIndex);
305 if((anObjects.size() + aTools.size() +
306 aCompSolidsObjects.size() + anEdgesAndFaces.size()) < 2) {
307 std::string aFeatureError = "Error: Not enough objects for boolean operation.";
308 setError(aFeatureError);
312 // Collecting all solids which will be fused.
313 ListOfShape aSolidsToFuse;
314 aSolidsToFuse.insert(aSolidsToFuse.end(), anObjects.begin(), anObjects.end());
315 aSolidsToFuse.insert(aSolidsToFuse.end(), aTools.begin(), aTools.end());
317 // Collecting solids from compsolids which will not be modified
318 // in boolean operation and will be added to result.
319 ListOfShape aShapesToAdd;
320 for(std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator
321 anIt = aCompSolidsObjects.begin();
322 anIt != aCompSolidsObjects.end(); anIt++) {
323 std::shared_ptr<GeomAPI_Shape> aCompSolid = anIt->first;
324 ListOfShape& aUsedInOperationSolids = anIt->second;
325 aSolidsToFuse.insert(aSolidsToFuse.end(), aUsedInOperationSolids.begin(),
326 aUsedInOperationSolids.end());
328 // Collect solids from compsolid which will not be modified in boolean operation.
329 for(GeomAPI_ShapeExplorer
330 anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
331 std::shared_ptr<GeomAPI_Shape> aSolidInCompSolid = anExp.current();
332 ListOfShape::iterator anIt = aUsedInOperationSolids.begin();
333 for(; anIt != aUsedInOperationSolids.end(); anIt++) {
334 if(aSolidInCompSolid->isEqual(*anIt)) {
338 if(anIt == aUsedInOperationSolids.end()) {
339 aShapesToAdd.push_back(aSolidInCompSolid);
344 ListOfShape anOriginalShapes = aSolidsToFuse;
345 anOriginalShapes.insert(anOriginalShapes.end(), aShapesToAdd.begin(), aShapesToAdd.end());
347 // Cut edges and faces(if we have any) with solids.
348 GeomAlgoAPI_MakeShapeList aMakeShapeList;
349 GeomAPI_DataMapOfShapeShape aMapOfShapes;
350 std::shared_ptr<GeomAPI_Shape> aCuttedEdgesAndFaces;
351 if(!anEdgesAndFaces.empty()) {
352 std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(new GeomAlgoAPI_Boolean(anEdgesAndFaces,
353 anOriginalShapes, GeomAlgoAPI_Boolean::BOOL_CUT));
354 if(aCutAlgo->isDone()) {
355 aCuttedEdgesAndFaces = aCutAlgo->shape();
356 aMakeShapeList.appendAlgo(aCutAlgo);
357 aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
360 anOriginalShapes.insert(anOriginalShapes.end(), anEdgesAndFaces.begin(),
361 anEdgesAndFaces.end());
363 // If we have compsolids then cut with not used solids all others.
364 if(!aShapesToAdd.empty()) {
365 aSolidsToFuse.clear();
366 for(ListOfShape::iterator
367 anIt = anOriginalShapes.begin(); anIt != anOriginalShapes.end(); anIt++) {
368 ListOfShape aOneObjectList;
369 aOneObjectList.push_back(*anIt);
370 std::shared_ptr<GeomAlgoAPI_Boolean> aCutAlgo(
371 new GeomAlgoAPI_Boolean(aOneObjectList, aShapesToAdd, GeomAlgoAPI_Boolean::BOOL_CUT));
373 if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-27) {
374 aSolidsToFuse.push_back(aCutAlgo->shape());
375 aMakeShapeList.appendAlgo(aCutAlgo);
376 aMapOfShapes.merge(aCutAlgo->mapOfSubShapes());
381 if(!aSolidsToFuse.empty()) {
383 anObjects.push_back(aSolidsToFuse.back());
384 aSolidsToFuse.pop_back();
385 aTools = aSolidsToFuse;
388 // Fuse all objects and all tools.
389 std::shared_ptr<GeomAPI_Shape> aShape;
390 if(anObjects.size() == 1 && aTools.empty()) {
391 aShape = anObjects.front();
392 } else if(anObjects.empty() && aTools.size() == 1) {
393 aShape = aTools.front();
394 } else if((anObjects.size() + aTools.size()) > 1){
395 std::shared_ptr<GeomAlgoAPI_Boolean> aFuseAlgo(new GeomAlgoAPI_Boolean(anObjects,
397 GeomAlgoAPI_Boolean::BOOL_FUSE));
399 // Checking that the algorithm worked properly.
400 if(!aFuseAlgo->isDone()) {
401 static const std::string aFeatureError = "Error: Boolean algorithm failed.";
402 setError(aFeatureError);
405 if(aFuseAlgo->shape()->isNull()) {
406 static const std::string aShapeError = "Error: Resulting shape is Null.";
407 setError(aShapeError);
410 if(!aFuseAlgo->isValid()) {
411 std::string aFeatureError = "Error: Resulting shape is not valid.";
412 setError(aFeatureError);
416 aShape = aFuseAlgo->shape();
417 aMakeShapeList.appendAlgo(aFuseAlgo);
418 aMapOfShapes.merge(aFuseAlgo->mapOfSubShapes());
421 // Combine result with not used solids from compsolid and edges and faces (if we have any).
422 if(aCuttedEdgesAndFaces.get() && !aCuttedEdgesAndFaces->isNull()) {
423 aShapesToAdd.push_back(aCuttedEdgesAndFaces);
425 aShapesToAdd.insert(aShapesToAdd.end(), anEdgesAndFaces.begin(), anEdgesAndFaces.end());
427 if(!aShapesToAdd.empty()) {
429 aShapesToAdd.push_back(aShape);
431 std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
432 new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
433 if(!aFillerAlgo->isDone()) {
434 std::string aFeatureError = "Error: PaveFiller algorithm failed.";
435 setError(aFeatureError);
438 if(aFillerAlgo->shape()->isNull()) {
439 static const std::string aShapeError = "Error: Resulting shape is Null.";
440 setError(aShapeError);
443 if(!aFillerAlgo->isValid()) {
444 std::string aFeatureError = "Error: Resulting shape is not valid.";
445 setError(aFeatureError);
449 aShape = aFillerAlgo->shape();
450 aMakeShapeList.appendAlgo(aFillerAlgo);
451 aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
454 std::shared_ptr<GeomAPI_Shape> aBackShape = anOriginalShapes.back();
455 anOriginalShapes.pop_back();
456 std::shared_ptr<ModelAPI_ResultBody> aResultBody =
457 document()->createBody(data(), aResultIndex);
458 loadNamingDS(aResultBody, aBackShape, anOriginalShapes,
459 aShape, aMakeShapeList, aMapOfShapes);
460 setResult(aResultBody, aResultIndex);
465 if((anObjects.empty() && aCompSolidsObjects.empty()) || aTools.empty()) {
466 std::string aFeatureError = "Error: Not enough objects for boolean operation.";
467 setError(aFeatureError);
471 // List of original solids for naming.
472 ListOfShape anOriginalShapes;
473 anOriginalShapes.insert(anOriginalShapes.end(), anObjects.begin(), anObjects.end());
474 anOriginalShapes.insert(anOriginalShapes.end(), aTools.begin(), aTools.end());
476 // Collecting all solids which will be smashed.
477 ListOfShape aShapesToSmash;
478 aShapesToSmash.insert(aShapesToSmash.end(), anObjects.begin(), anObjects.end());
480 // Collecting solids from compsolids which will not be modified in
481 // boolean operation and will be added to result.
482 ListOfShape aShapesToAdd;
483 for(std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator
484 anIt = aCompSolidsObjects.begin();
485 anIt != aCompSolidsObjects.end(); anIt++) {
486 std::shared_ptr<GeomAPI_Shape> aCompSolid = anIt->first;
487 ListOfShape& aUsedInOperationSolids = anIt->second;
488 anOriginalShapes.push_back(aCompSolid);
489 aShapesToSmash.insert(aShapesToSmash.end(), aUsedInOperationSolids.begin(),
490 aUsedInOperationSolids.end());
492 // Collect solids from compsolid which will not be modified in boolean operation.
493 for(GeomAPI_ShapeExplorer
494 anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
495 std::shared_ptr<GeomAPI_Shape> aSolidInCompSolid = anExp.current();
496 ListOfShape::iterator anIt = aUsedInOperationSolids.begin();
497 for(; anIt != aUsedInOperationSolids.end(); anIt++) {
498 if(aSolidInCompSolid->isEqual(*anIt)) {
502 if(anIt == aUsedInOperationSolids.end()) {
503 aShapesToAdd.push_back(aSolidInCompSolid);
508 GeomAlgoAPI_MakeShapeList aMakeShapeList;
509 GeomAPI_DataMapOfShapeShape aMapOfShapes;
510 if(!aShapesToAdd.empty()) {
511 // Cut objects with not used solids.
512 std::shared_ptr<GeomAlgoAPI_Boolean> anObjectsCutAlgo(new GeomAlgoAPI_Boolean(
515 GeomAlgoAPI_Boolean::BOOL_CUT));
517 if(GeomAlgoAPI_ShapeTools::volume(anObjectsCutAlgo->shape()) > 1.e-27) {
518 aShapesToSmash.clear();
519 aShapesToSmash.push_back(anObjectsCutAlgo->shape());
520 aMakeShapeList.appendAlgo(anObjectsCutAlgo);
521 aMapOfShapes.merge(anObjectsCutAlgo->mapOfSubShapes());
524 // Cut tools with not used solids.
525 std::shared_ptr<GeomAlgoAPI_Boolean> aToolsCutAlgo(new GeomAlgoAPI_Boolean(aTools,
527 GeomAlgoAPI_Boolean::BOOL_CUT));
529 if(GeomAlgoAPI_ShapeTools::volume(aToolsCutAlgo->shape()) > 1.e-27) {
531 aTools.push_back(aToolsCutAlgo->shape());
532 aMakeShapeList.appendAlgo(aToolsCutAlgo);
533 aMapOfShapes.merge(aToolsCutAlgo->mapOfSubShapes());
537 // Cut objects with tools.
538 std::shared_ptr<GeomAlgoAPI_Boolean> aBoolAlgo(new GeomAlgoAPI_Boolean(aShapesToSmash,
540 GeomAlgoAPI_Boolean::BOOL_CUT));
542 // Checking that the algorithm worked properly.
543 if(!aBoolAlgo->isDone()) {
544 static const std::string aFeatureError = "Error: Boolean algorithm failed.";
545 setError(aFeatureError);
548 if(aBoolAlgo->shape()->isNull()) {
549 static const std::string aShapeError = "Error: Resulting shape is Null.";
550 setError(aShapeError);
553 if(!aBoolAlgo->isValid()) {
554 std::string aFeatureError = "Error: Resulting shape is not valid.";
555 setError(aFeatureError);
558 aMakeShapeList.appendAlgo(aBoolAlgo);
559 aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes());
561 // Put all (cut result, tools and not used solids) to PaveFiller.
562 aShapesToAdd.push_back(aBoolAlgo->shape());
563 aShapesToAdd.insert(aShapesToAdd.end(), aTools.begin(), aTools.end());
565 std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(new GeomAlgoAPI_PaveFiller(aShapesToAdd,
567 if(!aFillerAlgo->isDone()) {
568 std::string aFeatureError = "Error: PaveFiller algorithm failed.";
569 setError(aFeatureError);
572 if(aFillerAlgo->shape()->isNull()) {
573 static const std::string aShapeError = "Error: Resulting shape is Null.";
574 setError(aShapeError);
577 if(!aFillerAlgo->isValid()) {
578 std::string aFeatureError = "Error: Resulting shape is not valid.";
579 setError(aFeatureError);
583 std::shared_ptr<GeomAPI_Shape> aShape = aFillerAlgo->shape();
584 aMakeShapeList.appendAlgo(aFillerAlgo);
585 aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes());
587 std::shared_ptr<GeomAPI_Shape> aFrontShape = anOriginalShapes.front();
588 anOriginalShapes.pop_front();
589 std::shared_ptr<ModelAPI_ResultBody> aResultBody =
590 document()->createBody(data(), aResultIndex);
591 loadNamingDS(aResultBody, aFrontShape, anOriginalShapes,
592 aShape, aMakeShapeList, aMapOfShapes);
593 setResult(aResultBody, aResultIndex);
599 std::string anOperationError = "Error: Wrong type of operation";
600 setError(anOperationError);
604 // remove the rest results if there were produced in the previous pass
605 removeResults(aResultIndex);
608 //=================================================================================================
609 void FeaturesPlugin_Boolean::loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
610 const std::shared_ptr<GeomAPI_Shape> theBaseShape,
611 const ListOfShape& theTools,
612 const std::shared_ptr<GeomAPI_Shape> theResultShape,
613 GeomAlgoAPI_MakeShape& theMakeShape,
614 GeomAPI_DataMapOfShapeShape& theMapOfShapes)
617 if(theBaseShape->isEqual(theResultShape)) {
618 theResultBody->store(theResultShape);
620 const int aModifyTag = 1;
621 const int aDeletedTag = 2;
622 /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids
623 const int aSubsolidsTag = 3;
624 const int anEdgesAndFacesTag = 10000;
626 theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
628 const std::string aModName = "Modified";
629 const std::string aModEName = "Modified_Edge";
630 const std::string aModFName = "Modified_Face";
632 theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE,
633 aModifyTag, aModName, theMapOfShapes);
634 theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape,
635 GeomAPI_Shape::FACE, aDeletedTag);
639 for(ListOfShape::const_iterator
640 anIter = theTools.begin(); anIter != theTools.end(); anIter++) {
641 if((*anIter)->shapeType() == GeomAPI_Shape::EDGE) {
642 aTag = anEdgesAndFacesTag;
645 else if((*anIter)->shapeType() == GeomAPI_Shape::FACE) {
646 aTag = anEdgesAndFacesTag;
652 theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter,
653 aName == aModEName ? GeomAPI_Shape::EDGE : GeomAPI_Shape::FACE,
654 aTag, aName, theMapOfShapes);
655 theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag);