/// <summary>
        /// Calculates slicing plane top offset
        /// </summary>
        /// <param name="Atar">Target area</param>
        /// <returns>Offset of the slicing plane from the top</returns>
        public double GetSlicePlaneTopOffset(double Atar)
        {
            double SlicePlaneCoordinate = 0.0;
            double Sum_hi            = 0; //summation of height of previous rectangles
            double Sum_Ai            = 0; //summation of areas of previous rectangles
            var    sortedRectanglesX = RectanglesXAxis.OrderByDescending(r => r.InsertionPoint.Y).ToList();

            foreach (var r in sortedRectanglesX)
            {
                double bn        = r.b;
                double hn        = r.h;
                double hn_actual = r.h_a; //actual height used for fillet areas
                double yn        = 0;

                double An = bn * hn;

                //distance from top of the rectangle to the slicing plane
                //this number is meaningful only for one rectangle
                double h_n_tilda = (Atar - Sum_Ai) / bn;
                double Y_n_tilda = 0;

                //check if this rectangle is the one where
                //slice plane is located
                if (h_n_tilda > 0 && h_n_tilda <= hn)
                {
                    //this condition is met only for one rectangle
                    Y_n_tilda            = Sum_hi + h_n_tilda;
                    SlicePlaneCoordinate = Y_n_tilda;//slicing plane coordinate is measured from top
                }
                Sum_Ai += An;
                Sum_hi += hn_actual;
            }

            return(SlicePlaneCoordinate);
        }
        private void CalculatePlasticProperties()
        {
            //sort rectangles collection to make sure that they go from top to bottom
            var sortedRectanglesX = RectanglesXAxis.OrderByDescending(r => r.InsertionPoint.Y).ToList();

            CalculatePlasticSectionModulus(AnalysisAxis.X, sortedRectanglesX);

            //sort rectangles collection to make sure that they go from left to right
            if (RectanglesYAxis != null)
            {
                var sortedRectanglesY = RectanglesYAxis.OrderBy(r => r.InsertionPoint.X).ToList();
                CalculatePlasticSectionModulus(AnalysisAxis.Y, sortedRectanglesY);
            }
        }
        /// <summary>
        /// Calculates a section based on slicing criteria
        /// </summary>
        /// <param name="YCoordinate">Plane Y coordinate in local coordinate system</param>
        /// <param name="sliceType">Indicates whether top or bottom slice is returned</param>
        /// <returns></returns>
        private IMoveableSection getSliceAtCoordinate(double YCoordinate, SliceType sliceType)
        {
            ArbitraryCompoundShape newShape = new ArbitraryCompoundShape(null, null);

            if (sliceType == SliceType.Top)
            {
                var sortedRectanglesX = RectanglesXAxis.OrderByDescending(r => r.InsertionPoint.Y).ToList();
                foreach (var r in sortedRectanglesX)
                {
                    if (r.Ymax > YCoordinate && r.Ymin >= YCoordinate)
                    {
                        newShape.rectanglesXAxis.Add(r);
                    }
                    else if (r.Ymax >= YCoordinate && r.Ymin <= YCoordinate)
                    {
                        double thisRectHeight = r.Ymax - YCoordinate;
                        newShape.rectanglesXAxis.Add(new CompoundShapePart(r.b, thisRectHeight, new Point2D(0, r.Ymax - thisRectHeight / 2.0)));
                    }
                    else
                    {
                        //do nothing since this rectangle does not belong here
                    }
                }
            }
            else
            {
                var sortedRectanglesX = RectanglesXAxis.OrderBy(r => r.InsertionPoint.Y).ToList();
                foreach (var r in sortedRectanglesX)
                {
                    if (r.Ymax <= YCoordinate && r.Ymin < YCoordinate)
                    {
                        newShape.rectanglesXAxis.Add(r);
                    }
                    else if (r.Ymax > YCoordinate && r.Ymin <= YCoordinate)
                    {
                        double thisRectHeight = YCoordinate - r.Ymin;
                        newShape.rectanglesXAxis.Add(new CompoundShapePart(r.b, thisRectHeight, new Point2D(0, r.Ymin + thisRectHeight / 2.0)));
                    }
                    else
                    {
                        //do nothing since this rectangle does not belong here
                    }
                }
            }

            return(newShape);
        }