mpacts.io. filereaders

Reading in typical (mesh) files. To facilitate easy scaling or translation, we usually return numpy-arrays, which can be easily mapped to normal python lists for mpacts using e.g.:

vertices, triangles = read_xxx( 'mymesh.xxx' )
vertices -= np.mean( vertices, 0 )#to approximately "center" the mesh
verts = map(tuple, vertices)
tris  = map(tuple, triangles)

For ease of implementation and generecity as well as speed, we like to use the vtk-python bindings whenever possible/sensible; on linux, install e.g.:

sudo apt-get install python-vtk

In order to be able to use this module import it like this:

import mpacts.io.filereaders
#or assign it to a shorter name
import mpacts.io.filereaders as fil
mpacts.io.filereaders.read_cgal(fname, make3D=True, keepInfinityFaces=False)

reads in cgal triangulation_2 files (.off)

Returns 2 numpy-arrays: the first are the vertices, the second are the faces.

mpacts.io.filereaders.read_dotmesh(fname)

Reads in dotmesh files.

mpacts.io.filereaders.read_obj(fname)

reads in obj files Uses vtk (so must be available).

Returns 2 numpy-arrays: the first are the vertices, the second are the polygons (only tested for homogeneous quad geometries).

mpacts.io.filereaders.read_oldDEMeter(fname, use_cols=None, verbose=True)

Reads back files written by ‘write’ into a numpy array. Now ignores whitespace, except where required by (deprecated) DEMeter.i format.

mpacts.io.filereaders.read_sol(fname)

Reads in sol files.

mpacts.io.filereaders.read_stl(fname)

reads in STL files. Uses vtk if available.

Returns 2 numpy-arrays: the first are the vertices, the second are the triangles.

mpacts.io.filereaders.read_tetgen(basename)