Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/tools/src/tools/annotation/PlanarFreehandROITool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,10 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
return;
}

if (annotation.invalidated) {
const { data, invalidated } = annotation;
const cachedStats = data && data.cachedStats;

if (invalidated || !cachedStats?.[targetId]) {
this._calculateStatsIfActive(
annotation,
targetId,
Expand Down Expand Up @@ -906,6 +909,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
const { voxelManager } = viewport.getImageData();

const indexPoints = points.map((point) => imageData.worldToIndex(point));
const dims = imageData.getDimensions();

let iMin = Number.MAX_SAFE_INTEGER;
let iMax = Number.MIN_SAFE_INTEGER;
Expand All @@ -915,7 +919,12 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
let kMax = Number.MIN_SAFE_INTEGER;

for (let j = 0; j < points.length; j++) {
const worldPosIndex = indexPoints[j].map(Math.floor);
const worldPosIndex = indexPoints[j].map((v) => Math.floor(v + 1e-3));

worldPosIndex[0] = Math.max(0, Math.min(dims[0] - 1, worldPosIndex[0]));
worldPosIndex[1] = Math.max(0, Math.min(dims[1] - 1, worldPosIndex[1]));
worldPosIndex[2] = Math.max(0, Math.min(dims[2] - 1, worldPosIndex[2]));

iMin = Math.min(iMin, worldPosIndex[0]);
iMax = Math.max(iMax, worldPosIndex[0]);

Expand Down
Loading