Skip to main content

Overlaps2D

Trait Overlaps2D 

Source
pub trait Overlaps2D {
    // Required method
    fn overlaps_box(&self, bx: Box2D) -> bool;

    // Provided method
    fn contains_box(&self, _bx: Box2D) -> bool { ... }
}
Expand description

Geometry that can be tested for overlap with 2D boxes.

Implement this trait to enable generic 2D region queries through Index2D::search and Index2D::visit.

§Example

use packed_spatial_index::{Box2D, Triangle2D, Overlaps2D, Index2DBuilder};

let mut b = Index2DBuilder::new(1);
b.add(Box2D::new(0.0, 0.0, 1.0, 1.0));
let index = b.finish().unwrap();

// Works with any geometry implementing Overlaps2D.
let tri = Triangle2D::new([0.0, 0.0], [2.0, 0.0], [0.0, 2.0]);
assert_eq!(index.search(&tri), vec![0]);

Required Methods§

Source

fn overlaps_box(&self, bx: Box2D) -> bool

Return true when this query geometry accepts or overlaps bx.

Built-in 2D region types use exact overlap predicates.

Provided Methods§

Source

fn contains_box(&self, _bx: Box2D) -> bool

Whether the box bx lies entirely inside this geometry.

Used to accept whole subtrees without per-item tests. Default is false (no containment optimization).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: Overlaps2D + ?Sized> Overlaps2D for &T

Source§

fn overlaps_box(&self, bx: Box2D) -> bool

Source§

fn contains_box(&self, bx: Box2D) -> bool

Implementors§