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
impl Arrangement
Sourcepub fn from_polygon(corners: &[Point2]) -> Result<Self, BuildError>
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
Source§impl Arrangement
impl Arrangement
Sourcepub fn add_vertex(&mut self, position: Point2) -> VertexId
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.
Sourcepub fn split_edge(
&mut self,
edge: HalfEdgeId,
at: Point2,
) -> Result<VertexId, EditError>
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.
Sourcepub fn drag_vertex(
&mut self,
vertex: VertexId,
to: Point2,
) -> Result<(), EditError>
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
impl Arrangement
Sourcepub fn face_halfedges(&self, face: FaceId) -> Vec<HalfEdgeId>
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).
Sourcepub fn face_outline(&self, face: FaceId) -> Vec<Point2> ⓘ
pub fn face_outline(&self, face: FaceId) -> Vec<Point2> ⓘ
Corner positions of a face, counter-clockwise.
Sourcepub fn face_area(&self, face: FaceId) -> f64
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.
Sourcepub fn neighbour_across(&self, edge: HalfEdgeId) -> FaceId
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.
Sourcepub fn bounded_faces(&self) -> impl Iterator<Item = FaceId> + '_
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.
Sourcepub fn vertex_halfedges(&self, vertex: VertexId) -> Vec<HalfEdgeId>
pub fn vertex_halfedges(&self, vertex: VertexId) -> Vec<HalfEdgeId>
Half-edges leaving a vertex, counter-clockwise around it.
Sourcepub fn halfedge_origin(&self, edge: HalfEdgeId) -> VertexId
pub fn halfedge_origin(&self, edge: HalfEdgeId) -> VertexId
Vertex a half-edge leaves from.
Sourcepub fn halfedge_face(&self, edge: HalfEdgeId) -> FaceId
pub fn halfedge_face(&self, edge: HalfEdgeId) -> FaceId
Face lying to the left of a half-edge.
Source§impl Arrangement
impl Arrangement
Sourcepub fn audit(&self) -> ArrangementHealth
pub fn audit(&self) -> ArrangementHealth
Check every structural invariant.
Source§impl Arrangement
impl Arrangement
Sourcepub const fn outer_face(&self) -> FaceId
pub const fn outer_face(&self) -> FaceId
The unbounded region surrounding every bounded face.
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Number of vertices, including any left isolated by edits.
Sourcepub fn face_count(&self) -> usize
pub fn face_count(&self) -> usize
Number of faces, including the unbounded one.
Sourcepub fn halfedge_count(&self) -> usize
pub fn halfedge_count(&self) -> usize
Number of half-edges; always twice the number of edges.
Trait Implementations§
Source§impl Clone for Arrangement
impl Clone for Arrangement
Source§fn clone(&self) -> Arrangement
fn clone(&self) -> Arrangement
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more