コード例 #1
0
        private vdPolyface AddMeshToEntities(vdEntities entities, MeshData mesh)
        {
            vdPolyface onepolyface = new vdPolyface();

            onepolyface.SetUnRegisterDocument(vDraw.ActiveDocument);
            onepolyface.setDocumentDefaults();

            // 顶点数组输入
            foreach (PointData point in mesh.Vertexes)
            {
                onepolyface.VertexList.Add(point.X * Tools.Ft2MmScale, point.Y * Tools.Ft2MmScale, point.Z * Tools.Ft2MmScale);
            }

            // 面片索引输入
            foreach (TriangleIndexData index in mesh.TriangleIndexes)
            {
                onepolyface.AddFaceItem(index.V1 + 1, index.V2 + 1, index.V3 + 1, index.V1 + 1, -1);
            }

            onepolyface.SmoothAngle = 45;
            onepolyface.Layer       = vDraw.ActiveDocument.Layers.FindName(mesh.MaterialName);
            entities.Add(onepolyface);

            if (ExportSetting.SystemSetting.IsExportTextureFile)
            {
                var material = Materials.Find(m => m.Name == mesh.MaterialName);
                if (material != null && !string.IsNullOrEmpty(material.GetValidMapFile()))
                {
                    var img = vDraw.ActiveDocument.Images.FindName(Path.GetFileNameWithoutExtension(material.GetValidMapFile()));
                    if (img != null)
                    {
                        onepolyface.PenColor.SystemColor   = Color.Gray;
                        onepolyface.PenColor.MaterialImage = img;

                        Matrix mtx = new Matrix();
                        mtx.IdentityMatrix();
                        mtx.ScaleMatrix(0.001, 0.001, 1);
                        onepolyface.PenColor.MaterialMatrix = mtx;
                    }
                }
            }

            onepolyface.Invalidate();
            onepolyface.Update();

            return(onepolyface);
        }
コード例 #2
0
        /// <summary>
        /// Implementation of the Slice command.
        /// </summary>
        /// <param name="doc"></param>
        public static void Slice(vdDocument doc)
        {
            doc.Prompt("Select a vdPolyface Figure");
            vdFigure fig;
            gPoint   userpt;
            //This command waits until thew user clicks an entity.
            StatusCode code = doc.ActionUtility.getUserEntity(out fig, out userpt);

            doc.Prompt(null);
            if (code == StatusCode.Success)
            {
                vdPolyface face = fig as vdPolyface;
                if (face != null)
                {
                    doc.Prompt("Pick the Origin Point");
                    gPoint origin;
                    code = doc.ActionUtility.getUserPoint(out origin);
                    doc.Prompt(null);
                    if (code != StatusCode.Success)
                    {
                        return;
                    }
                    doc.Prompt("Give the Slice Direction Vector");
                    gPoint vector;
                    code = doc.ActionUtility.getUserPoint(out vector);
                    doc.Prompt(null);
                    if (code != StatusCode.Success)
                    {
                        return;
                    }
                    Vector v = new Vector(vector);
                    face.Invalidate();
                    face.Slice(origin, v);
                    face.Update();
                    face.Invalidate();
                }
            }
        }