moved the qhull generator into the base grid class

This commit is contained in:
Stephen Mardson McQuay 2011-03-21 15:24:25 -06:00
parent b83dd04e14
commit e856851f1e
2 changed files with 21 additions and 39 deletions

View File

@ -8,26 +8,6 @@ class grid(basegrid):
def __init__(self, verts, q):
basegrid.__init__(self, verts, q)
def for_qhull_generator(self):
"""
this returns a generator that should be fed into qdelaunay
"""
yield '3';
yield '%d' % len(self.verts)
for p in self.verts:
yield "%f %f %f" % tuple(p)
def for_qhull(self):
"""
this returns a single string that should be fed into qdelaunay
"""
r = '3\n'
r += '%d\n' % len(self.verts)
for p in self.verts:
r += "%f %f %f\n" % tuple(p)
return r
class rect_grid(grid):
def __init__(self, xres = 5, yres = 5, zres = 5):
@ -60,26 +40,7 @@ class rect_grid(grid):
grid.__init__(self, verts, q)
# self.construct_connectivity()
def for_qhull_generator(self):
"""
this returns a generator that should be fed into qdelaunay
"""
yield '3';
yield '%d' % len(self.verts)
for p in self.verts:
yield "%f %f %f" % tuple(p)
def for_qhull(self):
"""
this returns a single string that should be fed into qdelaunay
"""
r = '3\n'
r += '%d\n' % len(self.verts)
for p in self.verts:
r += "%f %f %f\n" % tuple(p)
return r
class random_grid(rect_grid):
def __init__(self, num_verts = 10):

View File

@ -135,6 +135,27 @@ class grid(object):
answer = run_baker(X, R, S, order)
return answer
def for_qhull_generator(self):
"""
this returns a generator that should be fed into qdelaunay
"""
yield '3';
yield '%d' % len(self.verts)
for p in self.verts:
yield "%f %f %f" % tuple(p)
def for_qhull(self):
"""
this returns a single string that should be fed into qdelaunay
"""
r = '3\n'
r += '%d\n' % len(self.verts)
for p in self.verts:
r += "%f %f %f\n" % tuple(p)
return r
def __str__(self):
r = ''
assert( len(self.verts) == len(self.q) )