From abc7d5f01361df29b725422639820e8276e3da4d Mon Sep 17 00:00:00 2001 From: Antoine Date: Tue, 17 Feb 2026 01:40:55 +0000 Subject: [PATCH] fix(extract): increase chord tolerance to 1mm, cap at 500 pts/edge 0.1mm was generating thousands of unnecessary points on straight edges. Now: 1mm default, 0.5mm minimum, 500 max per edge. Curves still get proper sampling, straight edges stay lean. --- tools/adaptive-isogrid/src/nx/extract_sandbox.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/adaptive-isogrid/src/nx/extract_sandbox.py b/tools/adaptive-isogrid/src/nx/extract_sandbox.py index 522d7001..038f882a 100644 --- a/tools/adaptive-isogrid/src/nx/extract_sandbox.py +++ b/tools/adaptive-isogrid/src/nx/extract_sandbox.py @@ -156,10 +156,12 @@ def _sample_edge_polyline(edge: Any, chord_tol_mm: float, lister: Any = None) -> except Exception: length = _norm(_sub(p2, p1)) if not is_closed else 50.0 - tol = max(float(chord_tol_mm), 0.01) + tol = max(float(chord_tol_mm), 0.5) # 0.5mm chord tolerance — good balance n_pts = max(8, int(math.ceil(length / tol))) if is_circular or is_closed: n_pts = max(24, n_pts) + # Cap to avoid absurd point counts on long straight edges + n_pts = min(n_pts, 500) if is_linear and not is_closed: return [p1, p2] @@ -377,7 +379,7 @@ def _chain_edges_into_loops( edges: List[Any], lister: Any = None, tol: float = 0.01, - chord_tol_mm: float = 0.1, + chord_tol_mm: float = 1.0, ) -> List[Tuple[bool, List[Point3D]]]: """ Chain edges into closed loops by matching vertex endpoints. @@ -747,7 +749,7 @@ def extract_sandbox_geometry( body: Any, sandbox_id: str, lister: Any, - chord_tol_mm: float = 0.1, + chord_tol_mm: float = 1.0, ) -> Dict[str, Any]: """ Extract a sandbox face into a JSON-serializable dict. @@ -859,7 +861,7 @@ def main(): body=body, sandbox_id=sandbox_id, lister=lister, - chord_tol_mm=0.1, + chord_tol_mm=1.0, ) out_path = os.path.join(output_dir, f"geometry_{sandbox_id}.json")