pub trait SpatialIndex:
Clone
+ Copy
+ Default
+ Ord
+ Send
+ Debug {
type Diff: VectorSpace<Scalar = u32>;
type Point: Copy + EuclideanSpace<Diff = Self::Diff, Scalar = u32>;
type SubdivideResult: AsRef<[Self]>;
// Required methods
fn clamp_depth(_: u32) -> u32;
fn origin(self) -> Self::Point;
fn depth(self) -> u32;
fn set_origin(self, _: Self::Point) -> Self;
fn set_depth(self, _: u32) -> Self;
fn subdivide(self) -> Option<Self::SubdivideResult>;
fn overlaps(self, other: Self) -> bool;
fn same_cell_at_depth(lhs: Self, rhs: Self, depth: u32) -> bool;
}Expand description
An index representing an object’s position and scale
The Ord trait must be implemented such that sorting produces a topological ordering.
This may be accomplished using trivial comparison operators for a primitive integer type by:
- Packing bits such that
originis higher-significance thandepth - Storing the value of
originas a Morton code - Truncating
originbits to the level specified bydepth, such that it represents the minimum bound of the cell at the given scale
Currently, requirement #3 (truncating origin) is not the responsibility of the particular SpatialIndex
implementation — an appropriately-truncated value must be passed as an argument to set_origin
Ord should be implemented such that an X-bit is lower significance (changes more rapidly) than the
corresponding a Y-bit (which should, likewise, be lower significance than the corresponding Z-bit for
3D indices)
<SpatialIndex as Default>::default() is required to return an index which encompasses the entire system
bounds (i.e. zero origin and zero depth)
The following index types are provided:
Index32_2D: A 32-bit 2D index type providing 14 bits’ precision per axisIndex64_2D: A 64-bit 2D index type providing 29 bits’ precision per axisIndex64_3D: A 64-bit 3D index type providing 19 bits’ precision per axis
Required Associated Types§
type Diff: VectorSpace<Scalar = u32>
type Point: Copy + EuclideanSpace<Diff = Self::Diff, Scalar = u32>
type SubdivideResult: AsRef<[Self]>
Required Methods§
Sourcefn clamp_depth(_: u32) -> u32
fn clamp_depth(_: u32) -> u32
clamps a depth value to the representable range
fn origin(self) -> Self::Point
fn depth(self) -> u32
fn set_origin(self, _: Self::Point) -> Self
fn set_depth(self, _: u32) -> Self
Sourcefn subdivide(self) -> Option<Self::SubdivideResult>
fn subdivide(self) -> Option<Self::SubdivideResult>
Subdivide the cell represented by this index into cells of depth + 1
This is required to return results in sorted order. Returns None if depth limit has been reached.
Sourcefn overlaps(self, other: Self) -> bool
fn overlaps(self, other: Self) -> bool
Check if two indices represent overlapping regions of space
Sourcefn same_cell_at_depth(lhs: Self, rhs: Self, depth: u32) -> bool
fn same_cell_at_depth(lhs: Self, rhs: Self, depth: u32) -> bool
Check if two indices would fall into the same cell at a given (truncated) depth
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".