upxo.meshing.gbconformant.d3v2p0.pinch_cleaning module

Targeted repair of local edge/corner contacts, without majority filtering.

upxo.meshing.gbconformant.d3v2p0.pinch_cleaning.detect_pinch_candidates(labels)[source]

Map 2x2x2 block origins to labels with disconnected local face components.

These are candidate edge/corner contacts, not proof of a physical defect. This detector does not cover every thin neck or smoothing-induced pinch.

upxo.meshing.gbconformant.d3v2p0.pinch_cleaning.clean_pinch_contacts(labels, enabled=True, max_passes=5, max_changes=200, max_volume_fraction=0.03, protect_grains_up_to=8, progress=None, track_history=True)[source]

Greedily repair detected contacts, returning (copy, report, change_log).

Each accepted single-voxel reassignment must strictly reduce candidate (block, grain) pairs, introduce none nearby, retain every grain’s GLOBAL six-connected component count and respect per-grain net voxel-count limits. Grains initially <= protect_grains_up_to cannot donate voxels. Each grain’s volume allowance is max(1, floor(initial_count * max_volume_fraction)); zero fraction gives zero allowance. Positions/labels are recorded for every edit. Input is never mutated. Disabled mode returns an unchanged copy immediately.