Change voxelize to use arbitrary grid
This commit is contained in:
parent
de1c0b4814
commit
ddb4f2c473
1 changed files with 57 additions and 62 deletions
14
tpy_r3d.py
14
tpy_r3d.py
|
|
@ -211,19 +211,18 @@ def test_recursive_split(num_trials: int = 10, max_depth: int = 6 ):
|
|||
def test_voxelization():
|
||||
# Test r3d_voxelize() by checking that the voxelized moments
|
||||
# sum to those of the original input
|
||||
POLY_ORDER = 4
|
||||
grid_size = 25
|
||||
|
||||
dx = numpy.ones(3) / grid_size
|
||||
POLY_ORDER = 0
|
||||
grid_resolution = 250
|
||||
|
||||
verts = 1.5 * (numpy.array(rand_tetrahedron_vertices()) + 1)
|
||||
poly = build_tetrahedron(verts)
|
||||
moments = get_moments(poly, POLY_ORDER)
|
||||
|
||||
logger.info(f'Voxelizing a tetrahedron to a grid with dx = {dx} and moments of order {POLY_ORDER}')
|
||||
grid = voxelize(poly, dx, order=POLY_ORDER)
|
||||
edges = [numpy.linspace(-1, 3, grid_resolution) for _ in range(3)]
|
||||
logger.info(f'Voxelizing a tetrahedron to a grid with moments of order {POLY_ORDER}')
|
||||
grid = voxelize(poly, edges, order=POLY_ORDER)
|
||||
|
||||
# visualize_voxels(grid)
|
||||
visualize_voxels(grid)
|
||||
|
||||
voxsum = numpy.sum(grid, axis=(0, 1, 2))
|
||||
|
||||
|
|
@ -323,7 +322,6 @@ def plot_brep(brep):
|
|||
triangles.append([face[0], face[i], face[i+1]])
|
||||
triangles = numpy.array(triangles, dtype=int)
|
||||
|
||||
|
||||
m = stl.mesh.Mesh(numpy.empty(triangles.shape[0], dtype=stl.mesh.Mesh.dtype))
|
||||
for i, f in enumerate(triangles):
|
||||
for j in range(3):
|
||||
|
|
|
|||
Loading…
Reference in a new issue