simplify by splitting up r2ledges into rverts, lverts
This commit is contained in:
parent
87e2bbe521
commit
9189109c08
1 changed files with 14 additions and 11 deletions
|
|
@ -88,22 +88,25 @@ def split(poly, plane, same_only: bool = False):
|
||||||
Some edges cross the plane
|
Some edges cross the plane
|
||||||
'''
|
'''
|
||||||
right_inds3 = numpy.repeat(right_inds, 3)
|
right_inds3 = numpy.repeat(right_inds, 3)
|
||||||
pnbr_inds = numpy.arange(3 * num_right) % 3
|
|
||||||
|
|
||||||
# array of [[clipped vertex (cv0), connected vertex pv00], [cv0, pv01], [cv0, pv02], [cv1, pv10], ...]
|
# array of [[clipped vertex (cv0), connected vertex pv00], [cv0, pv01], [cv0, pv02], [cv1, pv10], ...]
|
||||||
# which is effectively a list of all edges which touch the right half-plane
|
# which is effectively a list of all edges which touch the right half-plane
|
||||||
r2l_edges = numpy.column_stack((right_inds3, next_vertex, pnbr_inds))
|
# remove edges which don't also touch the left half-plane
|
||||||
r2l_edges = r2l_edges[far_vertex_left, :] # remove edges which don't also touch the left half-plane
|
rverts = right_inds3[far_vertex_left]
|
||||||
|
lverts = next_vertex[far_vertex_left]
|
||||||
|
pinds = (numpy.arange(3 * num_right) % 3)[far_vertex_left]
|
||||||
|
# r2l_edges = numpy.column_stack((right_inds3, next_vertex, pnbr_inds))
|
||||||
|
# r2l_edges = r2l_edges[far_vertex_left, :] # remove edges which don't also touch the left half-plane
|
||||||
|
|
||||||
num_new_vertices = r2l_edges.shape[0]
|
num_new_vertices = rverts.size
|
||||||
|
|
||||||
'''
|
'''
|
||||||
walk to next crossing edge
|
walk to next crossing edge
|
||||||
'''
|
'''
|
||||||
prev_verts = r2l_edges[:, 0]
|
prev_verts = rverts
|
||||||
cur_verts = r2l_edges[:, 1]
|
cur_verts = lverts
|
||||||
edge_walk_inds = numpy.arange(num_new_vertices)
|
edge_walk_inds = numpy.arange(num_new_vertices)
|
||||||
edge_walk_results = numpy.empty((r2l_edges.shape[0], 2), dtype=int)
|
edge_walk_results = numpy.empty((rverts.size, 2), dtype=int)
|
||||||
src_pns = None
|
src_pns = None
|
||||||
while cur_verts.size > 0:
|
while cur_verts.size > 0:
|
||||||
# Get the list of our current neighbors, find which one points to the
|
# Get the list of our current neighbors, find which one points to the
|
||||||
|
|
@ -131,10 +134,10 @@ def split(poly, plane, same_only: bool = False):
|
||||||
# now edge_walk_results is list of [[target clipped adjacent vertex, target connected vertex], ...]
|
# now edge_walk_results is list of [[target clipped adjacent vertex, target connected vertex], ...]
|
||||||
|
|
||||||
# figure out the index of each target edge...
|
# figure out the index of each target edge...
|
||||||
target_edge_inds = _get_map_rows(r2l_edges[:, :2], edge_walk_results)
|
arr = numpy.column_stack((rverts, lverts))
|
||||||
|
target_edge_inds = _get_map_rows(arr, edge_walk_results)
|
||||||
|
|
||||||
re = r2l_edges[:, 0]
|
re, le = rverts, lverts
|
||||||
le = r2l_edges[:, 1]
|
|
||||||
d_right = dists[re][:, None]
|
d_right = dists[re][:, None]
|
||||||
d_left = dists[le][:, None]
|
d_left = dists[le][:, None]
|
||||||
new_vertices = (d_right * vertices[le] - d_left * vertices[re]) / (d_right - d_left)
|
new_vertices = (d_right * vertices[le] - d_left * vertices[re]) / (d_right - d_left)
|
||||||
|
|
@ -181,7 +184,7 @@ def split(poly, plane, same_only: bool = False):
|
||||||
|
|
||||||
old_neighbors_right = poly['neighbors'].copy()
|
old_neighbors_right = poly['neighbors'].copy()
|
||||||
old_neighbors_right[right] = ind_map_right[old_neighbors_right[right]]
|
old_neighbors_right[right] = ind_map_right[old_neighbors_right[right]]
|
||||||
old_neighbors_right[(re, r2l_edges[:, 2])] = num_right + numpy.arange(num_new_vertices)
|
old_neighbors_right[(re, pinds)] = num_right + numpy.arange(num_new_vertices)
|
||||||
old_neighbors_right = old_neighbors_right[right]
|
old_neighbors_right = old_neighbors_right[right]
|
||||||
|
|
||||||
right_poly = {
|
right_poly = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue