Пример #1
0
        public void DumpMesh(uint id)
        {
            CadFigureMesh fig = GetCadFigureMesh(id);

            if (fig == null)
            {
                ItConsole.println("dumpMesh(id) error: invalid ID");
                return;
            }

            CadMesh cm = HeModelConverter.ToCadMesh(fig.mHeModel);

            for (int i = 0; i < cm.VertexStore.Count; i++)
            {
                CadVertex v = cm.VertexStore[i];
                ItConsole.printf("{0}:{1},{2},{3}\n", i, v.X, v.Y, v.Z);
            }

            for (int i = 0; i < cm.FaceStore.Count; i++)
            {
                CadFace f = cm.FaceStore[i];

                string s = "";

                for (int j = 0; j < f.VList.Count; j++)
                {
                    s += f.VList[j].ToString() + ",";
                }

                ItConsole.println(s);
            }
        }
Пример #2
0
        public void Intersection(uint idA, uint idB)
        {
            CadFigureMesh figA = GetCadFigureMesh(idA);
            CadFigureMesh figB = GetCadFigureMesh(idB);

            if (figA == null || figB == null)
            {
                ItConsole.println("invalid ID");
                return;
            }
            HeModel he_a = figA.mHeModel;
            HeModel he_b = figB.mHeModel;

            CadMesh a = HeModelConverter.ToCadMesh(he_a);
            CadMesh b = HeModelConverter.ToCadMesh(he_b);

            CadMesh c = CarveW.Intersection(a, b);

            MeshUtil.SplitAllFace(c);


            HeModel hem = HeModelConverter.ToHeModel(c);

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

            fig.SetMesh(hem);

            CadOpe ope = new CadOpeAddFigure(Controller.CurrentLayer.ID, fig.ID);

            Session.AddOpe(ope);

            Controller.CurrentLayer.AddFigure(fig);

            Session.PostRemakeObjectTree();
        }
Пример #3
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();
        }
Пример #4
0
        private void testAminusB()
        {
            List <CadFigure> figList = Controller.DB.GetSelectedFigList();

            if (figList.Count < 2)
            {
                return;
            }

            if (figList[0].Type != CadFigure.Types.MESH)
            {
                return;
            }

            if (figList[1].Type != CadFigure.Types.MESH)
            {
                return;
            }

            CadFigureMesh fig_a = (CadFigureMesh)figList[0];
            CadFigureMesh fig_b = (CadFigureMesh)figList[1];

            if (fig_a.Current)
            {
                CadFigureMesh t = fig_a;
                fig_a = fig_b;
                fig_b = t;
            }

            ItConsole.println("ID:" + fig_a.ID.ToString() + " - ID:" + fig_b.ID.ToString());

            HeModel he_a = fig_a.mHeModel;
            HeModel he_b = fig_b.mHeModel;

            CadMesh a = HeModelConverter.ToCadMesh(he_a);
            CadMesh b = HeModelConverter.ToCadMesh(he_b);

            CadMesh c = CarveW.AMinusB(a, b);


            HeModel hem = HeModelConverter.ToHeModel(c);

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

            fig.SetMesh(hem);

            Controller.CurrentLayer.AddFigure(fig);
        }
Пример #5
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);
        }