From c202ae2da83390ac130a3f1d5b4634f50a6dc213 Mon Sep 17 00:00:00 2001 From: Emilio Date: Wed, 26 Jul 2023 14:15:22 +0200 Subject: [PATCH] these accessors should be `GridDescriptor` functions (#48) --- src/data_structure.rs | 68 +++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/data_structure.rs b/src/data_structure.rs index 123d1e2..27ba72d 100644 --- a/src/data_structure.rs +++ b/src/data_structure.rs @@ -34,40 +34,6 @@ impl Grid { node_3: None, } } - - // below values should always be present, see https://github.com/AcademySoftwareFoundation/openvdb/blob/master/openvdb/openvdb/Grid.cc#L387 - pub fn aabb_min(&self) -> Result { - match self.descriptor.meta_data.0["file_bbox_min"] { - MetadataValue::Vec3i(v) => Ok(v), - _ => Err(GridMetadataError::FieldNotPresent( - "file_bbox_min".to_string(), - )), - } - } - pub fn aabb_max(&self) -> Result { - match self.descriptor.meta_data.0["file_bbox_max"] { - MetadataValue::Vec3i(v) => Ok(v), - _ => Err(GridMetadataError::FieldNotPresent( - "file_bbox_max".to_string(), - )), - } - } - pub fn mem_bytes(&self) -> Result { - match self.descriptor.meta_data.0["file_mem_bytes"] { - MetadataValue::I64(v) => Ok(v), - _ => Err(GridMetadataError::FieldNotPresent( - "file_mem_bytes".to_string(), - )), - } - } - pub fn voxel_count(&self) -> Result { - match self.descriptor.meta_data.0["file_voxel_count"] { - MetadataValue::I64(v) => Ok(v), - _ => Err(GridMetadataError::FieldNotPresent( - "file_voxel_count".to_string(), - )), - } - } } pub struct GridIter<'a, ValueTy> { @@ -150,6 +116,40 @@ impl GridDescriptor { ) -> Result { reader.seek(SeekFrom::Start(self.block_pos)) } + + // below values should always be present, see https://github.com/AcademySoftwareFoundation/openvdb/blob/master/openvdb/openvdb/Grid.cc#L387 + pub fn aabb_min(&self) -> Result { + match self.meta_data.0["file_bbox_min"] { + MetadataValue::Vec3i(v) => Ok(v), + _ => Err(GridMetadataError::FieldNotPresent( + "file_bbox_min".to_string(), + )), + } + } + pub fn aabb_max(&self) -> Result { + match self.meta_data.0["file_bbox_max"] { + MetadataValue::Vec3i(v) => Ok(v), + _ => Err(GridMetadataError::FieldNotPresent( + "file_bbox_max".to_string(), + )), + } + } + pub fn mem_bytes(&self) -> Result { + match self.meta_data.0["file_mem_bytes"] { + MetadataValue::I64(v) => Ok(v), + _ => Err(GridMetadataError::FieldNotPresent( + "file_mem_bytes".to_string(), + )), + } + } + pub fn voxel_count(&self) -> Result { + match self.meta_data.0["file_voxel_count"] { + MetadataValue::I64(v) => Ok(v), + _ => Err(GridMetadataError::FieldNotPresent( + "file_voxel_count".to_string(), + )), + } + } } #[derive(Debug, Default, Clone)]