Skip to main content

VertexSequence

Struct VertexSequence 

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

A sequence of vertices that automatically filters coincident points.

Port of C++ vertex_sequence<T> which inherits from pod_bvector. When a new vertex is added, it calculates the distance from the previous vertex. If the previous vertex is coincident (distance <= epsilon), it is removed.

This is the Rust equivalent using Vec<VertexDist> as backing storage.

Implementations§

Source§

impl VertexSequence

Source

pub fn new() -> Self

Source

pub fn size(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn add(&mut self, val: VertexDist)

Add a vertex to the sequence, removing the previous vertex if it’s coincident with the one before it.

The C++ version checks if vertices[size-2] is coincident with vertices[size-1], and if so removes vertices[size-1]. This is a “lazy” check — coincident pairs are cleaned up when the NEXT vertex is added.

Source

pub fn modify_last(&mut self, val: VertexDist)

Modify the last vertex.

Source

pub fn close(&mut self, closed: bool)

Close the sequence, removing trailing coincident vertices. If closed is true, also removes the last vertex if it’s coincident with the first.

Source

pub fn remove_all(&mut self)

Source

pub fn clear(&mut self)

Source

pub fn remove_last(&mut self)

Remove the last vertex. Port of C++ pod_bvector::remove_last.

Source

pub fn prev(&self, idx: usize) -> &VertexDist

Get the previous vertex (wrapping index). Port of C++ pod_bvector::prev.

Source

pub fn curr(&self, idx: usize) -> &VertexDist

Get the current vertex. Port of C++ pod_bvector::curr.

Source

pub fn next(&self, idx: usize) -> &VertexDist

Get the next vertex (wrapping index). Port of C++ pod_bvector::next.

Source

pub fn as_slice(&self) -> &[VertexDist]

Get a reference to the underlying vertex slice.

Source

pub fn as_mut_slice(&mut self) -> &mut [VertexDist]

Get a mutable reference to the underlying vertex slice.

Trait Implementations§

Source§

impl Default for VertexSequence

Source§

fn default() -> Self

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

impl Index<usize> for VertexSequence

Source§

type Output = VertexDist

The returned type after indexing.
Source§

fn index(&self, i: usize) -> &VertexDist

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<usize> for VertexSequence

Source§

fn index_mut(&mut self, i: usize) -> &mut VertexDist

Performs the mutable indexing (container[index]) operation. 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.