pub fn insert_vertex_on_edge<T: CoordsFloat>(
cmap: &CMap2<T>,
trans: &mut Transaction,
edge_id: EdgeIdType,
new_darts: (DartIdType, DartIdType),
midpoint_vertex: Option<T>,
) -> TransactionClosureResult<(), VertexInsertionError>
Expand description
Insert a vertex in an edge, cutting it into two segments.
This implementation is 2D specific.
§Arguments
cmap: &mut CMap2<T>
– Reference to the modified map.trans: &mut Transaction
– Associated transaction.edge_id: EdgeIdentifier
– Target edge.new_darts: (DartIdentifier, DartIdentifier)
– Dart IDs used to build the new vertex/segments.midpoint_vertex: Option<T>
– Relative position of the new vertex, starting from the vertex of the dart sharingedge_id
as its identifier.
§Dart IDs Requirements & Usage
Because of the dimension, the number of dart needed to perform this operation is at most two. These are the requirements for these two darts:
- identifiers are passed as a tuple.
- the first dart of the tuple will always be used if the operation is successful.
- the second dart of the tuple will only be used if the original edge is made of two darts;
if that is not the case, the second dart ID can be
NULL_DART_ID
. - both of these darts should be free
§Errors
This function will abort and raise an error if:
- the transaction cannot be completed,
- a hypothesis over input isn’t verified (see
VertexInsertionError
), - an internal operation failed.
The returned error can be used in conjunction with transaction control to avoid any
modifications in case of failure at attribute level. The user can then choose to retry or
abort as he wishes using Transaction::with_control_and_err
.