Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | 78x 78x 78x 78x 78x 76x 75x 75x 75x 75x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 78x 2x 2x 2x 2x 2x | import { CellType } from 'vtk.js/Sources/Common/DataModel/CellTypes/Constants'; import vtkOBJReader from 'vtk.js/Sources/IO/Misc/OBJReader'; /** * Get the correct point ID from a cell id * @param {Array} cellPtsIds * @param {CellType} type * @param {Number} idx * @returns {Object} Contains three point's id of cells as 'ptId0', 'ptId1', 'ptId2' */ export function getCellTriangles(cellPtsIds, type, idx) { let ptId0 = -1; let ptId1 = -1; let ptId2 = -1; const cellListLength = cellPtsIds.length; switch (type) { case CellType.VTK_TRIANGLE: case CellType.VTK_POLYGON: case CellType.VTK_QUAD: { if (idx > cellListLength) break; ptId0 = cellPtsIds[0]; ptId1 = cellPtsIds[idx + 1]; ptId2 = cellPtsIds[idx + 2]; break; } case CellType.VTK_TRIANGLE_STRIP: { // eslint-disable-next-line no-bitwise const idx1 = idx + 1 + (idx & 1); // eslint-disable-next-line no-bitwise const idx2 = idx + 2 - (idx & 1); Iif (idx1 > cellListLength || idx2 > cellListLength) break; ptId0 = cellPtsIds[idx]; ptId1 = cellPtsIds[idx1]; ptId2 = cellPtsIds[idx2]; break; } default: ptId0 = -1; ptId1 = -1; ptId2 = -1; break; } return { ptId0, ptId1, ptId2 }; } /** * Concatenate second typed array to the first typed array. * @param {TypedArray} first * @param {TypedArray} second Must be of the same type as first * @return {TypedArray} */ export function pushArray(first, second) { const firstLength = first.length; const result = new first.constructor(firstLength + second.length); result.set(first); result.set(second, firstLength); return result; } /** * Load an obj with point's colors * * @param {string} url path to the OBJ file * @return Promise * ---> success : Return vtkPolyData * ---> failed : Error message */ export function loadOBJ(url) { return new Promise((resolve, reject) => { const reader = vtkOBJReader.newInstance(); reader.setUrl(url).then( () => { const data = reader.getOutputData(); resolve(data); }, () => { // eslint-disable-next-line prefer-promise-reject-errors reject('Error when loading ', url); } ); }); } |