Struct pasture_core::math::MortonIndex64WithDepth [−][src]
64-bit 3D Morton index with depth information. This is the more efficient, but more constraint
version of DynamicMortonIndex
because it can store at maximum 21 levels. Important note: Since
a Morton index defines a node in an octree, one has to define what index the root node has. As
each 3 bits within a 3D Morton index identify an octant at a certain level, there is no level that
defines the root node since it is just a single node. We now define that the root node is always at
level 0, so the level
parameter of this structure is always relative to the root node. A
MortonIndex64WithLevel
with a level
of 0 is therefore always zero. The first octant lies at level 1.
This can be a bit confusing because it makes the code prone to off-by-one errors, however it is better
than the alternative (IMO) where root node has level -1, or None.
Implementations
impl MortonIndex64WithDepth
[src]
pub fn from_octants(octants: &[Octant]) -> Self
[src]
Creates a new MortonIndex64WithDepth
from the given octants. octants.len()
must be <= MortonIndex64::LEVELS
Example
// Create a Morton index for the octants 1->2->4 (octant 4 of octant 2 of octant 1 of the root node) let morton_index_with_depth = MortonIndex64WithDepth::from_octants(&[Octant::ONE, Octant::TWO, Octant::FOUR]); assert_eq!(3, morton_index_with_depth.depth()); assert_eq!(Some(Octant::ONE), morton_index_with_depth.get_octant_at_level(1)); assert_eq!(Some(Octant::TWO), morton_index_with_depth.get_octant_at_level(2)); assert_eq!(Some(Octant::FOUR), morton_index_with_depth.get_octant_at_level(3));
pub fn raw_index(&self) -> u64
[src]
Returns the raw integer value of the associated MortonIndex64WithDepth
. This index is similar
to what MortonIndex64::index()
returns, however only the highest 3 * depth()
bits are used
(ignoring the MSB which is always unused for 64 bit Morton indices). All lower bits (and the MSB)
are zero!
pub fn depth(&self) -> u8
[src]
Returns the depth of the octree node represented by the associated MortonIndex64WithDepth
. A
depth of zero represents the root node and corresponds to a raw_index()
where no bits are used
pub fn get_octant_at_level(&self, level: u8) -> Option<Octant>
[src]
Returns the octant index relative to the parent node for the node at the given level
. Since
level zero represents the root node, and the root node has no parent, None
is returned for
level zero.
Panics
If level
is greater than depth()
pub fn child(&self, octant: Octant) -> Option<Self>
[src]
Returns the child node at the given octant
from the associated MortonIndex64WithDepth
. If the associated
index is already of maximum depth (MortonIndex64::LEVELS
), returns None
pub fn with_lower_depth(&self, lower_depth: u8) -> Self
[src]
Returns a version of the associated MortonIndex64WithDepth
with the given lower depth
pub fn as_grid_index(&self) -> Vector3<u32>
[src]
Converts the associated MortonIndex64WithDepth
into an XYZ index within a 3D grid of size (2^self.depth)x(2^self.depth)x(2^self.depth)
pub fn to_string(&self, naming: MortonIndexNaming) -> String
[src]
Returns a string representation of the associated MortonIndex64WithDepth
with the given MortonIndexNaming
Trait Implementations
impl Clone for MortonIndex64WithDepth
[src]
fn clone(&self) -> MortonIndex64WithDepth
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for MortonIndex64WithDepth
[src]
impl Default for MortonIndex64WithDepth
[src]
impl Eq for MortonIndex64WithDepth
[src]
impl From<&'_ MortonIndex64WithDepth> for DynamicMortonIndex
[src]
fn from(morton_index: &MortonIndex64WithDepth) -> Self
[src]
impl From<MortonIndex64WithDepth> for DynamicMortonIndex
[src]
fn from(morton_index: MortonIndex64WithDepth) -> Self
[src]
impl Hash for MortonIndex64WithDepth
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<MortonIndex64WithDepth> for MortonIndex64WithDepth
[src]
fn eq(&self, other: &MortonIndex64WithDepth) -> bool
[src]
fn ne(&self, other: &MortonIndex64WithDepth) -> bool
[src]
impl StructuralEq for MortonIndex64WithDepth
[src]
impl StructuralPartialEq for MortonIndex64WithDepth
[src]
impl TryFrom<&'_ DynamicMortonIndex> for MortonIndex64WithDepth
[src]
type Error = DynamicMortonIndexTooLargeError
The type returned in the event of a conversion error.
fn try_from(value: &DynamicMortonIndex) -> Result<Self, Self::Error>
[src]
impl TryFrom<DynamicMortonIndex> for MortonIndex64WithDepth
[src]
type Error = DynamicMortonIndexTooLargeError
The type returned in the event of a conversion error.
fn try_from(value: DynamicMortonIndex) -> Result<Self, Self::Error>
[src]
Auto Trait Implementations
impl RefUnwindSafe for MortonIndex64WithDepth
impl Send for MortonIndex64WithDepth
impl Sync for MortonIndex64WithDepth
impl Unpin for MortonIndex64WithDepth
impl UnwindSafe for MortonIndex64WithDepth
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn is_in_subset(&self) -> bool
pub fn to_subset_unchecked(&self) -> SS
pub fn from_subset(element: &SS) -> SP
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,