private static void WritePolyfaceMesh()
        {
            DxfDocument dxf = new DxfDocument();


            List <PolyfaceMeshVertex> vertexes = new List <PolyfaceMeshVertex>
            {
                new PolyfaceMeshVertex(0, 0, 0),
                new PolyfaceMeshVertex(10, 0, 0),
                new PolyfaceMeshVertex(10, 10, 0),
                new PolyfaceMeshVertex(5, 15, 0),
                new PolyfaceMeshVertex(0, 10, 0)
            };
            List <PolyfaceMeshFace> faces = new List <PolyfaceMeshFace>
            {
                new PolyfaceMeshFace(new[] { 1, 2, -3 }),
                new PolyfaceMeshFace(new[] { -1, 3, -4 }),
                new PolyfaceMeshFace(new[] { -1, 4, 5 })
            };

            PolyfaceMesh mesh = new PolyfaceMesh(vertexes, faces);

            dxf.AddEntity(mesh);

            dxf.Save("mesh.dxf", DxfVersion.AutoCad2000);
        }
예제 #2
0
		/*Draw PolyfaceMesh*/
		public static void DrawPolyfaceMesh(PolyfaceMesh xPoly, Canvas mainCanvas)
		{
			System.Windows.Shapes.Polygon wPoly = new System.Windows.Shapes.Polygon();

			foreach (netDxf.Entities.PolyfaceMeshVertex xVertex in xPoly.Vertexes) {
				System.Windows.Point myPt = TypeConverter.Vertex3ToPoint(xVertex.Location);
				getMaxPt(myPt);
				myPt.Y = mainCanvas.Height - myPt.Y;
				wPoly.Points.Add(myPt);
			}
			TypeConverter.Entity2Shape(xPoly, wPoly);
			mainCanvas.Children.Add(wPoly);
		}
예제 #3
0
    private void AddMesh(List <Vector3RD> triangleVertices, string layerName)
    {
        PolyfaceMesh pfm;
        // create Mesh
        List <PolyfaceMeshVertex> pfmVertices = new List <PolyfaceMeshVertex>();

        pfmVertices.Capacity = triangleVertices.Count;
        List <PolyfaceMeshFace> pfmFaces = new List <PolyfaceMeshFace>();

        pfmFaces.Capacity = triangleVertices.Count / 3;
        int facecounter = 0;

        Debug.Log(triangleVertices.Count);
        int vertexIndex = 0;

        for (int i = 0; i < triangleVertices.Count; i += 3)
        {
            pfmVertices.Add(new PolyfaceMeshVertex(triangleVertices[i].x, triangleVertices[i].y, triangleVertices[i].z));
            pfmVertices.Add(new PolyfaceMeshVertex(triangleVertices[i + 2].x, triangleVertices[i + 2].y, triangleVertices[i + 2].z));
            pfmVertices.Add(new PolyfaceMeshVertex(triangleVertices[i + 1].x, triangleVertices[i + 1].y, triangleVertices[i + 1].z));

            PolyfaceMeshFace pfmFace = new PolyfaceMeshFace(new List <short>()
            {
                (short)(vertexIndex + 1), (short)(vertexIndex + 2), (short)(vertexIndex + 3)
            });
            vertexIndex += 3;
            pfmFaces.Add(pfmFace);
            facecounter++;
            if (facecounter % 10000 == 0)
            {
                pfm       = new PolyfaceMesh(pfmVertices, pfmFaces);
                pfm.Layer = dxfLayer;
                dxfDocument.AddEntity(pfm);
                pfmVertices.Clear();
                pfmFaces.Clear();
                facecounter = 0;
                vertexIndex = 0;
            }
        }
        if (pfmFaces.Count > 0)
        {
            pfm       = new PolyfaceMesh(pfmVertices, pfmFaces);
            pfm.Layer = dxfLayer;
            dxfDocument.AddEntity(pfm);
        }
    }
예제 #4
0
 private void DrawPolyfaceMesh(PolyfaceMesh pm)
 {
     EntitiesToFcs(pm.Explode());
 }