1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
//$Procedure ZZGETVOX ( Coordinates of voxel containing a point )
pub fn ZZGETVOX(
VOXSIZ: f64,
VOXORI: &[f64],
NVOX: &[i32],
XYZ: &[f64],
INBOX: &mut bool,
VOXCOR: &mut [i32],
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let VOXORI = DummyArray::new(VOXORI, 1..=3);
let NVOX = DummyArray::new(NVOX, 1..=3);
let XYZ = DummyArray::new(XYZ, 1..=3);
let mut VOXCOR = DummyArrayMut::new(VOXCOR, 1..=3);
let mut TERM: f64 = 0.0;
//
// SPICELIB functions
//
//
// Local variables.
//
//
// Use discovery check-in.
//
if RETURN(ctx) {
return Ok(());
}
if (VOXSIZ <= 0.0) {
CHKIN(b"ZZGETVOX", ctx)?;
SETMSG(b"Voxel size was #; must be positive.", ctx);
ERRDP(b"#", VOXSIZ, ctx);
SIGERR(b"SPICE(NONPOSITIVEVALUE)", ctx)?;
CHKOUT(b"ZZGETVOX", ctx)?;
return Ok(());
}
//
// Initialize 'point in box' flag and voxel coordinates. The
// coordinates are assigned out-of-range values.
//
*INBOX = false;
VOXCOR[1] = 0;
VOXCOR[2] = 0;
VOXCOR[3] = 0;
//
// Scale the point's coordinates to voxel grid space
// and determine the indices of the voxel that contains it.
//
for I in 1..=3 {
//
// A Galilean transform. Calculate the voxel coordinate
// corresponding to the body centered coordinate. This
// operation performs the same task as TOGRID, but
// including the operation here improves ZZGETVOX's
// runtime performance.
//
TERM = ((XYZ[I] - VOXORI[I]) / VOXSIZ);
//
// Calculate the voxel index for each degree of freedom
// corresponding to the voxel coordinate.
//
// If the point is outside of the grid, return now.
//
if ((TERM < 0.0) || (TERM > NVOX[I] as f64)) {
return Ok(());
}
//
// Assign a 1-based value to the Ith component of the voxel's
// coordinates. The outer surface of the grid is considered part
// of the grid.
//
// Note that TERM is non-negative at this point.
//
if ((TERM as i32) < NVOX[I]) {
VOXCOR[I] = (1 + (TERM as i32));
} else {
//
// TERM is NVOX(I), since the cases
//
// TERM > NVOX(I)
// TERM < NVOX(I)
//
// have been ruled out.
//
VOXCOR[I] = NVOX[I];
}
}
*INBOX = true;
Ok(())
}