Struct Arrangement

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

A planar subdivision as a doubly-connected edge list.

Handles stay valid across edits unless the element they name is removed, which is what makes incremental editing possible at all.

Implementations§

Source§

impl Arrangement

Source

pub fn from_polygon(corners: &[Point2]) -> Result<Self, BuildError>

Build a single bounded face from a closed polygon.

Corners are taken counter-clockwise; a clockwise ring is reversed so the bounded face is the one inside it. Silently accepting either winding is the right call here because “which side is inside” is unambiguous for a simple closed ring, and forcing callers to normalise first only moves the same code outward.

§Errors

BuildError::DegenerateBoundary or BuildError::ZeroArea.

Source§

impl Arrangement

Source

pub fn add_vertex(&mut self, position: Point2) -> VertexId

Add an isolated vertex.

Legal on its own: a vertex with no edges is a valid, if uninteresting, arrangement element, and building incrementally needs it.

Source

pub fn split_edge( &mut self, edge: HalfEdgeId, at: Point2, ) -> Result<VertexId, EditError>

Split an edge at at, inserting a new vertex.

The point must lie on the segment. Both the edge and its twin are split, so the structure stays consistent.

§Errors

EditError::PointNotOnEdge if at is not collinear with the edge or lies outside it.

Source

pub fn drag_vertex( &mut self, vertex: VertexId, to: Point2, ) -> Result<(), EditError>

Move a vertex, refusing the move if it would break a face.

§Errors

EditError::WouldSelfIntersect if any incident face would stop being simple. The arrangement is left unchanged in that case.

Source§

impl Arrangement

Source

pub fn face_halfedges(&self, face: FaceId) -> Vec<HalfEdgeId>

Half-edges around a face’s boundary, counter-clockwise.

Returns empty for a face with no boundary (the unbounded face of an empty arrangement).

Source

pub fn face_outline(&self, face: FaceId) -> Vec<Point2> ⓘ

Corner positions of a face, counter-clockwise.

Source

pub fn face_area(&self, face: FaceId) -> f64

Signed area of a face, positive when its boundary runs counter-clockwise.

The unbounded face has no meaningful area; it reports 0.0 rather than a negative number that a caller might sum into a total.

Source

pub fn neighbour_across(&self, edge: HalfEdgeId) -> FaceId

The face on the other side of a half-edge.

Always defined: the unbounded face is a real face, so an edge on the outer boundary reports it rather than None.

Source

pub fn bounded_faces(&self) -> impl Iterator<Item = FaceId> + '_

Every bounded face, in arena order.

Deliberately excludes the unbounded face: a caller asking for “the regions” almost never means the infinite one, and including it is the kind of default that produces a wrong total on the first use.

Source

pub fn vertex_halfedges(&self, vertex: VertexId) -> Vec<HalfEdgeId>

Half-edges leaving a vertex, counter-clockwise around it.

Source

pub fn degree(&self, vertex: VertexId) -> usize

Number of edges meeting at a vertex.

Source

pub fn halfedge_origin(&self, edge: HalfEdgeId) -> VertexId

Vertex a half-edge leaves from.

Source

pub fn halfedge_face(&self, edge: HalfEdgeId) -> FaceId

Face lying to the left of a half-edge.

Source§

impl Arrangement

Source

pub fn audit(&self) -> ArrangementHealth

Check every structural invariant.

Source§

impl Arrangement

Source

pub fn new() -> Self

An empty plane: one unbounded face, no vertices or edges.

Source

pub const fn outer_face(&self) -> FaceId

The unbounded region surrounding every bounded face.

Source

pub fn vertex_count(&self) -> usize

Number of vertices, including any left isolated by edits.

Source

pub fn face_count(&self) -> usize

Number of faces, including the unbounded one.

Source

pub fn halfedge_count(&self) -> usize

Number of half-edges; always twice the number of edges.

Source

pub fn position(&self, vertex: VertexId) -> Point2

Position of a vertex.

Trait Implementations§

Source§

impl Clone for Arrangement

Source§

fn clone(&self) -> Arrangement

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Arrangement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Arrangement

Source§

fn default() -> Self

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.