# MeshPy

MeshPy offers quality triangular and tetrahedral mesh generation for Python. Meshes of this type are chiefly used in finite-element simulation codes, but also have many other applications ranging from computer graphics to robotics.

The above picture shows a cutaway of a sample mesh generated for an electron gun at the Advanced Photon Source at Argonne National Labs in Illinois.

In order to generate these 2D and 3D meshes, MeshPy provides Python interfaces to two well-regarded mesh generators, Triangle by J. Shewchuk and TetGen by Hang Si. Both are included in the package in slightly modified versions.

MeshPy requires Boost.Python. Parts of this package were written as part of my Diplom thesis. In a former life, this package was called PyAngle.

## Obtaining MeshPy

You may download releases from MeshPy’s Python Package Index page, browse the source or directly check out the very latest version using git:

```git clone http://git.tiker.net/trees/meshpy.git
```

## Documentation and Support

MeshPy now has documentation available. If you still run into trouble, feel free to post to the mailing list. There also is a support forum, which by now only exists in read-only form for posterity.

## Example

MeshPy makes scripted mesh generation as easy as never before. This simple code suffices to generate an elementary mesh of a “brick”:

```from meshpy.tet import MeshInfo, build

mesh_info = MeshInfo()
mesh_info.set_points([
(0,0,0), (2,0,0), (2,2,0), (0,2,0),
(0,0,12), (2,0,12), (2,2,12), (0,2,12),
])
mesh_info.set_facets([
[0,1,2,3],
[4,5,6,7],
[0,4,5,1],
[1,5,6,2],
[2,6,7,3],
[3,7,4,0],
])
mesh = build(mesh_info)
mesh.write_vtk("test.vtk")
```

The result of this short script is below: