pub fn splitn_edge_no_alloc<T: CoordsFloat>(
cmap: &mut CMap2<T>,
edge_id: EdgeIdType,
new_darts: &[DartIdType],
midpoint_vertices: &[T],
) -> Result<(), SplitEdgeError>
Expand description
Split an edge into n
segments.
This implementation is 2D specific.
This method is a variant of splitn_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 splitn_edge
, the only difference being
that the new darts won’t be added to the map on the fly. Instead, the method uses 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]
– Dart IDs used to build the new segments.midpoint_vertices: &[T]
– Relative positions of new vertices, starting from the vertex of the dart sharingedge_id
as its identifier.
§Dart IDs Requirements & Usage
Because of the dimension, we can easily compute the number of dart needed to perform this operation. These are the requirements for the darts:
- identifiers are passed as a slice:
- slice length should verify
new_darts.len() == 2 * midpoint_vertices.len()
- slice length should verify
- the first half of the slice will always be used if the operation is successful.
- the second half of the slice will only be used if the original edge is made of two darts;
if that is not the case, the second half IDs can all be
NULL_DART_ID
s. - all 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.