Struct Octree

Source
pub struct Octree<D>
where D: Default,
{ /* private fields */ }
Expand description

A barebones octree offering just the methods required for accessing and modifying its contents. Other management structures/functions will be needed to make this more useful, especially for the purpose of querying contents.

Implementations§

Source§

impl<D, S, T> Octree<ManagedOctreeData<D, S>>
where D: Default + Empty + Len + Clear + IntoIterator<Item = T> + OctreeCollection<T>, T: CentredItem<S>, S: Default + Copy + One + PartialOrd + Add<S, Output = S> + Sub<S, Output = S> + Div<S, Output = S>,

Source

pub fn new_managed(centre: (S, S, S), half_length: S) -> Self

Source

pub fn with_max_size(self, max_size: usize) -> Self

Set max_size

Source

pub fn with_drop_below_size(self, drop_below_size: usize) -> Self

Set drop_below_size

Panics when set to 0

Source

pub fn add(&mut self, item: T)

Adds data to the node without flushing/rebalancing the tree.

Source

pub fn clear_data(&mut self)

Clears data from the node (not the whole tree)

Source

pub fn rebalance(&mut self)

Source§

impl<D> Octree<D>
where D: Default,

Source

pub fn new() -> Self

Source

pub fn new_with_data(data: D) -> Self

Source

pub fn add_child( &mut self, idx: usize, child: Self, ) -> Result<&mut Self, AddChildError>

Adds and returns a reference to a child at a particular index.

§Errors

Returns an error if the idx is out of range (i.e. idx >= 8) or if the child is already added.

Source

pub fn add_child_at_pos( &mut self, pos_x: bool, pos_y: bool, pos_z: bool, child: Self, ) -> Result<&mut Self, AddChildError>

Adds and returns a reference to a child at an index based on whether the child is at the positive or negative side of each axis.

§Arguments
  • pos_x - positive x axis if true, negative if false.
  • pos_y - positive y axis if true, negative if false.
  • pos_z - positive z axis if true, negative if false.
§Errors

Returns an error if the child is already added.

Source

pub fn remove_child(&mut self, idx: usize) -> Option<Self>

Removes a child and returns the owned value, if it exists.

Source

pub fn remove_child_at_pos( &mut self, pos_x: bool, pos_y: bool, pos_z: bool, ) -> Option<Self>

Removes a child at an index based on whether the child is at the positive or negative side of each access and returns the owned value, if it exists.

§Arguments
  • pos_x - positive x axis if true, negative if false.
  • pos_y - positive y axis if true, negative if false.
  • pos_z - positive z axis if true, negative if false.
Source

pub fn get_child(&self, idx: usize) -> Option<&Self>

Gets a reference to a child given an index.

Source

pub fn get_child_mut(&mut self, idx: usize) -> Option<&mut Self>

Gets a mutable reference to a child given an index.

Source

pub fn get_child_at_pos( &self, pos_x: bool, pos_y: bool, pos_z: bool, ) -> Option<&Self>

Gets a reference to a child given whether the child is at the positive or negative side of an axis.

§Arguments
  • pos_x - positive x axis if true, negative if false.
  • pos_y - positive y axis if true, negative if false.
  • pos_z - positive z axis if true, negative if false.
Source

pub fn get_child_mut_at_pos( &mut self, pos_x: bool, pos_y: bool, pos_z: bool, ) -> Option<&mut Self>

Gets a mutable reference to a child given whether the child is at the positive or negative side of an axis.

§Arguments
  • pos_x - positive x axis if true, negative if false.
  • pos_y - positive y axis if true, negative if false.
  • pos_z - positive z axis if true, negative if false.
Source

pub fn get_data(&self) -> &D

Gets a reference to the underlying data in the node.

Source

pub fn get_data_mut(&mut self) -> &mut D

Gets a mutable reference to the underlying data in the node.

Trait Implementations§

Source§

impl<D> Default for Octree<D>
where D: Default + Default,

Source§

fn default() -> Octree<D>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<D> Freeze for Octree<D>
where D: Freeze,

§

impl<D> RefUnwindSafe for Octree<D>
where D: RefUnwindSafe,

§

impl<D> Send for Octree<D>
where D: Send,

§

impl<D> Sync for Octree<D>
where D: Sync,

§

impl<D> Unpin for Octree<D>
where D: Unpin,

§

impl<D> UnwindSafe for Octree<D>
where D: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.