Exemplo n.º 1
0
//C++ TO C# CONVERTER WARNING: The original C++ declaration of the following method implementation was not found:
        public void FindInnerBoxes(AdFront2 adfront, testinnerDelegate testinner)
        {
            //C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method:
            //	static int timer = NgProfiler::CreateTimer("LocalH::FindInnerBoxes 2d");
            NgProfiler.RegionTimer reg = new NgProfiler.RegionTimer(FindInnerBoxes_timer);

            for (int i = 0; i < boxes.Size(); i++)
            {
                boxes[i].flags.isinner = 0;
            }

            root.flags.isinner = 0;

            Point <2> rpmid(root.xmid[0], root.xmid[1]);              // , root->xmid[2]);
            Vec <2> rv(root.h2, root.h2);

            Point <2> rx2 = rpmid + rv;

            // Point<2> rx1 = rpmid - rv;


            root.flags.pinner = !adfront.SameSide(rpmid, rx2);

            if (testinner != null)
            {
                (*testout) << "inner = " << root.flags.pinner << " =?= " << testinner(rpmid) << "\n";
            }


            int              nf        = adfront.GetNFL();
            Array <int>      faceinds  = new Array <int>(nf);
            Array <Box <3> > faceboxes = new Array <Box <3> >(nf);

            for (int i = 0; i < nf; i++)
            {
                faceinds[i] = i;
                // adfront->GetFaceBoundingBox(i, faceboxes.Elem(i));

                FrontLine line = adfront.GetLine(i);
                faceboxes[i].Set(adfront.GetPoint(line.L().I1()));
                faceboxes[i].Add(adfront.GetPoint(line.L().I2()));
            }

            for (int i = 0; i < 8; i++)
            {
                FindInnerBoxesRec2(root.childs[i], adfront, faceboxes, faceinds, nf);
            }
        }
