diff --git a/bin/grid_regular.py b/bin/grid_regular.py index 23efd5c..22ec983 100755 --- a/bin/grid_regular.py +++ b/bin/grid_regular.py @@ -4,6 +4,7 @@ import sys import pickle from grid import simple_rect_grid, simple_random_grid +from baker import run_baker qfile = '/tmp/grid_regular.txt' @@ -15,8 +16,13 @@ if __name__ == '__main__': except: resolution = 3 - g = simple_rect_grid(resolution, resolution) - print g + source_mesh = simple_rect_grid(resolution, resolution) X = [0.4, 0.001] - print g.get_points_conn(X) - open(qfile, 'w').write(g.for_qhull()) + (R, S) = source_mesh.get_points_conn(X) + + print source_mesh + print R + print S + + print run_baker(X, R, S) + open(qfile, 'w').write(source_mesh.for_qhull()) diff --git a/lib/grid.py b/lib/grid.py index 11226e1..478f8a7 100755 --- a/lib/grid.py +++ b/lib/grid.py @@ -117,30 +117,26 @@ class grid(object): if not self.faces: self.construct_connectivity() + # get closest point (dist, indicies) = self.tree.query(X, 2) - smplx = None + + simplex = None for i in self.facets_for_point[indicies[0]]: if i.contains(X, self): - smplx = i + simplex = i break - if not smplx: + if not simplex: raise AssertionError('no containing simplex found') - print "containing verts:", smplx.verts - smplx_set = set(smplx.verts) - R = self.create_mesh(smplx.verts) + simplex_set = set(simplex.verts) + R = self.create_mesh(simplex.verts) s = [] - for c,i in enumerate(smplx.neighbors): - print "neighbor %d: %s: %s" % (c, i.name, i.verts) - st = set(i.verts) - s.append((st - smplx_set).pop()) -# s.append( [guy for guy in i.verts if not guy in smplx.verts]) - print s + for c,i in enumerate(simplex.neighbors): + s.extend([guy for guy in i.verts if not guy in simplex.verts]) S = self.create_mesh(s) - print S return R, S def run_baker(self, X):