use super::*;
use f2rust_std::*;
pub const LBCELL: i32 = -5;
pub fn ZZPSUN(
V1: &[f64],
P1: &[i32],
V2: &[f64],
P2: &[i32],
VOUT: &mut [f64],
POUT: &mut [i32],
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let V1 = DummyArray::new(V1, LBCELL..);
let P1 = DummyArray::new(P1, LBCELL..);
let V2 = DummyArray::new(V2, LBCELL..);
let P2 = DummyArray::new(P2, LBCELL..);
let mut VOUT = DummyArrayMut::new(VOUT, LBCELL..);
let mut POUT = DummyArrayMut::new(POUT, LBCELL..);
let mut CP1: i32 = 0;
let mut CP2: i32 = 0;
let mut CPOUT: i32 = 0;
let mut CV1: i32 = 0;
let mut CV2: i32 = 0;
let mut CVOUT: i32 = 0;
if spicelib::RETURN(ctx) {
return Ok(());
}
spicelib::CHKIN(b"ZZPSUN", ctx)?;
CV1 = spicelib::CARDD(V1.as_slice(), ctx)?;
CV2 = spicelib::CARDD(V2.as_slice(), ctx)?;
CVOUT = (CV1 + CV2);
if (spicelib::SIZED(VOUT.as_slice(), ctx)? < CVOUT) {
spicelib::SETMSG(b"Output vertex array is too small to contain union of input vertex arrays. Output vertex array size is #; required space is # elements.", ctx);
spicelib::ERRINT(b"#", spicelib::SIZED(VOUT.as_slice(), ctx)?, ctx);
spicelib::ERRINT(b"#", CVOUT, ctx);
spicelib::SIGERR(b"SPICE(VERTARRAYTOOSMALL)", ctx)?;
spicelib::CHKOUT(b"ZZPSUN", ctx)?;
return Ok(());
}
CP1 = spicelib::CARDI(P1.as_slice(), ctx)?;
CP2 = spicelib::CARDI(P2.as_slice(), ctx)?;
CPOUT = (CP1 + CP2);
if (spicelib::SIZEI(POUT.as_slice(), ctx)? < CPOUT) {
spicelib::SETMSG(b"Output plate array is too small to contain union of input plate arrays. Output plate array size is #; required space is # elements.", ctx);
spicelib::ERRINT(b"#", spicelib::SIZEI(POUT.as_slice(), ctx)?, ctx);
spicelib::ERRINT(b"#", CPOUT, ctx);
spicelib::SIGERR(b"SPICE(PLTARRAYTOOSMALL)", ctx)?;
spicelib::CHKOUT(b"ZZPSUN", ctx)?;
return Ok(());
}
spicelib::COPYD(V1.as_slice(), VOUT.as_slice_mut(), ctx)?;
spicelib::COPYI(P1.as_slice(), POUT.as_slice_mut(), ctx)?;
spicelib::MOVED(V2.subarray(1), CV2, VOUT.subarray_mut((CV1 + 1)));
spicelib::SCARDD((CV1 + CV2), VOUT.as_slice_mut(), ctx)?;
for I in 1..=CP2 {
POUT[(CP1 + I)] = (P2[I] + (CV1 / 3));
}
spicelib::SCARDI((CP1 + CP2), POUT.as_slice_mut(), ctx)?;
spicelib::CHKOUT(b"ZZPSUN", ctx)?;
Ok(())
}