Пример #1
0
//C++ TO C# CONVERTER WARNING: The original C++ declaration of the following method implementation was not found:
        public void SetFreeZoneTransformation(Vector devp, int tolclass)
        {
            double lam1 = 1.0 / tolclass;
            double lam2 = 1.0 - lam1;

            double[] mem1 = new double[100];
            double[] mem2 = new double[100];
            double[] mem3 = new double[100];

            int        vs      = oldutofreearea.Height();
            FlatVector devfree = new FlatVector(vs, ref mem1);

            int fzs = freezone.Size();

            transfreezone.SetSize(fzs);

            if (tolclass <= oldutofreearea_i.Size())
            {
                oldutofreearea_i[tolclass - 1].Mult(devp, devfree.functorMethod);

                Array <Point2d> fzi = *freezone_i[tolclass - 1];
                for (int i = 0; i < fzs; i++)
                {
                    transfreezone[i].X() = fzi[i].X() + devfree.functorMethod[2 * i];
                    transfreezone[i].Y() = fzi[i].Y() + devfree.functorMethod[2 * i + 1];
                }
            }
            else
            {
                FlatVector devfree1 = new FlatVector(vs, ref mem2);
                FlatVector devfree2 = new FlatVector(vs, ref mem3);

                oldutofreearea.Mult(devp, devfree1.functorMethod);
                oldutofreearealimit.Mult(devp, devfree2.functorMethod);
                devfree.Set2.functorMethod(lam1, devfree1.functorMethod, lam2, devfree2.functorMethod);

                for (int i = 0; i < fzs; i++)
                {
                    transfreezone[i].X() = lam1 * freezone[i].X() + lam2 * freezonelimit[i].X() + devfree.functorMethod[2 * i];
                    transfreezone[i].Y() = lam1 * freezone[i].Y() + lam2 * freezonelimit[i].Y() + devfree.functorMethod[2 * i + 1];
                }
            }


            if (fzs > 0)
            {
                fzmaxx = fzminx = transfreezone[0].X();
                fzmaxy = fzminy = transfreezone[0].Y();
            }

            for (int i = 1; i < fzs; i++)
            {
                if (transfreezone[i].X() > fzmaxx)
                {
                    fzmaxx = transfreezone[i].X();
                }
                if (transfreezone[i].X() < fzminx)
                {
                    fzminx = transfreezone[i].X();
                }
                if (transfreezone[i].Y() > fzmaxy)
                {
                    fzmaxy = transfreezone[i].Y();
                }
                if (transfreezone[i].Y() < fzminy)
                {
                    fzminy = transfreezone[i].Y();
                }
            }

            for (int i = 0; i < fzs; i++)
            {
                Point2d p1 = transfreezone[i];
                Point2d p2 = transfreezone[(i + 1) % fzs];

                Vec2d vn = new Vec2d(p2.Y() - p1.Y(), p1.X() - p2.X());

                double len2 = vn.Length2();

                if (len2 < 1e-10)
                {
                    freesetinequ(i, 0) = 0;
                    freesetinequ(i, 1) = 0;
                    freesetinequ(i, 2) = -1;
                }
                else
                {
                    vn /= ngsimd.GlobalMembers.sqrt(len2);       // scaling necessary ?

                    freesetinequ(i, 0) = vn.X();
                    freesetinequ(i, 1) = vn.Y();
                    freesetinequ(i, 2) = -(p1.X() * vn.X() + p1.Y() * vn.Y());
                }
            }
        }