PathSampler

Struct PathSampler 

Source
pub struct PathSampler<'l, PS, AS> { /* private fields */ }
Expand description

Performs fast sample queries on a path with cached measurements.

This object contains the mutable state necessary for speeding up the queries, this allows the path measurements to be immutable and accessible concurrently from multiple threads if needed.

Reusing a sampler over multiple queries saves a memory allocation if there are custom attributes, And speeds up queries if they are sequentially ordered along the path.

Implementations§

Source§

impl<'l, PS: PositionStore, AS: AttributeStore> PathSampler<'l, PS, AS>

Source

pub fn new( measurements: &'l PathMeasurements, positions: &'l PS, attributes: &'l AS, sample_type: SampleType, ) -> Self

Create a sampler.

The provided positions must be the ones used when initializing the path measurements.

Source

pub fn sample(&mut self, dist: f32) -> PathSample<'_>

Sample at a given distance along the path.

If the path is empty, the produced sample will contain NaNs.

Source

pub fn split_range(&mut self, range: Range<f32>, output: &mut dyn PathBuilder)

Construct a path for a specific sub-range of the measured path.

The path measurements must have been initialized with the same path. The distance is clamped to the beginning and end of the path. Panics if the path is empty.

Source

pub fn length(&self) -> f32

Returns the approximate length of the path.

Auto Trait Implementations§

§

impl<'l, PS, AS> Freeze for PathSampler<'l, PS, AS>

§

impl<'l, PS, AS> RefUnwindSafe for PathSampler<'l, PS, AS>

§

impl<'l, PS, AS> Send for PathSampler<'l, PS, AS>
where PS: Sync, AS: Sync,

§

impl<'l, PS, AS> Sync for PathSampler<'l, PS, AS>
where PS: Sync, AS: Sync,

§

impl<'l, PS, AS> Unpin for PathSampler<'l, PS, AS>

§

impl<'l, PS, AS> UnwindSafe for PathSampler<'l, PS, AS>

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.