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 <GeomAPI_Face.h>
42 #include <GeomAPI_ShapeExplorer.h>
43 #include <GeomAPI_ShapeIterator.h>
48 //=================================================================================================
49 void FeaturesPlugin_VersionedBoolean::initVersion(const int theVersion,
50 const AttributePtr theObjectsAttr,
51 const AttributePtr theToolsAttr)
53 AttributePtr aVerAttr = data()->addAttribute(VERSION_ID(), ModelAPI_AttributeInteger::typeId());
54 aVerAttr->setIsArgument(false);
55 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VERSION_ID());
56 if (!integer(VERSION_ID())->isInitialized() &&
57 (!theObjectsAttr || !theObjectsAttr->isInitialized()) &&
58 (!theToolsAttr || !theToolsAttr->isInitialized())) {
59 // this is a newly created feature (not read from file),
60 // so, initialize the latest version
61 integer(VERSION_ID())->setValue(theVersion);
65 //=================================================================================================
66 void FeaturesPlugin_VersionedBoolean::parentForShape(const GeomShapePtr& theShape,
67 const ResultPtr& theContext,
68 ObjectHierarchy& theShapesHierarchy)
70 ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(theContext);
71 if (aResCompSolidPtr.get()) {
72 std::shared_ptr<GeomAPI_Shape> aContextShape = aResCompSolidPtr->shape();
73 if (aContextShape->shapeType() <= GeomAPI_Shape::COMPSOLID) {
74 theShapesHierarchy.AddParent(theShape, aContextShape);
75 parentForShape(aContextShape, aResCompSolidPtr, theShapesHierarchy);
80 bool FeaturesPlugin_VersionedBoolean::processAttribute(const std::string& theAttributeName,
81 ObjectHierarchy& theObjects,
82 ListOfShape& thePlanesList)
84 AttributeSelectionListPtr anObjectsSelList = selectionList(theAttributeName);
85 for (int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
86 AttributeSelectionPtr anObjectAttr = anObjectsSelList->value(anObjectsIndex);
87 GeomShapePtr anObject = anObjectAttr->value();
88 if (!anObject.get()) {
89 // It could be a construction plane.
90 ResultPtr aContext = anObjectAttr->context();
91 anObject = anObjectAttr->context()->shape();
93 thePlanesList.push_back(anObject);
99 theObjects.AddObject(anObject);
101 ResultPtr aContext = anObjectAttr->context();
102 parentForShape(anObject, aContext, theObjects);
107 //=================================================================================================
108 bool FeaturesPlugin_VersionedBoolean::processObject(
109 const GeomAlgoAPI_Tools::BOPType theBooleanType,
110 const GeomShapePtr& theObject,
111 const ListOfShape& theTools,
112 const ListOfShape& thePlanes,
114 std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
115 ListOfShape& theResultShapesList,
116 GeomShapePtr theResultCompound)
118 ListOfShape aListWithObject;
119 aListWithObject.push_back(theObject);
120 std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
121 std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
122 GeomShapePtr aResShape;
125 ListOfShape aToolsWithPlanes = theTools;
126 ListOfShape aPlanesCopy = thePlanes;
127 resizePlanes(aListWithObject, aPlanesCopy, aMakeShapeList);
128 aToolsWithPlanes.insert(aToolsWithPlanes.end(), aPlanesCopy.begin(), aPlanesCopy.end());
130 if (theBooleanType == GeomAlgoAPI_Tools::BOOL_PARTITION)
131 aBoolAlgo.reset(new GeomAlgoAPI_Partition(aListWithObject, aToolsWithPlanes));
133 aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aListWithObject,
137 // Checking that the algorithm worked properly.
139 if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
144 aResShape = aBoolAlgo->shape();
145 if (aResShape.get() && aResShape->shapeType() == GeomAPI_Shape::COMPOUND) {
146 int aSubResultsNb = 0;
147 GeomAPI_ShapeIterator anIt(aResShape);
148 for (; anIt.more(); anIt.next())
151 if (aSubResultsNb == 1) {
152 anIt.init(aResShape);
154 aResShape = anIt.current();
158 aMakeShapeList->appendAlgo(aBoolAlgo);
160 GeomAPI_ShapeIterator aShapeIt(aResShape);
161 if (aShapeIt.more() || aResShape->shapeType() == GeomAPI_Shape::VERTEX) {
162 std::shared_ptr<ModelAPI_ResultBody> aResultBody;
164 if (theResultCompound) { // store BOP result to the compound
165 std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
166 aBuilder->add(theResultCompound, aResShape);
167 aMakeShapeList->appendAlgo(aBuilder);
169 else { // create a separate ResultBody
170 aResultBody = document()->createBody(data(), theResultIndex);
172 // tools should be added to the list to fulfill the correct history of modification
173 aListWithObject.insert(aListWithObject.end(), theTools.begin(), theTools.end());
175 ListOfShape aUsedTools = theTools;
176 aUsedTools.insert(aUsedTools.end(), thePlanes.begin(), thePlanes.end());
178 FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
183 setResult(aResultBody, theResultIndex);
188 FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
189 aRBA.resultBody = aResultBody;
190 aRBA.baseShape = theObject;
191 aRBA.makeShape = aMakeShapeList;
192 theResultBaseAlgoList.push_back(aRBA);
193 theResultShapesList.push_back(aResShape);
198 //=================================================================================================
199 bool FeaturesPlugin_VersionedBoolean::processCompsolid(
200 const GeomAlgoAPI_Tools::BOPType theBooleanType,
201 const ObjectHierarchy& theCompsolidHierarchy,
202 const GeomShapePtr& theCompsolid,
203 const ListOfShape& theTools,
204 const ListOfShape& thePlanes,
206 std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
207 ListOfShape& theResultShapesList,
208 GeomShapePtr theResultCompound)
210 ListOfShape aUsedInOperationSolids;
211 ListOfShape aNotUsedSolids;
212 theCompsolidHierarchy.SplitCompound(theCompsolid, aUsedInOperationSolids, aNotUsedSolids);
214 std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
217 ListOfShape aToolsWithPlanes = theTools;
218 ListOfShape aPlanesCopy = thePlanes;
219 resizePlanes(aUsedInOperationSolids, aPlanesCopy, aMakeShapeList);
220 aToolsWithPlanes.insert(aToolsWithPlanes.end(), aPlanesCopy.begin(), aPlanesCopy.end());
222 std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
223 if (theBooleanType == GeomAlgoAPI_Tools::BOOL_PARTITION)
224 aBoolAlgo.reset(new GeomAlgoAPI_Partition(aUsedInOperationSolids, aToolsWithPlanes));
226 aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aUsedInOperationSolids,
230 // Checking that the algorithm worked properly.
232 if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
237 aMakeShapeList->appendAlgo(aBoolAlgo);
238 GeomShapePtr aResultShape = aBoolAlgo->shape();
240 // Add result to not used solids from compsolid.
241 if (!aNotUsedSolids.empty()) {
242 ListOfShape aShapesToAdd = aNotUsedSolids;
243 aShapesToAdd.push_back(aBoolAlgo->shape());
244 std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
245 new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
246 if (!aFillerAlgo->isDone()) {
247 std::string aFeatureError = "Error: PaveFiller algorithm failed.";
248 setError(aFeatureError);
252 aMakeShapeList->appendAlgo(aFillerAlgo);
253 aResultShape = aFillerAlgo->shape();
256 GeomAPI_ShapeIterator aShapeIt(aResultShape);
257 if (aShapeIt.more() || aResultShape->shapeType() == GeomAPI_Shape::VERTEX)
259 std::shared_ptr<ModelAPI_ResultBody> aResultBody;
261 if (theResultCompound) { // store BOP result to the compound
262 std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
263 aBuilder->add(theResultCompound, aResultShape);
264 aMakeShapeList->appendAlgo(aBuilder);
266 else { // create a separate ResultBody
267 aResultBody = document()->createBody(data(), theResultIndex);
269 ListOfShape aCompSolidList;
270 aCompSolidList.push_back(theCompsolid);
271 // tools should be added to the list to fulfill the correct history of modification
272 aCompSolidList.insert(aCompSolidList.end(), theTools.begin(), theTools.end());
274 ListOfShape aUsedTools = theTools;
275 aUsedTools.insert(aUsedTools.end(), thePlanes.begin(), thePlanes.end());
277 FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
282 setResult(aResultBody, theResultIndex);
286 FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
287 aRBA.resultBody = aResultBody;
288 aRBA.baseShape = theCompsolid;
289 aRBA.makeShape = aMakeShapeList;
290 theResultBaseAlgoList.push_back(aRBA);
291 theResultShapesList.push_back(aResultShape);
296 //=================================================================================================
297 bool FeaturesPlugin_VersionedBoolean::processCompound(
298 const GeomAlgoAPI_Tools::BOPType theBooleanType,
299 const ObjectHierarchy& theCompoundHierarchy,
300 const GeomShapePtr& theCompound,
301 const ListOfShape& theTools,
303 std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
304 ListOfShape& theResultShapesList,
305 GeomShapePtr theResultCompound)
307 ListOfShape aUsedInOperationShapes;
308 ListOfShape aNotUsedShapes;
309 theCompoundHierarchy.SplitCompound(theCompound, aUsedInOperationShapes, aNotUsedShapes);
310 if (theResultCompound) {
311 // Not necessary to keep all subs of the current compound,
312 // all unused solids are already stored in the result compound.
313 aNotUsedShapes.clear();
316 std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
317 std::shared_ptr<GeomAlgoAPI_Boolean> aBoolAlgo(
318 new GeomAlgoAPI_Boolean(aUsedInOperationShapes,
322 // Checking that the algorithm worked properly.
324 if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
329 aMakeShapeList->appendAlgo(aBoolAlgo);
330 GeomShapePtr aResultShape = aBoolAlgo->shape();
332 // Add result to not used shape from compound.
333 if (!aNotUsedShapes.empty()) {
334 ListOfShape aShapesForResult = aNotUsedShapes;
335 if (aResultShape->shapeType() == GeomAPI_Shape::COMPOUND) {
336 for (GeomAPI_ShapeIterator aResultIt(aResultShape); aResultIt.more(); aResultIt.next()) {
337 aShapesForResult.push_back(aResultIt.current());
341 aShapesForResult.push_back(aResultShape);
344 if (aShapesForResult.size() == 1) {
345 aResultShape = aShapesForResult.front();
348 aResultShape = GeomAlgoAPI_CompoundBuilder::compound(aShapesForResult);
352 GeomAPI_ShapeIterator aShapeIt(aResultShape);
353 if (aShapeIt.more() || aResultShape->shapeType() == GeomAPI_Shape::VERTEX) {
354 std::shared_ptr<ModelAPI_ResultBody> aResultBody;
356 if (theResultCompound) { // store BOP result to the compound
357 std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
358 aBuilder->add(theResultCompound, aResultShape);
359 aMakeShapeList->appendAlgo(aBuilder);
361 else { // create a separate ResultBody
362 aResultBody = document()->createBody(data(), theResultIndex);
364 ListOfShape aCompoundList;
365 aCompoundList.push_back(theCompound);
366 FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
371 setResult(aResultBody, theResultIndex);
375 FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
376 aRBA.resultBody = aResultBody;
377 aRBA.baseShape = theCompound;
378 aRBA.makeShape = aMakeShapeList;
379 theResultBaseAlgoList.push_back(aRBA);
380 theResultShapesList.push_back(aResultShape);
385 //==================================================================================================
386 GeomShapePtr FeaturesPlugin_VersionedBoolean::keepUnusedSubsOfCompound(
387 const GeomShapePtr& theResult,
388 const ObjectHierarchy& theObjectsHierarchy,
389 const ObjectHierarchy& theToolsHierarchy,
390 std::shared_ptr<GeomAlgoAPI_MakeShapeList> theMakeShapeList)
392 ListOfShape aCompounds;
393 theObjectsHierarchy.CompoundsOfUnusedObjects(aCompounds);
394 theToolsHierarchy.CompoundsOfUnusedObjects(aCompounds);
396 GeomShapePtr aResultShape = theResult;
397 if (!aCompounds.empty()) {
398 aResultShape = aCompounds.front();
399 aCompounds.pop_front();
401 std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
402 for (ListOfShape::iterator anIt = aCompounds.begin(); anIt != aCompounds.end(); ++anIt) {
403 for (GeomAPI_ShapeIterator aSub(*anIt); aSub.more(); aSub.next())
404 aBuilder->add(aResultShape, aSub.current());
408 aBuilder->add(aResultShape, theResult);
410 theMakeShapeList->appendAlgo(aBuilder);
415 //=================================================================================================
416 void FeaturesPlugin_VersionedBoolean::resizePlanes(
417 const ListOfShape& theObjects,
418 ListOfShape& thePlanes,
419 std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theMakeShapeList)
421 if (thePlanes.empty())
424 std::list<std::shared_ptr<GeomAPI_Pnt> > aBoundingPoints =
425 GeomAlgoAPI_ShapeTools::getBoundingBox(theObjects, 1.0);
427 // Resize planes to fit in bounding box
428 for (ListOfShape::iterator anIt = thePlanes.begin(); anIt != thePlanes.end(); ++anIt) {
429 GeomShapePtr aPlane = *anIt;
430 GeomShapePtr aTool = GeomAlgoAPI_ShapeTools::fitPlaneToBox(aPlane, aBoundingPoints);
431 std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMkShCustom(new GeomAlgoAPI_MakeShapeCustom);
432 aMkShCustom->addModified(aPlane, aTool);
433 theMakeShapeList->appendAlgo(aMkShCustom);
438 //=================================================================================================
439 int FeaturesPlugin_VersionedBoolean::version()
441 AttributeIntegerPtr aVersionAttr = integer(VERSION_ID());
443 if (aVersionAttr && aVersionAttr->isInitialized())
444 aVersion = aVersionAttr->value();
448 //=================================================================================================
450 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::AddObject(const GeomShapePtr& theObject)
452 myObjects.push_back(theObject);
455 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::AddParent(const GeomShapePtr& theShape,
456 const GeomShapePtr& theParent)
458 myParent[theShape] = theParent;
460 MapShapeToIndex::iterator aFound = myParentIndices.find(theParent);
461 size_t anIndex = myParentIndices.size();
462 if (aFound == myParentIndices.end()) {
463 myParentIndices[theParent] = anIndex;
464 mySubshapes.push_back(ShapeAndSubshapes(theParent, ListOfShape()));
466 anIndex = aFound->second;
468 mySubshapes[anIndex].second.push_back(theShape);
471 GeomShapePtr FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Parent(const GeomShapePtr& theShape,
472 bool theMarkProcessed)
474 MapShapeToParent::const_iterator aFound = myParent.find(theShape);
475 GeomShapePtr aParent;
476 if (aFound != myParent.end()) {
477 aParent = aFound->second;
478 if (theMarkProcessed) {
479 // mark the parent and all its subs as processed by Boolean algorithm
480 myProcessedObjects.insert(aParent);
481 const ListOfShape& aSubs = mySubshapes[myParentIndices[aParent]].second;
482 for (ListOfShape::const_iterator anIt = aSubs.begin(); anIt != aSubs.end(); ++anIt)
483 myProcessedObjects.insert(*anIt);
489 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::ObjectsByType(
490 ListOfShape& theShapesByType,
491 ListOfShape& theOtherShapes,
492 const GeomAPI_Shape::ShapeType theMinType,
493 const GeomAPI_Shape::ShapeType theMaxType) const
495 if (theMinType > theMaxType)
496 return ObjectsByType(theShapesByType, theOtherShapes, theMaxType, theMinType);
498 // no need to select objects if whole range is specified
499 if (theMinType == GeomAPI_Shape::COMPOUND && theMaxType == GeomAPI_Shape::SHAPE) {
500 theShapesByType.insert(theShapesByType.end(), myObjects.begin(), myObjects.end());
504 for (ListOfShape::const_iterator anIt = myObjects.begin(); anIt != myObjects.end(); ++anIt) {
505 GeomAPI_Shape::ShapeType aType = (*anIt)->shapeType();
506 if (aType >= theMinType && aType <= theMaxType)
507 theShapesByType.push_back(*anIt);
509 theOtherShapes.push_back(*anIt);
514 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::SplitCompound(
515 const GeomShapePtr& theCompShape,
516 ListOfShape& theUsed,
517 ListOfShape& theNotUsed) const
522 MapShapeToIndex::const_iterator aFoundIndex = myParentIndices.find(theCompShape);
523 if (aFoundIndex == myParentIndices.end())
524 return; // no such shape
526 theUsed = mySubshapes[aFoundIndex->second].second;
528 aSubsSet.insert(theUsed.begin(), theUsed.end());
530 for (GeomAPI_ShapeIterator anExp(theCompShape); anExp.more(); anExp.next()) {
531 GeomShapePtr aCurrent = anExp.current();
532 if (aSubsSet.find(aCurrent) == aSubsSet.end())
533 theNotUsed.push_back(aCurrent);
537 bool FeaturesPlugin_VersionedBoolean::ObjectHierarchy::IsEmpty() const
539 return myObjects.empty();
542 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::CompoundsOfUnusedObjects(
543 ListOfShape& theDestination) const
545 SetOfShape aUsedObjects;
546 aUsedObjects.insert(myObjects.begin(), myObjects.end());
548 for (std::vector<ShapeAndSubshapes>::const_iterator anIt = mySubshapes.begin();
549 anIt != mySubshapes.end(); ++anIt) {
550 MapShapeToParent::const_iterator aParent = myParent.find(anIt->first);
551 if ((aParent == myParent.end() || !aParent->second) &&
552 anIt->first->shapeType() == GeomAPI_Shape::COMPOUND) {
553 // this is a top-level compound
554 GeomShapePtr aCompound = collectUnusedSubs(anIt->first, aUsedObjects);
555 // add to destination non-empty compounds only
557 theDestination.push_back(aCompound);
562 GeomShapePtr FeaturesPlugin_VersionedBoolean::ObjectHierarchy::collectUnusedSubs(
563 GeomShapePtr theTopLevelCompound,
564 const SetOfShape& theUsed) const
566 GeomShapePtr aResult = theTopLevelCompound->emptyCopied();
567 bool isResultEmpty = true;
569 for (GeomAPI_ShapeIterator aSub(theTopLevelCompound); aSub.more(); aSub.next()) {
570 GeomShapePtr aCurrent = aSub.current();
571 if (theUsed.find(aCurrent) != theUsed.end())
572 continue; // already used
574 MapShapeToIndex::const_iterator aFoundIndex = myParentIndices.find(aCurrent);
575 if (aCurrent->shapeType() > GeomAPI_Shape::COMPOUND ||
576 aFoundIndex == myParentIndices.end()) {
577 bool isAddShape = true;
578 // check compsolid is fully unused in the Boolean operation
579 if (aCurrent->shapeType() == GeomAPI_Shape::COMPSOLID) {
580 for (GeomAPI_ShapeIterator anIt(aCurrent); isAddShape && anIt.more(); anIt.next())
581 isAddShape = theUsed.find(anIt.current()) == theUsed.end();
584 if (isAddShape) { // low-level shape, add it
585 GeomAlgoAPI_ShapeBuilder::add(aResult, aCurrent);
586 isResultEmpty = false;
589 GeomShapePtr aCompound = collectUnusedSubs(aCurrent, theUsed);
591 GeomAlgoAPI_ShapeBuilder::add(aResult, aCompound);
592 isResultEmpty = false;
596 return isResultEmpty ? GeomShapePtr() : aResult;
600 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator
601 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Begin()
603 return Iterator(this);
606 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator
607 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::End()
609 return Iterator(this, false);
612 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::Iterator(
613 FeaturesPlugin_VersionedBoolean::ObjectHierarchy* theHierarchy, bool isBegin)
614 : myHierarchy(theHierarchy)
617 myObject = myHierarchy->myObjects.begin();
618 SkipAlreadyProcessed();
620 myObject = myHierarchy->myObjects.end();
623 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::SkipAlreadyProcessed()
625 while (myObject != myHierarchy->myObjects.end() &&
626 myHierarchy->myProcessedObjects.find(*myObject) != myHierarchy->myProcessedObjects.end())
630 bool FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::operator==(
631 const Iterator& theOther) const
633 return myObject == theOther.myObject;
636 bool FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::operator!=(
637 const Iterator& theOther) const
639 return !operator==(theOther);
642 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator&
643 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::operator++()
646 SkipAlreadyProcessed();
650 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator
651 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::operator++(int)
654 aCurrent.myHierarchy = myHierarchy;
655 aCurrent.myObject = myObject;
663 GeomShapePtr FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::operator*() const
665 myHierarchy->myProcessedObjects.insert(*myObject);