Skip to content

Commit 7714338

Browse files
committed
wip: uniform simplific ation
1 parent 2766f89 commit 7714338

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

pychunkedgraph/meshing/meshgen.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pylint: disable=invalid-name, missing-docstring, no-member, too-many-lines, c-extension-no-member, bare-except, not-callable
1+
# pylint: disable=invalid-name, missing-docstring, no-member, too-many-lines, c-extension-no-member, bare-except, not-callable, no-value-for-parameter, unused-argument
22

33
from typing import Sequence
44
import os
@@ -94,6 +94,8 @@ def simplify_skipped_layers(cg, fragment, fragment_id, fragment_parent_id):
9494
while layer < parent_layer:
9595
fragment = simplify(cg, fragment, fragment_id, lod=layer)
9696
layer += 1
97+
fragment["vertices"] = fragment["vertices"].reshape(-1, 3)
98+
fragment["faces"] = fragment["faces"].reshape(-1, 3)
9799
return fragment
98100

99101

@@ -257,7 +259,6 @@ def _lower_remaps(ks):
257259
lower_remaps = {}
258260
if cg.get_chunk_layer(chunk_id) > 2:
259261
for lower_chunk_id in cg.get_chunk_child_ids(chunk_id):
260-
# TODO speedup
261262
lower_remaps.update(
262263
get_higher_to_lower_remapping(cg, lower_chunk_id, time_stamp=time_stamp)
263264
)
@@ -749,7 +750,13 @@ def transform_draco_fragment_and_return_encoding_options(
749750

750751

751752
def merge_draco_meshes_across_boundaries(
752-
cg, fragments, chunk_id, mip, high_padding, return_zmesh_object=False
753+
cg,
754+
new_fragment_id,
755+
fragments,
756+
chunk_id,
757+
mip,
758+
high_padding,
759+
return_zmesh_object=False,
753760
):
754761
"""
755762
Merge a list of draco mesh fragments, removing duplicate vertices that lie
@@ -758,6 +765,13 @@ def merge_draco_meshes_across_boundaries(
758765

759766
# repeat simplify here?
760767

768+
for fragment in fragments:
769+
frag = fragment["mesh"]
770+
fragment_id = fragment["node_id"]
771+
fragment["mesh"] = simplify_skipped_layers(
772+
cg, frag, fragment_id, new_fragment_id
773+
)
774+
761775
vertexct = np.zeros(len(fragments) + 1, np.uint32)
762776
vertexct[1:] = np.cumsum([x["mesh"]["num_vertices"] for x in fragments])
763777
vertices = np.concatenate([x["mesh"]["vertices"] for x in fragments])
@@ -1091,11 +1105,11 @@ def chunk_initial_mesh_task(
10911105
stotal_faces = int(np.sum(og_mesh_faces))
10921106
stotal_vertices = int(np.sum(og_mesh_vertices))
10931107

1094-
# redis = get_redis_connection()
1095-
# redis.sadd(f"{cg.graph_id}/faces/2", total_faces)
1096-
# redis.sadd(f"{cg.graph_id}/vertices/2", total_vertices)
1097-
# redis.sadd(f"{cg.graph_id}/og_faces/2", stotal_faces)
1098-
# redis.sadd(f"{cg.graph_id}/og_vertices/2", stotal_vertices)
1108+
redis = get_redis_connection()
1109+
redis.sadd(f"{cg.graph_id}/faces/2", total_faces)
1110+
redis.sadd(f"{cg.graph_id}/vertices/2", total_vertices)
1111+
redis.sadd(f"{cg.graph_id}/og_faces/2", stotal_faces)
1112+
redis.sadd(f"{cg.graph_id}/og_vertices/2", stotal_vertices)
10991113

11001114
if sharded and WRITING_TO_CLOUD:
11011115
shard_binary = sharding_spec.synthesize_shard(merged_meshes)
@@ -1279,7 +1293,7 @@ def chunk_stitch_remeshing_task(
12791293
)
12801294

12811295
new_fragment = merge_draco_meshes_across_boundaries(
1282-
cg, old_fragments, chunk_id, mip, high_padding
1296+
cg, new_fragment_id, old_fragments, chunk_id, mip, high_padding
12831297
)
12841298
new_fragment = simplify(cg, new_fragment, new_fragment_id)
12851299

@@ -1403,7 +1417,7 @@ def chunk_initial_sharded_stitching_task(
14031417
)
14041418

14051419
new_fragment = merge_draco_meshes_across_boundaries(
1406-
cg, old_fragments, chunk_id, mip, high_padding
1420+
cg, new_fragment_id, old_fragments, chunk_id, mip, high_padding
14071421
)
14081422

14091423
new_fragment = simplify(cg, new_fragment, new_fragment_id)
@@ -1432,9 +1446,9 @@ def chunk_initial_sharded_stitching_task(
14321446
total_faces = int(np.sum(mesh_faces))
14331447
total_vertices = int(np.sum(mesh_vertices))
14341448

1435-
# redis = get_redis_connection()
1436-
# redis.sadd(f"{cg.graph_id}/faces/{layer}", total_faces)
1437-
# redis.sadd(f"{cg.graph_id}/vertices/{layer}", total_vertices)
1449+
redis = get_redis_connection()
1450+
redis.sadd(f"{cg.graph_id}/faces/{layer}", total_faces)
1451+
redis.sadd(f"{cg.graph_id}/vertices/{layer}", total_vertices)
14381452

14391453
del mesh_dict
14401454
shard_binary = sharding_spec.synthesize_shard(merged_meshes)

0 commit comments

Comments
 (0)