#[derive(Debug, Clone)]
pub struct VolumetricData {
pub id: usize,
pub boundary: Option<VolumetricBoundary>,
pub voxels: Option<VoxelGrid>,
pub implicit: Option<ImplicitVolume>,
}
impl VolumetricData {
pub fn new(id: usize) -> Self {
Self {
id,
boundary: None,
voxels: None,
implicit: None,
}
}
}
#[derive(Debug, Clone, Copy)]
pub struct VolumetricBoundary {
pub min: (f64, f64, f64),
pub max: (f64, f64, f64),
}
impl VolumetricBoundary {
pub fn new(min: (f64, f64, f64), max: (f64, f64, f64)) -> Self {
Self { min, max }
}
}
#[derive(Debug, Clone)]
pub struct VoxelGrid {
pub dimensions: (usize, usize, usize),
pub spacing: Option<(f64, f64, f64)>,
pub origin: Option<(f64, f64, f64)>,
pub voxels: Vec<Voxel>,
}
impl VoxelGrid {
pub fn new(dimensions: (usize, usize, usize)) -> Self {
Self {
dimensions,
spacing: None,
origin: None,
voxels: Vec::new(),
}
}
}
#[derive(Debug, Clone)]
pub struct Voxel {
pub position: (usize, usize, usize),
pub property_id: Option<usize>,
pub color_id: Option<usize>,
}
impl Voxel {
pub fn new(position: (usize, usize, usize)) -> Self {
Self {
position,
property_id: None,
color_id: None,
}
}
}
#[derive(Debug, Clone)]
pub struct ImplicitVolume {
pub implicit_type: String,
pub parameters: Vec<(String, String)>,
}
impl ImplicitVolume {
pub fn new(implicit_type: String) -> Self {
Self {
implicit_type,
parameters: Vec::new(),
}
}
}
#[derive(Debug, Clone)]
pub struct VolumetricPropertyGroup {
pub id: usize,
pub properties: Vec<VolumetricProperty>,
}
impl VolumetricPropertyGroup {
pub fn new(id: usize) -> Self {
Self {
id,
properties: Vec::new(),
}
}
}
#[derive(Debug, Clone)]
pub struct VolumetricProperty {
pub index: usize,
pub value: String,
}
impl VolumetricProperty {
pub fn new(index: usize, value: String) -> Self {
Self { index, value }
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_volumetric_data_creation() {
let data = VolumetricData::new(1);
assert_eq!(data.id, 1);
assert!(data.boundary.is_none());
assert!(data.voxels.is_none());
assert!(data.implicit.is_none());
}
#[test]
fn test_volumetric_boundary() {
let boundary = VolumetricBoundary::new((0.0, 0.0, 0.0), (100.0, 100.0, 100.0));
assert_eq!(boundary.min, (0.0, 0.0, 0.0));
assert_eq!(boundary.max, (100.0, 100.0, 100.0));
}
#[test]
fn test_voxel_grid() {
let grid = VoxelGrid::new((10, 10, 10));
assert_eq!(grid.dimensions, (10, 10, 10));
assert!(grid.spacing.is_none());
assert!(grid.origin.is_none());
assert!(grid.voxels.is_empty());
}
#[test]
fn test_voxel_creation() {
let voxel = Voxel::new((5, 5, 5));
assert_eq!(voxel.position, (5, 5, 5));
assert!(voxel.property_id.is_none());
assert!(voxel.color_id.is_none());
}
#[test]
fn test_implicit_volume() {
let mut implicit = ImplicitVolume::new("sdf".to_string());
assert_eq!(implicit.implicit_type, "sdf");
assert!(implicit.parameters.is_empty());
implicit
.parameters
.push(("param1".to_string(), "value1".to_string()));
assert_eq!(implicit.parameters.len(), 1);
}
#[test]
fn test_volumetric_property_group() {
let mut group = VolumetricPropertyGroup::new(1);
assert_eq!(group.id, 1);
assert!(group.properties.is_empty());
group
.properties
.push(VolumetricProperty::new(0, "value".to_string()));
assert_eq!(group.properties.len(), 1);
}
}