diff options
Diffstat (limited to 'geometry.py')
-rw-r--r-- | geometry.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/geometry.py b/geometry.py index 08ce291..2d11f62 100644 --- a/geometry.py +++ b/geometry.py @@ -33,6 +33,9 @@ class Mesh(object): if remove_duplicate_vertices: self.remove_duplicate_vertices() + def get_bounds(self): + return np.min(self.vertices, axis=0), np.max(self.vertices, axis=0) + def remove_duplicate_vertices(self): unique_vertices = list(unique_everseen(map(tuple, self.vertices))) @@ -125,11 +128,6 @@ class Surface(object): self.set('reflect_diffuse', 0) self.set('reflect_specular', 0) - #self.detect = None - #self.absorb = None - #self.reflect_diffuse = None - #self.reflect_specular = None - def set(self, name, value, wavelengths=standard_wavelengths): if np.iterable(value): if len(value) != len(wavelengths): @@ -164,13 +162,15 @@ def morton_order(mesh, bits): axis is quantized into 2**bits bins. """ - lower_bound = np.array([np.min(mesh[:,:,0]), - np.min(mesh[:,:,1]), - np.min(mesh[:,:,2])]) + #lower_bound = np.array([np.min(mesh[:,:,0]), + # np.min(mesh[:,:,1]), + # np.min(mesh[:,:,2])]) + + #upper_bound = np.array([np.max(mesh[:,:,0]), + # np.max(mesh[:,:,1]), + # np.max(mesh[:,:,2])]) - upper_bound = np.array([np.max(mesh[:,:,0]), - np.max(mesh[:,:,1]), - np.max(mesh[:,:,2])]) + lower_bound, upper_bound = mesh.get_bounds() if bits <= 0 or bits > 10: raise Exception('number of bits must be in the range (0,10].') @@ -180,7 +180,8 @@ def morton_order(mesh, bits): def quantize(x): return np.uint32((x-lower_bound)*max_value/(upper_bound-lower_bound)) - mean_positions = quantize(np.mean(mesh, axis=1)) + #mean_positions = quantize(np.mean(mesh, axis=1)) + mean_positions = quantize(np.mean(mesh[:], axis=1)) return interleave(mean_positions, bits) @@ -227,7 +228,7 @@ class Geometry(object): self.mesh = Mesh(vertices, triangles) - zvalues_mesh = morton_order(self.mesh[:], bits) + zvalues_mesh = morton_order(self.mesh, bits) reorder = np.argsort(zvalues_mesh) zvalues_mesh = zvalues_mesh[reorder] |