Function forsyth::order_triangles_inplace [−][src]
pub fn order_triangles_inplace<Index>(
config: Config,
indices: &mut [Index],
vertex_cache_size: u16
) -> Result<&[Index], Error> where
Index: TryInto<usize> + Default + PartialEq + Copy,
Expand description
Orders a slice of triangle indices in place.
The configuration in config
can be used to tweak the algorithm’s parameters.
No checks for sanity and/or validity of the provided values is done.
The slice indices
is assumed to contain the index triples making
up the triangles to be ordered.
vertex_cache_size
controls the size of the simulated LRU cache that
is used to drive the optimization. A size often used is 32.
Smaller cache sizes result in faster but worse ordering, whereas larger size
increase hit rates at the cost of runtime.
This size-performance-relationship may be sub-linear
Cache size is clamped internally to implementation-specific ranges.
Returns a reference to indices
use forsyth::{Config, order_triangles_inplace};
let mut indices = [0_u16, 1, 2, 3, 2, 0, 0, 1, 3, 0, 1, 4, 0, 1, 5];
assert!(
order_triangles_inplace(Config::default(), &mut indices, 32) ==
Ok(&[0_u16, 1, 4, 0, 1, 5, 0, 1, 2, 3, 2, 0, 0, 1, 3])
);