Skip to content

Commit e84dc31

Browse files
committed
wip
1 parent 80e9eef commit e84dc31

File tree

1 file changed

+32
-35
lines changed

1 file changed

+32
-35
lines changed

pychunkedgraph/meshing/meshgen.py

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,38 @@
3232
WRITING_TO_CLOUD = True
3333

3434

35+
def simplify(cg, new_fragment, new_fragment_id: np.uint64 = None):
36+
"""
37+
Simplify with pyfqmr; input and output flat vertices and faces.
38+
"""
39+
40+
v = new_fragment["vertices"].reshape(-1, 3)
41+
f = new_fragment["faces"].reshape(-1, 3)
42+
43+
l2factor = int(os.environ.get("l2factor", "2"))
44+
factor = int(os.environ.get("factor", "4"))
45+
aggressiveness = float(os.environ.get("aggr", "7.0"))
46+
47+
layer = cg.get_chunk_layer(new_fragment_id)
48+
if layer == 2:
49+
target_count = max(int(len(f) / l2factor), 4)
50+
else:
51+
target_count = max(int(len(f) / factor), 4)
52+
53+
simplifier = pyfqmr.Simplify()
54+
simplifier.setMesh(v, f)
55+
simplifier.simplify_mesh(
56+
target_count=target_count,
57+
aggressiveness=aggressiveness,
58+
preserve_border=True,
59+
verbose=False,
60+
)
61+
v, f, _ = simplifier.getMesh()
62+
new_fragment["vertices"] = v.flatten()
63+
new_fragment["faces"] = f.flatten()
64+
return new_fragment
65+
66+
3567
def decode_draco_mesh_buffer(fragment):
3668
try:
3769
mesh_object = DracoPy.decode_buffer_to_mesh(fragment)
@@ -1104,41 +1136,6 @@ def get_multi_child_nodes(cg, chunk_id, node_id_subset=None, chunk_bbox_string=F
11041136
return multi_child_nodes, multi_child_descendants
11051137

11061138

1107-
def simplify(cg, new_fragment, new_fragment_id: np.uint64 = None):
1108-
"""
1109-
Simplify with pyfqmr; input and output flat vertices and faces.
1110-
"""
1111-
1112-
v = new_fragment["vertices"].reshape(-1, 3)
1113-
f = new_fragment["faces"].reshape(-1, 3)
1114-
1115-
print(v)
1116-
print(f)
1117-
1118-
l2factor = int(os.environ.get("l2factor", "2"))
1119-
factor = int(os.environ.get("factor", "4"))
1120-
aggressiveness = float(os.environ.get("aggr", "7.0"))
1121-
1122-
layer = cg.get_chunk_layer(new_fragment_id)
1123-
if layer == 2:
1124-
target_count = max(int(len(f) / l2factor), 4)
1125-
else:
1126-
target_count = max(int(len(f) / factor), 4)
1127-
1128-
simplifier = pyfqmr.Simplify()
1129-
simplifier.setMesh(v, f)
1130-
simplifier.simplify_mesh(
1131-
target_count=target_count,
1132-
aggressiveness=aggressiveness,
1133-
preserve_border=True,
1134-
verbose=False,
1135-
)
1136-
v, f, _ = simplifier.getMesh()
1137-
new_fragment["vertices"] = v.flatten()
1138-
new_fragment["faces"] = f.flatten()
1139-
return new_fragment
1140-
1141-
11421139
def chunk_stitch_remeshing_task(
11431140
cg_name,
11441141
chunk_id,

0 commit comments

Comments
 (0)