All files / tools/src/stateManagement/segmentation/utilities removeCompleteContourAnnotation.ts

0% Statements 0/6
0% Branches 0/4
0% Functions 0/1
0% Lines 0/6

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 25 26 27 28                                                       
import type { ContourSegmentationAnnotation } from '../../../types';
import { removeContourSegmentationAnnotation } from '../../../utilities/contourSegmentation';
import {
  clearParentAnnotation,
  removeAnnotation,
} from '../../annotation/annotationState';
 
/**
 * Completely removes a contour segmentation annotation and cleans up all references.
 * This function handles both the annotation state removal and the segmentation data cleanup,
 * including removing parent-child relationships if they exist.
 *
 * @param annotation - The contour segmentation annotation to remove
 */
export function removeCompleteContourAnnotation(
  annotation: ContourSegmentationAnnotation
) {
  if (!annotation) {
    return;
  }
  // deleting reference of the child in the parent annotation
  if (annotation.parentAnnotationUID) {
    clearParentAnnotation(annotation);
  }
  removeAnnotation(annotation.annotationUID);
  removeContourSegmentationAnnotation(annotation);
}