@cornerstonejs/adapters 1.61.6 → 1.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41368,7 +41368,7 @@ class BaseVolumeViewport extends Viewport$1 {
41368
41368
  return;
41369
41369
  }
41370
41370
  const {
41371
- colormap,
41371
+ colormap: latestColormap,
41372
41372
  VOILUTFunction,
41373
41373
  interpolationType,
41374
41374
  invert,
@@ -41393,6 +41393,13 @@ class BaseVolumeViewport extends Viewport$1 {
41393
41393
  };
41394
41394
  }).filter(Boolean);
41395
41395
  const voiRange = voiRanges.length ? voiRanges[0].voiRange : null;
41396
+ const volumeColormap = this.getColormap(applicableVolumeActorInfo);
41397
+ let colormap;
41398
+ if (volumeId && volumeColormap) {
41399
+ colormap = volumeColormap;
41400
+ } else {
41401
+ colormap = latestColormap;
41402
+ }
41396
41403
  return {
41397
41404
  colormap: colormap,
41398
41405
  voiRange: voiRange,
@@ -41403,6 +41410,50 @@ class BaseVolumeViewport extends Viewport$1 {
41403
41410
  rotation: rotation
41404
41411
  };
41405
41412
  };
41413
+ this.getColormap = applicableVolumeActorInfo => {
41414
+ const {
41415
+ volumeActor
41416
+ } = applicableVolumeActorInfo;
41417
+ const cfun = volumeActor.getProperty().getRGBTransferFunction(0);
41418
+ const {
41419
+ nodes
41420
+ } = cfun.getState();
41421
+ const RGBPoints = nodes.reduce((acc, node) => {
41422
+ acc.push(node.x, node.r, node.g, node.b);
41423
+ return acc;
41424
+ }, []);
41425
+ const colormaps = vtkColorMaps.rgbPresetNames.map(presetName => vtkColorMaps.getPresetByName(presetName));
41426
+ const matchedColormap = colormaps.find(colormap => {
41427
+ const {
41428
+ RGBPoints: presetRGBPoints
41429
+ } = colormap;
41430
+ if (presetRGBPoints.length !== RGBPoints.length) {
41431
+ return false;
41432
+ }
41433
+ for (let i = 0; i < presetRGBPoints.length; i += 4) {
41434
+ if (!isEqual$2(presetRGBPoints.slice(i + 1, i + 4), RGBPoints.slice(i + 1, i + 4))) {
41435
+ return false;
41436
+ }
41437
+ }
41438
+ return true;
41439
+ });
41440
+ if (!matchedColormap) {
41441
+ return null;
41442
+ }
41443
+ const opacityPoints = volumeActor.getProperty().getScalarOpacity(0).getDataPointer();
41444
+ const opacity = [];
41445
+ for (let i = 0; i < opacityPoints.length; i += 2) {
41446
+ opacity.push({
41447
+ value: opacityPoints[i],
41448
+ opacity: opacityPoints[i + 1]
41449
+ });
41450
+ }
41451
+ const colormap = {
41452
+ name: matchedColormap.Name,
41453
+ opacity: opacity
41454
+ };
41455
+ return colormap;
41456
+ };
41406
41457
  this.getRotation = () => {
41407
41458
  const {
41408
41459
  viewUp: currentViewUp,
@@ -49690,17 +49741,19 @@ function getInterpolationData(viewportData, filterParams = []) {
49690
49741
  originalToolName
49691
49742
  } = annotation.metadata;
49692
49743
  const testToolName = originalToolName || toolName;
49693
- const annotations = getAnnotations(testToolName, viewport.element) || [];
49694
- const modifiedAnnotations = getAnnotations(DEFAULT_CONTOUR_SEG_TOOLNAME, viewport.element);
49695
- if (modifiedAnnotations?.length) {
49696
- modifiedAnnotations.forEach(annotation => {
49697
- const {
49698
- metadata
49699
- } = annotation;
49700
- if (metadata.originalToolName === testToolName && !annotations.find(it => it === annotation)) {
49701
- annotations.push(annotation);
49702
- }
49703
- });
49744
+ const annotations = (getAnnotations(testToolName, viewport.element) || []).filter(annotation => !annotation.metadata.originalToolName || annotation.metadata.originalToolName === testToolName);
49745
+ if (testToolName !== DEFAULT_CONTOUR_SEG_TOOLNAME) {
49746
+ const modifiedAnnotations = getAnnotations(DEFAULT_CONTOUR_SEG_TOOLNAME, viewport.element);
49747
+ if (modifiedAnnotations?.length) {
49748
+ modifiedAnnotations.forEach(annotation => {
49749
+ const {
49750
+ metadata
49751
+ } = annotation;
49752
+ if (metadata.originalToolName === testToolName && metadata.originalToolName !== metadata.toolName) {
49753
+ annotations.push(annotation);
49754
+ }
49755
+ });
49756
+ }
49704
49757
  }
49705
49758
  if (!annotations?.length) {
49706
49759
  return interpolationDatas;
@@ -49751,7 +49804,8 @@ function createPolylineToolData(polyline, handlePoints, referencedToolData) {
49751
49804
  invalidated: true,
49752
49805
  autoGenerated: true,
49753
49806
  annotationUID: undefined,
49754
- cachedStats: {}
49807
+ cachedStats: {},
49808
+ childAnnotationUIDs: []
49755
49809
  });
49756
49810
  Object.assign(annotation.data, {
49757
49811
  handles: {
@@ -50527,7 +50581,6 @@ class InterpolationManager {
50527
50581
  if (!this.toolNames.includes(toolName) && !this.toolNames.includes(originalToolName)) {
50528
50582
  return;
50529
50583
  }
50530
- console.log('Interpolation annotation', annotation.annotationUID);
50531
50584
  const viewport = getViewportForAnnotation(annotation);
50532
50585
  if (!viewport) {
50533
50586
  console.warn('Unable to find viewport for', annotation);