//! Configuration types for Digital Twin demo. use serde::{Deserialize, Serialize}; /// Tissue type for organ geometry. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)] #[serde(rename_all = "snake_case")] pub enum TissueType { /// Air/background #[default] Air, /// Bone tissue Bone, /// Muscle tissue Muscle, /// Fat tissue Fat, /// Liver tissue Liver, /// Kidney tissue Kidney, /// Lung tissue Lung, /// Brain tissue Brain, /// Heart tissue Heart, /// Tumor tissue Tumor, /// Blood vessel BloodVessel, /// Skin tissue Skin, } impl TissueType { /// Get display name for tissue type. #[must_use] pub fn display_name(&self) -> &'static str { match self { Self::Air => "Air", Self::Bone => "Bone", Self::Muscle => "Muscle", Self::Fat => "Fat", Self::Liver => "Liver", Self::Kidney => "Kidney", Self::Lung => "Lung", Self::Brain => "Brain", Self::Heart => "Heart", Self::Tumor => "Tumor", Self::BloodVessel => "Blood Vessel", Self::Skin => "Skin", } } /// Get color for visualization (RGB). #[must_use] pub fn color(&self) -> [u8; 3] { match self { Self::Air => [0, 0, 0], Self::Bone => [255, 255, 200], Self::Muscle => [200, 100, 100], Self::Fat => [255, 255, 150], Self::Liver => [150, 80, 80], Self::Kidney => [180, 100, 100], Self::Lung => [200, 150, 150], Self::Brain => [255, 200, 200], Self::Heart => [200, 50, 50], Self::Tumor => [100, 200, 100], Self::BloodVessel => [255, 50, 50], Self::Skin => [255, 220, 180], } } } /// Intervention type for thermal therapy. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)] #[serde(rename_all = "snake_case")] pub enum InterventionType { /// Radiofrequency ablation #[default] RadiofrequencyAblation, /// Microwave ablation MicrowaveAblation, /// High-intensity focused ultrasound HIFU, /// Cryoablation Cryoablation, /// Laser ablation LaserAblation, } impl InterventionType { /// Get display name. #[must_use] pub fn display_name(&self) -> &'static str { match self { Self::RadiofrequencyAblation => "Radiofrequency Ablation (RFA)", Self::MicrowaveAblation => "Microwave Ablation (MWA)", Self::HIFU => "High-Intensity Focused Ultrasound", Self::Cryoablation => "Cryoablation", Self::LaserAblation => "Laser Ablation", } } } /// Configuration for digital twin simulation. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct SimulationConfig { /// Grid resolution [x, y, z] pub resolution: [u32; 3], /// Voxel spacing in mm [dx, dy, dz] pub spacing: [f32; 3], /// Blood temperature in °C pub blood_temperature: f32, /// Simulation duration in seconds pub duration: f32, /// Time step in seconds pub time_step: f32, /// Enable damage calculation pub compute_damage: bool, } impl Default for SimulationConfig { fn default() -> Self { Self { resolution: [64, 64, 64], spacing: [1.0, 1.0, 1.0], blood_temperature: 37.0, duration: 60.0, time_step: 0.1, compute_damage: true, } } } /// Configuration for ablation probe intervention. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ProbeConfig { /// Intervention type pub intervention_type: InterventionType, /// Probe position in mm [x, y, z] pub position: [f32; 3], /// Power output in Watts pub power: f32, /// Active tip length in mm pub active_length: f32, /// Probe diameter in mm pub diameter: f32, } impl Default for ProbeConfig { fn default() -> Self { Self { intervention_type: InterventionType::RadiofrequencyAblation, position: [32.0, 32.0, 32.0], power: 50.0, active_length: 30.0, diameter: 2.0, } } } #[cfg(test)] mod tests { use super::*; #[test] fn test_tissue_type_display() { assert_eq!(TissueType::Liver.display_name(), "Liver"); assert_eq!(TissueType::Tumor.display_name(), "Tumor"); } #[test] fn test_tissue_type_color() { let color = TissueType::Tumor.color(); assert_eq!(color, [100, 200, 100]); } #[test] fn test_intervention_type_display() { assert_eq!( InterventionType::HIFU.display_name(), "High-Intensity Focused Ultrasound" ); } #[test] fn test_simulation_config_default() { let config = SimulationConfig::default(); assert_eq!(config.resolution, [64, 64, 64]); assert_eq!(config.blood_temperature, 37.0); } #[test] fn test_probe_config_default() { let config = ProbeConfig::default(); assert_eq!(config.power, 50.0); } }