SpatialIndex

Struct SpatialIndex 

Source
pub struct SpatialIndex { /* private fields */ }
Expand description

Spatial index for efficient viewport and proximity queries

Implementations§

Source§

impl SpatialIndex

Source

pub fn new() -> Self

Create a new spatial index with default cell size

Source

pub fn with_cell_size(cell_size: f64) -> Self

Create a new spatial index with specified cell size

Source

pub fn insert<T>(&mut self, node: &Node<T>) -> Result<()>
where T: Clone,

Insert a node into the spatial index

Source

pub fn remove(&mut self, node_id: &NodeId) -> bool

Remove a node from the spatial index

Source

pub fn update<T>(&mut self, node: &Node<T>) -> Result<()>
where T: Clone,

Update a node’s position in the spatial index

Source

pub fn clear(&mut self)

Clear all entries from the spatial index

Source

pub fn query_rect(&self, bounds: &Rect) -> Vec<NodeId>

Query nodes within a rectangular area

Source

pub fn query_viewport(&self, viewport: &Viewport) -> Vec<NodeId>

Query nodes within a viewport

Source

pub fn query_radius(&self, center: Position, radius: f64) -> Vec<NodeId>

Query nodes within a circular area

Source

pub fn nearest(&self, point: Position) -> Option<NodeId>

Find the nearest node to a given point

Source

pub fn node_ids(&self) -> Vec<NodeId>

Get all node IDs in the index

Source

pub fn len(&self) -> usize

Get the number of nodes in the index

Source

pub fn is_empty(&self) -> bool

Check if the index is empty

Source

pub fn bulk_load<T>(&mut self, nodes: &[Node<T>]) -> Result<()>
where T: Clone,

Bulk load multiple nodes into the index

Source

pub fn bounds(&self) -> Option<Rect>

Get the bounding rectangle of all nodes in the index

Source

pub fn cell_size(&self) -> f64

Get the cell size of the spatial index

Source

pub fn get_grid_cells_for_bounds(&self, bounds: &Rect) -> Vec<GridCell>

Get grid cells that a bounds rectangle intersects

Trait Implementations§

Source§

impl Default for SpatialIndex

Source§

fn default() -> Self

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

Auto Trait Implementations§

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.