imodfile 0.1.0

A pure-Rust IMOD model file decoder/encoder — binary & ASCII, with Python bindings
Documentation
#![doc = include_str!("../README.md")]

pub mod ascii;
pub mod binary;
pub mod chunk_ids;
pub mod error;
pub mod model;
pub mod store;

#[cfg(feature = "python")]
pub mod python;

pub use ascii::{read_ascii, write_ascii};
pub use binary::{read_binary, write_binary};
pub use error::{ImodError, ImodResult};
pub use model::{
    IclipPlanes, Icont, Iindex, Imesh, ImeshParams, Imod, Iobj,
    IobjPointsIter, ImodPointsIter,
    Iplane, Ipoint, IrefImage, Istore, IstoreItem, Iview, Ilabel,
    IlabelItem, SlicerAngles,
    // Flag constants
    IMODF_FLIPYZ, IMODF_HAS_MESH_THICK, IMODF_MAT1_IS_BYTES,
    IMODF_MULTIPLE_CLIP, IMODF_NEW_TO_3DMOD, IMODF_OTRANS_ORIGIN,
    IMODF_ROT90X, IMODF_TILTOK, IMODF_Z_FROM_MINUSPT5,
    IMOD_OBJFLAG_ANTI_ALIAS, IMOD_OBJFLAG_DRAW_LABEL,
    IMOD_OBJFLAG_FCOLOR, IMOD_OBJFLAG_FCOLOR_PNT,
    IMOD_OBJFLAG_FILL, IMOD_OBJFLAG_MCOLOR, IMOD_OBJFLAG_MESH,
    IMOD_OBJFLAG_NOLINE, IMOD_OBJFLAG_OFF, IMOD_OBJFLAG_OPEN,
    IMOD_OBJFLAG_OUT, IMOD_OBJFLAG_PNT_ON_SEC, IMOD_OBJFLAG_SCAT,
    IMOD_OBJFLAG_SCALE_WDTH, IMOD_OBJFLAG_TIME, IMOD_OBJFLAG_TWO_SIDE,
    IMOD_OBJFLAG_USE_VALUE,
};

/// Read an IMOD model from a file path, auto-detecting binary vs ASCII.
///
/// This is a thin wrapper around [`Imod::load`].
///
/// ```no_run
/// let model = imodfile::read("model.mod").unwrap();
/// ```
pub fn read(path: &str) -> ImodResult<Imod> {
    Imod::load(path)
}

/// Write an IMOD model to a file path.  Uses binary format unless the path
/// ends with `.txt` or `.ascii` (then ASCII).
///
/// This is a thin wrapper around [`Imod::save`].
///
/// ```no_run
/// let model = imodfile::read("model.mod").unwrap();
/// imodfile::write("output.mod", &model).unwrap();
/// ```
pub fn write(path: &str, model: &Imod) -> ImodResult<()> {
    model.save(path)
}