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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
const NONE: i32 = 0;
const LOWER: i32 = 1;
const UPPER: i32 = 2;
//$Procedure ZZRYTREC ( DSK, ray touches rectangular element )
pub fn ZZRYTREC(
VERTEX: &[f64],
RAYDIR: &[f64],
BOUNDS: &[f64],
MARGIN: f64,
NXPTS: &mut i32,
XPT: &mut [f64],
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let VERTEX = DummyArray::new(VERTEX, 1..=3);
let RAYDIR = DummyArray::new(RAYDIR, 1..=3);
let BOUNDS = DummyArray2D::new(BOUNDS, 1..=2, 1..=3);
let mut XPT = DummyArrayMut::new(XPT, 1..=3);
let mut BOXORI = StackArray::<f64, 3>::new(1..=3);
let mut EXTENT = StackArray::<f64, 3>::new(1..=3);
let mut DELTA = StackArray::<f64, 3>::new(1..=3);
let mut L = StackArray::<f64, 3>::new(1..=3);
let mut FOUND: bool = false;
let mut INSIDE: bool = false;
//
// SPICELIB functions
//
//
// Local parameters
//
//
// Element boundary indices:
//
//
// Local variables
//
if RETURN(ctx) {
return Ok(());
}
//
// Compute the original volume edge lengths from the coordinate
// bounds.
//
for I in 1..=3 {
L[I] = (BOUNDS[[UPPER, I]] - BOUNDS[[LOWER, I]]);
if (L[I] <= 0.0) {
CHKIN(b"ZZRYTREC", ctx)?;
SETMSG(
b"Coordinate # bounds were #:#; bounds must be strictly increasing.",
ctx,
);
ERRINT(b"#", I, ctx);
ERRDP(b"#", BOUNDS[[LOWER, I]], ctx);
ERRDP(b"#", BOUNDS[[UPPER, I]], ctx);
SIGERR(b"SPICE(BADCOORDBOUNDS)", ctx)?;
CHKOUT(b"ZZRYTREC", ctx)?;
return Ok(());
}
}
//
// Determine whether the vertex is inside the element.
// Use double the margin for this test, since we don't
// want to have false negative tests for rays having
// vertices lying on the expanded element boundary.
//
*NXPTS = 0;
ZZINREC(
VERTEX.as_slice(),
BOUNDS.as_slice(),
((2 as f64) * MARGIN),
NONE,
&mut INSIDE,
ctx,
)?;
if INSIDE {
//
// We know the answer.
//
*NXPTS = 1;
VEQU(VERTEX.as_slice(), XPT.as_slice_mut());
return Ok(());
}
//
// Expand the box using the specified margin.
//
for I in 1..=3 {
DELTA[I] = (MARGIN * f64::abs(L[I]));
BOXORI[I] = (BOUNDS[[LOWER, I]] - DELTA[I]);
EXTENT[I] = (L[I] + ((2 as f64) * DELTA[I]));
}
//
// Find the ray-surface intercept on the expanded element,
// if the intercept exists.
//
ZZRAYBOX(
VERTEX.as_slice(),
RAYDIR.as_slice(),
BOXORI.as_slice(),
EXTENT.as_slice(),
XPT.as_slice_mut(),
&mut FOUND,
ctx,
)?;
if FOUND {
*NXPTS = 1;
}
Ok(())
}