@ohif/app 3.7.0-beta.100 → 3.7.0-beta.102

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.
Files changed (28) hide show
  1. package/dist/{202.bundle.96bbb4547a346fe3921f.js → 202.bundle.d3490836f71e001dd30f.js} +746 -19
  2. package/dist/{221.bundle.0b9f7401294213262852.js → 221.bundle.1abd77673494f2d5e335.js} +69 -13
  3. package/dist/{342.bundle.6edc7ac022b4218ec99f.js → 342.bundle.d48025ca2b3e0c124c93.js} +27 -12
  4. package/dist/{831.bundle.83658f62fcc769043605.js → 757.bundle.ec8301d8e70d2b990f65.js} +368 -1
  5. package/dist/{782.bundle.8c17030f76b75035564c.js → 788.bundle.81692b0c71e1a1d198e5.js} +5 -305
  6. package/dist/{82.bundle.7a89cd8b81eb7e1e5c66.js → 82.bundle.a668df28c6de20b61d16.js} +24 -23
  7. package/dist/{app.bundle.dc0e89948c4f4568fe20.js → app.bundle.d8c304e220a0ad5711bd.js} +130 -91
  8. package/dist/index.html +1 -1
  9. package/dist/sw.js +1 -1
  10. package/package.json +19 -18
  11. /package/dist/{12.bundle.34050abb042540a90a3a.js → 12.bundle.712fe86dbec36eecc89f.js} +0 -0
  12. /package/dist/{181.bundle.169383e9b1a0358b44e8.js → 181.bundle.ceb057236403bcb630ac.js} +0 -0
  13. /package/dist/{19.bundle.eef637102334f1832ba9.js → 19.bundle.d6915be3c5318db388a1.js} +0 -0
  14. /package/dist/{236.bundle.7768b3e29b1fd618b9ec.js → 236.bundle.cf37a49db286f1480550.js} +0 -0
  15. /package/dist/{281.bundle.39cb630582cf8114fd5e.js → 281.bundle.8bbe8c1e24c8d712104b.js} +0 -0
  16. /package/dist/{359.bundle.a8f6cf2f90fe05fc346d.js → 359.bundle.68be297cb33dbd66988f.js} +0 -0
  17. /package/dist/{370.bundle.4e1276530ba7757347f5.js → 370.bundle.d37f54b9f761686f36d7.js} +0 -0
  18. /package/dist/{410.bundle.5a330214c0c31cbf2551.js → 410.bundle.5895d67416c61bc8b051.js} +0 -0
  19. /package/dist/{506.bundle.ac385e382f79bbf4f306.js → 506.bundle.556f5d2f1ec93f2086cb.js} +0 -0
  20. /package/dist/{613.bundle.f75fd669ddfe4ecf9c1b.js → 613.bundle.bdad486ed3721a5ad44e.js} +0 -0
  21. /package/dist/{663.bundle.3863ac49f85320c8ca96.js → 663.bundle.e1ba9b84535df72e79f8.js} +0 -0
  22. /package/dist/{687.bundle.ebd1260565c31ab9ad08.js → 687.bundle.acc37042575a9ed8b35a.js} +0 -0
  23. /package/dist/{743.bundle.4bfe6e562ffb2c22708f.js → 743.bundle.495448aa95758144af74.js} +0 -0
  24. /package/dist/{774.bundle.7528cba56a1407357144.js → 774.bundle.4b2dc46a35012b898e1a.js} +0 -0
  25. /package/dist/{814.bundle.cc0ed4fc75cb16e34f02.js → 814.bundle.b9e9871a97309c2659b5.js} +0 -0
  26. /package/dist/{822.bundle.0545d6dbb49515aa04ee.js → 822.bundle.891f2e57b1b7bc2f4cb4.js} +0 -0
  27. /package/dist/{957.bundle.71558794566041f37a92.js → 957.bundle.0fba9c5956bdb9972c73.js} +0 -0
  28. /package/dist/{99.bundle.c6876aaaa3ff2f1b08a1.js → 99.bundle.b51fcfa5d8e5057aa7e3.js} +0 -0
@@ -642,6 +642,11 @@ function PanelSegmentation(_ref) {
642
642
  });
643
643
  }
644
644
  };
