pub fn polygonise(
grid_cell: GridCell,
isolevel: f32,
triangles: &mut [Triangle],
) -> i32Expand description
Polygonises a grid cell based on the given isolevel, populating the given
triangles slice with the resulting triangles.
§Parameters
grid_cell: AGridCellstruct representing the cell to be polygonised. It contains the positions of the cell’s vertices and their values.isolevel: A float value representing the isolevel to use when determining which parts of the cell are inside and outside the surface. The isolevel separates the grid cell into parts that are either inside or outside the surface being represented.triangles: A mutable slice ofTrianglestructs to be filled with the resulting triangles. The triangles are generated by triangulating the parts of the grid cell that are inside the surface.
§Returns
The number of triangles generated, as an i32.
§Example
use iso::{GridCell, Triangle, polygonise};
let grid_cell = GridCell {
positions: [
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[1.0, 1.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0],
[1.0, 0.0, 1.0],
[1.0, 1.0, 1.0],
[0.0, 1.0, 1.0]
],
value: [0.0, 0.5, 0.5, 1.0, 0.0, 1.0, 1.0, 0.0],
};
let mut triangles = vec![];
let isolevel = 0.5;
let result = polygonise(grid_cell, isolevel, &mut triangles);
assert_eq!(result, 4);