rsspice 0.1.0

Pure Rust port of the SPICE Toolkit for space geometry
Documentation
//
// GENERATED FILE
//

use super::*;
use f2rust_std::*;

pub const LBCELL: i32 = -5;

//$Procedure ZZPSXFRM ( Plate set, transform )
pub fn ZZPSXFRM(
    V1: &[f64],
    XFORM: &[f64],
    VOUT: &mut [f64],
    ctx: &mut Context,
) -> f2rust_std::Result<()> {
    let V1 = DummyArray::new(V1, LBCELL..);
    let XFORM = DummyArray2D::new(XFORM, 1..=3, 1..=3);
    let mut VOUT = DummyArrayMut::new(VOUT, LBCELL..);
    let mut CV1: i32 = 0;
    let mut J: i32 = 0;
    let mut NV: i32 = 0;

    //
    // SPICELIB functions
    //

    if spicelib::RETURN(ctx) {
        return Ok(());
    }

    spicelib::CHKIN(b"ZZPSXFRM", ctx)?;

    //
    // Make sure the cardinality of the input vertex set is a
    // multiple of 3.
    //
    CV1 = spicelib::CARDD(V1.as_slice(), ctx)?;

    NV = (CV1 / 3);

    if ((NV * 3) != CV1) {
        spicelib::SETMSG(
            b"Input vertex set cardinality # is not a multiple of 3.",
            ctx,
        );
        spicelib::ERRINT(b"#", CV1, ctx);
        spicelib::SIGERR(b"SPICE(BADVERTEXARRAY)", ctx)?;
        spicelib::CHKOUT(b"ZZPSXFRM", ctx)?;
        return Ok(());
    }

    //
    // Check room in output vertex array.
    //
    if (spicelib::SIZED(VOUT.as_slice(), ctx)? < CV1) {
        spicelib::SETMSG(
            b"Output vertex array size is #; required space is # elements.",
            ctx,
        );
        spicelib::ERRINT(b"#", spicelib::SIZED(VOUT.as_slice(), ctx)?, ctx);
        spicelib::ERRINT(b"#", CV1, ctx);
        spicelib::SIGERR(b"SPICE(VERTARRAYTOOSMALL)", ctx)?;
        spicelib::CHKOUT(b"ZZPSXFRM", ctx)?;
        return Ok(());
    }

    //
    // Transform each vertex of the input plate set and append the
    // result to the output plate set. We've already verified there's
    // enough room in the output set.
    //
    for I in 1..=NV {
        J = (1 + ((I - 1) * 3));

        spicelib::MXV(XFORM.as_slice(), V1.subarray(J), VOUT.subarray_mut(J));
    }

    spicelib::SCARDD(CV1, VOUT.as_slice_mut(), ctx)?;

    spicelib::CHKOUT(b"ZZPSXFRM", ctx)?;
    Ok(())
}