Skip to main content

orient

Function orient 

Source
pub fn orient(tx: &mut Transaction<'_>) -> Result<OrientReport>
Expand description

Makes triangle winding consistent, reversing triangles by swapping their last two vertices.

  • Patches grow from the smallest unvisited triangle id across interior edges only (two triangles); boundary and non-manifold edges stop them. A neighbour that runs along the shared edge in the same direction gets the opposite parity.
  • A patch that reaches a triangle with both parities is non-orientable (a Möbius-like strip): it is counted and none of its triangles change.
  • Every orientable patch takes the winding of the larger area on its own, so patches meeting only at non-manifold edges are not aligned with each other. On a tie the winding of the patch’s smallest triangle id wins.
  • Then each closed component (no boundary and no non-manifold edge) whose signed volume, with the planned flips, is negative is reversed whole, so that it faces outward.

Triangles with a repeated vertex id are skipped: never flipped, never part of a patch. A consistent mesh is left without a write.

§Errors

OpsError::Store when memory runs out; nothing is written then.