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
impl VertexSequence
pub fn new() -> Self
pub fn size(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn add(&mut self, val: VertexDist)
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.
Sourcepub fn modify_last(&mut self, val: VertexDist)
pub fn modify_last(&mut self, val: VertexDist)
Modify the last vertex.
Sourcepub fn close(&mut self, closed: bool)
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.
pub fn remove_all(&mut self)
pub fn clear(&mut self)
Sourcepub fn remove_last(&mut self)
pub fn remove_last(&mut self)
Remove the last vertex.
Port of C++ pod_bvector::remove_last.
Sourcepub fn prev(&self, idx: usize) -> &VertexDist
pub fn prev(&self, idx: usize) -> &VertexDist
Get the previous vertex (wrapping index).
Port of C++ pod_bvector::prev.
Sourcepub fn curr(&self, idx: usize) -> &VertexDist
pub fn curr(&self, idx: usize) -> &VertexDist
Get the current vertex.
Port of C++ pod_bvector::curr.
Sourcepub fn next(&self, idx: usize) -> &VertexDist
pub fn next(&self, idx: usize) -> &VertexDist
Get the next vertex (wrapping index).
Port of C++ pod_bvector::next.
Sourcepub fn as_slice(&self) -> &[VertexDist]
pub fn as_slice(&self) -> &[VertexDist]
Get a reference to the underlying vertex slice.
Sourcepub fn as_mut_slice(&mut self) -> &mut [VertexDist]
pub fn as_mut_slice(&mut self) -> &mut [VertexDist]
Get a mutable reference to the underlying vertex slice.