Newer
Older
//! Data structures containing the light information flowing between [`OpticNodes`](crate::optic_node::OpticNode).
use uom::si::{energy::joule, f64::Energy};
use crate::spectrum::Spectrum;
/// Data structure defining the light properties. The actuals data type used depends on the
/// [`AnalyzerType`](crate::analyzer::AnalyzerType). For example, an energy analysis ([`LightData::Energy`]) only
/// contains a [`Spectrum`] information, while a geometric analysis ([`LightData::Geometric]) constains a set of optical
pub enum LightData {
/// data type used for energy analysis.
/// data type used for geometric optics analysis (ray tracing)
/// placeholder value for future Fourier optics analysis, nothing implementd yet.
impl LightData {
pub fn export(&self, file_name: &str) {
match self {
LightData::Energy(d) => {
d.spectrum.to_plot(file_name);
}
_ => println!("no export function defined for this type of LightData"),
impl Display for LightData {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
LightData::Energy(e) => {
let ef = Energy::format_args(joule, Abbreviation);
write!(
f,
"Energy: {}",
ef.with(Energy::new::<joule>(e.spectrum.total_energy()))
)
}
_ => write!(f, "No display defined for this type of LightData"),
}
}
}