#![forbid(unsafe_code)]
use serde::{Deserialize, Serialize};
use std::sync::Arc;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum Hardness {
Hard,
Interpolated,
Assumed,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum HorizonRole {
Top,
Base,
Intermediate,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ContactKind {
Owc,
Goc,
Gwc,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Boundary {
pub ring: Vec<[f64; 2]>,
pub hardness: Hardness,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct GriddedDepth {
pub ncol: usize,
pub nrow: usize,
pub depth_m: Vec<f64>,
pub is_control: Vec<bool>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Horizon {
pub name: String,
pub role: HorizonRole,
pub surface: GriddedDepth,
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct Contact {
pub kind: ContactKind,
pub depth_m: f64,
pub hardness: Hardness,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Wireframe {
pub boundary: Boundary,
pub horizons: Arc<Vec<Horizon>>,
pub contacts: Vec<Contact>,
}
impl Wireframe {
pub fn from_boundary(boundary: Boundary) -> Self {
Self {
boundary,
horizons: Arc::new(Vec::new()),
contacts: Vec::new(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn seed_from_boundary_is_empty() {
let b = Boundary {
ring: vec![[0.0, 0.0], [100.0, 0.0], [100.0, 100.0], [0.0, 100.0]],
hardness: Hardness::Hard,
};
let wf = Wireframe::from_boundary(b);
assert!(wf.horizons.is_empty());
assert!(wf.contacts.is_empty());
assert_eq!(wf.boundary.ring.len(), 4);
}
}