Skip to content

Commit

Permalink
scale normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
akhileshh committed Jan 11, 2023
1 parent 347b77b commit 9b61463
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pychunkedgraph/meshing/meshgen.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=invalid-name, missing-docstring, no-member, too-many-lines, c-extension-no-member, bare-except
# pylint: disable=invalid-name, missing-docstring, no-member, too-many-lines, c-extension-no-member, bare-except, not-callable

from typing import Sequence
import os
Expand Down Expand Up @@ -37,19 +37,22 @@ def simplify(cg, new_fragment, new_fragment_id: np.uint64 = None):
Simplify with pyfqmr; input and output flat vertices and faces.
"""

v = new_fragment["vertices"].reshape(-1, 3)
f = new_fragment["faces"].reshape(-1, 3)

l2factor = int(os.environ.get("l2factor", "2"))
factor = int(os.environ.get("factor", "4"))
aggressiveness = float(os.environ.get("aggr", "7.0"))

v = new_fragment["vertices"].reshape(-1, 3)
f = new_fragment["faces"].reshape(-1, 3)

layer = cg.get_chunk_layer(new_fragment_id)
if layer == 2:
target_count = max(int(len(f) / l2factor), 4)
else:
target_count = max(int(len(f) / factor), 4)

scale = (2 ** (layer - 2)) * np.array(cg.meta.graph_config.CHUNK_SIZE, dtype=int)
v = v / scale

simplifier = pyfqmr.Simplify()
simplifier.setMesh(v, f)
simplifier.simplify_mesh(
Expand All @@ -59,6 +62,7 @@ def simplify(cg, new_fragment, new_fragment_id: np.uint64 = None):
verbose=False,
)
v, f, _ = simplifier.getMesh()
v = v * scale
new_fragment["vertices"] = v.flatten()
new_fragment["faces"] = f.flatten()
return new_fragment
Expand Down

0 comments on commit 9b61463

Please sign in to comment.