pub struct SimdIndex2D { /* private fields */ }simd only.Expand description
Finished read-only SIMD index.
Created through Index2DBuilder::finish_simd.
It has the same public search and nearest-neighbor API as Index2D,
but stores box coordinates in structure-of-arrays form for SIMD traversal.
§Example
use packed_spatial_index::{Index2DBuilder, Box2D};
let mut builder = Index2DBuilder::new(1);
builder.add(Box2D::new(0.0, 0.0, 1.0, 1.0));
let index = builder.finish_simd().unwrap();
assert_eq!(index.search(Box2D::new(0.5, 0.5, 0.5, 0.5)), vec![0]);Implementations§
Source§impl SimdIndex2D
impl SimdIndex2D
Sourcepub fn raycast_closest_with(
&self,
ray: Ray2D,
workspace: &mut NeighborWorkspace,
) -> Option<(usize, f64)>
pub fn raycast_closest_with( &self, ray: Ray2D, workspace: &mut NeighborWorkspace, ) -> Option<(usize, f64)>
SoA/SIMD ordered closest-hit raycast (2D). Same result as
Index2D::raycast_closest_with, with the
slab test evaluated four (or eight, on AVX-512) children at a time.
Axis-parallel rays are handled by the wide::f64x4 path with a masked slab
test to avoid 0 * inf = NaN at box faces.
Sourcepub fn raycast_closest(&self, ray: Ray2D) -> Option<(usize, f64)>
pub fn raycast_closest(&self, ray: Ray2D) -> Option<(usize, f64)>
Return the nearest item whose box the ray segment enters, as
(item index, entry t), or None when the segment hits nothing.
Nodes are visited front-to-back by entry distance and pruned once a
closer hit is known, so the cost is roughly independent of
max_distance after the first hit. t is 0.0 when the ray origin
starts inside the item’s box.
Sourcepub fn raycast(&self, ray: Ray2D) -> Vec<usize>
pub fn raycast(&self, ray: Ray2D) -> Vec<usize>
Return the indices of all items whose boxes the ray segment touches.
Sourcepub fn raycast_into(&self, ray: Ray2D, results: &mut Vec<usize>)
pub fn raycast_into(&self, ray: Ray2D, results: &mut Vec<usize>)
Raycast with a reusable result buffer.
Sourcepub fn raycast_with<'a>(
&self,
ray: Ray2D,
workspace: &'a mut SearchWorkspace,
) -> &'a [usize]
pub fn raycast_with<'a>( &self, ray: Ray2D, workspace: &'a mut SearchWorkspace, ) -> &'a [usize]
Raycast with reusable result and traversal buffers.
Source§impl SimdIndex2D
impl SimdIndex2D
Sourcepub fn visit_raycast<B, F>(&self, ray: Ray2D, visitor: F) -> ControlFlow<B>
pub fn visit_raycast<B, F>(&self, ray: Ray2D, visitor: F) -> ControlFlow<B>
Visit items in nondecreasing entry-t order along the ray segment.
The visitor receives (item index, entry t). Return
ControlFlow::Break to stop early - for example after the first N
occluders. t is 0.0 when the ray origin starts inside a box.
Source§impl SimdIndex2D
impl SimdIndex2D
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize into the stable little-endian PSINDEX format.
The output is byte-identical to Index2D::to_bytes
for the same items, so a SimdIndex2D and an Index2D are interchangeable on
disk: either can load bytes produced by the other.
Sourcepub fn to_bytes_into(&self, out: &mut Vec<u8>)
pub fn to_bytes_into(&self, out: &mut Vec<u8>)
Serialize into a caller-provided buffer, reusing its allocation.
Equivalent to to_bytes but writes into out (cleared first).
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, LoadError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, LoadError>
Load a SIMD index from bytes produced by to_bytes or by
Index2D::to_bytes; the AoS box records are
scattered into the structure-of-arrays columns.
Source§impl SimdIndex2D
impl SimdIndex2D
Sourcepub fn extent(&self) -> Option<Box2D>
pub fn extent(&self) -> Option<Box2D>
Return the total extent of indexed items, or None for an empty index.
Sourcepub fn search(&self, query: Box2D) -> Vec<usize>
pub fn search(&self, query: Box2D) -> Vec<usize>
Return the indices of all items whose boxes intersect query.
Sourcepub fn search_into(&self, query: Box2D, out: &mut Vec<usize>)
pub fn search_into(&self, query: Box2D, out: &mut Vec<usize>)
Search with a reusable result buffer.
This automatically dispatches to the widest available kernel at runtime:
AVX-512 (VPCOMPRESSQ collection), then an explicit AVX2 tier (left-pack
collection), then the SSE2 wide fallback.
Sourcepub fn search_with<'a>(
&self,
query: Box2D,
workspace: &'a mut SearchWorkspace,
) -> &'a [usize]
pub fn search_with<'a>( &self, query: Box2D, workspace: &'a mut SearchWorkspace, ) -> &'a [usize]
Search with reusable result and traversal buffers.
Sourcepub fn neighbors(&self, point: Point2D, max_results: usize) -> Vec<usize>
pub fn neighbors(&self, point: Point2D, max_results: usize) -> Vec<usize>
Return up to max_results item indices nearest to point.
Sourcepub fn neighbors_within(
&self,
point: Point2D,
max_results: usize,
max_distance: f64,
) -> Vec<usize>
pub fn neighbors_within( &self, point: Point2D, max_results: usize, max_distance: f64, ) -> Vec<usize>
Return up to max_results item indices within max_distance of point.
Sourcepub fn neighbors_into(
&self,
point: Point2D,
max_results: usize,
max_distance: f64,
results: &mut Vec<usize>,
)
pub fn neighbors_into( &self, point: Point2D, max_results: usize, max_distance: f64, results: &mut Vec<usize>, )
Nearest-neighbor search with a reusable result buffer.
Sourcepub fn neighbors_with<'a>(
&self,
point: Point2D,
max_results: usize,
max_distance: f64,
workspace: &'a mut NeighborWorkspace,
) -> &'a [usize]
pub fn neighbors_with<'a>( &self, point: Point2D, max_results: usize, max_distance: f64, workspace: &'a mut NeighborWorkspace, ) -> &'a [usize]
Nearest-neighbor search with reusable result and priority-queue buffers.
Sourcepub fn visit_neighbors<B, F>(
&self,
point: Point2D,
max_distance: f64,
visitor: F,
) -> ControlFlow<B>
pub fn visit_neighbors<B, F>( &self, point: Point2D, max_distance: f64, visitor: F, ) -> ControlFlow<B>
Visit items in nondecreasing squared-distance order from point.
Sourcepub fn neighbors_of_box(&self, query: Box2D, max_results: usize) -> Vec<usize>
pub fn neighbors_of_box(&self, query: Box2D, max_results: usize) -> Vec<usize>
Return up to max_results item indices nearest to the box query.
See Index2D::neighbors_of_box.
Sourcepub fn neighbors_of_box_within(
&self,
query: Box2D,
max_results: usize,
max_distance: f64,
) -> Vec<usize>
pub fn neighbors_of_box_within( &self, query: Box2D, max_results: usize, max_distance: f64, ) -> Vec<usize>
Return up to max_results item indices within max_distance of the
box query. See Index2D::neighbors_of_box.
Sourcepub fn neighbors_of_box_into(
&self,
query: Box2D,
max_results: usize,
max_distance: f64,
results: &mut Vec<usize>,
)
pub fn neighbors_of_box_into( &self, query: Box2D, max_results: usize, max_distance: f64, results: &mut Vec<usize>, )
Box-query nearest-neighbor search with a reusable result buffer.
Sourcepub fn neighbors_of_box_with<'na>(
&self,
query: Box2D,
max_results: usize,
max_distance: f64,
workspace: &'na mut NeighborWorkspace,
) -> &'na [usize]
pub fn neighbors_of_box_with<'na>( &self, query: Box2D, max_results: usize, max_distance: f64, workspace: &'na mut NeighborWorkspace, ) -> &'na [usize]
Box-query nearest-neighbor search with reusable result and priority-queue buffers.
Sourcepub fn visit_neighbors_of_box<B, F>(
&self,
query: Box2D,
max_distance: f64,
visitor: F,
) -> ControlFlow<B>
pub fn visit_neighbors_of_box<B, F>( &self, query: Box2D, max_distance: f64, visitor: F, ) -> ControlFlow<B>
Visit items in nondecreasing box-to-box distance order from query.
See Index2D::visit_neighbors_of_box.
Sourcepub fn visit<B, F>(&self, query: Box2D, visitor: F) -> ControlFlow<B>
pub fn visit<B, F>(&self, query: Box2D, visitor: F) -> ControlFlow<B>
Visit intersecting items without collecting a result Vec.
Sourcepub fn join(&self, other: &SimdIndex2D) -> Vec<(usize, usize)>
pub fn join(&self, other: &SimdIndex2D) -> Vec<(usize, usize)>
Return every pair (i, j) where item i of self intersects item j
of other. See Index2D::join.
Sourcepub fn join_with<B, F>(&self, other: &SimdIndex2D, visitor: F) -> ControlFlow<B>
pub fn join_with<B, F>(&self, other: &SimdIndex2D, visitor: F) -> ControlFlow<B>
Visit every intersecting pair between self and other. See
Index2D::join_with.
Sourcepub fn self_join(&self) -> Vec<(usize, usize)>
pub fn self_join(&self) -> Vec<(usize, usize)>
Return every unordered pair of distinct intersecting items within this
index, each pair exactly once. See
Index2D::self_join.
Sourcepub fn self_join_with<B, F>(&self, visitor: F) -> ControlFlow<B>
pub fn self_join_with<B, F>(&self, visitor: F) -> ControlFlow<B>
Visit every unordered pair of distinct intersecting items within this
index. See Index2D::self_join_with.
Auto Trait Implementations§
impl Freeze for SimdIndex2D
impl RefUnwindSafe for SimdIndex2D
impl Send for SimdIndex2D
impl Sync for SimdIndex2D
impl Unpin for SimdIndex2D
impl UnsafeUnpin for SimdIndex2D
impl UnwindSafe for SimdIndex2D
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more