|
32 | 32 | WRITING_TO_CLOUD = True |
33 | 33 |
|
34 | 34 |
|
| 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 | + |
35 | 67 | def decode_draco_mesh_buffer(fragment): |
36 | 68 | try: |
37 | 69 | 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 |
1104 | 1136 | return multi_child_nodes, multi_child_descendants |
1105 | 1137 |
|
1106 | 1138 |
|
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 | | - |
1142 | 1139 | def chunk_stitch_remeshing_task( |
1143 | 1140 | cg_name, |
1144 | 1141 | chunk_id, |
|
0 commit comments