@acransac/vtk.js
Version:
Visualization Toolkit for the Web
49 lines (44 loc) • 1.4 kB
JavaScript
// ----------------------------------------------------------------------------
// Marching squares case functions (using lines to generate the 2D tessellation).
// For each case, a list of edge ids that form the triangles. A -1 marks the
// end of the list of edges. Edges are taken three at a time to generate
// triangle points.
// ----------------------------------------------------------------------------
const MARCHING_SQUARES_CASES = [
[-1, -1, -1, -1, -1] /* 0 */,
[] /* 1 */,
[] /* 2 */,
[] /* 3 */,
[] /* 4 */,
[] /* 5 */,
[] /* 6 */,
[] /* 7 */,
[] /* 8 */,
[] /* 9 */,
[] /* 10 */,
[] /* 11 */,
[] /* 12 */,
[] /* 13 */,
[] /* 14 */,
[-1, -1, -1, -1, -1] /* 15 */,
];
const EDGES = [
[],
[],
[],
[],
];
function getCase(index) {
return MARCHING_SQUARES_CASES[index];
}
// Define the four edges of the pixel by the following pairs of vertices
function getEdge(eid) {
return EDGES[eid];
}
// ----------------------------------------------------------------------------
// Static API
// ----------------------------------------------------------------------------
export default {
getCase,
getEdge,
};