1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "FeaturesPlugin_VersionedBoolean.h"
22 #include <ModelAPI_Data.h>
23 #include <ModelAPI_Document.h>
24 #include <ModelAPI_AttributeReference.h>
25 #include <ModelAPI_AttributeInteger.h>
26 #include <ModelAPI_ResultBody.h>
27 #include <ModelAPI_AttributeSelectionList.h>
28 #include <ModelAPI_Session.h>
29 #include <ModelAPI_Validator.h>
30 #include <ModelAPI_Tools.h>
32 #include <GeomAlgoAPI_Boolean.h>
33 #include <GeomAlgoAPI_CompoundBuilder.h>
34 #include <GeomAlgoAPI_MakeShapeCustom.h>
35 #include <GeomAlgoAPI_MakeShapeList.h>
36 #include <GeomAlgoAPI_Partition.h>
37 #include <GeomAlgoAPI_PaveFiller.h>
38 #include <GeomAlgoAPI_ShapeBuilder.h>
39 #include <GeomAlgoAPI_ShapeTools.h>
40 #include <GeomAlgoAPI_Tools.h>
41 #include <GeomAlgoAPI_UnifySameDomain.h>
42 #include <GeomAPI_Face.h>
43 #include <GeomAPI_ShapeExplorer.h>
44 #include <GeomAPI_ShapeIterator.h>
49 static void performBoolean(const GeomAlgoAPI_Tools::BOPType theBooleanType,
50 GeomMakeShapePtr& theBooleanAlgo,
51 const ListOfShape& theObjects,
52 const ListOfShape& theTools)
54 if (theBooleanType == GeomAlgoAPI_Tools::BOOL_PARTITION)
55 theBooleanAlgo.reset(new GeomAlgoAPI_Partition(theObjects, theTools));
57 // separate processing of FUSE, if only objects are given
58 if (theBooleanType == GeomAlgoAPI_Tools::BOOL_FUSE && theTools.empty()) {
59 if (theObjects.front()->shapeType() == GeomAPI_Shape::FACE)
60 theBooleanAlgo.reset(new GeomAlgoAPI_UnifySameDomain(theObjects));
62 ListOfShape anObjects = theObjects;
64 aTools.splice(aTools.begin(), anObjects, anObjects.begin());
65 theBooleanAlgo.reset(new GeomAlgoAPI_Boolean(anObjects, aTools, theBooleanType));
69 theBooleanAlgo.reset(new GeomAlgoAPI_Boolean(theObjects, theTools, theBooleanType));
73 //=================================================================================================
74 void FeaturesPlugin_VersionedBoolean::initVersion(const std::string& theVersion,
75 const AttributePtr theObjectsAttr,
76 const AttributePtr theToolsAttr)
78 AttributeIntegerPtr anOldVersionAttr = integer("version");
79 if (anOldVersionAttr && anOldVersionAttr->isInitialized() && data()->version().empty()) {
80 // move value to the common version interface in ModelAPI_Data
81 data()->setVersion(BOP_VERSION_9_4());
83 else if ((!theObjectsAttr || !theObjectsAttr->isInitialized()) &&
84 (!theToolsAttr || !theToolsAttr->isInitialized())) {
85 // this is a newly created feature (not read from file),
86 // so, initialize the latest version
87 data()->setVersion(theVersion);
91 //=================================================================================================
92 void FeaturesPlugin_VersionedBoolean::parentForShape(const GeomShapePtr& theShape,
93 const ResultPtr& theContext,
94 ObjectHierarchy& theShapesHierarchy)
96 ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(theContext);
97 if (aResCompSolidPtr.get()) {
98 std::shared_ptr<GeomAPI_Shape> aContextShape = aResCompSolidPtr->shape();
99 if (aContextShape->shapeType() <= GeomAPI_Shape::COMPSOLID) {
100 theShapesHierarchy.AddParent(theShape, aContextShape);
101 parentForShape(aContextShape, aResCompSolidPtr, theShapesHierarchy);
106 bool FeaturesPlugin_VersionedBoolean::processAttribute(const std::string& theAttributeName,
107 ObjectHierarchy& theObjects,
108 ListOfShape& thePlanesList)
110 AttributeSelectionListPtr anObjectsSelList = selectionList(theAttributeName);
111 for (int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
112 AttributeSelectionPtr anObjectAttr = anObjectsSelList->value(anObjectsIndex);
113 GeomShapePtr anObject = anObjectAttr->value();
114 if (!anObject.get()) {
115 // It could be a construction plane.
116 ResultPtr aContext = anObjectAttr->context();
117 anObject = anObjectAttr->context()->shape();
118 if (anObject.get()) {
119 thePlanesList.push_back(anObject);
125 theObjects.AddObject(anObject);
127 ResultPtr aContext = anObjectAttr->context();
128 parentForShape(anObject, aContext, theObjects);
133 //=================================================================================================
134 bool FeaturesPlugin_VersionedBoolean::processObject(
135 const GeomAlgoAPI_Tools::BOPType theBooleanType,
136 const GeomShapePtr& theObject,
137 const ListOfShape& theTools,
138 const ListOfShape& thePlanes,
140 std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
141 ListOfShape& theResultShapesList,
142 GeomShapePtr theResultCompound)
144 ListOfShape aListWithObject;
145 aListWithObject.push_back(theObject);
146 std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
147 std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
148 GeomShapePtr aResShape;
151 ListOfShape aToolsWithPlanes = theTools;
152 ListOfShape aPlanesCopy = thePlanes;
153 resizePlanes(aListWithObject, aPlanesCopy, aMakeShapeList);
154 aToolsWithPlanes.insert(aToolsWithPlanes.end(), aPlanesCopy.begin(), aPlanesCopy.end());
156 if (theBooleanType == GeomAlgoAPI_Tools::BOOL_PARTITION)
157 aBoolAlgo.reset(new GeomAlgoAPI_Partition(aListWithObject, aToolsWithPlanes));
159 aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aListWithObject,
163 // Checking that the algorithm worked properly.
165 if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
170 aResShape = aBoolAlgo->shape();
171 if (aResShape.get() && aResShape->shapeType() == GeomAPI_Shape::COMPOUND) {
172 int aSubResultsNb = 0;
173 GeomAPI_ShapeIterator anIt(aResShape);
174 for (; anIt.more(); anIt.next())
177 if (aSubResultsNb == 1) {
178 anIt.init(aResShape);
180 aResShape = anIt.current();
184 aMakeShapeList->appendAlgo(aBoolAlgo);
186 GeomAPI_ShapeIterator aShapeIt(aResShape);
187 if (aShapeIt.more() || aResShape->shapeType() == GeomAPI_Shape::VERTEX) {
188 std::shared_ptr<ModelAPI_ResultBody> aResultBody;
190 if (theResultCompound) { // store BOP result to the compound
191 std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
192 aBuilder->add(theResultCompound, aResShape);
193 aMakeShapeList->appendAlgo(aBuilder);
195 else { // create a separate ResultBody
196 aResultBody = document()->createBody(data(), theResultIndex);
198 // tools should be added to the list to fulfill the correct history of modification
199 aListWithObject.insert(aListWithObject.end(), theTools.begin(), theTools.end());
201 ListOfShape aUsedTools = theTools;
202 aUsedTools.insert(aUsedTools.end(), thePlanes.begin(), thePlanes.end());
204 FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
209 setResult(aResultBody, theResultIndex);
214 FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
215 aRBA.resultBody = aResultBody;
216 aRBA.baseShape = theObject;
217 aRBA.makeShape = aMakeShapeList;
218 theResultBaseAlgoList.push_back(aRBA);
219 theResultShapesList.push_back(aResShape);
224 //=================================================================================================
225 bool FeaturesPlugin_VersionedBoolean::processCompsolid(
226 const GeomAlgoAPI_Tools::BOPType theBooleanType,
227 ObjectHierarchy& theCompsolidHierarchy,
228 const GeomShapePtr& theCompsolid,
229 const ListOfShape& theTools,
230 const ListOfShape& thePlanes,
232 std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
233 ListOfShape& theResultShapesList,
234 GeomShapePtr theResultCompound)
236 ListOfShape aUsedInOperationSolids;
237 ListOfShape aNotUsedSolids;
238 theCompsolidHierarchy.SplitCompound(theCompsolid, aUsedInOperationSolids, aNotUsedSolids);
240 std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
243 ListOfShape aToolsWithPlanes = theTools;
244 ListOfShape aPlanesCopy = thePlanes;
245 resizePlanes(aUsedInOperationSolids, aPlanesCopy, aMakeShapeList);
246 aToolsWithPlanes.insert(aToolsWithPlanes.end(), aPlanesCopy.begin(), aPlanesCopy.end());
248 std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
249 performBoolean(theBooleanType, aBoolAlgo, aUsedInOperationSolids, aToolsWithPlanes);
251 // Checking that the algorithm worked properly.
253 if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
258 aMakeShapeList->appendAlgo(aBoolAlgo);
259 GeomShapePtr aResultShape = aBoolAlgo->shape();
261 // Add result to not used solids from compsolid.
262 if (!aNotUsedSolids.empty()) {
263 theCompsolidHierarchy.MarkProcessed(aNotUsedSolids);
265 ListOfShape aShapesToAdd = aNotUsedSolids;
266 aShapesToAdd.push_back(aBoolAlgo->shape());
267 std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
268 new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
269 if (!aFillerAlgo->isDone()) {
270 std::string aFeatureError = "Error: PaveFiller algorithm failed.";
271 setError(aFeatureError);
275 aMakeShapeList->appendAlgo(aFillerAlgo);
276 aResultShape = aFillerAlgo->shape();
279 GeomAPI_ShapeIterator aShapeIt(aResultShape);
280 if (aShapeIt.more() || aResultShape->shapeType() == GeomAPI_Shape::VERTEX)
282 std::shared_ptr<ModelAPI_ResultBody> aResultBody;
284 if (theResultCompound) { // store BOP result to the compound
285 std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
286 aBuilder->add(theResultCompound, aResultShape);
287 aMakeShapeList->appendAlgo(aBuilder);
289 else { // create a separate ResultBody
290 aResultBody = document()->createBody(data(), theResultIndex);
292 ListOfShape aCompSolidList;
293 aCompSolidList.push_back(theCompsolid);
294 // tools should be added to the list to fulfill the correct history of modification
295 aCompSolidList.insert(aCompSolidList.end(), theTools.begin(), theTools.end());
297 ListOfShape aUsedTools = theTools;
298 aUsedTools.insert(aUsedTools.end(), thePlanes.begin(), thePlanes.end());
300 FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
305 setResult(aResultBody, theResultIndex);
309 FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
310 aRBA.resultBody = aResultBody;
311 aRBA.baseShape = theCompsolid;
312 aRBA.makeShape = aMakeShapeList;
313 theResultBaseAlgoList.push_back(aRBA);
314 theResultShapesList.push_back(aResultShape);
319 //=================================================================================================
320 bool FeaturesPlugin_VersionedBoolean::processCompound(
321 const GeomAlgoAPI_Tools::BOPType theBooleanType,
322 ObjectHierarchy& theCompoundHierarchy,
323 const GeomShapePtr& theCompound,
324 const ListOfShape& theTools,
326 std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
327 ListOfShape& theResultShapesList,
328 GeomShapePtr theResultCompound)
330 ListOfShape aUsedInOperationShapes;
331 ListOfShape aNotUsedShapes;
332 theCompoundHierarchy.SplitCompound(theCompound, aUsedInOperationShapes, aNotUsedShapes);
333 if (theResultCompound) {
334 // Not necessary to keep all subs of the current compound,
335 // all unused solids are already stored in the result compound.
336 aNotUsedShapes.clear();
339 std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
340 std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
341 performBoolean(theBooleanType, aBoolAlgo, aUsedInOperationShapes, theTools);
343 // Checking that the algorithm worked properly.
345 if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
350 aMakeShapeList->appendAlgo(aBoolAlgo);
351 GeomShapePtr aResultShape = aBoolAlgo->shape();
353 // Add result to not used shape from compound.
354 if (!aNotUsedShapes.empty()) {
355 theCompoundHierarchy.MarkProcessed(aNotUsedShapes);
357 ListOfShape aShapesForResult = aNotUsedShapes;
358 if (aResultShape->shapeType() == GeomAPI_Shape::COMPOUND) {
359 for (GeomAPI_ShapeIterator aResultIt(aResultShape); aResultIt.more(); aResultIt.next()) {
360 aShapesForResult.push_back(aResultIt.current());
364 aShapesForResult.push_back(aResultShape);
367 if (aShapesForResult.size() == 1) {
368 aResultShape = aShapesForResult.front();
371 aResultShape = GeomAlgoAPI_CompoundBuilder::compound(aShapesForResult);
375 GeomAPI_ShapeIterator aShapeIt(aResultShape);
376 if (aShapeIt.more() || aResultShape->shapeType() == GeomAPI_Shape::VERTEX) {
377 std::shared_ptr<ModelAPI_ResultBody> aResultBody;
379 if (theResultCompound) { // store BOP result to the compound
380 std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
381 aBuilder->add(theResultCompound, aResultShape);
382 aMakeShapeList->appendAlgo(aBuilder);
384 else { // create a separate ResultBody
385 aResultBody = document()->createBody(data(), theResultIndex);
387 ListOfShape aCompoundList;
388 aCompoundList.push_back(theCompound);
389 FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
394 setResult(aResultBody, theResultIndex);
398 FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
399 aRBA.resultBody = aResultBody;
400 aRBA.baseShape = theCompound;
401 aRBA.makeShape = aMakeShapeList;
402 theResultBaseAlgoList.push_back(aRBA);
403 theResultShapesList.push_back(aResultShape);
408 //==================================================================================================
409 GeomShapePtr FeaturesPlugin_VersionedBoolean::keepUnusedSubsOfCompound(
410 const GeomShapePtr& theResult,
411 const ObjectHierarchy& theObjectsHierarchy,
412 const ObjectHierarchy& theToolsHierarchy,
413 std::shared_ptr<GeomAlgoAPI_MakeShapeList> theMakeShapeList)
415 ListOfShape aCompounds;
416 theObjectsHierarchy.CompoundsOfUnusedObjects(aCompounds);
417 theToolsHierarchy.CompoundsOfUnusedObjects(aCompounds);
419 GeomShapePtr aResultShape = theResult;
420 if (!aCompounds.empty()) {
421 aResultShape = GeomAlgoAPI_CompoundBuilder::compound(aCompounds);
423 std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
424 aBuilder->add(aResultShape, theResult);
425 theMakeShapeList->appendAlgo(aBuilder);
431 //=================================================================================================
432 void FeaturesPlugin_VersionedBoolean::resizePlanes(
433 const ListOfShape& theObjects,
434 ListOfShape& thePlanes,
435 std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theMakeShapeList)
437 if (thePlanes.empty())
440 std::list<std::shared_ptr<GeomAPI_Pnt> > aBoundingPoints =
441 GeomAlgoAPI_ShapeTools::getBoundingBox(theObjects, 1.0);
443 // Resize planes to fit in bounding box
444 for (ListOfShape::iterator anIt = thePlanes.begin(); anIt != thePlanes.end(); ++anIt) {
445 GeomShapePtr aPlane = *anIt;
446 GeomShapePtr aTool = GeomAlgoAPI_ShapeTools::fitPlaneToBox(aPlane, aBoundingPoints);
447 std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMkShCustom(new GeomAlgoAPI_MakeShapeCustom);
448 aMkShCustom->addModified(aPlane, aTool);
449 theMakeShapeList->appendAlgo(aMkShCustom);
454 //=================================================================================================
456 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::AddObject(const GeomShapePtr& theObject)
458 myObjects.push_back(theObject);
461 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::AddParent(const GeomShapePtr& theShape,
462 const GeomShapePtr& theParent)
464 myParent[theShape] = theParent;
466 MapShapeToIndex::iterator aFound = myParentIndices.find(theParent);
467 size_t anIndex = myParentIndices.size();
468 if (aFound == myParentIndices.end()) {
469 myParentIndices[theParent] = anIndex;
470 mySubshapes.push_back(ShapeAndSubshapes(theParent, ListOfShape()));
472 anIndex = aFound->second;
474 mySubshapes[anIndex].second.push_back(theShape);
477 GeomShapePtr FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Parent(const GeomShapePtr& theShape,
478 bool theMarkProcessed)
480 MapShapeToParent::const_iterator aFound = myParent.find(theShape);
481 GeomShapePtr aParent;
482 if (aFound != myParent.end()) {
483 aParent = aFound->second;
484 if (theMarkProcessed) {
485 // mark the parent and all its subs as processed by Boolean algorithm
486 myProcessedObjects.insert(aParent);
487 const ListOfShape& aSubs = mySubshapes[myParentIndices[aParent]].second;
488 for (ListOfShape::const_iterator anIt = aSubs.begin(); anIt != aSubs.end(); ++anIt)
489 myProcessedObjects.insert(*anIt);
495 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::MarkProcessed(const GeomShapePtr& theShape)
497 myProcessedObjects.insert(theShape);
500 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::MarkProcessed(const ListOfShape& theShapes)
502 for (ListOfShape::const_iterator anIt = theShapes.begin(); anIt != theShapes.end(); ++anIt)
503 MarkProcessed(*anIt);
506 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::ObjectsByType(
507 ListOfShape& theShapesByType,
508 ListOfShape& theOtherShapes,
509 const GeomAPI_Shape::ShapeType theMinType,
510 const GeomAPI_Shape::ShapeType theMaxType) const
512 if (theMinType > theMaxType)
513 return ObjectsByType(theShapesByType, theOtherShapes, theMaxType, theMinType);
515 // no need to select objects if whole range is specified
516 if (theMinType == GeomAPI_Shape::COMPOUND && theMaxType == GeomAPI_Shape::SHAPE) {
517 theShapesByType.insert(theShapesByType.end(), myObjects.begin(), myObjects.end());
521 for (ListOfShape::const_iterator anIt = myObjects.begin(); anIt != myObjects.end(); ++anIt) {
522 GeomAPI_Shape::ShapeType aType = (*anIt)->shapeType();
523 if (aType >= theMinType && aType <= theMaxType)
524 theShapesByType.push_back(*anIt);
526 theOtherShapes.push_back(*anIt);
531 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::SplitCompound(
532 const GeomShapePtr& theCompShape,
533 ListOfShape& theUsed,
534 ListOfShape& theNotUsed) const
539 MapShapeToIndex::const_iterator aFoundIndex = myParentIndices.find(theCompShape);
540 if (aFoundIndex == myParentIndices.end())
541 return; // no such shape
543 theUsed = mySubshapes[aFoundIndex->second].second;
545 aSubsSet.insert(theUsed.begin(), theUsed.end());
547 for (GeomAPI_ShapeIterator anExp(theCompShape); anExp.more(); anExp.next()) {
548 GeomShapePtr aCurrent = anExp.current();
549 if (aSubsSet.find(aCurrent) == aSubsSet.end())
550 theNotUsed.push_back(aCurrent);
554 bool FeaturesPlugin_VersionedBoolean::ObjectHierarchy::IsEmpty() const
556 return myObjects.empty();
559 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::CompoundsOfUnusedObjects(
560 ListOfShape& theDestination) const
562 SetOfShape aUsedObjects = myProcessedObjects;
563 aUsedObjects.insert(myObjects.begin(), myObjects.end());
565 for (std::vector<ShapeAndSubshapes>::const_iterator anIt = mySubshapes.begin();
566 anIt != mySubshapes.end(); ++anIt) {
567 MapShapeToParent::const_iterator aParent = myParent.find(anIt->first);
568 if ((aParent == myParent.end() || !aParent->second) &&
569 anIt->first->shapeType() == GeomAPI_Shape::COMPOUND) {
570 // this is a top-level compound
571 GeomShapePtr aCompound = collectUnusedSubs(anIt->first, aUsedObjects);
572 // add to destination non-empty compounds only
574 theDestination.push_back(aCompound);
579 GeomShapePtr FeaturesPlugin_VersionedBoolean::ObjectHierarchy::collectUnusedSubs(
580 GeomShapePtr theTopLevelCompound,
581 const SetOfShape& theUsed) const
583 GeomShapePtr aResult = theTopLevelCompound->emptyCopied();
584 bool isResultEmpty = true;
586 for (GeomAPI_ShapeIterator aSub(theTopLevelCompound); aSub.more(); aSub.next()) {
587 GeomShapePtr aCurrent = aSub.current();
588 if (theUsed.find(aCurrent) != theUsed.end())
589 continue; // already used
591 MapShapeToIndex::const_iterator aFoundIndex = myParentIndices.find(aCurrent);
592 if (aCurrent->shapeType() > GeomAPI_Shape::COMPOUND ||
593 aFoundIndex == myParentIndices.end()) {
594 bool isAddShape = true;
595 // check compsolid is fully unused in the Boolean operation
596 if (aCurrent->shapeType() == GeomAPI_Shape::COMPSOLID) {
597 for (GeomAPI_ShapeIterator anIt(aCurrent); isAddShape && anIt.more(); anIt.next())
598 isAddShape = theUsed.find(anIt.current()) == theUsed.end();
601 if (isAddShape) { // low-level shape, add it
602 GeomAlgoAPI_ShapeBuilder::add(aResult, aCurrent);
603 isResultEmpty = false;
606 GeomShapePtr aCompound = collectUnusedSubs(aCurrent, theUsed);
608 GeomAlgoAPI_ShapeBuilder::add(aResult, aCompound);
609 isResultEmpty = false;
613 return isResultEmpty ? GeomShapePtr() : aResult;
617 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator
618 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Begin()
620 return Iterator(this);
623 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator
624 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::End()
626 return Iterator(this, false);
629 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::Iterator(
630 FeaturesPlugin_VersionedBoolean::ObjectHierarchy* theHierarchy, bool isBegin)
631 : myHierarchy(theHierarchy)
634 myObject = myHierarchy->myObjects.begin();
635 SkipAlreadyProcessed();
637 myObject = myHierarchy->myObjects.end();
640 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::SkipAlreadyProcessed()
642 while (myObject != myHierarchy->myObjects.end() &&
643 myHierarchy->myProcessedObjects.find(*myObject) != myHierarchy->myProcessedObjects.end())
647 bool FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::operator==(
648 const Iterator& theOther) const
650 return myObject == theOther.myObject;
653 bool FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::operator!=(
654 const Iterator& theOther) const
656 return !operator==(theOther);
659 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator&
660 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::operator++()
663 SkipAlreadyProcessed();
667 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator
668 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::operator++(int)
671 aCurrent.myHierarchy = myHierarchy;
672 aCurrent.myObject = myObject;
680 GeomShapePtr FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::operator*() const
682 myHierarchy->myProcessedObjects.insert(*myObject);