All files / packages/tools/src/stateManagement/segmentation addSegmentations.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4

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                                  15x   15x 17x   17x          
import _cloneDeep from 'lodash.clonedeep';
import { SegmentationPublicInput } from '../../types/SegmentationStateTypes';
import { validateSegmentationInput } from './helpers';
import { addSegmentation as addSegmentationToState } from './segmentationState';
/**
 * Adds the segmentation to the cornerstone3D segmentation state. It should be
 * noted that segmentations are not added to any toolGroup's viewports. In order to
 * do so, you should add a "representation" of the segmentation to the toolGroup
 * using addSegmentationRepresentations helper. The reason for this is that there
 * can be multiple representations of the same segmentation (e.g. Labelmap and
 * Contour, etc. - Currently only Labelmap representations is supported).
 * @param segmentationInputArray - The array of segmentation input, each of which
 * defining the segmentationId and the main representation data for the segmentation.
 */
function addSegmentations(
  segmentationInputArray: SegmentationPublicInput[]
): void {
  validateSegmentationInput(segmentationInputArray);
 
  segmentationInputArray.map((segInput) => {
    const segmentationInput = _cloneDeep(segInput);
 
    addSegmentationToState(segmentationInput);
  });
}
 
export default addSegmentations;