smbinterp/test/qhull.test.py

34 lines
660 B
Python
Executable File

#!/usr/bin/python
import delaunay
import subprocess
QFILE = '/tmp/forQhull.txt'
l = [[-1, 1], [-1, 0], [-1, 1], [0, -1], [0, 0], [0, 1], [1, -1], [1, 0], [1, 1]]
qdelauney_file = open(QFILE, 'w')
qdelauney_file.write("%d\n" % len(l[0]))
qdelauney_file.write("%d\n" % len(l))
for i in l:
qdelauney_file.write("%0.3f %0.3f\n" % (i[0], i[1]))
dt = delaunay.Triangulation(l)
print dt.indices
answer = [
[4,1,3],
[1,5,0],
[5,1,4],
[7,3,6],
[7,4,3],
[7,5,4],
[5,7,8],
]
print answer == dt.indices
print dt.indices
print "now run /usr/bin/qdelaunay Qt i < %s" % QFILE