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;
124 std::list<std::shared_ptr<GeomAPI_Pnt> > aBoundingPoints =
125 GeomAlgoAPI_ShapeTools::getBoundingBox(aListWithObject, 1.0);
128 ListOfShape aToolsWithPlanes = theTools;
129 for (ListOfShape::const_iterator anIt = thePlanes.begin(); anIt != thePlanes.end(); ++anIt) {
130 GeomShapePtr aPlane = *anIt;
131 GeomShapePtr aTool = GeomAlgoAPI_ShapeTools::fitPlaneToBox(aPlane, aBoundingPoints);
132 std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMkShCustom(
133 new GeomAlgoAPI_MakeShapeCustom);
134 aMkShCustom->addModified(aPlane, aTool);
135 aMakeShapeList->appendAlgo(aMkShCustom);
136 aToolsWithPlanes.push_back(aTool);
139 if (theBooleanType == GeomAlgoAPI_Tools::BOOL_PARTITION)
140 aBoolAlgo.reset(new GeomAlgoAPI_Partition(aListWithObject, aToolsWithPlanes));
142 aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aListWithObject,
146 // Checking that the algorithm worked properly.
148 if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
153 aResShape = aBoolAlgo->shape();
154 if (aResShape.get() && aResShape->shapeType() == GeomAPI_Shape::COMPOUND) {
155 int aSubResultsNb = 0;
156 GeomAPI_ShapeIterator anIt(aResShape);
157 for (; anIt.more(); anIt.next())
160 if (aSubResultsNb == 1) {
161 anIt.init(aResShape);
163 aResShape = anIt.current();
167 aMakeShapeList->appendAlgo(aBoolAlgo);
169 GeomAPI_ShapeIterator aShapeIt(aResShape);
170 if (aShapeIt.more() || aResShape->shapeType() == GeomAPI_Shape::VERTEX) {
171 std::shared_ptr<ModelAPI_ResultBody> aResultBody;
173 if (theResultCompound) { // store BOP result to the compound
174 std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
175 aBuilder->add(theResultCompound, aResShape);
176 aMakeShapeList->appendAlgo(aBuilder);
178 else { // create a separate ResultBody
179 aResultBody = document()->createBody(data(), theResultIndex);
181 // tools should be added to the list to fulfill the correct history of modification
182 aListWithObject.insert(aListWithObject.end(), theTools.begin(), theTools.end());
184 ListOfShape aUsedTools = theTools;
185 aUsedTools.insert(aUsedTools.end(), thePlanes.begin(), thePlanes.end());
187 FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
192 setResult(aResultBody, theResultIndex);
197 FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
198 aRBA.resultBody = aResultBody;
199 aRBA.baseShape = theObject;
200 aRBA.makeShape = aMakeShapeList;
201 theResultBaseAlgoList.push_back(aRBA);
202 theResultShapesList.push_back(aResShape);
207 //=================================================================================================
208 bool FeaturesPlugin_VersionedBoolean::processCompsolid(
209 const GeomAlgoAPI_Tools::BOPType theBooleanType,
210 const ObjectHierarchy& theCompsolidHierarchy,
211 const GeomShapePtr& theCompsolid,
212 const ListOfShape& theTools,
213 const ListOfShape& thePlanes,
215 std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
216 ListOfShape& theResultShapesList,
217 GeomShapePtr theResultCompound)
219 ListOfShape aUsedInOperationSolids;
220 ListOfShape aNotUsedSolids;
221 theCompsolidHierarchy.SplitCompound(theCompsolid, aUsedInOperationSolids, aNotUsedSolids);
223 std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
225 std::list<std::shared_ptr<GeomAPI_Pnt> > aBoundingPoints =
226 GeomAlgoAPI_ShapeTools::getBoundingBox(aUsedInOperationSolids, 1.0);
229 ListOfShape aToolsWithPlanes = theTools;
230 for (ListOfShape::const_iterator anIt = thePlanes.begin(); anIt != thePlanes.end(); ++anIt)
232 GeomShapePtr aPlane = *anIt;
233 GeomShapePtr aTool = GeomAlgoAPI_ShapeTools::fitPlaneToBox(aPlane, aBoundingPoints);
234 std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMkShCustom(
235 new GeomAlgoAPI_MakeShapeCustom);
236 aMkShCustom->addModified(aPlane, aTool);
237 aMakeShapeList->appendAlgo(aMkShCustom);
238 aToolsWithPlanes.push_back(aTool);
241 std::shared_ptr<GeomAlgoAPI_MakeShape> aBoolAlgo;
242 if (theBooleanType == GeomAlgoAPI_Tools::BOOL_PARTITION)
243 aBoolAlgo.reset(new GeomAlgoAPI_Partition(aUsedInOperationSolids, aToolsWithPlanes));
245 aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aUsedInOperationSolids,
249 // Checking that the algorithm worked properly.
251 if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
256 aMakeShapeList->appendAlgo(aBoolAlgo);
257 GeomShapePtr aResultShape = aBoolAlgo->shape();
259 // Add result to not used solids from compsolid.
260 if (!aNotUsedSolids.empty()) {
261 ListOfShape aShapesToAdd = aNotUsedSolids;
262 aShapesToAdd.push_back(aBoolAlgo->shape());
263 std::shared_ptr<GeomAlgoAPI_PaveFiller> aFillerAlgo(
264 new GeomAlgoAPI_PaveFiller(aShapesToAdd, true));
265 if (!aFillerAlgo->isDone()) {
266 std::string aFeatureError = "Error: PaveFiller algorithm failed.";
267 setError(aFeatureError);
271 aMakeShapeList->appendAlgo(aFillerAlgo);
272 aResultShape = aFillerAlgo->shape();
275 GeomAPI_ShapeIterator aShapeIt(aResultShape);
276 if (aShapeIt.more() || aResultShape->shapeType() == GeomAPI_Shape::VERTEX)
278 std::shared_ptr<ModelAPI_ResultBody> aResultBody;
280 if (theResultCompound) { // store BOP result to the compound
281 std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
282 aBuilder->add(theResultCompound, aResultShape);
283 aMakeShapeList->appendAlgo(aBuilder);
285 else { // create a separate ResultBody
286 aResultBody = document()->createBody(data(), theResultIndex);
288 ListOfShape aCompSolidList;
289 aCompSolidList.push_back(theCompsolid);
290 // tools should be added to the list to fulfill the correct history of modification
291 aCompSolidList.insert(aCompSolidList.end(), theTools.begin(), theTools.end());
293 ListOfShape aUsedTools = theTools;
294 aUsedTools.insert(aUsedTools.end(), thePlanes.begin(), thePlanes.end());
296 FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
301 setResult(aResultBody, theResultIndex);
305 FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
306 aRBA.resultBody = aResultBody;
307 aRBA.baseShape = theCompsolid;
308 aRBA.makeShape = aMakeShapeList;
309 theResultBaseAlgoList.push_back(aRBA);
310 theResultShapesList.push_back(aResultShape);
315 //=================================================================================================
316 bool FeaturesPlugin_VersionedBoolean::processCompound(
317 const GeomAlgoAPI_Tools::BOPType theBooleanType,
318 const ObjectHierarchy& theCompoundHierarchy,
319 const GeomShapePtr& theCompound,
320 const ListOfShape& theTools,
322 std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>& theResultBaseAlgoList,
323 ListOfShape& theResultShapesList,
324 GeomShapePtr theResultCompound)
326 ListOfShape aUsedInOperationShapes;
327 ListOfShape aNotUsedShapes;
328 theCompoundHierarchy.SplitCompound(theCompound, aUsedInOperationShapes, aNotUsedShapes);
329 if (theResultCompound) {
330 // Not necessary to keep all subs of the current compound,
331 // all unused solids are already stored in the result compound.
332 aNotUsedShapes.clear();
335 std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
336 std::shared_ptr<GeomAlgoAPI_Boolean> aBoolAlgo(
337 new GeomAlgoAPI_Boolean(aUsedInOperationShapes,
341 // Checking that the algorithm worked properly.
343 if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) {
348 aMakeShapeList->appendAlgo(aBoolAlgo);
349 GeomShapePtr aResultShape = aBoolAlgo->shape();
351 // Add result to not used shape from compound.
352 if (!aNotUsedShapes.empty()) {
353 ListOfShape aShapesForResult = aNotUsedShapes;
354 if (aResultShape->shapeType() == GeomAPI_Shape::COMPOUND) {
355 for (GeomAPI_ShapeIterator aResultIt(aResultShape); aResultIt.more(); aResultIt.next()) {
356 aShapesForResult.push_back(aResultIt.current());
360 aShapesForResult.push_back(aResultShape);
363 if (aShapesForResult.size() == 1) {
364 aResultShape = aShapesForResult.front();
367 aResultShape = GeomAlgoAPI_CompoundBuilder::compound(aShapesForResult);
371 GeomAPI_ShapeIterator aShapeIt(aResultShape);
372 if (aShapeIt.more() || aResultShape->shapeType() == GeomAPI_Shape::VERTEX) {
373 std::shared_ptr<ModelAPI_ResultBody> aResultBody;
375 if (theResultCompound) { // store BOP result to the compound
376 std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
377 aBuilder->add(theResultCompound, aResultShape);
378 aMakeShapeList->appendAlgo(aBuilder);
380 else { // create a separate ResultBody
381 aResultBody = document()->createBody(data(), theResultIndex);
383 ListOfShape aCompoundList;
384 aCompoundList.push_back(theCompound);
385 FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
390 setResult(aResultBody, theResultIndex);
394 FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
395 aRBA.resultBody = aResultBody;
396 aRBA.baseShape = theCompound;
397 aRBA.makeShape = aMakeShapeList;
398 theResultBaseAlgoList.push_back(aRBA);
399 theResultShapesList.push_back(aResultShape);
404 //==================================================================================================
405 GeomShapePtr FeaturesPlugin_VersionedBoolean::keepUnusedSubsOfCompound(
406 const GeomShapePtr& theResult,
407 const ObjectHierarchy& theObjectsHierarchy,
408 const ObjectHierarchy& theToolsHierarchy,
409 std::shared_ptr<GeomAlgoAPI_MakeShapeList> theMakeShapeList)
411 ListOfShape aCompounds;
412 theObjectsHierarchy.CompoundsOfUnusedObjects(aCompounds);
413 theToolsHierarchy.CompoundsOfUnusedObjects(aCompounds);
415 GeomShapePtr aResultShape = theResult;
416 if (!aCompounds.empty()) {
417 aResultShape = aCompounds.front();
418 aCompounds.pop_front();
420 std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
421 for (ListOfShape::iterator anIt = aCompounds.begin(); anIt != aCompounds.end(); ++anIt) {
422 for (GeomAPI_ShapeIterator aSub(*anIt); aSub.more(); aSub.next())
423 aBuilder->add(aResultShape, aSub.current());
427 aBuilder->add(aResultShape, theResult);
429 theMakeShapeList->appendAlgo(aBuilder);
434 //=================================================================================================
435 int FeaturesPlugin_VersionedBoolean::version()
437 AttributeIntegerPtr aVersionAttr = integer(VERSION_ID());
439 if (aVersionAttr && aVersionAttr->isInitialized())
440 aVersion = aVersionAttr->value();
444 //=================================================================================================
446 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::AddObject(const GeomShapePtr& theObject)
448 myObjects.push_back(theObject);
451 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::AddParent(const GeomShapePtr& theShape,
452 const GeomShapePtr& theParent)
454 myParent[theShape] = theParent;
456 MapShapeToIndex::iterator aFound = myParentIndices.find(theParent);
457 size_t anIndex = myParentIndices.size();
458 if (aFound == myParentIndices.end()) {
459 myParentIndices[theParent] = anIndex;
460 mySubshapes.push_back(ShapeAndSubshapes(theParent, ListOfShape()));
462 anIndex = aFound->second;
464 mySubshapes[anIndex].second.push_back(theShape);
467 GeomShapePtr FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Parent(const GeomShapePtr& theShape,
468 bool theMarkProcessed)
470 MapShapeToParent::const_iterator aFound = myParent.find(theShape);
471 GeomShapePtr aParent;
472 if (aFound != myParent.end()) {
473 aParent = aFound->second;
474 if (theMarkProcessed) {
475 // mark the parent and all its subs as processed by Boolean algorithm
476 myProcessedObjects.insert(aParent);
477 const ListOfShape& aSubs = mySubshapes[myParentIndices[aParent]].second;
478 for (ListOfShape::const_iterator anIt = aSubs.begin(); anIt != aSubs.end(); ++anIt)
479 myProcessedObjects.insert(*anIt);
485 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::ObjectsByType(
486 ListOfShape& theShapesByType,
487 ListOfShape& theOtherShapes,
488 const GeomAPI_Shape::ShapeType theMinType,
489 const GeomAPI_Shape::ShapeType theMaxType) const
491 if (theMinType > theMaxType)
492 return ObjectsByType(theShapesByType, theOtherShapes, theMaxType, theMinType);
494 // no need to select objects if whole range is specified
495 if (theMinType == GeomAPI_Shape::COMPOUND && theMaxType == GeomAPI_Shape::SHAPE) {
496 theShapesByType.insert(theShapesByType.end(), myObjects.begin(), myObjects.end());
500 for (ListOfShape::const_iterator anIt = myObjects.begin(); anIt != myObjects.end(); ++anIt) {
501 GeomAPI_Shape::ShapeType aType = (*anIt)->shapeType();
502 if (aType >= theMinType && aType <= theMaxType)
503 theShapesByType.push_back(*anIt);
505 theOtherShapes.push_back(*anIt);
510 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::SplitCompound(const GeomShapePtr& theCompShape,
511 ListOfShape& theUsed,
512 ListOfShape& theNotUsed) const
517 MapShapeToIndex::const_iterator aFoundIndex = myParentIndices.find(theCompShape);
518 if (aFoundIndex == myParentIndices.end())
519 return; // no such shape
521 theUsed = mySubshapes[aFoundIndex->second].second;
523 aSubsSet.insert(theUsed.begin(), theUsed.end());
525 for (GeomAPI_ShapeIterator anExp(theCompShape); anExp.more(); anExp.next()) {
526 GeomShapePtr aCurrent = anExp.current();
527 if (aSubsSet.find(aCurrent) == aSubsSet.end())
528 theNotUsed.push_back(aCurrent);
532 bool FeaturesPlugin_VersionedBoolean::ObjectHierarchy::IsEmpty() const
534 return myObjects.empty();
537 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::CompoundsOfUnusedObjects(
538 ListOfShape& theDestination) const
540 SetOfShape aUsedObjects;
541 aUsedObjects.insert(myObjects.begin(), myObjects.end());
543 for (std::vector<ShapeAndSubshapes>::const_iterator anIt = mySubshapes.begin();
544 anIt != mySubshapes.end(); ++anIt) {
545 MapShapeToParent::const_iterator aParent = myParent.find(anIt->first);
546 if ((aParent == myParent.end() || !aParent->second) &&
547 anIt->first->shapeType() == GeomAPI_Shape::COMPOUND) {
548 // this is a top-level compound
549 GeomShapePtr aCompound = collectUnusedSubs(anIt->first, aUsedObjects);
550 // add to destination non-empty compounds only
552 theDestination.push_back(aCompound);
557 GeomShapePtr FeaturesPlugin_VersionedBoolean::ObjectHierarchy::collectUnusedSubs(
558 GeomShapePtr theTopLevelCompound,
559 const SetOfShape& theUsed) const
561 GeomShapePtr aResult = theTopLevelCompound->emptyCopied();
562 bool isResultEmpty = true;
564 for (GeomAPI_ShapeIterator aSub(theTopLevelCompound); aSub.more(); aSub.next()) {
565 GeomShapePtr aCurrent = aSub.current();
566 if (theUsed.find(aCurrent) != theUsed.end())
567 continue; // already used
569 MapShapeToIndex::const_iterator aFoundIndex = myParentIndices.find(aCurrent);
570 if (aCurrent->shapeType() > GeomAPI_Shape::COMPOUND ||
571 aFoundIndex == myParentIndices.end()) {
572 bool isAddShape = true;
573 // check compsolid is fully unused in the Boolean operation
574 if (aCurrent->shapeType() == GeomAPI_Shape::COMPSOLID) {
575 for (GeomAPI_ShapeIterator anIt(aCurrent); isAddShape && anIt.more(); anIt.next())
576 isAddShape = theUsed.find(anIt.current()) == theUsed.end();
579 if (isAddShape) { // low-level shape, add it
580 GeomAlgoAPI_ShapeBuilder::add(aResult, aCurrent);
581 isResultEmpty = false;
584 GeomShapePtr aCompound = collectUnusedSubs(aCurrent, theUsed);
586 GeomAlgoAPI_ShapeBuilder::add(theTopLevelCompound, aCompound);
587 isResultEmpty = false;
591 return isResultEmpty ? GeomShapePtr() : aResult;
595 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Begin()
597 return Iterator(this);
600 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator FeaturesPlugin_VersionedBoolean::ObjectHierarchy::End()
602 return Iterator(this, false);
605 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::Iterator(
606 FeaturesPlugin_VersionedBoolean::ObjectHierarchy* theHierarchy, bool isBegin)
607 : myHierarchy(theHierarchy)
610 myObject = myHierarchy->myObjects.begin();
611 SkipAlreadyProcessed();
613 myObject = myHierarchy->myObjects.end();
616 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::SkipAlreadyProcessed()
618 while (myObject != myHierarchy->myObjects.end() &&
619 myHierarchy->myProcessedObjects.find(*myObject) != myHierarchy->myProcessedObjects.end())
623 bool FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::operator==(const Iterator& theOther) const
625 return myObject == theOther.myObject;
628 bool FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::operator!=(const Iterator& theOther) const
630 return !operator==(theOther);
633 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator&
634 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::operator++()
637 SkipAlreadyProcessed();
641 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator
642 FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::operator++(int)
645 aCurrent.myHierarchy = myHierarchy;
646 aCurrent.myObject = myObject;
654 GeomShapePtr FeaturesPlugin_VersionedBoolean::ObjectHierarchy::Iterator::operator*() const
656 myHierarchy->myProcessedObjects.insert(*myObject);