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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
const CNVTOL: f64 = 0.000001;
const NWMAX: i32 = 15;
const NWDIST: i32 = 5;
const NWSEP: i32 = 5;
const NWRR: i32 = 5;
const NWUDS: i32 = 5;
const NWPA: i32 = 5;
const NWILUM: i32 = 5;
const ADDWIN: f64 = 0.5;
const FRMNLN: i32 = 32;
const FOVTLN: i32 = 40;
const FTCIRC: &[u8] = b"CIRCLE";
const FTELLI: &[u8] = b"ELLIPSE";
const FTPOLY: &[u8] = b"POLYGON";
const FTRECT: &[u8] = b"RECTANGLE";
const ANNULR: &[u8] = b"ANNULAR";
const ANY: &[u8] = b"ANY";
const PARTL: &[u8] = b"PARTIAL";
const FULL: &[u8] = b"FULL";
const DSSHAP: &[u8] = b"DSK";
const EDSHAP: &[u8] = b"ELLIPSOID";
const PTSHAP: &[u8] = b"POINT";
const RYSHAP: &[u8] = b"RAY";
const SPSHAP: &[u8] = b"SPHERE";
const NOCTYP: i32 = 4;
const OCLLN: i32 = 7;
const SHPLEN: i32 = 9;
const MAXVRT: i32 = 10000;
const CIRFOV: &[u8] = b"CIRCLE";
const ELLFOV: &[u8] = b"ELLIPSE";
const POLFOV: &[u8] = b"POLYGON";
const RECFOV: &[u8] = b"RECTANGLE";
const LBCELL: i32 = -5;
const STEP: f64 = 1.0;
const CSTEP: bool = false;
//$Procedure ZZGFUDB ( Private --- GF, general use boolean search )
pub fn ZZGFUDB(
UDFUNS: fn(&mut f64, &mut f64, &mut Context) -> f2rust_std::Result<()>,
UDFUNB: fn(
fn(&mut f64, &mut f64, &mut Context) -> f2rust_std::Result<()>,
&mut f64,
&mut bool,
&mut Context,
) -> f2rust_std::Result<()>,
TOL: f64,
UDSTEP: fn(&mut f64, &mut f64, &mut Context) -> f2rust_std::Result<()>,
UDREFN: fn(f64, f64, bool, bool, &mut f64) -> (),
RPT: bool,
UDREPI: fn(&[f64], &[u8], &[u8], &mut Context) -> f2rust_std::Result<()>,
UDREPU: fn(f64, f64, f64, &mut Context) -> f2rust_std::Result<()>,
UDREPF: fn(&mut Context) -> f2rust_std::Result<()>,
BAIL: bool,
UDBAIL: fn() -> bool,
CNFINE: &[f64],
RESULT: &mut [f64],
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let CNFINE = DummyArray::new(CNFINE, LBCELL..);
let mut RESULT = DummyArrayMut::new(RESULT, LBCELL..);
let mut FINISH: f64 = 0.0;
let mut START: f64 = 0.0;
let mut COUNT: i32 = 0;
//
// SPICELIB functions
//
//
// Local parameters
//
//
// STEP is a step size initializer for the unused, dummy step size
// argument to ZZGFSOLVX. The routine UDSTEP, which is passed to
// ZZGFSOLVX, will be used by that routine to obtain the step size.
//
//
// CSTEP indicates whether a constant step size, provided
// via the input argument STEP, is to be used by ZZGFSOLVX.
//
//
// Local variables
//
//
// Standard SPICE error handling.
//
if RETURN(ctx) {
return Ok(());
}
CHKIN(b"ZZGFUDB", ctx)?;
//
// Check the convergence tolerance.
//
if (TOL <= 0.0) {
SETMSG(b"Tolerance must be positive but was #.", ctx);
ERRDP(b"#", TOL, ctx);
SIGERR(b"SPICE(INVALIDTOLERANCE)", ctx)?;
CHKOUT(b"ZZGFUDB", ctx)?;
return Ok(());
}
//
// Prepare the progress reporter if appropriate.
//
if RPT {
UDREPI(
CNFINE.as_slice(),
b"User defined boolean event search ",
b"done.",
ctx,
)?;
}
//
// Cycle over the intervals in the confining window.
//
COUNT = WNCARD(CNFINE.as_slice(), ctx)?;
for I in 1..=COUNT {
//
// Retrieve the bounds for the Ith interval of the confinement
// window. Search this interval for boolean events. Union the
// result with the contents of the RESULT window.
//
WNFETD(CNFINE.as_slice(), I, &mut START, &mut FINISH, ctx)?;
//
// Call ZZGFSOLVX to do the event detection work. The boolean
// function passes as UDFUNB, the scalar as UDFUNS.
//
ZZGFSOLVX(
UDFUNS,
UDFUNB,
UDSTEP,
UDREFN,
BAIL,
UDBAIL,
CSTEP,
STEP,
START,
FINISH,
TOL,
RPT,
UDREPU,
RESULT.as_slice_mut(),
ctx,
)?;
if FAILED(ctx) {
CHKOUT(b"ZZGFUDB", ctx)?;
return Ok(());
}
if BAIL {
//
// Interrupt handling is enabled.
//
if UDBAIL() {
//
// An interrupt has been issued. Return now regardless of
// whether the search completed.
//
CHKOUT(b"ZZGFUDB", ctx)?;
return Ok(());
}
}
}
//
// End the progress report.
//
if RPT {
UDREPF(ctx)?;
}
CHKOUT(b"ZZGFUDB", ctx)?;
Ok(())
}