All files / packages/tools/src/utilities/contours/interpolation updateChildInterpolationUID.ts

37.5% Statements 3/8
50% Branches 1/2
100% Functions 1/1
37.5% Lines 3/8

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                      6x 6x 6x                    
import type { InterpolationROIAnnotation } from '../../../types/ToolSpecificAnnotationTypes';
import * as annotationState from '../../../stateManagement/annotation';
 
/**
 * Updates child annotation interpolation UIDs to be the parent interpolationUID
 * followed by `-{index}` where the index is the hole/child index.  This causes
 * child annotations to be matched positionally within the parent.
 */
export default function updateChildInterpolationUID(
  annotation: InterpolationROIAnnotation
) {
  const { parentAnnotationUID, annotationUID } = annotation;
  Eif (!parentAnnotationUID) {
    return annotation.interpolationUID;
  }
  const parentAnnotation = annotationState.state.getAnnotation(
    parentAnnotationUID
  ) as InterpolationROIAnnotation;
  const { interpolationUID } = parentAnnotation;
  const index = parentAnnotation.childAnnotationUIDs.indexOf(annotationUID);
  annotation.interpolationUID = `${interpolationUID}-${index}`;
  return annotation.interpolationUID;
}