nx_partanalyze.nx source
↩ module page · 34 lines · 1601 B
1// nx_partanalyze.nx -- END-TO-END underbuilt-part analysis (cadtwin R8-geometric): the operator's literal goal
2// "rebuild a car and identify underbuilt parts if flipping them." COMPOSES three gated organs: nx_meshseg3d
3// (segment a scanned mesh into PARTS) -> nx_meshthick (per-part wall THICKNESS by ray-casting) -> flag any part
4// whose min wall < a DATA-DRIVEN threshold as UNDERBUILT. The geometric half of the flip-analysis; the data half
5// is nx_underbuilt_board (NHTSA complaints/recalls per component) -- cross-referenced by the caller. Deterministic.
6// license_tier: ORIGINAL
7import "nx_meshseg3d.nx"
8
9// segment the mesh, measure per-part min wall thickness, flag underbuilt. labels[F], seg_thick[k], seg_flag[k]
10// filled; out_k[0] = part count. Returns number of UNDERBUILT parts. thick_thresh in fx256 (data-driven).
11func pa_analyze(base: i64, cos_thresh: i64, thick_thresh: i64, labels: *i64, seg_thick: *i64, seg_flag: *i64, out_k: *i64) -> i64 {
12 let k: i64 = ms_segment(base, cos_thresh, labels)
13 out_k[0] = k
14 var s: i64 = 0
15 while s < k { seg_thick[s] = MTK_BIG; s = s + 1 }
16 let h: *i64 = m3_hdr(base)
17 let nf: i64 = h[1]
18 var f: i64 = 0
19 while f < nf {
20 let th: i64 = mtk_face_thickness(base, f)
21 if th > 0 {
22 let sl: i64 = labels[f]
23 if sl >= 0 { if th < seg_thick[sl] { seg_thick[sl] = th } }
24 }
25 f = f + 1
26 }
27 var nu: i64 = 0
28 s = 0
29 while s < k {
30 if seg_thick[s] < thick_thresh { seg_flag[s] = 1; nu = nu + 1 } else { seg_flag[s] = 0 }
31 s = s + 1
32 }
33 return nu
34}