private void GetBlockAfterMerge(List <Line2D> orderAddedLines, List <Rectangle2D> minimumRectangles, List <Line2D> leftLines)
        {
            List <Line2D> remainLines = new List <Line2D>();

            Merge(orderAddedLines, minimumRectangles, leftLines);
            remainLines.AddRange(leftLines);
            GraphicAlgorithm.MergeLine(leftLines);
            GraphicAlgorithm.OrderLinesByLength(leftLines);
            if (remainLines.Count != leftLines.Count)
            {
                orderAddedLines = new List <Line2D>(leftLines);
                GetBlockAfterMerge(orderAddedLines, minimumRectangles, leftLines);
            }
        }
        private Rectangle2D Rebuild(List <Rectangle2D> targets)
        {
            Rectangle2D   rec1     = targets[0];
            Rectangle2D   rec2     = targets[1];
            List <Line2D> recEdges = new List <Line2D> {
                rec1.Bottom, rec1.Top, rec1.Left, rec1.Right, rec2.Bottom, rec2.Top, rec2.Left, rec2.Right
            };
            List <Line2D>      leftLines   = new List <Line2D>();
            List <Rectangle2D> newRec      = new List <Rectangle2D>(targets);
            List <Line2D>      sortedLines = new List <Line2D>(recEdges);

            foreach (var edge in recEdges)
            {
                if (IsRectangleEdge(edge, rec1) && IsRectangleEdge(edge, rec2))
                {
                    sortedLines.Remove(edge);
                }
            }
            GraphicAlgorithm.MergeLine(sortedLines);
            GraphicAlgorithm.HuntCurveByStartPoint(sortedLines, sortedLines.First().Start, leftLines);
            return(new Rectangle2D(leftLines));
        }