645
+ const onSegmentationDownloadRTSS = segmentationId => {
646
+ commandsManager.runCommand('downloadRTSS', {
647
+ segmentationId
648
+ });
649
+ };
645
650
  return /*#__PURE__*/react.createElement(react.Fragment, null, /*#__PURE__*/react.createElement("div", {
646
651
  className: "ohif-scrollbar flex min-h-0 flex-auto select-none flex-col justify-between overflow-auto"
647
652
  }, /*#__PURE__*/react.createElement(ui_src/* SegmentationGroupTable */.cX, {
@@ -653,6 +658,7 @@ function PanelSegmentation(_ref) {
653
658
  onSegmentationClick: onSegmentationClick,
654
659
  onSegmentationDelete: onSegmentationDelete,
655
660
  onSegmentationDownload: onSegmentationDownload,
661
+ onSegmentationDownloadRTSS: onSegmentationDownloadRTSS,
656
662
  storeSegmentation: storeSegmentation,
657
663
  onSegmentationEdit: onSegmentationEdit,
658
664
  onSegmentClick: onSegmentClick,
@@ -706,9 +712,9 @@ const TOOL_TYPES = {
706
712
  SPHERE_BRUSH: 'SphereBrush',
707
713
  CIRCULAR_ERASER: 'CircularEraser',
708
714
  SPHERE_ERASER: 'SphereEraser',
709
- CIRCLE_SCISSOR: 'CircleScissor',
710
- RECTANGLE_SCISSOR: 'RectangleScissor',
711
- SPHERE_SCISSOR: 'SphereScissor',
715
+ CIRCLE_SHAPE: 'CircleScissor',
716
+ RECTANGLE_SHAPE: 'RectangleScissor',
717
+ SPHERE_SHAPE: 'SphereScissor',
712
718
  THRESHOLD_CIRCULAR_BRUSH: 'ThresholdCircularBrush',
713
719
  THRESHOLD_SPHERE_BRUSH: 'ThresholdSphereBrush'
714
720
  };
@@ -727,7 +733,7 @@ const initialState = {
727
733
  mode: 'CircularEraser' // Can be 'CircularEraser' or 'SphereEraser'
728
734
  },
729
735
 
730
- Scissors: {
736
+ Shapes: {
731
737
  brushSize: 15,
732
738
  mode: 'CircleScissor' // E.g., 'CircleScissor', 'RectangleScissor', or 'SphereScissor'
733
739
  },
@@ -966,24 +972,24 @@ function SegmentationToolbox(_ref) {
966
972
  onChange: value => setToolActive(value)
967
973
  }]
968
974
  }, {
969
- name: 'Scissor',
970
- icon: 'icon-tool-scissor',
975
+ name: 'Shapes',
976
+ icon: 'icon-tool-shape',
971
977
  disabled: !toolsEnabled,
972
- active: state.activeTool === TOOL_TYPES.CIRCLE_SCISSOR || state.activeTool === TOOL_TYPES.RECTANGLE_SCISSOR || state.activeTool === TOOL_TYPES.SPHERE_SCISSOR,
973
- onClick: () => setToolActive(TOOL_TYPES.CIRCLE_SCISSOR),
978
+ active: state.activeTool === TOOL_TYPES.CIRCLE_SHAPE || state.activeTool === TOOL_TYPES.RECTANGLE_SHAPE || state.activeTool === TOOL_TYPES.SPHERE_SHAPE,
979
+ onClick: () => setToolActive(TOOL_TYPES.CIRCLE_SHAPE),
974
980
  options: [{
975
981
  name: 'Mode',
976
982
  type: 'radio',
977
- value: state.Scissors.mode,
978
- id: 'scissor-mode',
983
+ value: state.Shapes.mode,
984
+ id: 'shape-mode',
979
985
  values: [{
980
- value: TOOL_TYPES.CIRCLE_SCISSOR,
986
+ value: TOOL_TYPES.CIRCLE_SHAPE,
981
987
  label: 'Circle'
982
988
  }, {
983
- value: TOOL_TYPES.RECTANGLE_SCISSOR,
989
+ value: TOOL_TYPES.RECTANGLE_SHAPE,
984
990
  label: 'Rectangle'
985
991
  }, {
986
- value: TOOL_TYPES.SPHERE_SCISSOR,
992
+ value: TOOL_TYPES.SPHERE_SHAPE,
987
993
  label: 'Sphere'
988
994
  }],
989
995
  onChange: value => setToolActive(value)
@@ -1118,6 +1124,12 @@ const getPanelModule = _ref => {
1118
1124
  }];
1119
1125
  };
1120
1126
  /* harmony default export */ const src_getPanelModule = (getPanelModule);
1127
+ // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Filters/General/ImageMarchingSquares.js + 2 modules
1128
+ var ImageMarchingSquares = __webpack_require__(49399);
1129
+ // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Common/Core/DataArray.js
1130
+ var DataArray = __webpack_require__(54131);
1131
+ // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Common/DataModel/ImageData.js + 2 modules
1132
+ var ImageData = __webpack_require__(96372);
1121
1133
  ;// CONCATENATED MODULE: ../../../extensions/cornerstone-dicom-seg/src/utils/hydrationUtils.ts
1122
1134
 
1123
1135
 
@@ -1287,6 +1299,12 @@ function getUpdatedViewportsForSegmentation(_ref3) {
1287
1299
 
1288
1300
 
1289
1301
 
1302
+
1303
+
1304
+
1305
+ const {
1306
+ datasetToBlob
1307
+ } = dcmjs_es["default"].data;
1290
1308
  const {
1291
1309
  Cornerstone3D: {
1292
1310
  Segmentation: {
@@ -1295,6 +1313,13 @@ const {
1295
1313
  }
1296
1314
  }
1297
1315
  } = adapters_es.adaptersSEG;
1316
+ const {
1317
+ Cornerstone3D: {
1318
+ RTSS: {
1319
+ generateRTSSFromSegmentations
1320
+ }
1321
+ }
1322
+ } = adapters_es.adaptersRT;
1298
1323
  const {
1299
1324
  downloadDICOMData
1300
1325
  } = adapters_es.helpers;
@@ -1608,6 +1633,34 @@ const commandsModule = _ref => {
1608
1633
  naturalizedReport.wadoRoot = dataSource.getConfig().wadoRoot;
1609
1634
  src.DicomMetadataStore.addInstances([naturalizedReport], true);
1610
1635
  return naturalizedReport;
1636
+ },
1637
+ /**
1638
+ * Converts segmentations into RTSS for download.
1639
+ * This sample function retrieves all segentations and passes to
1640
+ * cornerstone tool adapter to convert to DICOM RTSS format. It then
1641
+ * converts dataset to downloadable blob.
1642
+ *
1643
+ */
1644
+ downloadRTSS: _ref8 => {
1645
+ let {
1646
+ segmentationId
1647
+ } = _ref8;
1648
+ const segmentations = segmentationService.getSegmentation(segmentationId);
1649
+ const vtkUtils = {
1650
+ vtkImageMarchingSquares: ImageMarchingSquares/* default */.ZP,
1651
+ vtkDataArray: DataArray/* default */.ZP,
1652
+ vtkImageData: ImageData/* default */.ZP
1653
+ };
1654
+ const RTSS = generateRTSSFromSegmentations(segmentations, src.classes.MetadataProvider, src.DicomMetadataStore, esm.cache, dist_esm.Enums, vtkUtils);
1655
+ try {
1656
+ const reportBlob = datasetToBlob(RTSS);
1657
+
1658
+ //Create a URL for the binary.
1659
+ const objectUrl = URL.createObjectURL(reportBlob);
1660
+ window.location.assign(objectUrl);
1661
+ } catch (e) {
1662
+ console.warn(e);
1663
+ }
1611
1664
  }
1612
1665
  };
1613
1666
  const definitions = {
@@ -1631,6 +1684,9 @@ const commandsModule = _ref => {
1631
1684
  },
1632
1685
  storeSegmentation: {
1633
1686
  commandFn: actions.storeSegmentation
1687
+ },
1688
+ downloadRTSS: {
1689
+ commandFn: actions.downloadRTSS
1634
1690
  }
1635
1691
  };
1636
1692
  return {
@@ -831,7 +831,7 @@ class StaticWadoClient extends dicomweb_client_es.api.DICOMwebClient {
831
831
  if (!valueElem) {
832
832
  return false;
833
833
  }
834
- if (valueElem.vr == 'DA') {
834
+ if (valueElem.vr === 'DA' && valueElem.Value?.[0]) {
835
835
  return this.compareDateRange(testValue, valueElem.Value[0]);
836
836
  }
837
837
  const value = valueElem.Value;
@@ -2166,8 +2166,8 @@ function ViewerHeader(_ref) {
2166
2166
  hotkeyDefinitions,
2167
2167
  hotkeyDefaults
2168
2168
  } = hotkeysManager;
2169
- const versionNumber = "3.7.0-beta.100";
2170
- const commitHash = "1fd98d922094d10fe0c6e9df726314ec9fce49e8";
2169
+ const versionNumber = "3.7.0-beta.102";
2170
+ const commitHash = "40673f64b36b1150149c55632aa1825178a39e65";
2171
2171
  const menuOptions = [{
2172
2172
  title: t('Header:About'),
2173
2173
  icon: 'info',
@@ -2508,7 +2508,6 @@ function PanelStudyBrowser(_ref) {
2508
2508
  const [studyDisplayList, setStudyDisplayList] = (0,react.useState)([]);
2509
2509
  const [displaySets, setDisplaySets] = (0,react.useState)([]);
2510
2510
  const [thumbnailImageSrcMap, setThumbnailImageSrcMap] = (0,react.useState)({});
2511
- const isMounted = (0,react.useRef)(true);
2512
2511
  const onDoubleClickThumbnailHandler = displaySetInstanceUID => {
2513
2512
  let updatedViewports = [];
2514
2513
  const viewportId = activeViewportId;
@@ -2585,9 +2584,6 @@ function PanelStudyBrowser(_ref) {
2585
2584
  }
2586
2585
  // When the image arrives, render it and store the result in the thumbnailImgSrcMap
2587
2586
  newImageSrcEntry[dSet.displaySetInstanceUID] = await getImageSrc(imageId);
2588
- if (!isMounted.current) {
2589
- return;
2590
- }
2591
2587
  setThumbnailImageSrcMap(prevState => {
2592
2588
  return {
2593
2589
  ...prevState,
@@ -2595,9 +2591,6 @@ function PanelStudyBrowser(_ref) {
2595
2591
  };
2596
2592
  });
2597
2593
  });
2598
- return () => {
2599
- isMounted.current = false;
2600
- };
2601
2594
  }, [StudyInstanceUIDs, dataSource, displaySetService, getImageSrc]);
2602
2595
 
2603
2596
  // ~~ displaySets
@@ -5570,6 +5563,7 @@ const commandsModule = _ref => {
5570
5563
  stageIndex,
5571
5564
  reset = false
5572
5565
  } = _ref3;
5566
+ const primaryToolBeforeHPChange = toolbarService.getActivePrimaryTool();
5573
5567
  try {
5574
5568
  // Stores in the state the display set selector id to displaySetUID mapping
5575
5569
  // Pass in viewportId for the active viewport. This item will get set as
@@ -5632,7 +5626,27 @@ const commandsModule = _ref => {
5632
5626
  const {
5633
5627
  protocol
5634
5628
  } = hangingProtocolService.getActiveProtocol();
5635
- actions.toggleHpTools(protocol);
5629
+ actions.toggleHpTools();
5630
+
5631
+ // try to use the same tool in the new hanging protocol stage
5632
+ const primaryButton = toolbarService.getButton(primaryToolBeforeHPChange);
5633
+ if (primaryButton) {
5634
+ // is there any type of interaction on this button, if not it might be in the
5635
+ // items. This is a bit of a hack, but it works for now.
5636
+
5637
+ let interactionType = primaryButton.props?.interactionType;
5638
+ if (!interactionType && primaryButton.props?.items) {
5639
+ const firstItem = primaryButton.props.items[0];
5640
+ interactionType = firstItem.props?.interactionType || firstItem.props?.type;
5641
+ }
5642
+ if (interactionType) {
5643
+ toolbarService.recordInteraction({
5644
+ interactionType,
5645
+ ...primaryButton.props
5646
+ });
5647
+ }
5648
+ }
5649
+
5636
5650
  // Send the notification about updating the state
5637
5651
  if (protocolId !== hpInfo.protocolId) {
5638
5652
  // The old protocol callbacks are used for turning off things
@@ -5645,7 +5659,8 @@ const commandsModule = _ref => {
5645
5659
  commandsManager.run(protocol.callbacks?.onProtocolEnter);
5646
5660
  return true;
5647
5661
  } catch (e) {
5648
- actions.toggleHpTools(hangingProtocolService.getActiveProtocol());
5662
+ console.error(e);
5663
+ actions.toggleHpTools();
5649
5664
  uiNotificationService.show({
5650
5665
  title: 'Apply Hanging Protocol',
5651
5666
  message: 'The hanging protocol could not be applied.',
@@ -1,4 +1,4 @@
1
- (self["webpackChunk"] = self["webpackChunk"] || []).push([[831],{
1
+ (self["webpackChunk"] = self["webpackChunk"] || []).push([[757],{
2
2
 
3
3
  /***/ 82803:
4
4
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
@@ -90,6 +90,373 @@ exports.Z = function (_ref) {
90
90
  );
91
91
  };
92
92
 
93
+ /***/ }),
94
+
95
+ /***/ 49399:
96
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
97
+
98
+ "use strict";
99
+
100
+ // EXPORTS
101
+ __webpack_require__.d(__webpack_exports__, {
102
+ ZP: () => (/* binding */ vtkImageMarchingSquares$1)
103
+ });
104
+
105
+ // UNUSED EXPORTS: extend, newInstance
106
+
107
+ // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/macros.js + 6 modules
108
+ var macros = __webpack_require__(41168);
109
+ // EXTERNAL MODULE: ../../../node_modules/@kitware/vtk.js/Common/DataModel/PolyData.js + 9 modules
110
+ var PolyData = __webpack_require__(1299);
111
+ // EXTERNAL MODULE: ../../../node_modules/@babel/runtime/helpers/esm/classCallCheck.js
112
+ var classCallCheck = __webpack_require__(72688);
113
+ // EXTERNAL MODULE: ../../../node_modules/@babel/runtime/helpers/esm/createClass.js
114
+ var createClass = __webpack_require__(75755);
115
+ ;// CONCATENATED MODULE: ../../../node_modules/@kitware/vtk.js/Common/DataModel/EdgeLocator.js
116
+
117
+
118
+
119
+ var EdgeLocator = /*#__PURE__*/function () {
120
+ function EdgeLocator() {
121
+ var oriented = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
122
+
123
+ (0,classCallCheck/* default */.Z)(this, EdgeLocator);
124
+
125
+ this.oriented = oriented;
126
+ this.edgeMap = new Map();
127
+ }
128
+
129
+ (0,createClass/* default */.Z)(EdgeLocator, [{
130
+ key: "initialize",
131
+ value: function initialize() {
132
+ this.edgeMap.clear();
133
+ }
134
+ }, {
135
+ key: "computeEdgeKey",
136
+ value: function computeEdgeKey(pointId0, pointId1) {
137
+ return this.oriented || pointId0 < pointId1 ? // Cantor pairing function:
138
+ 0.5 * (pointId0 * pointId1) * (pointId0 * pointId1 + 1) + pointId1 : 0.5 * (pointId1 * pointId0) * (pointId1 * pointId0 + 1) + pointId0;
139
+ }
140
+ }, {
141
+ key: "insertUniqueEdge",
142
+ value: function insertUniqueEdge(pointId0, pointId1, newEdgeValue) {
143
+ // Generate a unique key
144
+ var key = this.computeEdgeKey(pointId0, pointId1);
145
+ var node = this.edgeMap.get(key);
146
+
147
+ if (!node) {
148
+ // Didn't find key, so add a new edge entry
149
+ node = {
150
+ key: key,
151
+ edgeId: this.edgeMap.size,
152
+ value: newEdgeValue
153
+ };
154
+ this.edgeMap.set(key, node);
155
+ }
156
+
157
+ return node;
158
+ }
159
+ }, {
160
+ key: "insertEdge",
161
+ value: function insertEdge(pointId0, pointId1, newEdgeValue) {
162
+ // Generate a unique key
163
+ var key = this.computeEdgeKey(pointId0, pointId1);
164
+ var node = {
165
+ key: key,
166
+ edgeId: this.edgeMap.size,
167
+ value: newEdgeValue
168
+ };
169
+ this.edgeMap.set(key, node);
170
+ return node;
171
+ }
172
+ }, {
173
+ key: "isInsertedEdge",
174
+ value: function isInsertedEdge(pointId0, pointId1) {
175
+ var key = this.computeEdgeKey(pointId0, pointId1);
176
+ return this.edgeMap.get(key);
177
+ }
178
+ }], [{
179
+ key: "getEdgePointIds",
180
+ value: function getEdgePointIds(node) {
181
+ var n = 0.5 * (-1 + Math.sqrt(8 * node.key + 1));
182
+ var pointId0 = node.key - 0.5 * (n + 1) * n;
183
+ var pointId1 = n - pointId0;
184
+ return [pointId0, pointId1];
185
+ }
186
+ }]);
187
+
188
+ return EdgeLocator;
189
+ }();
190
+
191
+ function newInstance() {
192
+ var initialValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
193
+ return new EdgeLocator(initialValues.oriented);
194
+ }
195
+
196
+ var vtkEdgeLocator = {
197
+ newInstance: newInstance
198
+ };
199
+
200
+
201
+
202
+ ;// CONCATENATED MODULE: ../../../node_modules/@kitware/vtk.js/Filters/General/ImageMarchingSquares/caseTable.js
203
+ // ----------------------------------------------------------------------------
204
+ // Marching squares case functions (using lines to generate the 2D tessellation).
205
+ // For each case, a list of edge ids that form the triangles. A -1 marks the
206
+ // end of the list of edges. Edges are taken three at a time to generate
207
+ // triangle points.
208
+ // ----------------------------------------------------------------------------
209
+ var MARCHING_SQUARES_CASES = [[-1, -1, -1, -1, -1]
210
+ /* 0 */
211
+ , [0, 3, -1, -1, -1]
212
+ /* 1 */
213
+ , [1, 0, -1, -1, -1]
214
+ /* 2 */
215
+ , [1, 3, -1, -1, -1]
216
+ /* 3 */
217
+ , [2, 1, -1, -1, -1]
218
+ /* 4 */
219
+ , [0, 3, 2, 1, -1]
220
+ /* 5 */
221
+ , [2, 0, -1, -1, -1]
222
+ /* 6 */
223
+ , [2, 3, -1, -1, -1]
224
+ /* 7 */
225
+ , [3, 2, -1, -1, -1]
226
+ /* 8 */
227
+ , [0, 2, -1, -1, -1]
228
+ /* 9 */
229
+ , [1, 0, 3, 2, -1]
230
+ /* 10 */
231
+ , [1, 2, -1, -1, -1]
232
+ /* 11 */
233
+ , [3, 1, -1, -1, -1]
234
+ /* 12 */
235
+ , [0, 1, -1, -1, -1]
236
+ /* 13 */
237
+ , [3, 0, -1, -1, -1]
238
+ /* 14 */
239
+ , [-1, -1, -1, -1, -1]
240
+ /* 15 */
241
+ ];
242
+ var EDGES = [[0, 1], [1, 3], [2, 3], [0, 2]];
243
+
244
+ function getCase(index) {
245
+ return MARCHING_SQUARES_CASES[index];
246
+ } // Define the four edges of the pixel by the following pairs of vertices
247
+
248
+
249
+ function getEdge(eid) {
250
+ return EDGES[eid];
251
+ } // ----------------------------------------------------------------------------
252
+ // Static API
253
+ // ----------------------------------------------------------------------------
254
+
255
+
256
+ var vtkCaseTable = {
257
+ getCase: getCase,
258
+ getEdge: getEdge
259
+ };
260
+
261
+
262
+
263
+ ;// CONCATENATED MODULE: ../../../node_modules/@kitware/vtk.js/Filters/General/ImageMarchingSquares.js
264
+
265
+
266
+
267
+
268
+
269
+ var vtkErrorMacro = macros["default"].vtkErrorMacro,
270
+ vtkDebugMacro = macros["default"].vtkDebugMacro; // ----------------------------------------------------------------------------
271
+ // vtkImageMarchingSquares methods
272
+ // ----------------------------------------------------------------------------
273
+
274
+ function vtkImageMarchingSquares(publicAPI, model) {
275
+ // Set our className
276
+ model.classHierarchy.push('vtkImageMarchingSquares');
277
+
278
+ publicAPI.getContourValues = function () {
279
+ return model.contourValues;
280
+ };
281
+
282
+ publicAPI.setContourValues = function (cValues) {
283
+ model.contourValues = cValues;
284
+ publicAPI.modified();
285
+ };
286
+
287
+ var ids = [];
288
+ var pixelScalars = [];
289
+ var pixelPts = [];
290
+ var edgeLocator = vtkEdgeLocator.newInstance(); // Retrieve scalars and pixel coordinates. i-j-k is origin of pixel.
291
+
292
+ publicAPI.getPixelScalars = function (i, j, k, slice, dims, origin, spacing, s) {
293
+ // First get the indices for the pixel
294
+ ids[0] = k * slice + j * dims[0] + i; // i, j, k
295
+
296
+ ids[1] = ids[0] + 1; // i+1, j, k
297
+
298
+ ids[2] = ids[0] + dims[0]; // i, j+1, k
299
+
300
+ ids[3] = ids[2] + 1; // i+1, j+1, k
301
+ // Now retrieve the scalars
302
+
303
+ for (var ii = 0; ii < 4; ++ii) {
304
+ pixelScalars[ii] = s[ids[ii]];
305
+ }
306
+ }; // Retrieve pixel coordinates. i-j-k is origin of pixel.
307
+
308
+
309
+ publicAPI.getPixelPoints = function (i, j, k, dims, origin, spacing) {
310
+ // (i,i+1),(j,j+1),(k,k+1) - i varies fastest; then j; then k
311
+ pixelPts[0] = origin[0] + i * spacing[0]; // 0
312
+
313
+ pixelPts[1] = origin[1] + j * spacing[1];
314
+ pixelPts[2] = pixelPts[0] + spacing[0]; // 1
315
+
316
+ pixelPts[3] = pixelPts[1];
317
+ pixelPts[4] = pixelPts[0]; // 2
318
+
319
+ pixelPts[5] = pixelPts[1] + spacing[1];
320
+ pixelPts[6] = pixelPts[2]; // 3
321
+
322
+ pixelPts[7] = pixelPts[5];
323
+ };
324
+
325
+ publicAPI.produceLines = function (cVal, i, j, k, slice, dims, origin, spacing, scalars, points, lines) {
326
+ var CASE_MASK = [1, 2, 8, 4]; // case table is actually for quad
327
+
328
+ var xyz = [];
329
+ var pId;
330
+ publicAPI.getPixelScalars(i, j, k, slice, dims, origin, spacing, scalars);
331
+ var index = 0;
332
+
333
+ for (var idx = 0; idx < 4; idx++) {
334
+ if (pixelScalars[idx] >= cVal) {
335
+ index |= CASE_MASK[idx]; // eslint-disable-line no-bitwise
336
+ }
337
+ }
338
+
339
+ var pixelLines = vtkCaseTable.getCase(index);
340
+
341
+ if (pixelLines[0] < 0) {
342
+ return; // don't get the pixel coordinates, nothing to do
343
+ }
344
+
345
+ publicAPI.getPixelPoints(i, j, k, dims, origin, spacing);
346
+ var z = origin[2] + k * spacing[2];
347
+
348
+ for (var _idx = 0; pixelLines[_idx] >= 0; _idx += 3) {
349
+ lines.push(2);
350
+
351
+ for (var eid = 0; eid < 2; eid++) {
352
+ var edgeVerts = vtkCaseTable.getEdge(pixelLines[_idx + eid]);
353
+ pId = undefined;
354
+
355
+ if (model.mergePoints) {
356
+ var _edgeLocator$isInsert;
357
+
358
+ pId = (_edgeLocator$isInsert = edgeLocator.isInsertedEdge(ids[edgeVerts[0]], ids[edgeVerts[1]])) === null || _edgeLocator$isInsert === void 0 ? void 0 : _edgeLocator$isInsert.value;
359
+ }
360
+
361
+ if (pId === undefined) {
362
+ var t = (cVal - pixelScalars[edgeVerts[0]]) / (pixelScalars[edgeVerts[1]] - pixelScalars[edgeVerts[0]]);
363
+ var x0 = pixelPts.slice(edgeVerts[0] * 2, (edgeVerts[0] + 1) * 2);
364
+ var x1 = pixelPts.slice(edgeVerts[1] * 2, (edgeVerts[1] + 1) * 2);
365
+ xyz[0] = x0[0] + t * (x1[0] - x0[0]);
366
+ xyz[1] = x0[1] + t * (x1[1] - x0[1]);
367
+ pId = points.length / 3;
368
+ points.push(xyz[0], xyz[1], z);
369
+
370
+ if (model.mergePoints) {
371
+ edgeLocator.insertEdge(ids[edgeVerts[0]], ids[edgeVerts[1]], pId);
372
+ }
373
+ }
374
+
375
+ lines.push(pId);
376
+ }
377
+ }
378
+ };
379
+
380
+ publicAPI.requestData = function (inData, outData) {
381
+ // implement requestData
382
+ var input = inData[0];
383
+
384
+ if (!input) {
385
+ vtkErrorMacro('Invalid or missing input');
386
+ return;
387
+ }
388
+
389
+ console.time('msquares'); // Retrieve output and volume data
390
+
391
+ var origin = input.getOrigin();
392
+ var spacing = input.getSpacing();
393
+ var dims = input.getDimensions();
394
+ var s = input.getPointData().getScalars().getData(); // Points - dynamic array
395
+
396
+ var pBuffer = []; // Cells - dynamic array
397
+
398
+ var lBuffer = []; // Ensure slice is valid
399
+
400
+ var slice = dims[0] * dims[1];
401
+ var k = Math.round(model.slice);
402
+
403
+ if (k >= dims[2]) {
404
+ k = 0;
405
+ } // Loop over all contour values, and then pixels, determine case and process
406
+
407
+
408
+ for (var cv = 0; cv < model.contourValues.length; ++cv) {
409
+ for (var j = 0; j < dims[1] - 1; ++j) {
410
+ for (var i = 0; i < dims[0] - 1; ++i) {
411
+ publicAPI.produceLines(model.contourValues[cv], i, j, k, slice, dims, origin, spacing, s, pBuffer, lBuffer);
412
+ }
413
+ }
414
+
415
+ edgeLocator.initialize();
416
+ } // Update output
417
+
418
+
419
+ var polydata = PolyData/* default.newInstance */.ZP.newInstance();
420
+ polydata.getPoints().setData(new Float32Array(pBuffer), 3);
421
+ polydata.getLines().setData(new Uint32Array(lBuffer));
422
+ outData[0] = polydata;
423
+ vtkDebugMacro('Produced output');
424
+ console.timeEnd('msquares');
425
+ };
426
+ } // ----------------------------------------------------------------------------
427
+ // Object factory
428
+ // ----------------------------------------------------------------------------
429
+
430
+
431
+ var DEFAULT_VALUES = {
432
+ contourValues: [],
433
+ slice: 0,
434
+ mergePoints: false
435
+ }; // ----------------------------------------------------------------------------
436
+
437
+ function extend(publicAPI, model) {
438
+ var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
439
+ Object.assign(model, DEFAULT_VALUES, initialValues); // Make this a VTK object
440
+
441
+ macros["default"].obj(publicAPI, model); // Also make it an algorithm with one input and one output
442
+
443
+ macros["default"].algo(publicAPI, model, 1, 1);
444
+ macros["default"].setGet(publicAPI, model, ['slice', 'mergePoints']); // Object specific methods
445
+
446
+ macros["default"].algo(publicAPI, model, 1, 1);
447
+ vtkImageMarchingSquares(publicAPI, model);
448
+ } // ----------------------------------------------------------------------------
449
+
450
+ var ImageMarchingSquares_newInstance = macros["default"].newInstance(extend, 'vtkImageMarchingSquares'); // ----------------------------------------------------------------------------
451
+
452
+ var vtkImageMarchingSquares$1 = {
453
+ newInstance: ImageMarchingSquares_newInstance,
454
+ extend: extend
455
+ };
456
+
457
+
458
+
459
+
93
460
  /***/ }),
94
461
 
95
462
  /***/ 55187: