nx_section_projection.nx source
↩ module page · 23 lines · 941 B
1// Project connected cross-section segments onto an X-bin occupancy array.
2// Each consecutive pair is one segment from a triangle/plane intersection.
3// This preserves projected connectivity across sparse endpoint samples; it does not
4// claim that overlapping projections identify one connected contour in 3D.
5// Caller owns valid point/histogram spans and initializes histogram accumulation.
6func section_project_x_pairs(points:*i64, begin:i64, count:i64, lo:i64, span:i64, hist:*i64, bins:i64)->i64 {
7 if begin < 0 { return 0-1 }
8 if count < 0 { return 0-1 }
9 if count % 2 != 0 { return 0-1 }
10 if span <= 0 { return 0-1 }
11 if bins <= 0 { return 0-1 }
12 var k:i64=0
13 while k < count {
14 var a:i64=(points[begin+k]-lo)*(bins-1)/span
15 var b:i64=(points[begin+k+1]-lo)*(bins-1)/span
16 if a > b { let swap:i64=a; a=b; b=swap }
17 if a < 0 { a=0 }
18 if b > bins-1 { b=bins-1 }
19 while a <= b { hist[a]=hist[a]+1; a=a+1 }
20 k=k+2
21 }
22 return 0
23}