Reset platonic code.
[voro++.git] / branches / 2d_boundary / Tests / old / svg2bnd.py
blob1dde5f03858d1d63e5e326eec2a844648cac9ac9
1 """svg2bnd.py -- Converts a path in an SVG file to a boundary for Voro++."""
3 import sys
4 from svgfig import *
6 if len(sys.argv) < 2:
7 print 'Usage: svg2bnd <file>'
8 sys.exit(0)
10 obj = load(sys.argv[1])
11 for e in obj.values():
12 if isinstance(e, SVG) and e.t == u'path':
13 print '# Start'
14 path = pathtoPath(e)
15 commands = path.d
16 count= 0
17 x,y = 0.0, 0.0
18 print count,x,y
19 for c in commands[1:]:
20 if c[0] == u'm':
21 count += 1
22 lx=x
23 ly=y
24 x += c[1]
25 y += c[2]
26 if abs((x-lx)**2 + (y-ly)**2) > 1e-8:
27 print count,x,y
28 print '# End'