fix(jump-to-contour-segment): For contours like those from RSTRUCTs, use generic jumpToSegmentCenter if a segment center is available. (#5785)

This commit is contained in:
Joe Boccanfuso 2026-02-05 16:57:15 -05:00 committed by GitHub
parent 54ff608605
commit 45739b31a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1368,8 +1368,11 @@ class SegmentationService extends PubSubService {
const representation = representations[0]; const representation = representations[0];
const { type } = representation; const { type } = representation;
// For labelmaps, use the existing jumpToSegmentCenter method // For contours, check if we have a segment center.
if (type !== CONTOUR) { const center =
type === CONTOUR ? this._getSegmentCenter(segmentationId, segmentIndex) : undefined;
const canUseSegmentCenter = type !== CONTOUR || !!center;
if (canUseSegmentCenter) {
this.jumpToSegmentCenter( this.jumpToSegmentCenter(
segmentationId, segmentationId,
segmentIndex, segmentIndex,
@ -1378,7 +1381,8 @@ class SegmentationService extends PubSubService {
highlightSegment, highlightSegment,
animationLength, animationLength,
highlightHideOthers, highlightHideOthers,
animationFunctionType animationFunctionType,
center
); );
return; return;
} }
@ -1398,7 +1402,7 @@ class SegmentationService extends PubSubService {
let nearestSliceIndex = null; let nearestSliceIndex = null;
let loopSliceIndex = null; let loopSliceIndex = null;
for (const [sliceIndex, viewRef] of viewRefs.entries()) { for (const [sliceIndex] of viewRefs.entries()) {
// Track loop index for wraparound (smallest for forward, largest for backward) // Track loop index for wraparound (smallest for forward, largest for backward)
if (direction > 0) { if (direction > 0) {
if (loopSliceIndex === null || sliceIndex < loopSliceIndex) { if (loopSliceIndex === null || sliceIndex < loopSliceIndex) {
@ -1452,15 +1456,16 @@ class SegmentationService extends PubSubService {
highlightSegment = true, highlightSegment = true,
animationLength = 750, animationLength = 750,
highlightHideOthers = false, highlightHideOthers = false,
animationFunctionType: EasingFunctionEnum = EasingFunctionEnum.EASE_IN_OUT animationFunctionType: EasingFunctionEnum = EasingFunctionEnum.EASE_IN_OUT,
center?: { image?: csTypes.Point3; world: csTypes.Point3 }
): void { ): void {
const center = this._getSegmentCenter(segmentationId, segmentIndex); const resolvedCenter = center ?? this._getSegmentCenter(segmentationId, segmentIndex);
if (!center) { if (!resolvedCenter) {
console.warn('No center found for segmentation', segmentationId, segmentIndex); console.warn('No center found for segmentation', segmentationId, segmentIndex);
return; return;
} }
const { world } = center as { world: csTypes.Point3 }; const { world } = resolvedCenter as { world: csTypes.Point3 };
// need to find which viewports are displaying the segmentation // need to find which viewports are displaying the segmentation
const viewportIds = viewportId const viewportIds = viewportId