Пример #1
0
        public static void test_planar_fill()
        {
            //DMesh3 mesh = TestUtil.LoadTestInputMesh("bunny_solid.obj");
            //DMesh3 mesh = TestUtil.LoadTestInputMesh("bunny_hollow.obj");
            DMesh3 mesh = TestUtil.LoadTestInputMesh("local\\__LAST_FAILED_CUT_MESH.obj");
            double mine, maxe, avge;

            MeshQueries.EdgeLengthStats(mesh, out mine, out maxe, out avge);

            AxisAlignedBox3d bounds    = mesh.CachedBounds;
            Vector3d         origin    = bounds.Center;
            Vector3d         axis      = Vector3d.AxisY;
            double           targetLen = avge;

            origin    = new Vector3d(-7.53203300, -39.50826000, -4.22260500);
            axis      = new Vector3d(0.00000007, 0.00000007, -0.99999960);
            targetLen = 3.0;

            MeshPlaneCut cut = new MeshPlaneCut(mesh, origin, axis);

            cut.Cut();

            PlanarHoleFiller fill = new PlanarHoleFiller(cut)
            {
                FillTargetEdgeLen = targetLen
            };

            if (fill.Fill() == false)
            {
                System.Console.WriteLine("test_meshEdits.test_planar_fill: Fill() failed!");
            }

            TestUtil.WriteTestOutputMesh(mesh, "planar_filled.obj");
        }
Пример #2
0
        DMesh3 compute_cut(Vector3d origin, Vector3d normal, double tol, bool fill_holes, double fill_len, out bool fill_errors)
        {
            fill_errors = false;
            DMesh3 cutMesh = new DMesh3(MeshSource.GetDMeshUnsafe());

            MeshPlaneCut cut = new MeshPlaneCut(cutMesh, origin, normal);

            cut.DegenerateEdgeTol = tol;

            if (cut.Cut() == false)
            {
                throw new Exception("[PlanarCutOp] cut.Cut() returned false");
            }

            if (fill_holes)
            {
                PlanarHoleFiller fill = new PlanarHoleFiller(cut)
                {
                    FillTargetEdgeLen = fill_len
                };
                if (fill.Fill() == false)
                {
                    fill_errors = true;
                }
            }

            return(cutMesh);
        }
Пример #3
0
        private void CutSectionSide(DMesh3 mesh, Vector3d origin, Vector3d direction, bool fill)
        {
            MeshPlaneCut cut = new MeshPlaneCut(mesh, origin, direction);
            bool         bc  = cut.Cut();

            if (fill)
            {
                PlanarHoleFiller filler = new PlanarHoleFiller(cut)
                {
                    FillTargetEdgeLen = _cubeSize
                };
                bool bf = filler.Fill();
            }
        }
Пример #4
0
        public static DMesh3 PlanarFill(DMesh3 mesh, EdgeLoop loop, double eLen)
        {
            PlanarHoleFiller holeFiller = new PlanarHoleFiller(mesh);

            holeFiller.AddFillLoop(loop);

            Plane.FitPlaneToPoints(loop.Vertices.Select(ind => mesh.GetVertex(ind).ToRhinoPt()), out Plane pl);

            holeFiller.SetPlane(pl.Origin.ToVec3d(), pl.ZAxis.ToVec3d());

            holeFiller.FillTargetEdgeLen = eLen;

            holeFiller.Fill();

            return(holeFiller.Mesh);
        }
Пример #5
0
        bool fill_planar()
        {
            Vector3d n = Vector3d.Zero, c = Vector3d.Zero;
            int      NE = FillLoop.EdgeCount;

            for (int k = 0; k < NE; ++k)
            {
                int eid = FillLoop.Edges[k];
                n += Mesh.GetTriNormal(Mesh.GetEdgeT(eid).a);
                c += Mesh.GetEdgePoint(eid, 0.5);
            }
            n.Normalize(); c /= (double)NE;

            var filler = new PlanarHoleFiller(Mesh);

            filler.FillTargetEdgeLen = TargetEdgeLength;
            filler.AddFillLoop(FillLoop);
            filler.SetPlane(c, n);

            bool bOK = filler.Fill();

            return(bOK);
        }