#!/usr/bin/env python

from optparse import OptionParser
import fluidity.diagnostics.triangletools as triangletools
import fluidity.diagnostics.gmshtools as gmshtools

optparser=OptionParser(usage='usage: %prog <filename>',
                       add_help_option=True,
                       description="""Converts Fluidity-generated Triangle """ + 
                       """mesh files and converts them to the Gmsh format.""")

optparser.add_option("--ascii", "-a",
                  help="Convert to ASCII Gmsh format",
                     action="store_const", const=True, dest="ascii", default=False)

(options, argv) = optparser.parse_args()
filename = argv[0]

mesh = triangletools.ReadTriangle(filename)
gmshtools.WriteMsh(mesh, "%s.msh" % (filename), binary=not options.ascii)

Add triangle2gmsh conversion tool