use crate::motion::WallMotion;
use soil_core::region::Region;
pub struct WallPlane {
pub point_x: f64,
pub point_y: f64,
pub point_z: f64,
pub normal_x: f64,
pub normal_y: f64,
pub normal_z: f64,
pub material_index: usize,
pub name: Option<String>,
pub bound_x_low: f64,
pub bound_x_high: f64,
pub bound_y_low: f64,
pub bound_y_high: f64,
pub bound_z_low: f64,
pub bound_z_high: f64,
pub velocity: [f64; 3],
pub motion: WallMotion,
pub origin: [f64; 3],
pub force_accumulator: f64,
pub temperature: Option<f64>,
}
impl WallPlane {
#[inline]
pub fn in_bounds(&self, x: f64, y: f64, z: f64) -> bool {
x >= self.bound_x_low
&& x <= self.bound_x_high
&& y >= self.bound_y_low
&& y <= self.bound_y_high
&& z >= self.bound_z_low
&& z <= self.bound_z_high
}
}
pub struct WallCylinder {
pub axis: usize,
pub center: [f64; 2],
pub radius: f64,
pub lo: f64,
pub hi: f64,
pub inside: bool,
pub material_index: usize,
pub name: Option<String>,
pub force_accumulator: f64,
pub temperature: Option<f64>,
}
pub struct WallSphere {
pub center: [f64; 3],
pub radius: f64,
pub inside: bool,
pub material_index: usize,
pub name: Option<String>,
pub force_accumulator: f64,
pub temperature: Option<f64>,
}
pub struct WallRegion {
pub region: Region,
pub inside: bool,
pub material_index: usize,
pub name: Option<String>,
pub force_accumulator: f64,
pub temperature: Option<f64>,
}
pub struct Walls {
pub planes: Vec<WallPlane>,
pub active: Vec<bool>,
pub cylinders: Vec<WallCylinder>,
pub cylinder_active: Vec<bool>,
pub spheres: Vec<WallSphere>,
pub sphere_active: Vec<bool>,
pub regions: Vec<WallRegion>,
pub region_active: Vec<bool>,
pub time: f64,
pub tangential_springs: std::collections::HashMap<(u8, usize, u32), [f64; 3]>,
pub rolling_springs: std::collections::HashMap<(u8, usize, u32), [f64; 3]>,
}
impl Walls {
pub fn deactivate_by_name(&mut self, name: &str) {
for (i, wall) in self.planes.iter().enumerate() {
if wall.name.as_deref() == Some(name) {
self.active[i] = false;
}
}
for (i, wall) in self.cylinders.iter().enumerate() {
if wall.name.as_deref() == Some(name) {
self.cylinder_active[i] = false;
}
}
for (i, wall) in self.spheres.iter().enumerate() {
if wall.name.as_deref() == Some(name) {
self.sphere_active[i] = false;
}
}
for (i, wall) in self.regions.iter().enumerate() {
if wall.name.as_deref() == Some(name) {
self.region_active[i] = false;
}
}
}
pub fn activate_by_name(&mut self, name: &str) {
for (i, wall) in self.planes.iter().enumerate() {
if wall.name.as_deref() == Some(name) {
self.active[i] = true;
}
}
for (i, wall) in self.cylinders.iter().enumerate() {
if wall.name.as_deref() == Some(name) {
self.cylinder_active[i] = true;
}
}
for (i, wall) in self.spheres.iter().enumerate() {
if wall.name.as_deref() == Some(name) {
self.sphere_active[i] = true;
}
}
for (i, wall) in self.regions.iter().enumerate() {
if wall.name.as_deref() == Some(name) {
self.region_active[i] = true;
}
}
}
}