honeycomb_kernels::triangulation

Function fan_convex_cell

Source
pub fn fan_convex_cell<T: CoordsFloat>(
    cmap: &mut CMap2<T>,
    face_id: FaceIdType,
    new_darts: &[DartIdType],
) -> Result<(), TriangulateError>
Expand description

Triangulates a face using a fan triangulation method.

This function triangulates a cell (face) in a 2D combinatorial map by creating a fan of triangles from a the first vertex of

Note that this function assumes the polygon is convex and correctly defined (i.e. all vertices are) and may fail or produce incorrect results if called on a cell that does not verify these requirements.

§Arguments

  • cmap: &mut CMap2 - A mutable reference to the modified CMap2.
  • face_id: FaceIdentifier - Identifier of the face to triangulate within the map.
  • new_darts: &[DartIdentifier] - Identifiers of pre-allocated darts for the new edges; the slice length should match the expected number of edges created by the triangulation. For an n-sided polygon, the number of created edge is n-3, so the number of dart is (n-3)*2.

§Behavior

  • The function begins by checking if the face has 3 or fewer vertices, in which case it’s already triangulated or cannot be further processed.
  • It verifies if the number of new darts matches the expected number for triangulation.
  • The function creates triangles by linking new darts in a fan-like structure to the first vertex of the polygon. This is done unconditionnally, whether the polygon is convex or not.

§Errors

This function will return an error if the face wasn’t triangulated. There can be multiple reason for this:

  • The face is incompatible with the operation (made of 1, 2 or 3 vertices)
  • The number of pre-allocated darts did not match the expected number (see [#arguments])

Note that in any of these cases, the face will remain the same as it was before the function call.