Skip to content

Commit

Permalink
fix(splines): add auto removing when outside image for SplineROITool …
Browse files Browse the repository at this point in the history
…series (#1021)

Co-authored-by: Dongsheng Zhao <[email protected]>
  • Loading branch information
Blackman99 and Dongsheng Zhao authored Jan 22, 2024
1 parent b48d4bc commit 6f24dd3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/tools/src/tools/annotation/SplineROITool.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { utilities } from '@cornerstonejs/core';
import {
getEnabledElement,
eventTarget,
triggerEvent,
utilities,
} from '@cornerstonejs/core';
import type { Types } from '@cornerstonejs/core';
import { vec3 } from 'gl-matrix';
Expand Down Expand Up @@ -305,6 +305,16 @@ class SplineROITool extends ContourSegmentationBaseTool {
const enabledElement = getEnabledElement(element);
const { renderingEngine } = enabledElement;

// Decide whether there's at least one point is outside image
const image = this.getTargetIdImage(
this.getTargetId(enabledElement.viewport),
enabledElement.renderingEngine
);
const { imageData, dimensions } = image;
this.isHandleOutsideImage = data.handles.points
.map((p) => utilities.transformWorldToIndex(imageData, p))
.some((index) => !utilities.indexWithinDimensions(index, dimensions));

if (
this.isHandleOutsideImage &&
this.configuration.preventHandleOutsideImage
Expand Down

0 comments on commit 6f24dd3

Please sign in to comment.