@cornerstonejs/tools 3.29.3 → 3.29.5

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.
@@ -65,6 +65,7 @@ function _imageChangeEventListener(evt) {
65
65
  if (!derivedImageIds) {
66
66
  return;
67
67
  }
68
+ let shouldTriggerSegmentationRender = false;
68
69
  const updateSegmentationActor = (derivedImageId) => {
69
70
  const derivedImage = cache.getImage(derivedImageId);
70
71
  if (!derivedImage) {
@@ -103,7 +104,7 @@ function _imageChangeEventListener(evt) {
103
104
  },
104
105
  },
105
106
  ]);
106
- triggerSegmentationRender(viewportId);
107
+ shouldTriggerSegmentationRender = true;
107
108
  return;
108
109
  }
109
110
  else {
@@ -119,6 +120,9 @@ function _imageChangeEventListener(evt) {
119
120
  }
120
121
  };
121
122
  derivedImageIds.forEach(updateSegmentationActor);
123
+ if (shouldTriggerSegmentationRender) {
124
+ triggerSegmentationRender(viewportId);
125
+ }
122
126
  viewport.render();
123
127
  if (evt.type === Enums.Events.IMAGE_RENDERED) {
124
128
  viewport.element.removeEventListener(Enums.Events.IMAGE_RENDERED, _imageChangeEventListener);
@@ -1,5 +1,6 @@
1
1
  declare class SegmentationRenderingEngine {
2
2
  private _needsRender;
3
+ private _pendingRenderQueue;
3
4
  private _animationFrameSet;
4
5
  private _animationFrameHandle;
5
6
  hasBeenDestroyed: boolean;
@@ -18,6 +18,7 @@ const planarContourToolName = PlanarFreehandContourSegmentationTool.toolName;
18
18
  class SegmentationRenderingEngine {
19
19
  constructor() {
20
20
  this._needsRender = new Set();
21
+ this._pendingRenderQueue = [];
21
22
  this._animationFrameSet = false;
22
23
  this._animationFrameHandle = null;
23
24
  this._getAllViewports = () => {
@@ -33,6 +34,12 @@ class SegmentationRenderingEngine {
33
34
  this._needsRender.clear();
34
35
  this._animationFrameSet = false;
35
36
  this._animationFrameHandle = null;
37
+ if (this._pendingRenderQueue.length > 0) {
38
+ const nextViewportIds = this._pendingRenderQueue.shift();
39
+ if (nextViewportIds && nextViewportIds.length > 0) {
40
+ this._setViewportsToBeRenderedNextFrame(nextViewportIds);
41
+ }
42
+ }
36
43
  };
37
44
  }
38
45
  renderSegmentationsForViewport(viewportId) {
@@ -71,6 +78,10 @@ class SegmentationRenderingEngine {
71
78
  }
72
79
  }
73
80
  _setViewportsToBeRenderedNextFrame(viewportIds) {
81
+ if (this._animationFrameSet) {
82
+ this._pendingRenderQueue.push(viewportIds);
83
+ return;
84
+ }
74
85
  viewportIds.forEach((viewportId) => {
75
86
  this._needsRender.add(viewportId);
76
87
  });
@@ -44,6 +44,9 @@ function normalizeSegments(segmentsConfig, type, data) {
44
44
  normalizedSegments[segmentIndex] = normalizedSegment;
45
45
  });
46
46
  }
47
+ else if (type === SegmentationRepresentations.Contour) {
48
+ normalizeContourSegments(normalizedSegments, data);
49
+ }
47
50
  else if (type === SegmentationRepresentations.Surface) {
48
51
  normalizeSurfaceSegments(normalizedSegments, data);
49
52
  }
@@ -52,6 +55,16 @@ function normalizeSegments(segmentsConfig, type, data) {
52
55
  }
53
56
  return normalizedSegments;
54
57
  }
58
+ function normalizeContourSegments(normalizedSegments, contourData) {
59
+ const { geometryIds } = contourData;
60
+ geometryIds?.forEach((geometryId) => {
61
+ const geometry = cache.getGeometry(geometryId);
62
+ if (geometry?.data) {
63
+ const { segmentIndex } = geometry.data;
64
+ normalizedSegments[segmentIndex] = { segmentIndex };
65
+ }
66
+ });
67
+ }
55
68
  function normalizeSurfaceSegments(normalizedSegments, surfaceData) {
56
69
  const { geometryIds } = surfaceData;
57
70
  geometryIds?.forEach((geometryId) => {
@@ -1 +1 @@
1
- export declare const version = "3.29.3";
1
+ export declare const version = "3.29.5";
@@ -1 +1 @@
1
- export const version = '3.29.3';
1
+ export const version = '3.29.5';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "3.29.3",
3
+ "version": "3.29.5",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -108,7 +108,7 @@
108
108
  "canvas": "^3.1.0"
109
109
  },
110
110
  "peerDependencies": {
111
- "@cornerstonejs/core": "^3.29.3",
111
+ "@cornerstonejs/core": "^3.29.5",
112
112
  "@kitware/vtk.js": "32.12.1",
113
113
  "@types/d3-array": "^3.0.4",
114
114
  "@types/d3-interpolate": "^3.0.1",
@@ -127,5 +127,5 @@
127
127
  "type": "individual",
128
128
  "url": "https://ohif.org/donate"
129
129
  },
130
- "gitHead": "b3073ebc138e6bf613b6e4b2b66d6d8d7d7cfb89"
130
+ "gitHead": "1396a52e3ace22acf8f5f0d21f4d4dd03612a802"
131
131
  }