Table of Contents

Class DxfPolygonMesh

Namespace
GeometryHelper.Dxf
Assembly
GeometryHelper.dll

A polygon mesh of a DXF file (a POLYLINE of flag 16 of its group 70), as AutoCAD's PolygonMesh: a grid of MSize rows of NSize points (DxfPolygonMeshVertex), row after row, each cell a face of four corners, closed in M where flag 1 is set and in N where flag 32 is.

public sealed class DxfPolygonMesh : DxfEntity, IEnumerable<DxfPolygonMeshVertex>, IEnumerable
Inheritance
DxfPolygonMesh
Implements
Inherited Members
Extension Methods

Remarks

The mesh is walked as AutoCAD walks one, foreach (DxfPolygonMeshVertex vertex in mesh). GetGeometry() gives the body DxfReader reads of it: a grid of 3 by 4 closed in N is 8 cells, 8 faces of four corners.

A point set is written in its own record; one appended is a record put in, every other keeping its handle. The sizes are the record's groups 71 and 72, which are not changed by appending: set them to the grid the points make.

Constructors

DxfPolygonMesh()

Initializes a mesh of no points, as AutoCAD's new PolygonMesh(), on layer 0 in no file.

DxfPolygonMesh(DxfPolyMeshType, int, int, IEnumerable<GeoPoint3>, bool, bool)

Initializes a mesh of a grid of points, as AutoCAD's new PolygonMesh(type, size, sizeValue, vertices, closedValue, closed), on layer 0 in no file until it is added to one.

Properties

IsMClosed

Gets whether the last row is joined to the first (flag 1 of group 70), as AutoCAD's IsMClosed.

IsNClosed

Gets whether the last point of each row is joined to its first (flag 32 of group 70), as AutoCAD's IsNClosed.

MSize

Gets or sets how many rows the mesh has, M (group 71), as AutoCAD's MSize.

MSurfaceDensity

Gets or sets how many rows the smoothed surface has, M (group 73), as AutoCAD's MSurfaceDensity; nought where the record gives none.

NSize

Gets or sets how many points each row of the mesh has, N (group 72), as AutoCAD's NSize.

NSurfaceDensity

Gets or sets how many points each row of the smoothed surface has, N (group 74), as AutoCAD's NSurfaceDensity; nought where the record gives none.

PolyMeshType

Gets or sets the surface the mesh is smoothed into, as AutoCAD's PolyMeshType: group 75 where flag 4 of group 70 says it is smoothed, SimpleMesh where it is not.

Methods

AppendVertex(DxfPolygonMeshVertex)

Appends a point made in code after the last, as AutoCAD's AppendVertex; the sizes are not changed.

ConvertToPolyMeshType(DxfPolyMeshType)

Converts the mesh to a type, as AutoCAD's ConvertToPolyMeshType: straightened for SimpleMesh, otherwise smoothed into that surface as SurfaceFit(DxfPolyMeshType, int, int) smooths it, of the mesh's own densities (groups 73 and 74) where they are 2 or more, else the header's SURFU and SURFV (6 where the file gives none).

Explode()

Gets the faces the mesh breaks into, as AutoCAD's Explode, as ezdxf's virtual_entities gives them: a 3DFACE for each cell of its grid, row after row, from its corner (m, n) to (m + 1, n), (m + 1, n + 1) and (m, n + 1), the last row joined to the first where it is closed in M and the last point of each row to its first where it is closed in N; each with the mesh's look, every edge drawn. A grid of 3 rows of 4 points gives 6 faces, closed both ways 12. A smoothed mesh breaks as AutoCAD 2021's Explode breaks one: its points the smoothing made (flag 8), a grid of one point more than MSurfaceDensity and NSurfaceDensity along an open direction, are read as a grid of the densities themselves, row after row from the first, each cell from (m, n) to (m, n + 1), (m + 1, n + 1) and (m + 1, n): the 7 by 7 points of densities 6 and 6 give 25 faces, the first of the points 0, 1, 7 and 6, the last row of the points left out and the cells running across the ends of the rows, as AutoCAD's do. Where those points fill neither grid, it breaks into the cells of its frame.

GetEnumerator()

Gets an enumerator over the points, row after row, as AutoCAD's GetEnumerator: each the same object while its record is there.

MakeMClosed()

Joins the last row to the first, as AutoCAD's MakeMClosed: flag 1 of group 70.

MakeMOpen()

Parts the last row from the first, as AutoCAD's MakeMOpen.

MakeNClosed()

Joins the last point of each row to its first, as AutoCAD's MakeNClosed: flag 32 of group 70.

MakeNOpen()

Parts the last point of each row from its first, as AutoCAD's MakeNOpen.

Straighten()

Straightens a smoothed mesh, as AutoCAD's Straighten (PEDIT Desmooth): the points the smoothing made (flag 8 of their group 70) taken out, those of the grid (16) points of the mesh again, flag 4 of the mesh's group 70 and its group 75 taken out; its densities (73 and 74) kept. A mesh that is not smoothed is left as it is.

SurfaceFit()

Smooths the mesh into the header's surface, as AutoCAD's SurfaceFit (PEDIT Smooth surface): of SURFTYPE (5 quadratic, 6 cubic, 8 Bezier; cubic where the file gives none), SURFU and SURFV (6 where it gives none), as SurfaceFit(DxfPolyMeshType, int, int) smooths it.

SurfaceFit(DxfPolyMeshType, int, int)

Smooths the mesh into a surface, as AutoCAD's SurfaceFit: its grid made the frame of the surface (flag 16 of each point's group 70, each keeping its handle), and the points of the surface added after them (flag 8), a grid of surfU spans by surfV spread evenly from end to end of an open direction and round a closed one, as AutoCAD's PEDIT makes it: an open mesh smoothed at 6 and 6 is given 7 rows of 7 points, 49, one closed both ways 6 of 6; flag 4 of the mesh's group 70, its densities in groups 73 and 74 and the surface in 75. A quadratic or cubic surface is the uniform B-spline on the grid of that degree each way (one less than the rows or points where they are fewer), clamped to the edges of an open direction; a Bezier surface the Bernstein one of the whole grid, which AutoCAD takes up to 11 by 11. A smoothed mesh is straightened first. The reader reads a smoothed mesh as the grid of its first M by N points, its frame.