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 | import type { Types } from '@cornerstonejs/core';
/**
* Converts floating-point min/max index bounds to integer voxel indices.
*
* For planar annotations (delta ≤ 1), floating-point drift from world-to-index
* conversion can map to adjacent slices. Collapsing to a single rounded index
* keeps planar ROIs on the intended slice across viewport types.
*
* For bounds spanning multiple voxels (delta > 1), floor/ceil preserves coverage.
*/
function snapIndexBounds(min: number, max: number): Types.Point2 {
const delta = max - min;
if (delta <= 1) {
const index = Math.round((min + max) / 2);
return [index, index];
}
return [Math.floor(min), Math.ceil(max)];
}
export default snapIndexBounds;
|