Ejemplo n.º 1
0
        private void testMesh()
        {
            var figlist = Controller.DB.GetSelectedFigList();

            CadOpeList opeRoot = new CadOpeList();

            CadOpe ope;

            for (int i = 0; i < figlist.Count; i++)
            {
                CadFigure fig = figlist[i];

                if (fig == null)
                {
                    continue;
                }

                if (fig.Type != CadFigure.Types.POLY_LINES)
                {
                    continue;
                }

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

                mesh.CreateModel(fig);


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

                Controller.CurrentLayer.AddFigure(mesh);


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

                Controller.CurrentLayer.RemoveFigureByID(fig.ID);
            }

            if (opeRoot.OpeList.Count > 0)
            {
                Controller.HistoryMan.foward(opeRoot);
            }

            Controller.UpdateObjectTree(true);
        }
Ejemplo n.º 2
0
        public void ToMesh(uint id)
        {
            CadOpeList opeRoot = new CadOpeList();

            CadOpe ope;

            CadFigure orgFig = Controller.DB.GetFigure(id);


            if (orgFig == null)
            {
                return;
            }

            if (orgFig.Type != CadFigure.Types.POLY_LINES)
            {
                return;
            }

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

            mesh.CreateModel(orgFig);

            foreach (CadFigure fig in orgFig.ChildList)
            {
                mesh.AddChild(fig);
            }

            CadFigure parent = orgFig.Parent;

            if (parent != null)
            {
                int index = orgFig.Parent.ChildList.IndexOf(orgFig);

                // Remove original poly lines object
                ope = new CadOpeRemoveChild(parent, orgFig, index);
                opeRoot.Add(ope);

                orgFig.Parent.ChildList.Remove(orgFig);

                // Insert mesh object
                ope = new CadOpeAddChild(parent, mesh, index);
                opeRoot.Add(ope);

                orgFig.Parent.ChildList.Insert(index, mesh);
                mesh.Parent = parent;
            }
            else
            {
                // Remove original poly lines object
                ope = new CadOpeAddFigure(Controller.CurrentLayer.ID, mesh.ID);
                opeRoot.Add(ope);
                Controller.CurrentLayer.AddFigure(mesh);

                // Insert mesh object
                ope = new CadOpeRemoveFigure(Controller.CurrentLayer, orgFig.ID);
                opeRoot.Add(ope);
                Controller.CurrentLayer.RemoveFigureByID(orgFig.ID);
            }

            Session.AddOpe(opeRoot);

            Env.RunOnMainThread(() =>
            {
                Controller.ClearSelection();
            });

            Session.PostRemakeObjectTree();
            //PrintSuccess();
        }