Exemplo n.º 2
0
//C++ TO C# CONVERTER WARNING: The original C++ declaration of the following method implementation was not found:
        public void BlockFillLocalH(Mesh mesh, MeshingParameters mp)
        {
            //C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method:
            //	static int timer = NgProfiler::CreateTimer("Meshing2::BlockFill");
            //C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method:
            //	static int timer1 = NgProfiler::CreateTimer("Meshing2::BlockFill 1");
            //C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method:
            //	static int timer2 = NgProfiler::CreateTimer("Meshing2::BlockFill 2");
            //C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method:
            //	static int timer3 = NgProfiler::CreateTimer("Meshing2::BlockFill 3");
            //C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method:
            //	static int timer4 = NgProfiler::CreateTimer("Meshing2::BlockFill 4");
            NgProfiler.RegionTimer reg = new NgProfiler.RegionTimer(BlockFillLocalH_timer);

            NgProfiler.StartTimer(BlockFillLocalH_timer1);

            double filldist = mp.filldist;

            Console.Write("blockfill local h");
            Console.Write("\n");
            Console.Write("rel filldist = ");
            Console.Write(filldist);
            Console.Write("\n");
            PrintMessage(3, "blockfill local h");

            Array <Point <3> > npoints = new Array <Point <3> >();

            // adfront -> CreateTrees();

            Box <3> bbox(Box <3> .EMPTY_BOX);

            double maxh = 0;

            for (int i = 0; i < adfront.GetNFL(); i++)
            {
                FrontLine line = adfront.GetLine(i);

                const Point <3>& p1 = adfront.GetPoint(line.L().I1());
                const Point <3>& p2 = adfront.GetPoint(line.L().I2());

                maxh = Math.Max(maxh, Dist(p1, p2));

                bbox.Add(p1);
                bbox.Add(p2);
            }


            Console.Write("bbox = ");
            Console.Write(bbox);
            Console.Write("\n");


            // Point<3> mpc = bbox.Center();
            bbox.Increase(bbox.Diam() / 2);
            Box <3> meshbox = bbox;

            NgProfiler.StopTimer(BlockFillLocalH_timer1);
            NgProfiler.StartTimer(BlockFillLocalH_timer2);


            LocalH loch2 = new LocalH(bbox, 1, 2);

            if (mp.maxh < maxh)
            {
                maxh = mp.maxh;
            }

            bool changed;

            do
            {
                mesh.LocalHFunction().ClearFlags();

                for (int i = 0; i < adfront.GetNFL(); i++)
                {
                    FrontLine line = adfront.GetLine(i);

                    Box <3> bbox(adfront.GetPoint(line.L().I1()));

                    bbox.Add(adfront.GetPoint(line.L().I2()));


                    double filld = filldist * bbox.Diam();
                    bbox.Increase(filld);

                    mesh.LocalHFunction().CutBoundary(bbox);
                }


                mesh.LocalHFunction().FindInnerBoxes(adfront, null);

                npoints.SetSize(0);
                mesh.LocalHFunction().GetInnerPoints(npoints);

                changed = false;
                for (int i = 0; i < npoints.Size(); i++)
                {
                    if (mesh.LocalHFunction().GetH(npoints[i]) > 1.2 * maxh)
                    {
                        mesh.LocalHFunction().SetH(npoints[i], maxh);
                        changed = true;
                    }
                }
            } while (changed);

            NgProfiler.StopTimer(BlockFillLocalH_timer2);
            NgProfiler.StartTimer(BlockFillLocalH_timer3);


            if (debugparam.slowchecks)
            {
                (*testout) << "Blockfill with points: " << "\n";
            }
            *testout << "loch = " << mesh.LocalHFunction() << "\n";

            *testout << "npoints = " << "\n" << npoints << "\n";

            for (int i = 1; i <= npoints.Size(); i++)
            {
                if (meshbox.IsIn(npoints.Get(i)))
                {
                    PointIndex gpnum = mesh.AddPoint(npoints.Get(i));
                    adfront.AddPoint(npoints.Get(i), gpnum);

                    if (debugparam.slowchecks)
                    {
                        (*testout) << npoints.Get(i) << "\n";

                        Point <2> p2d(npoints.Get(i)(0), npoints.Get(i)(1));

                        if (!adfront.Inside(p2d))
                        {
                            Console.Write("add outside point");
                            Console.Write("\n");
                            (*testout) << "outside" << "\n";
                        }
                    }
                }
            }

            NgProfiler.StopTimer(BlockFillLocalH_timer3);
            NgProfiler.StartTimer(BlockFillLocalH_timer4);


            // find outer points

            loch2.ClearFlags();

            for (int i = 0; i < adfront.GetNFL(); i++)
            {
                FrontLine line = adfront.GetLine(i);

                Box <3> bbox(adfront.GetPoint(line.L().I1()));

                bbox.Add(adfront.GetPoint(line.L().I2()));

                loch2.SetH(bbox.Center(), bbox.Diam());
            }


            for (int i = 0; i < adfront.GetNFL(); i++)
            {
                FrontLine line = adfront.GetLine(i);

                Box <3> bbox(adfront.GetPoint(line.L().I1()));

                bbox.Add(adfront.GetPoint(line.L().I2()));

                bbox.Increase(filldist * bbox.Diam());
                loch2.CutBoundary(bbox);
            }

            loch2.FindInnerBoxes(adfront, null);

            // outer points : smooth mesh-grading
            npoints.SetSize(0);
            loch2.GetOuterPoints(npoints);

            for (int i = 1; i <= npoints.Size(); i++)
            {
                if (meshbox.IsIn(npoints.Get(i)))
                {
                    PointIndex gpnum = mesh.AddPoint(npoints.Get(i));
                    adfront.AddPoint(npoints.Get(i), gpnum);
                }
            }

            NgProfiler.StopTimer(BlockFillLocalH_timer4);
        }