minor fixes and optim

This commit is contained in:
jan 2018-04-03 15:43:11 -07:00
commit 1473633a11
2 changed files with 9 additions and 11 deletions

View file

@ -73,9 +73,6 @@ def find_faces(neighbors: numpy.ndarray) -> List[numpy.ndarray]:
v_current = v_start.copy()
v_next = neighbors[v_current, nxt_edge]
mask = v_start # dummy for loop init, could use numpy.array([True]) instead
remove = numpy.zeros_like(edge_id, dtype=bool)
'''
Choose a method for storing the face info based on expected
runtime vs unnecessary memory allocation
@ -115,9 +112,10 @@ def find_faces(neighbors: numpy.ndarray) -> List[numpy.ndarray]:
b) we reach the original vertex (stop, done with this path)
'''
k = 1
#init_mask = v_next > v_current
#v = numpy.vstack((edge_id, v_start, v_current, v_next))[:, init_mask]
v = numpy.vstack((edge_id, v_start, v_current, v_next))
mask = v_next > v_current
v = numpy.vstack((edge_id, v_start, v_current, v_next))[:, mask]
remove = numpy.logical_not(mask)
while mask.any():
add_edges(v[0], v[3], k)
@ -182,12 +180,12 @@ def _get_maps(a, b):
@profile
def _get_maps_rows(a, b):
'''
Row-wise _get_map_2way
Row-wise _get_maps
'''
dims = numpy.maximum(a.max(0), b.max(0)) + 1
a1d = numpy.ravel_multi_index(a.T, dims)
b1d = numpy.ravel_multi_index(b.T, dims)
return _get_map(a1d, b1d)
return _get_maps(a1d, b1d)
def _argsort_rows(a):

View file

@ -85,7 +85,7 @@ def test_split_tets_thru_centroid():
def time_split():
NUM_TRIALS = 100_000
NUM_TRIALS = 10_000
logger.info(f'Intersecting {NUM_TRIALS} pairs of tetrahedra.')
polys = [build_rand_tetrahedron() for _ in range(NUM_TRIALS)]
facesets = [planes_from_tetrahedron(rand_tetrahedron_vertices()) for _ in range(NUM_TRIALS)]
@ -94,7 +94,7 @@ def time_split():
# clip the first tet against the faces of the second
for face in facesets[t]:
polys[t] = clip(polys[t], face)
if (t+1) % 10000 == 0:
if (t+1) % (NUM_TRIALS // 10) == 0:
t_each = (perf_counter() - t0) / (t + 1)
logger.info(f'time per split for {t+1} splits: {t_each}')
logger.info(f'done timing, time per split: {(perf_counter() - t0) / NUM_TRIALS}')
@ -224,7 +224,7 @@ def test_voxelization():
grid = voxelize(poly, edges, order=POLY_ORDER)
print(f'voxel time: {perf_counter() - t0}')
visualize_voxels(grid)
#visualize_voxels(grid)
voxsum = numpy.sum(grid, axis=(0, 1, 2))