pub fn split_edge_noalloc<T: CoordsFloat>(
cmap: &mut CMap2<T>,
edge_id: EdgeIdType,
new_darts: (DartIdType, DartIdType),
midpoint_vertex: Option<T>,
) -> Result<(), SplitEdgeError>
Expand description
Split an edge into two segments.
This implementation is 2D specific.
This method is a variant of split_edge
where inline dart allocations are removed. The
aim of this variant is to enhance performance by enabling the user to pre-allocate a number
of darts.
The method follows the same logic as the regular split_edge
, the only difference being
that the new darts won’t be added to the map on the fly. Instead, the method uses the two
darts passed as argument (new_darts
) to build the new segments. Consequently, there is no
guarantee that IDs will be consistent between this and the regular method.
§Arguments
cmap: &mut CMap2<T>
– Reference to the modified map.edge_id: EdgeIdentifier
– Edge to split in two.new_darts: (DartIdentifier, DartIdentifier)
– Dart IDs used to build the new 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
§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 and in requirements mentionned above.