Skip to content

Commit

Permalink
these accessors should be GridDescriptor functions (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilioLaiso authored Jul 26, 2023
1 parent a743501 commit c202ae2
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions src/data_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,40 +34,6 @@ impl<ValueTy> Grid<ValueTy> {
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<IVec3, GridMetadataError> {
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<IVec3, GridMetadataError> {
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<i64, GridMetadataError> {
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<i64, GridMetadataError> {
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> {
Expand Down Expand Up @@ -150,6 +116,40 @@ impl GridDescriptor {
) -> Result<u64, std::io::Error> {
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<IVec3, GridMetadataError> {
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<IVec3, GridMetadataError> {
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<i64, GridMetadataError> {
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<i64, GridMetadataError> {
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)]
Expand Down

0 comments on commit c202ae2

Please sign in to comment.