Ejemplo n.º 1
0
        public void CutMesh(uint id)
        {
            CadFigureMesh tfig = GetCadFigureMesh(id);

            if (tfig == null)
            {
                ItConsole.println("invalid ID");
                return;
            }

            (Vector3d p0, Vector3d p1) = InputLine();

            if (p0.IsInvalid() || p1.IsInvalid())
            {
                return;
            }


            HeModel he  = tfig.mHeModel;
            CadMesh src = HeModelConverter.ToCadMesh(he);

            Vector3d normal = CadMath.Normal(
                p1 - p0, (Controller.DC.ViewDir));

            (CadMesh m1, CadMesh m2) = MeshUtil.CutMeshWithVector(src, p0, p1, normal);


            CadFigureMesh fig1 = (CadFigureMesh)Controller.DB.NewFigure(CadFigure.Types.MESH);

            fig1.SetMesh(HeModelConverter.ToHeModel(m1));

            CadFigureMesh fig2 = (CadFigureMesh)Controller.DB.NewFigure(CadFigure.Types.MESH);

            fig2.SetMesh(HeModelConverter.ToHeModel(m2));

            CadOpe ope;

            ope = new CadOpeAddFigure(Controller.CurrentLayer.ID, fig1.ID);
            Session.AddOpe(ope);
            Controller.CurrentLayer.AddFigure(fig1);

            ope = new CadOpeAddFigure(Controller.CurrentLayer.ID, fig2.ID);
            Session.AddOpe(ope);
            Controller.CurrentLayer.AddFigure(fig2);

            ope = new CadOpeRemoveFigure(Controller.CurrentLayer, tfig.ID);
            Session.AddOpe(ope);
            Controller.CurrentLayer.RemoveFigureByID(tfig.ID);

            Controller.ClearSelection();

            Session.PostRemakeObjectTree();
        }
Ejemplo n.º 2
0
        public void CutMeshWithVector(CadFigureMesh tfig, Vector3d p0, Vector3d p1, Vector3d normal)
        {
            HeModel he  = tfig.mHeModel;
            CadMesh src = HeModelConverter.ToCadMesh(he);

            (CadMesh m1, CadMesh m2) = MeshUtil.CutMeshWithVector(src, p0, p1, normal);

            if (m1 == null || m2 == null)
            {
                return;
            }

            CadFigureMesh fig1 = (CadFigureMesh)Controller.DB.NewFigure(CadFigure.Types.MESH);

            fig1.SetMesh(HeModelConverter.ToHeModel(m1));

            CadFigureMesh fig2 = (CadFigureMesh)Controller.DB.NewFigure(CadFigure.Types.MESH);

            fig2.SetMesh(HeModelConverter.ToHeModel(m2));


            CadOpeList opeRoot = new CadOpeList();

            CadOpe ope;

            ope = new CadOpeAddFigure(Controller.CurrentLayer.ID, fig1.ID);
            opeRoot.Add(ope);
            Controller.CurrentLayer.AddFigure(fig1);

            ope = new CadOpeAddFigure(Controller.CurrentLayer.ID, fig2.ID);
            opeRoot.Add(ope);
            Controller.CurrentLayer.AddFigure(fig2);

            ope = new CadOpeRemoveFigure(Controller.CurrentLayer, tfig.ID);
            opeRoot.Add(ope);
            Controller.CurrentLayer.RemoveFigureByID(tfig.ID);

            Controller.HistoryMan.foward(opeRoot);
        }