+ // update list of un-selected objects of the partition
+ GeomAPI_Shape::ShapeType aType = theSubsToCut.front()->shapeType();
+ theSubsToCut.clear();
+ for (GeomAPI_ShapeExplorer anExp(aCutAlgo->shape(), aType); anExp.more(); anExp.next())
+ theSubsToCut.push_back(anExp.current());
+ return true;
+}
+
+bool FeaturesPlugin_Partition::cutSubs(
+ GeomAPI_ShapeHierarchy& theHierarchy,
+ ListOfShape& theUsed,
+ ListOfShape& theNotUsed,
+ std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theMakeShapeList,
+ std::string& theError)
+{
+ theUsed.clear();
+ theNotUsed.clear();
+
+ GeomAPI_ShapeHierarchy::iterator anIt = theHierarchy.begin();
+
+ // compose a set of tools for the CUT operation:
+ // find the list of unused subs of the first argument or use itself
+ ListOfShape aToolsForUsed, aToolsForUnused;
+ GeomShapePtr aFirstArgument = theHierarchy.parent(*anIt, false);
+ if (aFirstArgument && aFirstArgument->shapeType() == GeomAPI_Shape::COMPSOLID) {
+ theHierarchy.splitCompound(aFirstArgument, theUsed, aToolsForUsed);
+ theNotUsed = aToolsForUsed;
+ }
+ else {
+ aFirstArgument = *anIt;
+ theUsed.push_back(aFirstArgument);
+ }
+ aToolsForUnused.push_back(aFirstArgument);
+
+ // cut subs
+ bool isOk = true;
+ for (++anIt; anIt != theHierarchy.end() && isOk; ++anIt) {
+ ListOfShape aUsed, aNotUsed;
+
+ GeomShapePtr aParent = theHierarchy.parent(*anIt, false);
+ if (aParent && aParent->shapeType() == GeomAPI_Shape::COMPSOLID) {
+ aParent = theHierarchy.parent(*anIt); // get parent once again to mark its subs as processed
+ theHierarchy.splitCompound(aParent, aUsed, aNotUsed);
+ }
+ else
+ aUsed.push_back(*anIt);
+
+ isOk = ::cutSubs(aUsed, aToolsForUsed, theMakeShapeList, theError)
+ && ::cutSubs(aNotUsed, aToolsForUnused, theMakeShapeList, theError);
+ if (isOk) {
+ theUsed.insert(theUsed.end(), aUsed.begin(), aUsed.end());
+ theNotUsed.insert(theNotUsed.end(), aNotUsed.begin(), aNotUsed.end());