//--------------------------------------------------------------------------------------------------

        bool _DoCutoutBoxes(MakeContext context)
        {
            var listOfTools = new TopTools_ListOfShape();

            foreach (var boxes in context.Boxes)
            {
                for (int boxIndex = _ReverseOrder == _IsFirst ? 0 : 1; boxIndex < boxes.Count; boxIndex += 2)
                {
                    listOfTools.Append(boxes[boxIndex]);
                }
            }

            var listOfArguments = new TopTools_ListOfShape();

            listOfArguments.Append(context.OwnBrep);

            var cutter = new BRepAlgoAPI_Cut();

            cutter.SetArguments(listOfArguments);
            cutter.SetTools(listOfTools);
            cutter.Build();
            if (!cutter.IsDone())
            {
                Messages.Error("Cannot cut boxes out of shape.");
                return(false);
            }

            context.Result = cutter.Shape();
            UpdateModifiedSubshapes(context.OwnBrep, cutter);

            return(true);
        }
        //--------------------------------------------------------------------------------------------------

        bool _DoCutoffExcess(MakeContext context)
        {
            var listOfArguments = new TopTools_ListOfShape();

            listOfArguments.Append(context.OwnBrep);

            // Cutout Commons
            var listOfTools = new TopTools_ListOfShape();

            foreach (var commonSolid in context.Common)
            {
                listOfTools.Append(commonSolid);
            }

            var cutter = new BRepAlgoAPI_Cut();

            cutter.SetArguments(listOfArguments);
            cutter.SetTools(listOfTools);
            cutter.Build();
            if (!cutter.IsDone())
            {
                Messages.Error("Cannot determine excess of instrusion.");
                return(false);
            }

            // Check if we have more solids than before
            var originalSolidCount = context.OwnBrep.Solids().Count;
            var solids             = cutter.Shape().Solids();
            var excessCount        = solids.Count - originalSolidCount;

            if (excessCount <= 0)
            {
                return(true); // No excess found
            }
            // Cutout additional solids
            listOfTools = new TopTools_ListOfShape();
            var orderedSolids = solids.OrderBy(solid => solid.Volume()).Take(excessCount);

            foreach (var solid in orderedSolids)
            {
                listOfTools.Append(solid);
            }

            cutter = new BRepAlgoAPI_Cut();
            cutter.SetArguments(listOfArguments);
            cutter.SetTools(listOfTools);
            cutter.Build();
            if (!cutter.IsDone())
            {
                Messages.Error("Cannot remove excess of instrusion from shape.");
                return(false);
            }

            UpdateModifiedSubshapes(context.OwnBrep, cutter);
            context.OwnBrep = cutter.Shape();
            return(true);
        }