static void Algorithm(ISet<Paralepiped> SetP, ISet<Paralepiped> SetF, Paralepiped FulP)
        {
            char[] color = FulP.GetColor();
            //подсчитываем колличество паралепипедов на стыках сторон
            int n_d = 0, n_w = 0, n_h = 0;
            foreach (Paralepiped P in SetP)
            {
                if (P.TestColor(2, new char[] { color[0], color[2] }) == true)
                    n_h++;
                if (P.TestColor(2, new char[] { color[2], color[4] }) == true)
                    n_w++;
                if (P.TestColor(2, new char[] { color[0], color[4] }) == true)
                    n_d++;
            }
            int[] h_mas = new int[n_h];
            int[] d_mas = new int[n_d];
            int[] w_mas = new int[n_w];

            //-------------------------------------------------------------------------------------------------
            //устанавливаем паралепипеды с 3 цветами
            for (int i = 0; i < 2; i++)
                for (int j = 2; j < 4; j++)
                    for (int k = 4; k < 6; k++)
                        foreach (Paralepiped P in SetP)
                            if (Turn3(i, j, k, P, color) == true)
                            {
                                SetP.Remove(P);
                                P.SetXYZ((i == 0) ? 0 : FulP.GetW() - P.GetW(), (j == 2) ? 0 : FulP.GetD() - P.GetD(), (k == 4) ? 0 : FulP.GetH() - P.GetH());
                                w_mas[(i == 0) ? 0 : w_mas.Length - 1] = (i == 0) ? P.GetW() : FulP.GetW();
                                d_mas[(j == 2) ? 0 : d_mas.Length - 1] = (j == 2) ? P.GetD() : FulP.GetD();
                                h_mas[(k == 4) ? 0 : h_mas.Length - 1] = (k == 4) ? P.GetH() : FulP.GetH();
                                SetF.Add(P);
                                break;
                            }
            //------------------------------------------------------------------------------------------------
            U2(w_mas, d_mas, h_mas, SetP, SetF, color);
            U1(w_mas, d_mas, h_mas, SetP, SetF, color);
            //устанавливаем паралепипеды без цветов
            for (int i = 1; i < w_mas.Length - 1; i++)
                for (int j = 1; j < d_mas.Length - 1; j++)
                    for (int k = 1; k < h_mas.Length - 1; k++)
                        foreach (Paralepiped P in SetP)
                            if (P.TestSize(w_mas[i] - w_mas[i - 1], d_mas[j] - d_mas[j - 1], h_mas[k] - h_mas[k - 1]) == true)
                            {
                                SetP.Remove(P);
                                if (P.GetW() != w_mas[i] - w_mas[i - 1])
                                    if (P.GetH() == w_mas[i] - w_mas[i - 1])
                                        P.TurnVertical();
                                    else
                                        P.TurnHorisontal1();
                                if (P.GetH() != h_mas[k] - h_mas[k - 1])
                                    P.TurnHorisontal();
                                P.SetXYZ(w_mas[i - 1], d_mas[j - 1], h_mas[k - 1]);
                                SetF.Add(P);
                                break;
                            }
        }