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
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,14 @@ class CircleROIStartEndThresholdTool extends CircleROITool {
// if it is inside the start/end slice, but not exactly the first or
// last slice, we render the line in dash, but not the handles

let isMiddleSlice = false;
if (roundedCameraCoordinate === middleCoordinate) {
isMiddleSlice = true;
let isNearMiddleSlice = false;
const targetId = this.getTargetId(viewport);
const imageVolume = cache.getVolume(targetId.split(/volumeId:|\?/)[1]);
if (
Math.abs(roundedCameraCoordinate - middleCoordinate) <
csUtils.getSpacingInNormalDirection(imageVolume, viewplaneNormal)
) {
Comment on lines +429 to +435

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Use the annotation’s stored spacing here instead of reloading the viewport volume.

This render-path lookup can now throw if the volume was decached, and it can also pick the wrong spacing after a viewport target switch. spacingInNormal is already persisted on the annotation metadata, so use that instead of cache.getVolume(...) here.

Proposed fix
-      let isNearMiddleSlice = false;
-      const targetId = this.getTargetId(viewport);
-      const imageVolume = cache.getVolume(targetId.split(/volumeId:|\?/)[1]);
-      if (
-        Math.abs(roundedCameraCoordinate - middleCoordinate) <
-        csUtils.getSpacingInNormalDirection(imageVolume, viewplaneNormal)
-      ) {
-        isNearMiddleSlice = true;
-      }
+      const isNearMiddleSlice =
+        Math.abs(roundedCameraCoordinate - middleCoordinate) <
+        metadata.spacingInNormal;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let isNearMiddleSlice = false;
const targetId = this.getTargetId(viewport);
const imageVolume = cache.getVolume(targetId.split(/volumeId:|\?/)[1]);
if (
Math.abs(roundedCameraCoordinate - middleCoordinate) <
csUtils.getSpacingInNormalDirection(imageVolume, viewplaneNormal)
) {
const isNearMiddleSlice =
Math.abs(roundedCameraCoordinate - middleCoordinate) <
metadata.spacingInNormal;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/tools/src/tools/segmentation/CircleROIStartEndThresholdTool.ts`
around lines 429 - 435, The middle-slice spacing check in
CircleROIStartEndThresholdTool should use the annotation’s persisted spacing
instead of reloading the volume from cache. Remove the cache.getVolume lookup
based on getTargetId(viewport), and read spacingInNormal from the annotation
metadata already attached to the ROI state. Update the Math.abs(...) comparison
in the render-path logic to pass that stored spacing into the threshold check so
it remains stable after decaching or viewport target switches.

isNearMiddleSlice = true;
}

data.handles.points[0][
Expand Down Expand Up @@ -467,7 +472,7 @@ class CircleROIStartEndThresholdTool extends CircleROITool {
!isAnnotationLocked(annotationUID) &&
!this.editData &&
activeHandleIndex !== null &&
isMiddleSlice
isNearMiddleSlice
) {
if (this.configuration.simplified) {
activeHandleCanvasCoords = [canvasCoordinates[activeHandleIndex]];
Expand All @@ -493,7 +498,7 @@ class CircleROIStartEndThresholdTool extends CircleROITool {
let lineWidthToUse = lineWidth;
let lineDashToUse = lineDash;

if (isMiddleSlice) {
if (isNearMiddleSlice) {
lineWidthToUse = lineWidth;
lineDashToUse = []; // Use solid line for real line
} else {
Expand Down
Loading