pub fn split_edge<T: CoordsFloat>(
cmap: &mut CMap2<T>,
edge_id: EdgeIdType,
midpoint_vertex: Option<T>,
) -> Result<(), SplitEdgeError>
Expand description
Split an edge into two segments.
This implementation is 2D specific.
This method takes all darts of an edge and rebuild connections in order to create a new point on this edge. The position of the point defaults to the midway point, but it can optionally be specified.
In order to minimize editing of embedded data, the original darts are kept to their original vertices while the new darts are used to model the new point.
For an illustration of both principles, refer to the example.
§Arguments
cmap: &mut CMap2<T>
– Reference to the modified map.edge_id: EdgeIdentifier
– Edge to split in two.midpoint_vertex: Option<T>
– Relative position of the new vertex, starting from the vertex of the dart sharingedge_id
as its identifier.
§Return / Errors
This method will return:
Ok(())
if the operation is successful & the edge was splitErr(SplitEdgeError)
if the operation fails & the edge is left unchanged. Causes of failure are described inSplitEdgeError
’s documentation.
§Example
Given an edge made of darts 1
and 2
, these darts respectively encoding vertices
(0.0, 0.0)
and (2.0, 0.0)
, calling map.split_edge(1, Some(0.2))
would result in the
creation of two new darts, a new vertex (ID 3
) at position (0.4, 0.0)
and the following
topology:
+----1----> +-1-> +-3-> |
1 2 => 1 3 2 | + denote darts that encode vertex IDs
<----2----+ <-4-- <-2-+ |