Struct crater::kdtree::QueryOptions

source ·
pub struct QueryOptions<'a, R: KdRegion> {
    pub inner_bound: QueryBound<'a, R>,
    pub outer_bound: QueryBound<'a, R>,
    pub keep_ties: bool,
}
Expand description

Fine grained control over a query within the tree (KdTree::k_closest).

Fields§

§inner_bound: QueryBound<'a, R>

Points within this bound will be EXCLUDED from the query result. Points ON the inner boundary will also be EXCLUDED (ie the excluded region is a closed set). Useful to exclude points that are “too close” to the query point, for example when iteratively increasing a sampling radius in a shortest path algorithm or some other situation where the number of k_closest points needed is not know a prior. For QueryBound::SqDist(d), this means points whose sqdist from the query point is <= d will be excluded. Since the query point itself is included by default if it is in the tree, passing QueryBound::SqDist(Distance::zero()) here can be used to exclude it. For QueryBound::Region(&r), this means points within r (where r.min_sqdist is Distance::zero()) will excluded. NB this cannot be conservative like an unbounded search. That is, if R::min_sqdist can be an underestimate, then QueryBound::Region should not be used. For QueryBound::None, no points will be excluded for being “too close” to the query point.

§outer_bound: QueryBound<'a, R>

Points outside this bound will be EXCLUDED from the query result. Points ON the outer boundary will be INCLUDED (ie the excluded region is an open set). This makes the overall included region a half open set, excluding the inner bound but including the outer bound. This is to make it easy to have successive queries cover additional area without duplicate results. For QueryBound::SqDist(d), points whose sqdist from the query point is > d will be excluded. For QueryBount::Region(&r), points outside r (where r.min_sqdist is not Distance::zero()) will be excluded. Unlike the inner bound, this will work correctly with a conservative R::min_sqdist (ie if min_sqdist is an underestimate it can only cause the result to include extra points, not miss points that should be included). For QueryBound::None, no points will be excluded for being “too far” from the query point.

§keep_ties: bool

If false, if multiple points are tied for being the kth closest, which one will be returned is arbitrary, but exactly k points will be returned. If true, if multiple points are tied for being the kth closest, all of them will be returned, and more than k points will be returned in this case. Setting this to true is necessary to correctly call KdTree::k_closest with an iteratively increasing sampling radius.

Implementations§

source§

impl<'a, R: KdRegion> QueryOptions<'a, R>

source

pub const ALL_KEEP_TIES: Self = _

Default QueryOptions to have the included region be the entire tree, and return all points which are tied for being the kth-closest

source

pub const ALL_NO_TIES: Self = _

Default QueryOptions to have the included region be the entire tree, and arbitrarily break ties for the kth-closest point so no more than k points are ever returned.

source

pub fn contains(&self, point: &R::Point, pt: &R::Point) -> bool

Returns true if the included region contains the point pt, where point is the center of the query, or false if pt is in the excluded region.

source

pub fn might_overlap( &self, point: &R::Point, max_sqdist: Option<&<R::Point as KdPoint>::Distance>, bounds: &R ) -> bool

Returns true if the included region might overlap with bounds and might contain additional points within max_sqdist of the center of the query, point. When some of the required functions of <R as KdRegion> are implemented conservatively, this function will return true in cases where the query region and bounds can’t actually contain any additional points in the result set. However, when this function returns false, the query region will always be disjoint from bounds, UNLESS self.inner_bound is not QueryBound::None and a conservative implementation is used for KdRegion.

Auto Trait Implementations§

§

impl<'a, R> RefUnwindSafe for QueryOptions<'a, R>

§

impl<'a, R> Send for QueryOptions<'a, R>
where R: Sync, <<R as KdRegion>::Point as KdPoint>::Distance: Send,

§

impl<'a, R> Sync for QueryOptions<'a, R>
where R: Sync, <<R as KdRegion>::Point as KdPoint>::Distance: Sync,

§

impl<'a, R> Unpin for QueryOptions<'a, R>
where <<R as KdRegion>::Point as KdPoint>::Distance: Unpin,

§

impl<'a, R> UnwindSafe for QueryOptions<'a, R>

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>,

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V