code wiki / (root) / nx_meshcheck.nx

nx_meshcheck.nx

buildroot/runtime/nx_meshcheck.nx

18066 B382 linesdepth 2pulls 2 transitivereach 13 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_meshcheck.nx nx_isosurf_orientation_gate_t343.n nx_meshcheck_gate.nx nx_meshgen_analytic_gate_t336.nx nx_meshgen_cell_audit_t337.nx nx_meshgen_connected_audit_t335.nx nx_meshgen_connected_locations_t33 nx_meshgen_domain_gate_t337.nx nx_meshgen_domain_locations_t337.n nx_meshgen_orientation_gate_t336.n nx_obj_cohort_qualification_t282.n

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

33const MC_I64: i64 = 8
34const MC_LIST_MAX: i64 = 32 // offenders NAMED per class; beyond this the list is a declared PREFIX
40const MC_TRIKEY_MAX_NV: i64 = 2097151
43const MC_CLEAN: i64 = 0
44const MC_DEFECTS: i64 = 1
45const MC_UNMEASURABLE: i64 = 3 // no faces or no vertices: an empty mesh is not a clean mesh
46const MC_INVALID: i64 = 4 // an index out of range: nothing further can be trusted
49const MC_O_VERTS: i64 = 0
50const MC_O_TRIS: i64 = 1
51const MC_O_EDGES: i64 = 2 // distinct undirected edges
52const MC_O_BADINDEX: i64 = 3 // triangles referencing a vertex outside [0,nv)
53const MC_O_DEGEN_TOPO: i64 = 4 // a triangle naming the same vertex twice
54const MC_O_DEGEN_AREA: i64 = 5 // three distinct vertices that are collinear: exact zero cross product
55const MC_O_LOOSE: i64 = 6 // vertices no triangle references
56const MC_O_BOUNDARY: i64 = 7 // edges with exactly ONE incident face: the surface is open here
57const MC_O_NONMANIFOLD: i64 = 8 // edges with THREE OR MORE incident faces
58const MC_O_WINDING: i64 = 9 // two-face edges whose faces traverse it the SAME way
59const MC_O_DUPFACE: i64 = 10 // two triangles over the same three vertices
60const MC_O_EULER: i64 = 11 // V - E + F, REPORTED not judged: a proxy, and it is why this organ exists
61const MC_O_DUPCHECKED: i64 = 12 // 1 when the duplicate-face check actually ran, 0 when nv exceeded its bound
62const MC_O_LIST_PREFIX: i64 = 13 // 1 when at least one worklist below is a prefix of its own count
63const MC_O_SLOTS: i64 = 14
67const MC_L_BADINDEX: i64 = 0
68const MC_L_DEGEN_TOPO: i64 = 1
69const MC_L_DEGEN_AREA: i64 = 2
70const MC_L_LOOSE: i64 = 3
71const MC_L_BOUNDARY: i64 = 4
72const MC_L_NONMANIFOLD: i64 = 5
73const MC_L_WINDING: i64 = 6
74const MC_L_DUPFACE: i64 = 7
75const MC_L_CLASSES: i64 = 8

functions

77func mc_list_slots() -> i64 { return MC_L_CLASSES * MC_LIST_MAX }
79func mc_list_put(list: *i64, klass: i64, count_so_far: i64, value: i64) -> i64
called by 1: mc_check
83func mc_list_get(list: *i64, klass: i64, i: i64) -> i64 { return list[klass * MC_LIST_MAX + i] }
called by 4: mainmainmainmain
90func mc_msort(k: *i64, d: *i64, tk: *i64, td: *i64, n: i64) -> i64
called by 1: mc_check
122func mc_min(a: i64, b: i64) -> i64 { if a < b { return a } return b }
called by 1: mc_check
123func mc_max(a: i64, b: i64) -> i64 { if a > b { return a } return b }
called by 1: mc_check
128func mc_check(verts: *i64, nv: i64, tris: *i64, nt: i64, out: *i64, list: *i64) -> i64
371func mc_watertight(out: *i64) -> i64
379func mc_defect_total(out: *i64) -> i64
called by 1: main