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

        public TopoDS_Compound Reconstruct()
        {
            var compound = new TopoDS_Compound();
            var builder  = new BRep_Builder();

            builder.MakeCompound(compound);

            var thicknessVector = SliceDirection.ToVec().Multiplied(SliceThickness / Slices.Length);

            if (thicknessVector.SquareMagnitude() == 0)
            {
                Messages.Error("Sliced shape has no thickness.");
                return(compound);
            }

            for (int index = 0; index < Slices.Length; index++)
            {
                var basePlane      = Slices[index].CutPlane.Translated(thicknessVector.Multiplied(0.5).ToPnt(), Pnt.Origin);
                var location       = new TopLoc_Location(new Trsf(basePlane.Position, Ax3.XOY));
                var relocatedShape = Slices[index].BRep.Located(location);
                var thickener      = new BRepPrimAPI_MakePrism(relocatedShape, thicknessVector, true);
                builder.Add(compound, thickener.Shape());
            }

            return(compound);
        }
        //--------------------------------------------------------------------------------------------------

        bool _CreateSlices()
        {
            var sliceInterval = SliceThickness / SliceCount;

            for (int sliceIndex = 0; sliceIndex < SliceCount; sliceIndex++)
            {
                var sliceOffset  = sliceInterval * (sliceIndex + 0.5);
                var cutPlane     = _RefPlane.Translated(SliceDirection.ToVec().Multiplied(sliceOffset));
                var cutPlaneFace = new TopoDS_Face();
                new BRep_Builder().MakeFace(cutPlaneFace, new Geom_Plane(cutPlane), 1e-7);

                // Create contour
                var common = new BRepAlgoAPI_Common(SourceShape, cutPlaneFace);
                if (!common.IsDone())
                {
                    Messages.Error("Cannot create contour face from shape.");
                    return(false);
                }
                var bodySpaceShape = common.Shape();

                // Move to origin
                var transform   = new Trsf(Ax3.XOY, cutPlane.Position);
                var transformer = new BRepBuilderAPI_Transform(bodySpaceShape, transform, true);
                var shape       = transformer.Shape();

                var slice = new Slice(shape, cutPlane);

                _Slices[sliceIndex] = slice;
            }

            return(true);
        }