honeycomb_kernels::triangulation

Function fan_cell

Source
pub fn fan_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 chosen vertex to all other vertices of the polygon, if such a vertex exist.

Note that this function will not have any effect if the polygon isn’t fannable.

§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 then attempts to find a vertex from which all other vertices can be seen (a star vertex), using the orientation properties of N-maps.
  • If such a star vertex is found, the function proceeds to create triangles by linking new darts in a fan-like structure from this vertex. Otherwise, the cell is left unchanged

§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])
  • The face contains one or more undefined vertices
  • The face isn’t starrable

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