use crate::{c, cstr, fcstr, malloc, mallocstr};
use spice_derive::{cspice_proc, return_output};
use std::ops::{Deref, DerefMut};
#[cfg(any(feature = "lock", doc))]
use {crate::core::lock::SpiceLock, spice_derive::impl_for};
#[allow(clippy::upper_case_acronyms)]
pub type DLADSC = c::SpiceDLADescr;
#[allow(clippy::upper_case_acronyms)]
pub type DSKDSC = c::SpiceDSKDescr;
#[allow(clippy::upper_case_acronyms)]
pub type CELL = c::SpiceCell;
pub const CELL_MAXID: usize = 10_000;
#[derive(Debug)]
pub struct Cell(c::SpiceCell);
impl Cell {
pub fn new_int() -> Self {
let base = malloc!(i32, CELL_MAXID + c::SPICE_CELL_CTRLSZ as usize);
Self(CELL {
dtype: c::_SpiceDataType_SPICE_INT,
length: 0i32,
size: CELL_MAXID as i32,
card: 0i32,
isSet: 1i32,
adjust: 0i32,
init: 0i32,
base: base as *mut libc::c_void,
data: base.wrapping_add(c::SPICE_CELL_CTRLSZ as usize) as *mut libc::c_void,
})
}
pub fn get_data_int(&self, index: usize) -> i32 {
unsafe { *(self.data as *mut i32).wrapping_add(index) }
}
}
impl Deref for Cell {
type Target = c::SpiceCell;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for Cell {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
cspice_proc! {
pub fn bodc2n(code: i32, lenout: i32) -> (String, bool) {}
}
cspice_proc! {
#[return_output]
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn bodfnd(body: i32, item: &str) -> bool {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn bodn2c(name: &str) -> (i32, bool) {}
}
pub fn bodvrd(bodynm: &str, item: &str, maxn: usize) -> Vec<f64> {
let bodynm = cstr!(bodynm);
let item = cstr!(item);
let mut dim = 0;
let mut values = vec![0.0; maxn];
unsafe { crate::c::bodvrd_c(bodynm, item, maxn as _, &mut dim, values.as_mut_ptr()) };
values.truncate(dim as _);
values
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn dascls(handle: i32) {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn dasopr(fname: &str) -> i32 {}
}
pub fn deltet(epoch: f64, eptype: &str) -> f64 {
let eptype = cstr!(eptype);
let mut delta = 0.0;
unsafe {
crate::c::deltet_c(epoch, eptype, &mut delta);
}
delta
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn dlabfs(handle: i32) -> (DLADSC, bool) {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn dskgd(handle: i32, dladsc: DLADSC) -> DSKDSC {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn dskn02(handle: i32, dladsc: DLADSC, plid: i32) -> [f64; 3] {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn dskobj(dsk: &str) -> Cell {}
}
pub fn dskp02(handle: i32, mut dladsc: DLADSC, start: usize, room: usize) -> Vec<[i32; 3]> {
let mut n = 0;
let mut plates = vec![[0; 3]; room];
unsafe {
crate::c::dskp02_c(
handle,
&mut dladsc,
start as _,
room as _,
&mut n,
plates.as_mut_ptr(),
);
}
plates.truncate(n as _);
plates
}
pub fn dskv02(handle: i32, mut dladsc: DLADSC, start: usize, room: usize) -> Vec<[f64; 3]> {
let mut n = 0;
let mut vrtces = vec![[0.0; 3]; room];
unsafe {
crate::c::dskv02_c(
handle,
&mut dladsc,
start as _,
room as _,
&mut n,
vrtces.as_mut_ptr(),
);
}
vrtces.truncate(n as _);
vrtces
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn dskx02(
handle: i32,
dladsc: DLADSC,
vertex: [f64; 3],
raydir: [f64; 3]
) -> (i32, [f64; 3], bool) {
}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn dskz02(handle: i32, dladsc: DLADSC) -> (i32, i32) {}
}
pub fn gdpool(name: &str, start: usize, room: usize) -> Vec<f64> {
let name = cstr!(name);
let start = start as _;
let mut n = 0;
let mut values = vec![0.0; room];
let mut found = 0;
unsafe {
crate::c::gdpool_c(
name,
start,
room as _,
&mut n,
values.as_mut_ptr(),
&mut found,
)
}
values.truncate(n as _);
values
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn georec(lon: f64, lat: f64, alt: f64, re: f64, f: f64) -> [f64; 3] {}
}
pub fn getfov(
instid: isize,
room: usize,
shapelen: usize,
framelen: usize,
) -> (String, String, [f64; 3], Vec<[f64; 3]>) {
let shape = mallocstr!(shapelen);
let frame = mallocstr!(framelen);
let mut bsight = [0.0; 3];
let mut n = 0;
let mut bounds = vec![[0.0; 3]; room];
unsafe {
crate::c::getfov_c(
instid as _,
room as _,
shapelen as _,
framelen as _,
shape,
frame,
bsight.as_mut_ptr(),
&mut n,
bounds.as_mut_ptr(),
)
};
bounds.truncate(n as _);
(fcstr!(shape), fcstr!(frame), bsight, bounds)
}
cspice_proc! {
#[allow(clippy::too_many_arguments)]
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn illumf(
method: &str,
target: &str,
ilusrc: &str,
et: f64,
fixref: &str,
abcorr: &str,
obsrvr: &str,
spoint: [f64; 3]
) -> (f64, [f64; 3], f64, f64, f64, bool, bool) {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn furnsh(name: &str) {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn kclear() {}
}
pub fn kdata(
which: i32,
kind: &str,
fillen: i32,
typlen: i32,
srclen: i32,
) -> (String, String, String, i32, bool) {
#[allow(unused_unsafe)]
unsafe {
let varout_0 = mallocstr!(fillen);
let varout_1 = mallocstr!(typlen);
let varout_2 = mallocstr!(srclen);
let mut varout_3 = 0i32;
let mut varout_4 = 0i32;
crate::c::kdata_c(
which,
cstr!(kind),
fillen,
typlen,
srclen,
varout_0,
varout_1,
varout_2,
&mut varout_3,
&mut varout_4,
);
(
fcstr!(varout_0),
fcstr!(varout_1),
fcstr!(varout_2),
varout_3,
varout_4 != 0,
)
}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn ktotal(kind: &str) -> i32 {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn latrec(radius: f64, longitude: f64, latitude: f64) -> [f64; 3] {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn mxv(m1: [[f64; 3]; 3], vin: [f64; 3]) -> [f64; 3] {}
}
cspice_proc! {
#[allow(clippy::too_many_arguments)]
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn occult(
targ1: &str,
shape1: &str,
frame1: &str,
targ2: &str,
shape2: &str,
frame2: &str,
abcorr: &str,
obsrvr: &str,
et: f64,
) -> i32 {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn pxform(from: &str, to: &str, et: f64) -> [[f64; 3]; 3] {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn pxfrm2(from: &str, to: &str, etfrom: f64, etto: f64) -> [[f64; 3]; 3] {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn radrec(range: f64, ra: f64, dec: f64) -> [f64; 3] {}
}
pub fn recpgr(body: &str, rectan: [f64; 3], re: f64, f: f64) -> [f64; 3] {
let body = cstr!(body);
let mut rectan: [f64; 3] = rectan;
let mut lon = 0.0;
let mut lat = 0.0;
let mut alt = 0.0;
unsafe { crate::c::recpgr_c(body, &mut rectan as _, re, f, &mut lon, &mut lat, &mut alt) };
[lon, lat, alt]
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn recrad(rectan: [f64; 3]) -> (f64, f64, f64) {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn sincpt(
method:&str,
target: &str,
et: f64,
fixred: &str,
abcorr: &str,
obsrvr: &str,
dref: &str,
dvec: [f64; 3]) -> ([f64; 3], f64, [f64; 3], bool) {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn spkcls(handle: i32) {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn spkopn(fname: &str, ifname: &str, ncomch: i32) -> i32 {}
}
cspice_proc! {
#[allow(clippy::too_many_arguments)]
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn spkw09(handle: i32, body: i32, center: i32, frame: &str, first: f64, last: f64, segid: &str, degree: i32, n: i32, states: &mut [[f64; 6]], epochs: &mut [f64]) {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn spkpos(targ: &str, et: f64, frame: &str, abcorr: &str, obs: &str) -> ([f64; 3], f64) {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn spkezr(targ: &str, et: f64, frame: &str, abcorr: &str, obs: &str) -> ([f64; 6], f64) {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn str2et(targ: &str) -> f64 {}
}
pub fn subpnt(
method: &str,
target: &str,
et: f64,
fixref: &str,
abcorr: &str,
obsrvr: &str,
) -> ([f64; 3], f64, [f64; 3]) {
let method = cstr!(method);
let target = cstr!(target);
let fixref = cstr!(fixref);
let abcorr = cstr!(abcorr);
let obsrvr = cstr!(obsrvr);
let mut sp = [0.0; 3];
let mut et_sp = 0.0;
let mut vec_sp = [0.0; 3];
unsafe {
crate::c::subpnt_c(
method,
target,
et,
fixref,
abcorr,
obsrvr,
&mut sp as _,
&mut et_sp,
&mut vec_sp as _,
)
};
(sp, et_sp, vec_sp)
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn surfpt(positn: [f64; 3], u: [f64; 3], a: f64, b: f64, c: f64) -> ([f64; 3], bool) {}
}
pub fn timout(et: f64, pictur: &str, lenout: usize) -> String {
let varout_0 = mallocstr!(lenout);
unsafe {
crate::c::timout_c(et, cstr!(pictur), lenout as i32, varout_0);
}
fcstr!(varout_0)
}
pub fn unitim(epoch: f64, insys: &str, outsys: &str) -> f64 {
let insys = cstr!(insys);
let outsys = cstr!(outsys);
unsafe { crate::c::unitim_c(epoch, insys, outsys) }
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn unload(name: &str) {}
}
cspice_proc! {
#[return_output]
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn vsep(v1: [f64; 3], v2: [f64; 3]) -> f64 {}
}
cspice_proc! {
#[return_output]
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn vdot(v1: [f64; 3], v2: [f64; 3]) -> f64 {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn vcrss(v1: [f64; 3], v2: [f64; 3]) -> [f64; 3] {}
}
cspice_proc! {
#[cfg_attr(any(feature = "lock", doc), impl_for(SpiceLock))]
pub fn xpose(m1: [[f64; 3]; 3]) -> [[f64; 3]; 3] {}
}