nx_meshcheck.nx
buildroot/runtime/nx_meshcheck.nx
about
nx_meshcheck.nx -- MESH INTEGRITY, the check nothing in this estate performed.
WHAT THIS IS AND WHY IT IS MISSING-SHAPED. The estate GENERATES meshes -- surface nets from SDFs,
layered bodies, skulls, faces -- and measures them for SHAPE AGREEMENT against a reference
(nx_mmdev_lib md_measure, exact per-vertex deviation) and for anatomical plausibility. Nothing
asks the prior question: IS THIS MESH STRUCTURALLY WELL-FORMED AT ALL. A mesh can sit perfectly
on its reference and still have inverted winding on a third of its faces, an edge shared by three
triangles, or four hundred vertices no triangle references -- and every one of those shows up to
the eye as junk while every ruler we own reports agreement.
THE ONE PRIOR CHECK, AND WHY IT IS NOT ENOUGH. nx_faceanat_mesh_gate carries a WATERTIGHT tooth
using the Euler characteristic: for a closed genus-0 triangle mesh V = F/2 + 2, tested within a
tolerance of F/16. That is a real check and it is NECESSARY, NOT SUFFICIENT, for two reasons the
tooth itself cannot see. First, Euler is a SINGLE SCALAR over the whole surface, so compensating
defects cancel: punch a hole and add a handle and the characteristic is unchanged. Second, it is
computed on ONE subject inside ONE gate, so it is a tooth rather than a ruler -- no other mesh in
the estate is ever asked. This organ counts the actual incidences instead, which is the direct
measurement Euler is a proxy for.
EVERY DEFECT CLASS IS COUNTED SEPARATELY AND CARRIES A WORKLIST. A single is-it-broken boolean is
not actionable, and two defect classes with opposite remedies must never share a counter: a
boundary edge means the surface is OPEN, a three-face edge means it is NON-MANIFOLD, and an
inconsistently wound pair means the surface is CLOSED but its normals disagree. Those are three
different repairs. Each class reports its count AND the first offenders by index, and says so when
that list is a PREFIX rather than the whole set.
PURE INTEGER, NO FLOAT ANYWHERE. Coordinates are caller-defined integer units (micrometres is the
estate's habit). The area test is an exact integer cross product, so a degenerate triangle is
PROVEN degenerate rather than declared so by an epsilon somebody picked.
license_tier: ORIGINAL No hardware writes (Rule 26). Reads buffers, opens nothing.
dependencies 1 imports · 13 importers
diagram shows first 10 each side; +0 more imports, +3 more importers in the complete lists below.
imports: nx_syscalls.nx
imported by: nx_isosurf_orientation_gate_t343.nxnx_meshcheck_gate.nxnx_meshgen_analytic_gate_t336.nxnx_meshgen_cell_audit_t337.nxnx_meshgen_connected_audit_t335.nxnx_meshgen_connected_locations_t335.nxnx_meshgen_domain_gate_t337.nxnx_meshgen_domain_locations_t337.nxnx_meshgen_orientation_gate_t336.nxnx_obj_cohort_qualification_t282.nxnx_obj_exact_gate_t284.nxnx_person_mesh_candidate_t343.nxnx_person_mesh_oriented_t343.nx
structs
| none |
consts
| 33 | const MC_I64: i64 = 8 |
| 34 | const MC_LIST_MAX: i64 = 32 // offenders NAMED per class; beyond this the list is a declared PREFIX |
| 40 | const MC_TRIKEY_MAX_NV: i64 = 2097151 |
| 43 | const MC_CLEAN: i64 = 0 |
| 44 | const MC_DEFECTS: i64 = 1 |
| 45 | const MC_UNMEASURABLE: i64 = 3 // no faces or no vertices: an empty mesh is not a clean mesh |
| 46 | const MC_INVALID: i64 = 4 // an index out of range: nothing further can be trusted |
| 49 | const MC_O_VERTS: i64 = 0 |
| 50 | const MC_O_TRIS: i64 = 1 |
| 51 | const MC_O_EDGES: i64 = 2 // distinct undirected edges |
| 52 | const MC_O_BADINDEX: i64 = 3 // triangles referencing a vertex outside [0,nv) |
| 53 | const MC_O_DEGEN_TOPO: i64 = 4 // a triangle naming the same vertex twice |
| 54 | const MC_O_DEGEN_AREA: i64 = 5 // three distinct vertices that are collinear: exact zero cross product |
| 55 | const MC_O_LOOSE: i64 = 6 // vertices no triangle references |
| 56 | const MC_O_BOUNDARY: i64 = 7 // edges with exactly ONE incident face: the surface is open here |
| 57 | const MC_O_NONMANIFOLD: i64 = 8 // edges with THREE OR MORE incident faces |
| 58 | const MC_O_WINDING: i64 = 9 // two-face edges whose faces traverse it the SAME way |
| 59 | const MC_O_DUPFACE: i64 = 10 // two triangles over the same three vertices |
| 60 | const MC_O_EULER: i64 = 11 // V - E + F, REPORTED not judged: a proxy, and it is why this organ exists |
| 61 | const MC_O_DUPCHECKED: i64 = 12 // 1 when the duplicate-face check actually ran, 0 when nv exceeded its bound |
| 62 | const MC_O_LIST_PREFIX: i64 = 13 // 1 when at least one worklist below is a prefix of its own count |
| 63 | const MC_O_SLOTS: i64 = 14 |
| 67 | const MC_L_BADINDEX: i64 = 0 |
| 68 | const MC_L_DEGEN_TOPO: i64 = 1 |
| 69 | const MC_L_DEGEN_AREA: i64 = 2 |
| 70 | const MC_L_LOOSE: i64 = 3 |
| 71 | const MC_L_BOUNDARY: i64 = 4 |
| 72 | const MC_L_NONMANIFOLD: i64 = 5 |
| 73 | const MC_L_WINDING: i64 = 6 |
| 74 | const MC_L_DUPFACE: i64 = 7 |
| 75 | const MC_L_CLASSES: i64 = 8 |
functions
| 77 | func mc_list_slots() -> i64 { return MC_L_CLASSES * MC_LIST_MAX } |
| 79 | func mc_list_put(list: *i64, klass: i64, count_so_far: i64, value: i64) -> i64 called by 1: mc_check |
| 83 | func mc_list_get(list: *i64, klass: i64, i: i64) -> i64 { return list[klass * MC_LIST_MAX + i] } |
| 90 | func mc_msort(k: *i64, d: *i64, tk: *i64, td: *i64, n: i64) -> i64 called by 1: mc_check |
| 122 | func mc_min(a: i64, b: i64) -> i64 { if a < b { return a } return b } called by 1: mc_check |
| 123 | func mc_max(a: i64, b: i64) -> i64 { if a > b { return a } return b } called by 1: mc_check |
| 128 | func mc_check(verts: *i64, nv: i64, tris: *i64, nt: i64, out: *i64, list: *i64) -> i64 called by 13: iog_onemainmainmainmainmain+7 calls 7: mc_list_slotsmc_list_putsys_mmapsys_munmapmc_minmc_max+1 |
| 371 | func mc_watertight(out: *i64) -> i64 |
| 379 | func mc_defect_total(out: *i64) -> i64 called by 1: main |