@cornerstonejs/tools 2.0.0-beta.21 → 2.0.0-beta.22

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 (249) hide show
  1. package/dist/esm/cursors/elementCursor.d.ts +1 -1
  2. package/dist/esm/cursors/elementCursor.js +1 -1
  3. package/dist/esm/drawingSvg/getSvgDrawingHelper.js +1 -1
  4. package/dist/esm/eventDispatchers/keyboardEventHandlers/keyDown.js +2 -2
  5. package/dist/esm/eventDispatchers/keyboardEventHandlers/keyUp.js +2 -2
  6. package/dist/esm/eventDispatchers/mouseEventHandlers/mouseDown.js +1 -1
  7. package/dist/esm/eventDispatchers/mouseEventHandlers/mouseDownActivate.js +1 -1
  8. package/dist/esm/eventDispatchers/mouseEventHandlers/mouseDownAnnotationAction.js +1 -1
  9. package/dist/esm/eventDispatchers/mouseEventHandlers/mouseDrag.js +1 -1
  10. package/dist/esm/eventDispatchers/mouseEventHandlers/mouseMove.js +1 -1
  11. package/dist/esm/eventDispatchers/mouseEventHandlers/mouseWheel.js +1 -1
  12. package/dist/esm/eventDispatchers/shared/customCallbackHandler.js +3 -2
  13. package/dist/esm/eventDispatchers/shared/getActiveToolForKeyboardEvent.js +2 -2
  14. package/dist/esm/eventDispatchers/shared/getActiveToolForMouseEvent.js +2 -2
  15. package/dist/esm/eventDispatchers/shared/getActiveToolForTouchEvent.js +3 -3
  16. package/dist/esm/eventDispatchers/shared/getToolsWithActionsForKeyboardEvents.js +2 -2
  17. package/dist/esm/eventDispatchers/shared/getToolsWithActionsForMouseEvent.js +2 -2
  18. package/dist/esm/eventDispatchers/shared/getToolsWithModesForMouseEvent.js +2 -2
  19. package/dist/esm/eventDispatchers/shared/getToolsWithModesForTouchEvent.js +2 -2
  20. package/dist/esm/eventDispatchers/touchEventHandlers/touchDrag.js +1 -1
  21. package/dist/esm/eventDispatchers/touchEventHandlers/touchStart.js +1 -1
  22. package/dist/esm/eventDispatchers/touchEventHandlers/touchStartActivate.js +1 -1
  23. package/dist/esm/eventListeners/annotations/annotationSelectionListener.js +1 -1
  24. package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js +21 -20
  25. package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js +8 -6
  26. package/dist/esm/eventListeners/segmentation/segmentationDataModifiedEventListener.js +1 -1
  27. package/dist/esm/eventListeners/segmentation/segmentationModifiedEventListener.js +1 -1
  28. package/dist/esm/eventListeners/segmentation/segmentationRepresentationModifiedEventListener.js +1 -1
  29. package/dist/esm/eventListeners/segmentation/segmentationRepresentationRemovedEventListener.js +1 -1
  30. package/dist/esm/index.d.ts +2 -1
  31. package/dist/esm/index.js +2 -1
  32. package/dist/esm/init.js +2 -2
  33. package/dist/esm/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.js +0 -2
  34. package/dist/esm/stateManagement/annotation/annotationSelection.js +1 -1
  35. package/dist/esm/stateManagement/annotation/annotationState.d.ts +2 -2
  36. package/dist/esm/stateManagement/annotation/annotationState.js +4 -6
  37. package/dist/esm/stateManagement/annotation/annotationVisibility.js +1 -1
  38. package/dist/esm/stateManagement/annotation/getAnnotation.d.ts +2 -0
  39. package/dist/esm/stateManagement/annotation/getAnnotation.js +6 -0
  40. package/dist/esm/stateManagement/index.d.ts +0 -2
  41. package/dist/esm/stateManagement/index.js +2 -1
  42. package/dist/esm/stateManagement/segmentation/SegmentationRenderingEngine.d.ts +3 -1
  43. package/dist/esm/stateManagement/segmentation/SegmentationRenderingEngine.js +13 -6
  44. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +17 -1
  45. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +46 -4
  46. package/dist/esm/stateManagement/segmentation/activeSegmentation.js +6 -4
  47. package/dist/esm/stateManagement/segmentation/addColorLUT.d.ts +2 -0
  48. package/dist/esm/stateManagement/segmentation/addColorLUT.js +5 -0
  49. package/dist/esm/stateManagement/segmentation/addRepresentationData.js +1 -1
  50. package/dist/esm/stateManagement/segmentation/addSegmentation.d.ts +2 -0
  51. package/dist/esm/stateManagement/segmentation/addSegmentation.js +11 -0
  52. package/dist/esm/stateManagement/segmentation/addSegmentationRepresentation.js +29 -8
  53. package/dist/esm/stateManagement/segmentation/addSegmentationRepresentationState.d.ts +2 -0
  54. package/dist/esm/stateManagement/segmentation/addSegmentationRepresentationState.js +10 -0
  55. package/dist/esm/stateManagement/segmentation/config/segmentationColor.js +8 -6
  56. package/dist/esm/stateManagement/segmentation/config/segmentationConfig.js +14 -9
  57. package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js +8 -5
  58. package/dist/esm/stateManagement/segmentation/convertVolumeToStackSegmentation.d.ts +0 -8
  59. package/dist/esm/stateManagement/segmentation/convertVolumeToStackSegmentation.js +3 -33
  60. package/dist/esm/stateManagement/segmentation/events/triggerSegmentationDataModified.d.ts +1 -0
  61. package/dist/esm/stateManagement/segmentation/events/triggerSegmentationDataModified.js +11 -0
  62. package/dist/esm/stateManagement/segmentation/events/triggerSegmentationModified.d.ts +1 -0
  63. package/dist/esm/stateManagement/segmentation/events/triggerSegmentationModified.js +18 -0
  64. package/dist/esm/stateManagement/segmentation/events/triggerSegmentationRemoved.d.ts +1 -0
  65. package/dist/esm/stateManagement/segmentation/events/triggerSegmentationRemoved.js +8 -0
  66. package/dist/esm/stateManagement/segmentation/events/triggerSegmentationRepresentationModified.d.ts +1 -0
  67. package/dist/esm/stateManagement/segmentation/events/triggerSegmentationRepresentationModified.js +8 -0
  68. package/dist/esm/stateManagement/segmentation/events/triggerSegmentationRepresentationRemoved.d.ts +1 -0
  69. package/dist/esm/stateManagement/segmentation/events/triggerSegmentationRepresentationRemoved.js +8 -0
  70. package/dist/esm/stateManagement/segmentation/getActiveSegmentIndex.d.ts +1 -0
  71. package/dist/esm/stateManagement/segmentation/getActiveSegmentIndex.js +7 -0
  72. package/dist/esm/stateManagement/segmentation/getActiveSegmentationRepresentation.d.ts +2 -0
  73. package/dist/esm/stateManagement/segmentation/getActiveSegmentationRepresentation.js +5 -0
  74. package/dist/esm/stateManagement/segmentation/getAllSegmentationRepresentations.d.ts +2 -0
  75. package/dist/esm/stateManagement/segmentation/getAllSegmentationRepresentations.js +6 -0
  76. package/dist/esm/stateManagement/segmentation/getColorLUT.d.ts +2 -0
  77. package/dist/esm/stateManagement/segmentation/getColorLUT.js +5 -0
  78. package/dist/esm/stateManagement/segmentation/getCurrentLabelmapImageIdForViewport.d.ts +1 -0
  79. package/dist/esm/stateManagement/segmentation/getCurrentLabelmapImageIdForViewport.js +5 -0
  80. package/dist/esm/stateManagement/segmentation/getGlobalConfig.d.ts +2 -0
  81. package/dist/esm/stateManagement/segmentation/getGlobalConfig.js +5 -0
  82. package/dist/esm/stateManagement/segmentation/getNextColorLUTIndex.d.ts +1 -0
  83. package/dist/esm/stateManagement/segmentation/getNextColorLUTIndex.js +5 -0
  84. package/dist/esm/stateManagement/segmentation/getPerSegmentConfig.d.ts +2 -0
  85. package/dist/esm/stateManagement/segmentation/getPerSegmentConfig.js +5 -0
  86. package/dist/esm/stateManagement/segmentation/getSegmentation.d.ts +2 -0
  87. package/dist/esm/stateManagement/segmentation/getSegmentation.js +5 -0
  88. package/dist/esm/stateManagement/segmentation/getSegmentationRepresentation.d.ts +2 -0
  89. package/dist/esm/stateManagement/segmentation/getSegmentationRepresentation.js +5 -0
  90. package/dist/esm/stateManagement/segmentation/getSegmentationRepresentationConfig.d.ts +2 -0
  91. package/dist/esm/stateManagement/segmentation/getSegmentationRepresentationConfig.js +5 -0
  92. package/dist/esm/stateManagement/segmentation/getSegmentationRepresentationViewportStates.d.ts +7 -0
  93. package/dist/esm/stateManagement/segmentation/getSegmentationRepresentationViewportStates.js +6 -0
  94. package/dist/esm/stateManagement/segmentation/getSegmentationRepresentationVisibility.d.ts +1 -0
  95. package/dist/esm/stateManagement/segmentation/getSegmentationRepresentationVisibility.js +5 -0
  96. package/dist/esm/stateManagement/segmentation/getSegmentationRepresentations.d.ts +2 -0
  97. package/dist/esm/stateManagement/segmentation/getSegmentationRepresentations.js +12 -0
  98. package/dist/esm/stateManagement/segmentation/getSegmentationRepresentationsForSegmentation.d.ts +2 -0
  99. package/dist/esm/stateManagement/segmentation/getSegmentationRepresentationsForSegmentation.js +5 -0
  100. package/dist/esm/stateManagement/segmentation/getSegmentations.d.ts +2 -0
  101. package/dist/esm/stateManagement/segmentation/getSegmentations.js +6 -0
  102. package/dist/esm/stateManagement/segmentation/getViewportIdsWithSegmentation.d.ts +1 -0
  103. package/dist/esm/stateManagement/segmentation/getViewportIdsWithSegmentation.js +10 -0
  104. package/dist/esm/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.js +1 -1
  105. package/dist/esm/stateManagement/segmentation/helpers/updateStackSegmentationState.d.ts +8 -0
  106. package/dist/esm/stateManagement/segmentation/helpers/updateStackSegmentationState.js +31 -0
  107. package/dist/esm/stateManagement/segmentation/index.d.ts +1 -1
  108. package/dist/esm/stateManagement/segmentation/index.js +1 -1
  109. package/dist/esm/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js +3 -2
  110. package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.js +1 -1
  111. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.js +1 -1
  112. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.js +3 -3
  113. package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.js +2 -3
  114. package/dist/esm/stateManagement/segmentation/polySeg/Surface/createAndCacheSurfacesFromRaw.js +2 -1
  115. package/dist/esm/stateManagement/segmentation/polySeg/Surface/surfaceComputationStrategies.js +2 -2
  116. package/dist/esm/stateManagement/segmentation/polySeg/Surface/updateSurfaceData.js +2 -3
  117. package/dist/esm/stateManagement/segmentation/polySeg/canComputeRequestedRepresentation.js +3 -2
  118. package/dist/esm/stateManagement/segmentation/polySeg/computeAndAddRepresentation.js +1 -1
  119. package/dist/esm/stateManagement/segmentation/removeColorLUT.d.ts +1 -0
  120. package/dist/esm/stateManagement/segmentation/removeColorLUT.js +5 -0
  121. package/dist/esm/stateManagement/segmentation/removeRepresentation.d.ts +1 -0
  122. package/dist/esm/stateManagement/segmentation/removeRepresentation.js +9 -0
  123. package/dist/esm/stateManagement/segmentation/removeSegmentation.d.ts +1 -0
  124. package/dist/esm/stateManagement/segmentation/removeSegmentation.js +7 -0
  125. package/dist/esm/stateManagement/segmentation/removeSegmentationRepresentations.js +2 -2
  126. package/dist/esm/stateManagement/segmentation/segmentIndex.d.ts +2 -2
  127. package/dist/esm/stateManagement/segmentation/segmentIndex.js +5 -9
  128. package/dist/esm/stateManagement/segmentation/segmentLocking.js +1 -1
  129. package/dist/esm/stateManagement/segmentation/segmentationState.d.ts +29 -38
  130. package/dist/esm/stateManagement/segmentation/segmentationState.js +29 -157
  131. package/dist/esm/stateManagement/segmentation/setActiveSegmentationRepresentation.d.ts +1 -0
  132. package/dist/esm/stateManagement/segmentation/setActiveSegmentationRepresentation.js +9 -0
  133. package/dist/esm/stateManagement/segmentation/setGlobalConfig.d.ts +2 -0
  134. package/dist/esm/stateManagement/segmentation/setGlobalConfig.js +9 -0
  135. package/dist/esm/stateManagement/segmentation/setPerSegmentConfig.d.ts +2 -0
  136. package/dist/esm/stateManagement/segmentation/setPerSegmentConfig.js +9 -0
  137. package/dist/esm/stateManagement/segmentation/setSegmentationRepresentationConfig.d.ts +2 -0
  138. package/dist/esm/stateManagement/segmentation/setSegmentationRepresentationConfig.js +9 -0
  139. package/dist/esm/stateManagement/segmentation/setSegmentationRepresentationVisibility.d.ts +1 -0
  140. package/dist/esm/stateManagement/segmentation/setSegmentationRepresentationVisibility.js +5 -0
  141. package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.d.ts +5 -5
  142. package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.js +5 -45
  143. package/dist/esm/stateManagement/segmentation/updateLabelmapSegmentationImageReferences.d.ts +1 -0
  144. package/dist/esm/stateManagement/segmentation/updateLabelmapSegmentationImageReferences.js +5 -0
  145. package/dist/esm/store/SynchronizerManager/createSynchronizer.js +1 -1
  146. package/dist/esm/store/SynchronizerManager/destroy.js +1 -1
  147. package/dist/esm/store/SynchronizerManager/destroySynchronizer.js +1 -1
  148. package/dist/esm/store/SynchronizerManager/getAllSynchronizers.js +1 -1
  149. package/dist/esm/store/SynchronizerManager/getSynchronizer.js +1 -1
  150. package/dist/esm/store/SynchronizerManager/getSynchronizersForViewport.js +1 -1
  151. package/dist/esm/store/ToolGroupManager/ToolGroup.js +7 -6
  152. package/dist/esm/store/ToolGroupManager/createToolGroup.js +1 -1
  153. package/dist/esm/store/ToolGroupManager/destroy.js +3 -3
  154. package/dist/esm/store/ToolGroupManager/destroyToolGroup.js +1 -2
  155. package/dist/esm/store/ToolGroupManager/getAllToolGroups.js +1 -1
  156. package/dist/esm/store/ToolGroupManager/getToolGroup.js +1 -1
  157. package/dist/esm/store/ToolGroupManager/getToolGroupForViewport.js +1 -1
  158. package/dist/esm/store/ToolGroupManager/getToolGroupsWithToolName.js +1 -1
  159. package/dist/esm/store/addTool.d.ts +1 -0
  160. package/dist/esm/store/addTool.js +3 -0
  161. package/dist/esm/store/index.d.ts +1 -2
  162. package/dist/esm/store/index.js +1 -2
  163. package/dist/esm/tools/AdvancedMagnifyTool.d.ts +93 -2
  164. package/dist/esm/tools/AdvancedMagnifyTool.js +506 -4
  165. package/dist/esm/tools/AnnotationEraserTool.js +2 -2
  166. package/dist/esm/tools/CrosshairsTool.js +1 -1
  167. package/dist/esm/tools/MagnifyTool.js +1 -1
  168. package/dist/esm/tools/SculptorTool.js +3 -3
  169. package/dist/esm/tools/WindowLevelRegionTool.js +1 -1
  170. package/dist/esm/tools/annotation/AngleTool.js +4 -3
  171. package/dist/esm/tools/annotation/ArrowAnnotateTool.js +1 -1
  172. package/dist/esm/tools/annotation/BidirectionalTool.js +2 -3
  173. package/dist/esm/tools/annotation/CircleROITool.js +7 -8
  174. package/dist/esm/tools/annotation/CobbAngleTool.js +1 -1
  175. package/dist/esm/tools/annotation/EllipticalROITool.js +5 -6
  176. package/dist/esm/tools/annotation/HeightTool.js +2 -3
  177. package/dist/esm/tools/annotation/KeyImageTool.js +1 -1
  178. package/dist/esm/tools/annotation/LengthTool.js +2 -3
  179. package/dist/esm/tools/annotation/LivewireContourTool.js +3 -2
  180. package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts +1 -2
  181. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +7 -7
  182. package/dist/esm/tools/annotation/ProbeTool.js +3 -4
  183. package/dist/esm/tools/annotation/RectangleROITool.js +5 -6
  184. package/dist/esm/tools/annotation/SplineROITool.js +7 -4
  185. package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js +6 -7
  186. package/dist/esm/tools/annotation/VideoRedactionTool.js +1 -1
  187. package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +1 -1
  188. package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js +1 -1
  189. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js +2 -2
  190. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js +1 -1
  191. package/dist/esm/tools/annotation/planarFreehandROITool/renderMethods.js +1 -1
  192. package/dist/esm/tools/base/ContourBaseTool.js +2 -2
  193. package/dist/esm/tools/base/ContourSegmentationBaseTool.js +24 -15
  194. package/dist/esm/tools/displayTools/Contour/contourDisplay.js +9 -8
  195. package/dist/esm/tools/displayTools/Contour/contourHandler/handleContourSegmentation.js +3 -3
  196. package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.js +2 -1
  197. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.d.ts +1 -8
  198. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +19 -25
  199. package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js +10 -7
  200. package/dist/esm/tools/segmentation/BrushTool.js +10 -8
  201. package/dist/esm/tools/segmentation/CircleROIStartEndThresholdTool.js +4 -5
  202. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +7 -9
  203. package/dist/esm/tools/segmentation/SegmentSelectTool.js +1 -1
  204. package/dist/esm/tools/segmentation/strategies/compositions/preview.js +4 -4
  205. package/dist/esm/utilities/annotationHydration.js +1 -1
  206. package/dist/esm/utilities/contourSegmentation/addContourSegmentationAnnotation.js +1 -1
  207. package/dist/esm/utilities/contourSegmentation/removeContourSegmentationAnnotation.js +2 -2
  208. package/dist/esm/utilities/contours/generateContourSetsFromLabelmap.js +1 -1
  209. package/dist/esm/utilities/contours/getContourHolesDataWorld.js +1 -1
  210. package/dist/esm/utilities/contours/index.d.ts +1 -2
  211. package/dist/esm/utilities/contours/index.js +1 -2
  212. package/dist/esm/utilities/contours/updateContourPolyline.js +1 -1
  213. package/dist/esm/utilities/getToolsWithModesForElement.js +2 -2
  214. package/dist/esm/utilities/index.d.ts +1 -2
  215. package/dist/esm/utilities/index.js +1 -2
  216. package/dist/esm/utilities/math/line/distanceToPointSquaredInfo.js +3 -3
  217. package/dist/esm/utilities/math/polyline/isClosed.js +2 -2
  218. package/dist/esm/utilities/planarFreehandROITool/smoothAnnotation.js +3 -3
  219. package/dist/esm/utilities/segmentation/brushSizeForToolGroup.js +1 -1
  220. package/dist/esm/utilities/segmentation/brushThresholdForToolGroup.js +1 -1
  221. package/dist/esm/utilities/segmentation/getBrushToolInstances.d.ts +1 -0
  222. package/dist/esm/utilities/segmentation/getBrushToolInstances.js +17 -0
  223. package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.d.ts +0 -2
  224. package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.js +3 -22
  225. package/dist/esm/utilities/segmentation/index.d.ts +2 -2
  226. package/dist/esm/utilities/segmentation/index.js +2 -2
  227. package/dist/esm/utilities/segmentation/invalidateBrushCursor.js +1 -4
  228. package/dist/esm/utilities/segmentation/rectangleROIThresholdVolumeByRange.js +2 -1
  229. package/dist/esm/utilities/segmentation/segmentContourAction.js +5 -5
  230. package/dist/esm/utilities/segmentation/utilities.d.ts +4 -1
  231. package/dist/esm/utilities/segmentation/utilities.js +23 -17
  232. package/dist/esm/utilities/viewportFilters/filterViewportsWithToolEnabled.js +2 -2
  233. package/dist/umd/985.index.js.map +1 -1
  234. package/dist/umd/index.js +2 -1
  235. package/dist/umd/index.js.LICENSE.txt +6 -0
  236. package/dist/umd/index.js.map +1 -1
  237. package/package.json +5 -4
  238. package/dist/esm/stateManagement/segmentation/convertStackToVolumeSegmentation.d.ts +0 -17
  239. package/dist/esm/stateManagement/segmentation/convertStackToVolumeSegmentation.js +0 -50
  240. package/dist/esm/stateManagement/segmentation/helpers/getSegmentationRepresentationRenderingConfig.d.ts +0 -2
  241. package/dist/esm/stateManagement/segmentation/helpers/getSegmentationRepresentationRenderingConfig.js +0 -11
  242. package/dist/esm/tools/AdvancedMagnifyViewport.d.ts +0 -76
  243. package/dist/esm/tools/AdvancedMagnifyViewport.js +0 -351
  244. package/dist/esm/tools/AdvancedMagnifyViewportManager.d.ts +0 -38
  245. package/dist/esm/tools/AdvancedMagnifyViewportManager.js +0 -161
  246. package/dist/esm/utilities/contours/interpolation/index.d.ts +0 -2
  247. package/dist/esm/utilities/contours/interpolation/index.js +0 -2
  248. package/dist/esm/utilities/segmentation/triggerSegmentationRender.d.ts +0 -3
  249. package/dist/esm/utilities/segmentation/triggerSegmentationRender.js +0 -8
@@ -4,7 +4,7 @@ import createMergedLabelmapForIndex from './createMergedLabelmapForIndex';
4
4
  import isValidRepresentationConfig from './isValidRepresentationConfig';
5
5
  import getDefaultRepresentationConfig from './getDefaultRepresentationConfig';
6
6
  import createLabelmapVolumeForViewport from './createLabelmapVolumeForViewport';
7
- import { triggerSegmentationRender, triggerSegmentationRenderBySegmentationId } from './triggerSegmentationRender';
7
+ import { triggerSegmentationRender, triggerSegmentationRenderBySegmentationId } from '../../stateManagement/segmentation/SegmentationRenderingEngine';
8
8
  import floodFill from './floodFill';
9
9
  import { getBrushSizeForToolGroup, setBrushSizeForToolGroup } from './brushSizeForToolGroup';
10
10
  import { getBrushThresholdForToolGroup, setBrushThresholdForToolGroup } from './brushThresholdForToolGroup';
@@ -17,5 +17,5 @@ import { getUniqueSegmentIndices } from './getUniqueSegmentIndices';
17
17
  import { getSegmentIndexAtWorldPoint } from './getSegmentIndexAtWorldPoint';
18
18
  import { getSegmentIndexAtLabelmapBorder } from './getSegmentIndexAtLabelmapBorder';
19
19
  import { getHoveredContourSegmentationAnnotation } from './getHoveredContourSegmentationAnnotation';
20
- import { getBrushToolInstances } from './utilities';
20
+ import { getBrushToolInstances } from './getBrushToolInstances';
21
21
  export { thresholdVolumeByRange, createMergedLabelmapForIndex, isValidRepresentationConfig, getDefaultRepresentationConfig, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, };
@@ -4,7 +4,7 @@ import createMergedLabelmapForIndex from './createMergedLabelmapForIndex';
4
4
  import isValidRepresentationConfig from './isValidRepresentationConfig';
5
5
  import getDefaultRepresentationConfig from './getDefaultRepresentationConfig';
6
6
  import createLabelmapVolumeForViewport from './createLabelmapVolumeForViewport';
7
- import { triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, } from './triggerSegmentationRender';
7
+ import { triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, } from '../../stateManagement/segmentation/SegmentationRenderingEngine';
8
8
  import floodFill from './floodFill';
9
9
  import { getBrushSizeForToolGroup, setBrushSizeForToolGroup, } from './brushSizeForToolGroup';
10
10
  import { getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, } from './brushThresholdForToolGroup';
@@ -17,5 +17,5 @@ import { getUniqueSegmentIndices } from './getUniqueSegmentIndices';
17
17
  import { getSegmentIndexAtWorldPoint } from './getSegmentIndexAtWorldPoint';
18
18
  import { getSegmentIndexAtLabelmapBorder } from './getSegmentIndexAtLabelmapBorder';
19
19
  import { getHoveredContourSegmentationAnnotation } from './getHoveredContourSegmentationAnnotation';
20
- import { getBrushToolInstances } from './utilities';
20
+ import { getBrushToolInstances } from './getBrushToolInstances';
21
21
  export { thresholdVolumeByRange, createMergedLabelmapForIndex, isValidRepresentationConfig, getDefaultRepresentationConfig, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, triggerSegmentationRenderBySegmentationId, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, };
@@ -1,7 +1,6 @@
1
1
  import { getToolGroup } from '../../store/ToolGroupManager';
2
2
  import triggerAnnotationRenderForViewportIds from '../triggerAnnotationRenderForViewportIds';
3
- import { getRenderingEngine } from '@cornerstonejs/core';
4
- import { getBrushToolInstances } from './utilities';
3
+ import { getBrushToolInstances } from './getBrushToolInstances';
5
4
  export function invalidateBrushCursor(toolGroupId) {
6
5
  const toolGroup = getToolGroup(toolGroupId);
7
6
  if (toolGroup === undefined) {
@@ -16,8 +15,6 @@ export function invalidateBrushCursor(toolGroupId) {
16
15
  if (!viewportsInfoArray.length) {
17
16
  return;
18
17
  }
19
- const { renderingEngineId } = viewportsInfoArray[0];
20
18
  const viewportIds = toolGroup.getViewportIds();
21
- const renderingEngine = getRenderingEngine(renderingEngineId);
22
19
  triggerAnnotationRenderForViewportIds(viewportIds);
23
20
  }
@@ -1,5 +1,6 @@
1
1
  import { state } from '../../stateManagement/annotation';
2
- import { RectangleROIStartEndThresholdTool, RectangleROIThresholdTool, } from '../../tools';
2
+ import RectangleROIStartEndThresholdTool from '../../tools/segmentation/RectangleROIStartEndThresholdTool';
3
+ import RectangleROIThresholdTool from '../../tools/segmentation/RectangleROIThresholdTool';
3
4
  import thresholdVolumeByRange from './thresholdVolumeByRange';
4
5
  import getBoundsIJKFromRectangleAnnotations from '../rectangleROITool/getBoundsIJKFromRectangleAnnotations';
5
6
  function rectangleROIThresholdVolumeByRange(annotationUIDs, segmentationVolume, thresholdVolumeInformation, options) {
@@ -1,10 +1,11 @@
1
1
  import { getEnabledElement } from '@cornerstonejs/core';
2
- import * as segmentation from '../../stateManagement/segmentation';
3
2
  import { state as annotationState, config as annotationConfig, } from '../../stateManagement/annotation';
4
3
  import { jumpToSlice } from '../viewport';
5
4
  import contourAndFindLargestBidirectional from './contourAndFindLargestBidirectional';
6
5
  import createBidirectionalToolData from './createBidirectionalToolData';
7
6
  import BidirectionalTool from '../../tools/annotation/BidirectionalTool';
7
+ import { getSegmentations } from '../../stateManagement/segmentation/getSegmentations';
8
+ import { getActiveSegmentIndex } from '../../stateManagement/segmentation/getActiveSegmentIndex';
8
9
  export default function segmentContourAction(element, configuration) {
9
10
  const { data: configurationData } = configuration;
10
11
  const enabledElement = getEnabledElement(element);
@@ -13,7 +14,7 @@ export default function segmentContourAction(element, configuration) {
13
14
  return;
14
15
  }
15
16
  const FrameOfReferenceUID = enabledElement.viewport.getFrameOfReferenceUID();
16
- const segmentationsList = segmentation.state.getSegmentations();
17
+ const segmentationsList = getSegmentations();
17
18
  const { segmentIndex, segmentationId } = segment;
18
19
  const bidirectionals = annotationState.getAnnotations(this.toolName || BidirectionalTool.toolName, FrameOfReferenceUID);
19
20
  let hasExistingActiveSegment = false;
@@ -76,13 +77,12 @@ export default function segmentContourAction(element, configuration) {
76
77
  return newBidirectional;
77
78
  }
78
79
  export function defaultGetSegment(enabledElement, configuration) {
79
- const segmentationsList = segmentation.state.getSegmentations();
80
+ const segmentationsList = getSegmentations();
80
81
  if (!segmentationsList.length) {
81
82
  return;
82
83
  }
83
84
  const segmentationId = configuration.segmentationId || segmentationsList[0].segmentationId;
84
- const segmentIndex = configuration.segmentIndex ??
85
- segmentation.segmentIndex.getActiveSegmentIndex(segmentationId);
85
+ const segmentIndex = configuration.segmentIndex ?? getActiveSegmentIndex(segmentationId);
86
86
  if (!segmentIndex) {
87
87
  return;
88
88
  }
@@ -14,9 +14,12 @@ export type VolumeInfo = {
14
14
  volumeSize: number;
15
15
  voxelManager: Types.IVoxelManager<number> | Types.IVoxelManager<Types.RGB>;
16
16
  };
17
- export declare function getBrushToolInstances(toolGroupId: string, toolName?: string): any[];
18
17
  export declare function getVoxelOverlap(imageData: any, dimensions: any, voxelSpacing: any, voxelCenter: any): [Types.Point2, Types.Point2, null] | [Types.Point2, Types.Point2, Types.Point2];
19
18
  export declare function processVolumes(segmentationVolume: Types.IImageVolume, thresholdVolumeInformation: ThresholdInformation[]): {
20
19
  volumeInfoList: VolumeInfo[];
21
20
  baseVolumeIdx: number;
22
21
  };
22
+ export declare const setSegmentationDirty: (segmentationId: string) => void;
23
+ export declare const setSegmentationClean: (segmentationId: string) => void;
24
+ export declare const getCachedSegmentIndices: (segmentationId: string) => number[];
25
+ export declare const setCachedSegmentIndices: (segmentationId: string, indices: number[]) => void;
@@ -1,22 +1,5 @@
1
1
  import { utilities as csUtils } from '@cornerstonejs/core';
2
- import { getToolGroup } from '../../store/ToolGroupManager';
3
- import BrushTool from '../../tools/segmentation/BrushTool';
4
2
  import { getBoundingBoxAroundShapeIJK } from '../boundingBox/getBoundingBoxAroundShape';
5
- export function getBrushToolInstances(toolGroupId, toolName) {
6
- const toolGroup = getToolGroup(toolGroupId);
7
- if (toolGroup === undefined) {
8
- return;
9
- }
10
- const toolInstances = toolGroup._toolInstances;
11
- if (!Object.keys(toolInstances).length) {
12
- return;
13
- }
14
- if (toolName && toolInstances[toolName]) {
15
- return [toolInstances[toolName]];
16
- }
17
- const brushBasedToolInstances = Object.values(toolInstances).filter((toolInstance) => toolInstance instanceof BrushTool);
18
- return brushBasedToolInstances;
19
- }
20
3
  const equalsCheck = (a, b) => {
21
4
  return JSON.stringify(a) === JSON.stringify(b);
22
5
  };
@@ -66,3 +49,26 @@ export function processVolumes(segmentationVolume, thresholdVolumeInformation) {
66
49
  baseVolumeIdx,
67
50
  };
68
51
  }
52
+ const segmentIndicesCache = new Map();
53
+ export const setSegmentationDirty = (segmentationId) => {
54
+ const cached = segmentIndicesCache.get(segmentationId);
55
+ if (cached) {
56
+ cached.isDirty = true;
57
+ }
58
+ };
59
+ export const setSegmentationClean = (segmentationId) => {
60
+ const cached = segmentIndicesCache.get(segmentationId);
61
+ if (cached) {
62
+ cached.isDirty = false;
63
+ }
64
+ };
65
+ export const getCachedSegmentIndices = (segmentationId) => {
66
+ const cached = segmentIndicesCache.get(segmentationId);
67
+ if (cached && !cached.isDirty) {
68
+ return cached.indices;
69
+ }
70
+ return null;
71
+ };
72
+ export const setCachedSegmentIndices = (segmentationId, indices) => {
73
+ segmentIndicesCache.set(segmentationId, { indices, isDirty: false });
74
+ };
@@ -1,12 +1,12 @@
1
- import { ToolGroupManager } from '../../store';
2
1
  import { ToolModes } from '../../enums';
2
+ import { getToolGroupForViewport } from '../../store/ToolGroupManager';
3
3
  const { Active, Passive, Enabled } = ToolModes;
4
4
  export default function filterViewportsWithToolEnabled(viewports, toolName) {
5
5
  const numViewports = viewports.length;
6
6
  const viewportsWithToolEnabled = [];
7
7
  for (let vp = 0; vp < numViewports; vp++) {
8
8
  const viewport = viewports[vp];
9
- const toolGroup = ToolGroupManager.getToolGroupForViewport(viewport.id, viewport.renderingEngineId);
9
+ const toolGroup = getToolGroupForViewport(viewport.id, viewport.renderingEngineId);
10
10
  if (!toolGroup) {
11
11
  continue;
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"985.index.js","mappings":"CAAA,SAA2CA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,YAAa,KACpF/C,EAAoBlP,EAAIyR,C,WCdxB,IAAIS,EAAkB,CACrB,IAAK,GAkBNhD,EAAoB0B,EAAE7Q,EAAI,CAAC8Q,EAASpG,KAE/ByH,EAAgBrB,IAElBa,cAAcxC,EAAoBlP,EAAIkP,EAAoB6B,EAAEF,GAE9D,EAGD,IAAIsB,EAAqBjU,KAAqC,+BAAIA,KAAqC,gCAAK,GACxGkU,EAA6BD,EAAmBhR,KAAKkR,KAAKF,GAC9DA,EAAmBhR,KAzBCgK,IACnB,IAAIsE,EAAWtE,EAAK,GAChBmH,EAAcnH,EAAK,GACnBoH,EAAUpH,EAAK,GACnB,IAAI,IAAIgE,KAAYmD,EAChBpD,EAAoBuB,EAAE6B,EAAanD,KACrCD,EAAoBI,EAAEH,GAAYmD,EAAYnD,IAIhD,IADGoD,GAASA,EAAQrD,GACdO,EAASpQ,QACd6S,EAAgBzC,EAAS+C,OAAS,EACnCJ,EAA2BjH,EAAK,C,KzBrB7BvM,EAAOsQ,EAAoBrL,EAC/BqL,EAAoBrL,EAAI,IAChBqL,EAAoBlB,EAAE,IAAIvI,KAAK7G,G0BDbsQ,EAAoBrL,G","sources":["webpack://cornerstoneTools3D/webpack/universalModuleDefinition","webpack://cornerstoneTools3D/webpack/runtime/chunk loaded","webpack://cornerstoneTools3D/webpack/runtime/startup chunk dependencies","webpack://cornerstoneTools3D/./src/utilities/boundingBox/getBoundingBoxAroundShape.ts","webpack://cornerstoneTools3D/./src/utilities/math/polyline/projectTo2D.ts","webpack://cornerstoneTools3D/./src/utilities/math/polyline/containsPoint.ts","webpack://cornerstoneTools3D/./src/utilities/math/polyline/isClosed.ts","webpack://cornerstoneTools3D/./src/utilities/math/point/distanceToPointSquared.ts","webpack://cornerstoneTools3D/./src/utilities/math/polyline/getAABB.ts","webpack://cornerstoneTools3D/./src/utilities/planar/isPlaneIntersectingAABB.ts","webpack://cornerstoneTools3D/./src/workers/polySegConverters.js","webpack://cornerstoneTools3D/external umd \"@kitware/vtk.js/Common/Core/DataArray\"","webpack://cornerstoneTools3D/external umd \"@kitware/vtk.js/Common/DataModel/ImageData\"","webpack://cornerstoneTools3D/external umd \"@kitware/vtk.js/Common/DataModel/Plane\"","webpack://cornerstoneTools3D/external umd \"@kitware/vtk.js/Common/DataModel/PolyData\"","webpack://cornerstoneTools3D/external umd \"@kitware/vtk.js/Filters/Core/Cutter\"","webpack://cornerstoneTools3D/external umd \"@kitware/vtk.js/Filters/General/ContourLoopExtraction\"","webpack://cornerstoneTools3D/external umd {\"root\":\"cornerstone3D\",\"commonjs\":\"@cornerstonejs/core\",\"commonjs2\":\"@cornerstonejs/core\",\"amd\":\"@cornerstonejs/core\"}","webpack://cornerstoneTools3D/external umd {\"root\":\"window\",\"commonjs\":\"gl-matrix\",\"commonjs2\":\"gl-matrix\",\"amd\":\"gl-matrix\"}","webpack://cornerstoneTools3D/webpack/bootstrap","webpack://cornerstoneTools3D/webpack/runtime/compat get default export","webpack://cornerstoneTools3D/webpack/runtime/define property getters","webpack://cornerstoneTools3D/webpack/runtime/ensure chunk","webpack://cornerstoneTools3D/webpack/runtime/get javascript chunk filename","webpack://cornerstoneTools3D/webpack/runtime/global","webpack://cornerstoneTools3D/webpack/runtime/hasOwnProperty shorthand","webpack://cornerstoneTools3D/webpack/runtime/publicPath","webpack://cornerstoneTools3D/webpack/runtime/importScripts chunk loading","webpack://cornerstoneTools3D/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"@cornerstonejs/core\"), require(\"@kitware/vtk.js/Common/DataModel/ImageData\"), require(\"@kitware/vtk.js/Common/Core/DataArray\"), require(\"@kitware/vtk.js/Common/DataModel/Plane\"), require(\"@kitware/vtk.js/Common/DataModel/PolyData\"), require(\"@kitware/vtk.js/Filters/General/ContourLoopExtraction\"), require(\"@kitware/vtk.js/Filters/Core/Cutter\"), require(\"gl-matrix\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"@cornerstonejs/core\", \"@kitware/vtk.js/Common/DataModel/ImageData\", \"@kitware/vtk.js/Common/Core/DataArray\", \"@kitware/vtk.js/Common/DataModel/Plane\", \"@kitware/vtk.js/Common/DataModel/PolyData\", \"@kitware/vtk.js/Filters/General/ContourLoopExtraction\", \"@kitware/vtk.js/Filters/Core/Cutter\", \"gl-matrix\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"cornerstoneTools3D\"] = factory(require(\"@cornerstonejs/core\"), require(\"@kitware/vtk.js/Common/DataModel/ImageData\"), require(\"@kitware/vtk.js/Common/Core/DataArray\"), require(\"@kitware/vtk.js/Common/DataModel/Plane\"), require(\"@kitware/vtk.js/Common/DataModel/PolyData\"), require(\"@kitware/vtk.js/Filters/General/ContourLoopExtraction\"), require(\"@kitware/vtk.js/Filters/Core/Cutter\"), require(\"gl-matrix\"));\n\telse\n\t\troot[\"cornerstoneTools3D\"] = factory(root[\"cornerstone3D\"], root[\"@kitware/vtk.js/Common/DataModel/ImageData\"], root[\"@kitware/vtk.js/Common/Core/DataArray\"], root[\"@kitware/vtk.js/Common/DataModel/Plane\"], root[\"@kitware/vtk.js/Common/DataModel/PolyData\"], root[\"@kitware/vtk.js/Filters/General/ContourLoopExtraction\"], root[\"@kitware/vtk.js/Filters/Core/Cutter\"], root[\"window\"]);\n})(self, (__WEBPACK_EXTERNAL_MODULE__953__, __WEBPACK_EXTERNAL_MODULE__283__, __WEBPACK_EXTERNAL_MODULE__785__, __WEBPACK_EXTERNAL_MODULE__864__, __WEBPACK_EXTERNAL_MODULE__70__, __WEBPACK_EXTERNAL_MODULE__336__, __WEBPACK_EXTERNAL_MODULE__481__, __WEBPACK_EXTERNAL_MODULE__976__) => {\nreturn ","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar chunkIds = deferred[i][0];\n\t\tvar fn = deferred[i][1];\n\t\tvar priority = deferred[i][2];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","var next = __webpack_require__.x;\n__webpack_require__.x = () => {\n\treturn __webpack_require__.e(78).then(next);\n};","import type { Types } from '@cornerstonejs/core';\nimport { CONSTANTS } from '@cornerstonejs/core';\n\nconst { EPSILON } = CONSTANTS;\n\n/** Bounding box type */\ntype BoundingBox =\n | [Types.Point2, Types.Point2, null]\n | [Types.Point2, Types.Point2, Types.Point2];\n\nfunction calculateBoundingBox(\n points,\n dimensions,\n isWorld = false\n): BoundingBox {\n let xMin = Infinity;\n let xMax = isWorld ? -Infinity : 0;\n let yMin = Infinity;\n let yMax = isWorld ? -Infinity : 0;\n let zMin = Infinity;\n let zMax = isWorld ? -Infinity : 0;\n\n const is3D = points[0]?.length === 3;\n\n // use for loop for performance\n for (let i = 0; i < points.length; i++) {\n const p = points[i];\n xMin = Math.min(p[0], xMin);\n xMax = Math.max(p[0], xMax);\n yMin = Math.min(p[1], yMin);\n yMax = Math.max(p[1], yMax);\n\n if (is3D) {\n zMin = Math.min(p[2] ?? zMin, zMin);\n zMax = Math.max(p[2] ?? zMax, zMax);\n }\n }\n\n if (dimensions) {\n xMin = Math.max(isWorld ? dimensions[0] + EPSILON : 0, xMin);\n xMax = Math.min(\n isWorld ? dimensions[0] - EPSILON : dimensions[0] - 1,\n xMax\n );\n yMin = Math.max(isWorld ? dimensions[1] + EPSILON : 0, yMin);\n yMax = Math.min(\n isWorld ? dimensions[1] - EPSILON : dimensions[1] - 1,\n yMax\n );\n\n if (is3D && dimensions.length === 3) {\n zMin = Math.max(isWorld ? dimensions[2] + EPSILON : 0, zMin);\n zMax = Math.min(\n isWorld ? dimensions[2] - EPSILON : dimensions[2] - 1,\n zMax\n );\n }\n } else if (!isWorld) {\n // still need to bound to 0 and Infinity if no dimensions are provided for ijk\n xMin = Math.max(0, xMin);\n xMax = Math.min(Infinity, xMax);\n yMin = Math.max(0, yMin);\n yMax = Math.min(Infinity, yMax);\n\n if (is3D) {\n zMin = Math.max(0, zMin);\n zMax = Math.min(Infinity, zMax);\n }\n }\n\n return is3D\n ? [\n [xMin, xMax],\n [yMin, yMax],\n [zMin, zMax],\n ]\n : [[xMin, xMax], [yMin, yMax], null];\n}\n\n/**\n * With a given vertices (points) coordinates in 2D or 3D in IJK, it calculates the minimum and maximum\n * coordinate in each axis, and returns them. If clipBounds are provided it also\n * clip the min, max to the provided width, height and depth\n *\n * @param points - shape corner points coordinates either in IJK (image coordinate)\n * @param dimensions - bounds to clip the min, max\n * @returns [[xMin,xMax],[yMin,yMax], [zMin,zMax]]\n */\nexport function getBoundingBoxAroundShapeIJK(\n points: Types.Point2[] | Types.Point3[],\n dimensions?: Types.Point2 | Types.Point3\n): BoundingBox {\n return calculateBoundingBox(points, dimensions, false);\n}\n\n/**\n * With a given vertices (points) coordinates in 2D or 3D in World Coordinates, it calculates the minimum and maximum\n * coordinate in each axis, and returns them. If clipBounds are provided it also\n * clip the min, max to the provided width, height and depth\n *\n * @param points - shape corner points coordinates either in IJK (image coordinate)\n * @param clipBounds - bounds to clip the min, max\n * @returns [[xMin,xMax],[yMin,yMax], [zMin,zMax]]\n */\nexport function getBoundingBoxAroundShapeWorld(\n points: Types.Point2[] | Types.Point3[],\n clipBounds?: Types.Point2 | Types.Point3\n): BoundingBox {\n return calculateBoundingBox(points, clipBounds, true);\n}\n","import { utilities } from '@cornerstonejs/core';\nimport type { Types } from '@cornerstonejs/core';\n\nconst epsilon = 1e-6;\n\n/**\n * Projects a polyline from 3D to 2D by reducing one dimension.\n *\n * @param polyline - The polyline to be projected.\n * @returns An object containing the shared dimension index and the projected polyline in 2D.\n * @throws Error if a shared dimension index cannot be found for the polyline.\n */\nexport function projectTo2D(polyline: Types.Point3[]) {\n // We need to reduce one dimension to 2D, so basically\n // we need to find the dimension index that is shared by all points\n // Use the first three points, two is enough but three is more robust\n let sharedDimensionIndex;\n\n const testPoints = utilities.getRandomSampleFromArray(polyline, 50);\n\n for (let i = 0; i < 3; i++) {\n if (\n testPoints.every(\n (point, index, array) => Math.abs(point[i] - array[0][i]) < epsilon\n )\n ) {\n sharedDimensionIndex = i;\n break;\n }\n }\n\n if (sharedDimensionIndex === undefined) {\n throw new Error(\n 'Cannot find a shared dimension index for polyline, probably oblique plane'\n );\n }\n\n // convert polyline list and point to 2D\n const points2D = [] as Types.Point2[];\n\n const firstDim = (sharedDimensionIndex + 1) % 3;\n const secondDim = (sharedDimensionIndex + 2) % 3;\n\n for (let i = 0; i < polyline.length; i++) {\n points2D.push([polyline[i][firstDim], polyline[i][secondDim]]);\n }\n\n return {\n sharedDimensionIndex,\n projectedPolyline: points2D,\n };\n}\n","import type { Types } from '@cornerstonejs/core';\nimport isClosed from './isClosed';\n\n/**\n * Checks if a 2D point is inside the polyline.\n *\n * A point is inside a curve/polygon if the number of intersections between the horizontal\n * ray emanating from the given point and to the right and the line segments is odd.\n * https://www.eecs.umich.edu/courses/eecs380/HANDOUTS/PROJ2/InsidePoly.html\n *\n * Note that a point on the polyline is considered inside.\n *\n * @param polyline - Polyline points (2D)\n * @param point - 2D Point\n * @returns True if the point is inside the polyline or false otherwise\n */\nexport default function containsPoint(\n polyline: Types.Point2[],\n point: Types.Point2,\n options: {\n closed?: boolean;\n holes?: Types.Point2[][];\n } = {\n closed: undefined,\n }\n): boolean {\n if (polyline.length < 3) {\n return false;\n }\n\n const numPolylinePoints = polyline.length;\n let numIntersections = 0;\n\n const { closed, holes } = options;\n\n if (holes?.length) {\n for (const hole of holes) {\n if (containsPoint(hole, point)) {\n return false;\n }\n }\n }\n\n // Test intersection against [end, start] line segment if it should be closed\n const shouldClose = !(closed === undefined ? isClosed(polyline) : closed);\n const maxSegmentIndex = polyline.length - (shouldClose ? 1 : 2);\n\n for (let i = 0; i <= maxSegmentIndex; i++) {\n const p1 = polyline[i];\n\n // Calculating the next point index without using % (mod) operator like in\n // `(i + 1) % numPolylinePoints` to make it 20% faster\n const p2Index = i === numPolylinePoints - 1 ? 0 : i + 1;\n const p2 = polyline[p2Index];\n\n // Calculating min/max without using Math.min/max to make it ~3% faster\n const maxX = p1[0] >= p2[0] ? p1[0] : p2[0];\n const maxY = p1[1] >= p2[1] ? p1[1] : p2[1];\n const minY = p1[1] <= p2[1] ? p1[1] : p2[1];\n\n const mayIntersectLineSegment =\n point[0] <= maxX && point[1] >= minY && point[1] < maxY;\n\n if (mayIntersectLineSegment) {\n const isVerticalLine = p1[0] === p2[0];\n let intersects = isVerticalLine;\n\n if (!intersects) {\n const xIntersection =\n ((point[1] - p1[1]) * (p2[0] - p1[0])) / (p2[1] - p1[1]) + p1[0];\n\n intersects = point[0] <= xIntersection;\n }\n\n numIntersections += intersects ? 1 : 0;\n }\n }\n\n return !!(numIntersections % 2);\n}\n","import { glMatrix } from 'gl-matrix';\nimport type { Types } from '@cornerstonejs/core';\nimport * as math from '..';\n\n/**\n * A polyline is considered closed if the start and end points are at the same position\n *\n * @param polyline - Polyline points (2D)\n * @returns True if the polyline is already closed or false otherwise\n */\nexport default function isClosed(polyline: Types.Point2[]): boolean {\n if (polyline.length < 3) {\n return false;\n }\n\n const numPolylinePoints = polyline.length;\n\n const firstPoint = polyline[0];\n const lastPoint = polyline[numPolylinePoints - 1];\n const distFirstToLastPoints = math.point.distanceToPointSquared(\n firstPoint,\n lastPoint\n );\n\n return glMatrix.equals(0, distFirstToLastPoints);\n}\n","import type { Types } from '@cornerstonejs/core';\n\ntype Point = Types.Point2 | Types.Point3;\n\n/**\n * Calculates the distance squared of a point to another point\n *\n * @param p1 - x,y or x,y,z of the point\n * @param p2 - x,y or x,y,z of the point\n * @returns distance\n */\nexport default function distanceToPointSquared(p1: Point, p2: Point): number {\n if (p1.length !== p2.length) {\n throw Error('Both points should have the same dimensionality');\n }\n\n const [x1, y1, z1 = 0] = p1;\n const [x2, y2, z2 = 0] = p2;\n const dx = x2 - x1;\n const dy = y2 - y1;\n const dz = z2 - z1;\n\n // Time to square 10M numbers:\n // (n * n) = 161ms | (n ** 2) = 199ms | Math.pow(n, 2) = 29529ms\n return dx * dx + dy * dy + dz * dz;\n}\n","import type { Types } from '@cornerstonejs/core';\n\n/**\n * Calculates the axis-aligned bounding box (AABB) of a polyline.\n *\n * @param polyline - The polyline represented as an array of points.\n * @param options - Additional options for calculating the AABB.\n * @param options.isWorld - Indicates whether the polyline represents points in 3D space (true) or 2D space (false).\n *\n * @returns The AABB of the polyline. If the polyline represents points in 3D space, returns an AABB3 object with properties minX, maxX, minY, maxY, minZ, and maxZ. If the polyline represents points in 2D space, returns an AABB2 object with properties minX, maxX, minY, and maxY.\n */\nexport default function getAABB(\n polyline: Types.Point2[] | Types.Point3[] | number[],\n options?: {\n numDimensions: number;\n }\n): Types.AABB2 | Types.AABB3 {\n // need to check if the polyline is array of arrays or just\n // a flat array of numbers\n let polylineToUse = polyline;\n const numDimensions = options?.numDimensions || 2;\n const is3D = numDimensions === 3;\n\n if (!Array.isArray(polyline[0])) {\n const currentPolyline = polyline as number[];\n // check the isWorld flag is provided or not which means every\n // 3 elements in the array represent a point in 3D space\n // otherwise, every 2 elements in the array represent a point in 2D space\n const totalPoints = currentPolyline.length / numDimensions;\n\n polylineToUse = new Array(currentPolyline.length / numDimensions) as\n | Types.Point2[]\n | Types.Point3[];\n\n for (let i = 0, len = totalPoints; i < len; i++) {\n polylineToUse[i] = [\n currentPolyline[i * numDimensions],\n currentPolyline[i * numDimensions + 1],\n ];\n\n if (is3D) {\n polylineToUse[i].push(currentPolyline[i * numDimensions + 2]);\n }\n }\n }\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n let minZ = Infinity;\n let maxZ = -Infinity;\n\n polylineToUse = polylineToUse as Types.Point2[] | Types.Point3[];\n\n for (let i = 0, len = polylineToUse.length; i < len; i++) {\n const [x, y, z] = polylineToUse[i];\n\n // No Math.min/max calls for better performance\n minX = minX < x ? minX : x;\n minY = minY < y ? minY : y;\n maxX = maxX > x ? maxX : x;\n maxY = maxY > y ? maxY : y;\n\n if (is3D) {\n minZ = minZ < z ? minZ : z;\n maxZ = maxZ > z ? maxZ : z;\n }\n }\n\n return is3D\n ? { minX, maxX, minY, maxY, minZ, maxZ } // AABB3\n : { minX, maxX, minY, maxY }; // AABB2\n}\n","import { vec3 } from 'gl-matrix';\n\n/**\n * Checks if a plane intersects with an Axis-Aligned Bounding Box (AABB).\n *\n * @param origin - The origin point of the plane.\n * @param normal - The normal vector of the plane.\n * @param minX - The minimum x-coordinate of the AABB.\n * @param minY - The minimum y-coordinate of the AABB.\n * @param minZ - The minimum z-coordinate of the AABB.\n * @param maxX - The maximum x-coordinate of the AABB.\n * @param maxY - The maximum y-coordinate of the AABB.\n * @param maxZ - The maximum z-coordinate of the AABB.\n * @returns A boolean indicating whether the plane intersects with the AABB.\n */\nexport const isPlaneIntersectingAABB = (\n origin,\n normal,\n minX,\n minY,\n minZ,\n maxX,\n maxY,\n maxZ\n) => {\n const vertices = [\n vec3.fromValues(minX, minY, minZ),\n vec3.fromValues(maxX, minY, minZ),\n vec3.fromValues(minX, maxY, minZ),\n vec3.fromValues(maxX, maxY, minZ),\n vec3.fromValues(minX, minY, maxZ),\n vec3.fromValues(maxX, minY, maxZ),\n vec3.fromValues(minX, maxY, maxZ),\n vec3.fromValues(maxX, maxY, maxZ),\n ];\n\n const normalVec = vec3.fromValues(normal[0], normal[1], normal[2]);\n const originVec = vec3.fromValues(origin[0], origin[1], origin[2]);\n\n // Compute the distance from the plane to the origin using vec3.dot\n const planeDistance = -vec3.dot(normalVec, originVec);\n\n // Check if all vertices are on the same side of the plane\n let initialSign = null;\n for (const vertex of vertices) {\n // Calculate distance using vec3.dot to simplify the equation\n const distance = vec3.dot(normalVec, vertex) + planeDistance;\n if (initialSign === null) {\n initialSign = Math.sign(distance);\n } else if (Math.sign(distance) !== initialSign) {\n return true; // Found a vertex on the other side, so it intersects\n }\n }\n\n return false;\n};\n","import { expose } from 'comlink';\nimport { utilities } from '@cornerstonejs/core';\nimport vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';\nimport vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';\nimport ICRPolySeg from '@icr/polyseg-wasm';\nimport vtkPlane from '@kitware/vtk.js/Common/DataModel/Plane';\nimport vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';\nimport vtkContourLoopExtraction from '@kitware/vtk.js/Filters/General/ContourLoopExtraction';\nimport vtkCutter from '@kitware/vtk.js/Filters/Core/Cutter';\n\nimport { getBoundingBoxAroundShapeWorld } from '../utilities/boundingBox';\nimport {\n containsPoint,\n getAABB,\n projectTo2D,\n} from '../utilities/math/polyline';\nimport { isPlaneIntersectingAABB } from '../utilities/planar';\n\n/**\n * Object containing methods for converting between different representations of\n * segmentations (e.g., contour, labelmap, surface, etc.) These logics\n * are used in a webworker to avoid blocking the main thread. You can\n * search for workerManager.executeTask('polySeg', ...) to see\n * how these methods are used.\n *\n * See also the webworker docs at packages/docs/docs/concepts/cornerstone-core/web-worker.md\n * to learn more about how to use web-workers in the context of Cornerstone.\n */\nconst polySegConverters = {\n /**\n * The polySeg instance that is used to convert between different representations\n */\n polySeg: null,\n /**\n * Utilities to keep track of the initialization state of the polySeg instance\n * and avoid initializing it multiple times\n */\n polySegInitializing: false,\n polySegInitializingPromise: null,\n /**\n * This method initializes the polySeg instance and sets it to this.polySeg\n */\n async initializePolySeg(progressCallback) {\n if (this.polySegInitializing) {\n await this.polySegInitializingPromise;\n return;\n }\n\n if (this.polySeg?.instance) {\n return;\n }\n\n this.polySegInitializing = true;\n this.polySegInitializingPromise = new Promise((resolve) => {\n this.polySeg = new ICRPolySeg();\n this.polySeg\n .initialize({\n updateProgress: progressCallback,\n })\n .then(() => {\n this.polySegInitializing = false;\n resolve();\n });\n });\n\n await this.polySegInitializingPromise;\n },\n /**\n * Converts a contour to a surface using the PolySeg library.\n * @param {Object} args - The arguments for the conversion.\n * @param {Array} args.polylines - The polylines representing the contour.\n * @param {Array} args.numPointsArray - The number of points in each polyline.\n * @param {...Function} callbacks - Optional callback functions.\n * @returns {Promise} - A promise that resolves to the converted surface.\n */\n async convertContourToSurface(args, ...callbacks) {\n const { polylines, numPointsArray } = args;\n const [progressCallback] = callbacks;\n await this.initializePolySeg(progressCallback);\n const results = await this.polySeg.instance.convertContourRoiToSurface(\n polylines,\n numPointsArray\n );\n\n return results;\n },\n /**\n * Converts a labelmap to a surface using the specified arguments.\n * @param {Object} args - The arguments for the conversion.\n * @param {Array} args.scalarData - The scalar data of the labelmap.\n * @param {Array} args.dimensions - The dimensions of the labelmap.\n * @param {Array} args.spacing - The spacing of the labelmap.\n * @param {Array} args.direction - The direction of the labelmap.\n * @param {Array} args.origin - The origin of the labelmap.\n * @param {number} args.segmentIndex - The segment index of the labelmap.\n * @param {Function} progressCallback - The callback function for progress updates.\n * @returns {Promise} - A promise that resolves with the converted surface results.\n */\n async convertLabelmapToSurface(args, ...callbacks) {\n const [progressCallback] = callbacks;\n await this.initializePolySeg(progressCallback);\n\n const results = this.polySeg.instance.convertLabelmapToSurface(\n args.scalarData,\n args.dimensions,\n args.spacing,\n args.direction,\n args.origin,\n [args.segmentIndex]\n );\n return results;\n },\n /**\n * Converts a contour to a volume labelmap.\n * @param {Object} args - The arguments for the conversion.\n * @param {Array} args.segmentIndices - The indices of the segments.\n * @param {Array} args.scalarData - The scalar data.\n * @param {Map} args.annotationUIDsInSegmentMap - The map of annotation UIDs in segment.\n * @param {Array} args.dimensions - The dimensions of the image data.\n * @param {Array} args.origin - The origin of the image data.\n * @param {Array} args.direction - The direction of the image data.\n * @param {Array} args.spacing - The spacing of the image data.\n * @param {...Function} callbacks - Optional callbacks.\n * @param {Function} callbacks[0] - The progress callback.\n * @returns {Array} - The scalar data of the segmentation voxel manager.\n */\n async convertContourToVolumeLabelmap(args, ...callbacks) {\n const [progressCallback] = callbacks;\n const polySeg = await new ICRPolySeg();\n await polySeg.initialize({\n updateProgress: progressCallback,\n });\n\n const {\n segmentIndices,\n scalarData,\n annotationUIDsInSegmentMap,\n dimensions,\n origin,\n direction,\n spacing,\n } = args;\n\n const segmentationVoxelManager =\n utilities.VoxelManager.createScalarVolumeVoxelManager({\n dimensions,\n scalarData,\n });\n\n const imageData = vtkImageData.newInstance();\n imageData.setDimensions(dimensions);\n imageData.setOrigin(origin);\n imageData.setDirection(direction);\n imageData.setSpacing(spacing);\n\n const scalarArray = vtkDataArray.newInstance({\n name: 'Pixels',\n numberOfComponents: 1,\n values: scalarData,\n });\n\n imageData.getPointData().setScalars(scalarArray);\n\n imageData.modified();\n\n for (const index of segmentIndices) {\n const annotations = annotationUIDsInSegmentMap.get(index);\n\n for (const annotation of annotations) {\n if (!annotation.polyline) {\n continue;\n }\n\n const { polyline, holesPolyline } = annotation;\n const bounds = getBoundingBoxAroundShapeWorld(polyline);\n\n const [iMin, jMin, kMin] = utilities.transformWorldToIndex(imageData, [\n bounds[0][0],\n bounds[1][0],\n bounds[2][0],\n ]);\n\n const [iMax, jMax, kMax] = utilities.transformWorldToIndex(imageData, [\n bounds[0][1],\n bounds[1][1],\n bounds[2][1],\n ]);\n\n const { projectedPolyline, sharedDimensionIndex } =\n projectTo2D(polyline);\n\n const holes = holesPolyline?.map((hole) => {\n const { projectedPolyline: projectedHole } = projectTo2D(hole);\n return projectedHole;\n });\n\n const firstDim = (sharedDimensionIndex + 1) % 3;\n const secondDim = (sharedDimensionIndex + 2) % 3;\n\n const voxels = utilities.VoxelManager.createScalarVolumeVoxelManager({\n dimensions,\n scalarData,\n });\n\n voxels.forEach(\n ({ pointIJK }) => {\n segmentationVoxelManager.setAtIJKPoint(pointIJK, index);\n },\n {\n imageData,\n isInObject: (pointLPS) => {\n const point2D = [pointLPS[firstDim], pointLPS[secondDim]];\n\n // Check if the point is inside any of the polylines for this segment\n const isInside = containsPoint(projectedPolyline, point2D, {\n holes,\n });\n\n return isInside;\n },\n boundsIJK: [\n [iMin, iMax],\n [jMin, jMax],\n [kMin, kMax],\n ],\n }\n );\n }\n }\n\n return segmentationVoxelManager.scalarData;\n },\n /**\n * Converts a contour to a stack labelmap.\n * @param {Object} args - The arguments for the conversion.\n * @param {Array} callbacks - Optional callbacks for progress updates.\n * @returns {Promise<Object>} - The converted segmentations information.\n */\n async convertContourToStackLabelmap(args, ...callbacks) {\n const [progressCallback] = callbacks;\n const polySeg = await new ICRPolySeg();\n await polySeg.initialize({\n updateProgress: progressCallback,\n });\n\n const { segmentationsInfo, annotationUIDsInSegmentMap, segmentIndices } =\n args;\n\n const segmentationVoxelManagers = new Map();\n\n segmentationsInfo.forEach((segmentationInfo, referencedImageId) => {\n const { dimensions, scalarData, direction, spacing, origin } =\n segmentationInfo;\n const manager = utilities.VoxelManager.createScalarVolumeVoxelManager({\n dimensions,\n scalarData,\n });\n\n const imageData = vtkImageData.newInstance();\n imageData.setDimensions(dimensions);\n imageData.setOrigin(origin);\n imageData.setDirection(direction);\n imageData.setSpacing(spacing);\n\n const scalarArray = vtkDataArray.newInstance({\n name: 'Pixels',\n numberOfComponents: 1,\n values: scalarData,\n });\n\n imageData.getPointData().setScalars(scalarArray);\n\n imageData.modified();\n\n segmentationVoxelManagers.set(referencedImageId, { manager, imageData });\n });\n\n for (const index of segmentIndices) {\n const annotations = annotationUIDsInSegmentMap.get(index);\n\n for (const annotation of annotations) {\n if (!annotation.polyline) {\n continue;\n }\n\n const { polyline, holesPolyline, referencedImageId } = annotation;\n const bounds = getBoundingBoxAroundShapeWorld(polyline);\n\n const { manager: segmentationVoxelManager, imageData } =\n segmentationVoxelManagers.get(referencedImageId);\n\n const [iMin, jMin, kMin] = utilities.transformWorldToIndex(imageData, [\n bounds[0][0],\n bounds[1][0],\n bounds[2][0],\n ]);\n\n const [iMax, jMax, kMax] = utilities.transformWorldToIndex(imageData, [\n bounds[0][1],\n bounds[1][1],\n bounds[2][1],\n ]);\n\n const { projectedPolyline, sharedDimensionIndex } =\n projectTo2D(polyline);\n\n const holes = holesPolyline?.map((hole) => {\n const { projectedPolyline: projectedHole } = projectTo2D(hole);\n return projectedHole;\n });\n\n const firstDim = (sharedDimensionIndex + 1) % 3;\n const secondDim = (sharedDimensionIndex + 2) % 3;\n\n const voxels = utilities.VoxelManager.createScalarVolumeVoxelManager({\n dimensions: imageData.getDimensions(),\n scalarData: imageData.getPointData().getScalars().getData(),\n });\n\n voxels.forEach(\n ({ pointIJK }) => {\n segmentationVoxelManager.setAtIJKPoint(pointIJK, index);\n },\n {\n imageData,\n isInObject: (pointLPS) => {\n const point2D = [pointLPS[firstDim], pointLPS[secondDim]];\n\n // Check if the point is inside any of the polylines for this segment\n const isInside = containsPoint(projectedPolyline, point2D, {\n holes,\n });\n\n return isInside;\n },\n boundsIJK: [\n [iMin, iMax],\n [jMin, jMax],\n [kMin, kMax],\n ],\n }\n );\n }\n }\n\n segmentationsInfo.forEach((segmentationInfo, referencedImageId) => {\n const { manager: segmentationVoxelManager } =\n segmentationVoxelManagers.get(referencedImageId);\n\n segmentationInfo.scalarData = segmentationVoxelManager.scalarData;\n });\n return segmentationsInfo;\n },\n /**\n * Converts a surface to a volume labelmap.\n *\n * @param {Object} args - The arguments for the conversion.\n * @param {Array} args.points - The points defining the surface.\n * @param {Array} args.polys - The polygons defining the surface.\n * @param {Array} args.dimensions - The dimensions of the volume.\n * @param {Array} args.spacing - The spacing between voxels in the volume.\n * @param {Array} args.direction - The direction of the volume.\n * @param {Array} args.origin - The origin of the volume.\n * @param {Function} progressCallback - The callback function for reporting progress.\n * @returns {Promise} - A promise that resolves with the converted labelmap.\n */\n async convertSurfaceToVolumeLabelmap(args, ...callbacks) {\n const [progressCallback] = callbacks;\n await this.initializePolySeg(progressCallback);\n\n const results = this.polySeg.instance.convertSurfaceToLabelmap(\n args.points,\n args.polys,\n args.dimensions,\n args.spacing,\n args.direction,\n args.origin\n );\n\n return results;\n },\n /**\n * Converts surfaces to a volume labelmap.\n * @param {Object} args - The arguments for the conversion.\n * @param {Map} args.segmentsInfo - A map containing information about the segments.\n * @param {Function} progressCallback - A callback function for reporting progress.\n * @returns {Uint8Array} - The resulting volume labelmap.\n */\n async convertSurfacesToVolumeLabelmap(args, ...callbacks) {\n const [progressCallback] = callbacks;\n await this.initializePolySeg(progressCallback);\n\n const { segmentsInfo } = args;\n\n const promises = Array.from(segmentsInfo.keys()).map((segmentIndex) => {\n const { points, polys } = segmentsInfo.get(segmentIndex);\n const result = this.polySeg.instance.convertSurfaceToLabelmap(\n points,\n polys,\n args.dimensions,\n args.spacing,\n args.direction,\n args.origin\n );\n\n return {\n ...result,\n segmentIndex,\n };\n });\n\n const results = await Promise.all(promises);\n\n const targetImageData = vtkImageData.newInstance();\n targetImageData.setDimensions(args.dimensions);\n targetImageData.setOrigin(args.origin);\n targetImageData.setSpacing(args.spacing);\n targetImageData.setDirection(args.direction);\n\n const totalSize =\n args.dimensions[0] * args.dimensions[1] * args.dimensions[2];\n\n const scalarArray = vtkDataArray.newInstance({\n name: 'Pixels',\n numberOfComponents: 1,\n values: new Uint8Array(totalSize),\n });\n\n targetImageData.getPointData().setScalars(scalarArray);\n targetImageData.modified();\n\n // we need to then consolidate the results into a single volume\n // by looping into each voxel with voxelmanager for each\n // and check if the voxel is inside any of the reconstructed\n // labelmaps\n const { dimensions } = args;\n const scalarData = targetImageData.getPointData().getScalars().getData();\n const segmentationVoxelManager =\n utilities.VoxelManager.createScalarVolumeVoxelManager({\n dimensions,\n scalarData,\n });\n\n const outputVolumesInfo = results.map((result) => {\n const { data, dimensions, direction, origin, spacing } = result;\n const volume = vtkImageData.newInstance();\n volume.setDimensions(dimensions);\n volume.setOrigin(origin);\n volume.setSpacing(spacing);\n volume.setDirection(direction);\n\n const scalarArray = vtkDataArray.newInstance({\n name: 'Pixels',\n numberOfComponents: 1,\n values: data,\n });\n\n volume.getPointData().setScalars(scalarArray);\n\n volume.modified();\n\n const voxelManager =\n utilities.VoxelManager.createScalarVolumeVoxelManager({\n dimensions,\n scalarData: data,\n });\n\n const extent = volume.getExtent(); // e.g., [0, 176, 0, 268, 0, 337] for dimensions of [177, 269, 338]\n\n return {\n volume,\n voxelManager,\n extent,\n scalarData: data,\n segmentIndex: result.segmentIndex,\n };\n });\n\n const voxels = utilities.VoxelManager.createScalarVolumeVoxelManager({\n dimensions: targetImageData.getDimensions(),\n scalarData: targetImageData.getPointData().getScalars().getData(),\n });\n\n voxels.forEach(\n ({ pointIJK, pointLPS }) => {\n // Check if the point is inside any of the reconstructed labelmaps\n // Todo: we can optimize this by returning early if the bounding box\n // of the point is outside the bounding box of the labelmap\n\n try {\n for (const volumeInfo of outputVolumesInfo) {\n const { volume, extent, voxelManager, segmentIndex } = volumeInfo;\n\n const index = volume.worldToIndex(pointLPS);\n\n // check if the ijk point is inside the volume\n if (\n index[0] < extent[0] ||\n index[0] > extent[1] ||\n index[1] < extent[2] ||\n index[1] > extent[3] ||\n index[2] < extent[4] ||\n index[2] > extent[5]\n ) {\n continue;\n }\n\n const roundedIndex = index.map(Math.round);\n const value = voxelManager.getAtIJK(...roundedIndex);\n if (value > 0) {\n segmentationVoxelManager.setAtIJKPoint(pointIJK, segmentIndex);\n break;\n }\n }\n } catch (error) {\n // right now there is weird error if the point is outside the volume\n }\n },\n { imageData: targetImageData }\n );\n\n return segmentationVoxelManager.scalarData;\n },\n getSurfacesAABBs({ surfacesInfo }) {\n const aabbs = new Map();\n for (const { points, id } of surfacesInfo) {\n const aabb = getAABB(points, { numDimensions: 3 });\n aabbs.set(id, aabb);\n }\n return aabbs;\n },\n /**\n * Cuts the surfaces into planes.\n *\n * @param {Object} options - The options object.\n * @param {Array} options.planesInfo - The information about the planes.\n * @param {Array} options.surfacesInfo - The information about the surfaces.\n * @param {Function} progressCallback - The callback function for progress updates.\n * @param {Function} updateCacheCallback - The callback function for updating the cache.\n */\n cutSurfacesIntoPlanes(\n { planesInfo, surfacesInfo, surfacesAABB = new Map() },\n progressCallback,\n updateCacheCallback\n ) {\n const numberOfPlanes = planesInfo.length;\n const cutter = vtkCutter.newInstance();\n\n const plane1 = vtkPlane.newInstance();\n\n cutter.setCutFunction(plane1);\n\n const surfacePolyData = vtkPolyData.newInstance();\n\n try {\n for (const [index, planeInfo] of planesInfo.entries()) {\n const { sliceIndex, planes } = planeInfo;\n\n const polyDataResults = new Map();\n for (const polyDataInfo of surfacesInfo) {\n const { points, polys, id } = polyDataInfo;\n\n const aabb3 =\n surfacesAABB.get(id) || getAABB(points, { numDimensions: 3 });\n\n if (!surfacesAABB.has(id)) {\n surfacesAABB.set(id, aabb3);\n }\n\n const { minX, minY, minZ, maxX, maxY, maxZ } = aabb3;\n\n const { origin, normal } = planes[0];\n\n // Check if the plane intersects the AABB\n if (\n !isPlaneIntersectingAABB(\n origin,\n normal,\n minX,\n minY,\n minZ,\n maxX,\n maxY,\n maxZ\n )\n ) {\n continue;\n }\n\n surfacePolyData.getPoints().setData(points, 3);\n surfacePolyData.getPolys().setData(polys, 3);\n surfacePolyData.modified();\n\n cutter.setInputData(surfacePolyData);\n plane1.setOrigin(origin);\n plane1.setNormal(normal);\n\n try {\n cutter.update();\n } catch (e) {\n console.warn('Error during clipping', e);\n continue;\n }\n\n const polyData = cutter.getOutputData();\n\n const cutterOutput = polyData;\n cutterOutput.buildLinks();\n const loopExtraction = vtkContourLoopExtraction.newInstance();\n loopExtraction.setInputData(cutterOutput);\n\n const loopOutput = loopExtraction.getOutputData();\n if (polyData) {\n polyDataResults.set(id, {\n points: loopOutput.getPoints().getData(),\n lines: loopOutput.getLines().getData(),\n numberOfCells: loopOutput.getLines().getNumberOfCells(),\n });\n }\n }\n\n progressCallback({ progress: (index + 1) / numberOfPlanes });\n\n updateCacheCallback({ sliceIndex, polyDataResults });\n }\n } catch (e) {\n console.warn('Error during processing', e);\n } finally {\n // Cleanup on completion\n surfacesInfo = null;\n plane1.delete();\n }\n },\n};\n\nexpose(polySegConverters);\n","module.exports = __WEBPACK_EXTERNAL_MODULE__785__;","module.exports = __WEBPACK_EXTERNAL_MODULE__283__;","module.exports = __WEBPACK_EXTERNAL_MODULE__864__;","module.exports = __WEBPACK_EXTERNAL_MODULE__70__;","module.exports = __WEBPACK_EXTERNAL_MODULE__481__;","module.exports = __WEBPACK_EXTERNAL_MODULE__336__;","module.exports = __WEBPACK_EXTERNAL_MODULE__953__;","module.exports = __WEBPACK_EXTERNAL_MODULE__976__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n// the startup function\n__webpack_require__.x = () => {\n\t// Load entry module and return exports\n\t// This entry module depends on other loaded chunks and execution need to be delayed\n\tvar __webpack_exports__ = __webpack_require__.O(undefined, [78], () => (__webpack_require__(280)))\n\t__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n\treturn __webpack_exports__;\n};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.f = {};\n// This file contains only the entry chunk.\n// The chunk loading function for additional chunks\n__webpack_require__.e = (chunkId) => {\n\treturn Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {\n\t\t__webpack_require__.f[key](chunkId, promises);\n\t\treturn promises;\n\t}, []));\n};","// This function allow to reference async chunks and sibling chunks for the entrypoint\n__webpack_require__.u = (chunkId) => {\n\t// return url for filenames based on template\n\treturn \"\" + chunkId + \".index.js\";\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","var scriptUrl;\nif (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + \"\";\nvar document = __webpack_require__.g.document;\nif (!scriptUrl && document) {\n\tif (document.currentScript)\n\t\tscriptUrl = document.currentScript.src;\n\tif (!scriptUrl) {\n\t\tvar scripts = document.getElementsByTagName(\"script\");\n\t\tif(scripts.length) {\n\t\t\tvar i = scripts.length - 1;\n\t\t\twhile (i > -1 && !scriptUrl) scriptUrl = scripts[i--].src;\n\t\t}\n\t}\n}\n// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration\n// or pass an empty string (\"\") and set the __webpack_public_path__ variable from your code to use your own logic.\nif (!scriptUrl) throw new Error(\"Automatic publicPath is not supported in this browser\");\nscriptUrl = scriptUrl.replace(/#.*$/, \"\").replace(/\\?.*$/, \"\").replace(/\\/[^\\/]+$/, \"/\");\n__webpack_require__.p = scriptUrl;","// no baseURI\n\n// object to store loaded chunks\n// \"1\" means \"already loaded\"\nvar installedChunks = {\n\t985: 1\n};\n\n// importScripts chunk loading\nvar installChunk = (data) => {\n\tvar chunkIds = data[0];\n\tvar moreModules = data[1];\n\tvar runtime = data[2];\n\tfor(var moduleId in moreModules) {\n\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t}\n\t}\n\tif(runtime) runtime(__webpack_require__);\n\twhile(chunkIds.length)\n\t\tinstalledChunks[chunkIds.pop()] = 1;\n\tparentChunkLoadingFunction(data);\n};\n__webpack_require__.f.i = (chunkId, promises) => {\n\t// \"1\" is the signal for \"already loaded\"\n\tif(!installedChunks[chunkId]) {\n\t\tif(true) { // all chunks have JS\n\t\t\timportScripts(__webpack_require__.p + __webpack_require__.u(chunkId));\n\t\t}\n\t}\n};\n\nvar chunkLoadingGlobal = self[\"webpackChunkcornerstoneTools3D\"] = self[\"webpackChunkcornerstoneTools3D\"] || [];\nvar parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);\nchunkLoadingGlobal.push = installChunk;\n\n// no HMR\n\n// no HMR manifest","// run startup\nvar __webpack_exports__ = __webpack_require__.x();\n"],"names":["root","factory","exports","module","require","define","amd","self","__WEBPACK_EXTERNAL_MODULE__953__","__WEBPACK_EXTERNAL_MODULE__283__","__WEBPACK_EXTERNAL_MODULE__785__","__WEBPACK_EXTERNAL_MODULE__864__","__WEBPACK_EXTERNAL_MODULE__70__","__WEBPACK_EXTERNAL_MODULE__336__","__WEBPACK_EXTERNAL_MODULE__481__","__WEBPACK_EXTERNAL_MODULE__976__","deferred","next","EPSILON","CONSTANTS","getBoundingBoxAroundShapeWorld","points","clipBounds","dimensions","isWorld","arguments","length","undefined","xMin","Infinity","xMax","yMin","yMax","zMin","zMax","is3D","i","p","Math","min","max","calculateBoundingBox","projectTo2D","polyline","sharedDimensionIndex","testPoints","utilities","every","point","index","array","abs","Error","points2D","firstDim","secondDim","push","projectedPolyline","containsPoint","options","closed","numPolylinePoints","numIntersections","holes","hole","shouldClose","distFirstToLastPoints","p1","p2","x1","y1","z1","x2","y2","z2","dx","dy","dz","math","glMatrix","isClosed","maxSegmentIndex","maxX","maxY","minY","intersects","xIntersection","getAABB","polylineToUse","numDimensions","Array","isArray","currentPolyline","totalPoints","len","minX","minZ","maxZ","x","y","z","isPlaneIntersectingAABB","origin","normal","vertices","vec3","normalVec","originVec","planeDistance","initialSign","vertex","distance","sign","polySegConverters","polySeg","polySegInitializing","polySegInitializingPromise","initializePolySeg","progressCallback","this","instance","Promise","resolve","ICRPolySeg","initialize","updateProgress","then","convertContourToSurface","args","polylines","numPointsArray","_len","callbacks","_key","convertContourRoiToSurface","convertLabelmapToSurface","_len2","_key2","scalarData","spacing","direction","segmentIndex","convertContourToVolumeLabelmap","_len3","_key3","segmentIndices","annotationUIDsInSegmentMap","segmentationVoxelManager","imageData","vtkImageData","setDimensions","setOrigin","setDirection","setSpacing","scalarArray","vtkDataArray","name","numberOfComponents","values","getPointData","setScalars","modified","annotations","get","annotation","holesPolyline","bounds","iMin","jMin","kMin","iMax","jMax","kMax","map","projectedHole","forEach","_ref","pointIJK","setAtIJKPoint","isInObject","pointLPS","point2D","boundsIJK","convertContourToStackLabelmap","_len4","_key4","segmentationsInfo","segmentationVoxelManagers","Map","segmentationInfo","referencedImageId","manager","set","getDimensions","getScalars","getData","_ref2","convertSurfaceToVolumeLabelmap","_len5","_key5","convertSurfaceToLabelmap","polys","convertSurfacesToVolumeLabelmap","_len6","_key6","segmentsInfo","promises","from","keys","results","all","targetImageData","totalSize","Uint8Array","outputVolumesInfo","result","data","volume","voxelManager","extent","getExtent","_ref3","volumeInfo","worldToIndex","roundedIndex","round","getAtIJK","error","getSurfacesAABBs","_ref4","surfacesInfo","aabbs","id","aabb","cutSurfacesIntoPlanes","_ref5","updateCacheCallback","planesInfo","surfacesAABB","numberOfPlanes","cutter","vtkCutter","plane1","vtkPlane","setCutFunction","surfacePolyData","vtkPolyData","planeInfo","entries","sliceIndex","planes","polyDataResults","polyDataInfo","aabb3","has","getPoints","setData","getPolys","setInputData","setNormal","update","e","console","warn","polyData","getOutputData","cutterOutput","buildLinks","loopExtraction","vtkContourLoopExtraction","loopOutput","lines","getLines","numberOfCells","getNumberOfCells","progress","delete","expose","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","m","__webpack_exports__","O","chunkIds","fn","priority","notFulfilled","fulfilled","j","Object","key","splice","r","n","getter","__esModule","d","a","definition","o","defineProperty","enumerable","f","chunkId","reduce","u","g","globalThis","Function","window","obj","prop","prototype","hasOwnProperty","call","scriptUrl","importScripts","location","document","currentScript","src","scripts","getElementsByTagName","replace","installedChunks","chunkLoadingGlobal","parentChunkLoadingFunction","bind","moreModules","runtime","pop"],"sourceRoot":""}
1
+ {"version":3,"file":"985.index.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,uBAAwBA,QAAQ,8CAA+CA,QAAQ,yCAA0CA,QAAQ,0CAA2CA,QAAQ,6CAA8CA,QAAQ,yDAA0DA,QAAQ,uCAAwCA,QAAQ,cAC5W,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,sBAAuB,6CAA8C,wCAAyC,yCAA0C,4CAA6C,wDAAyD,sCAAuC,aAAcJ,GACjS,iBAAZC,QACdA,QAA4B,mBAAID,EAAQG,QAAQ,uBAAwBA,QAAQ,8CAA+CA,QAAQ,yCAA0CA,QAAQ,0CAA2CA,QAAQ,6CAA8CA,QAAQ,yDAA0DA,QAAQ,uCAAwCA,QAAQ,cAEpZJ,EAAyB,mBAAIC,EAAQD,EAAoB,cAAGA,EAAK,8CAA+CA,EAAK,yCAA0CA,EAAK,0CAA2CA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S,EACnCJ,EAA2BjH,EAAK,C,KzBrB7BvM,EAAOsQ,EAAoBrL,EAC/BqL,EAAoBrL,EAAI,IAChBqL,EAAoBlB,EAAE,IAAIvI,KAAK7G,G0BDbsQ,EAAoBrL,G","sources":["webpack://cornerstoneTools3D/webpack/universalModuleDefinition","webpack://cornerstoneTools3D/webpack/runtime/chunk loaded","webpack://cornerstoneTools3D/webpack/runtime/startup chunk dependencies","webpack://cornerstoneTools3D/./src/utilities/boundingBox/getBoundingBoxAroundShape.ts","webpack://cornerstoneTools3D/./src/utilities/math/polyline/projectTo2D.ts","webpack://cornerstoneTools3D/./src/utilities/math/polyline/containsPoint.ts","webpack://cornerstoneTools3D/./src/utilities/math/polyline/isClosed.ts","webpack://cornerstoneTools3D/./src/utilities/math/point/distanceToPointSquared.ts","webpack://cornerstoneTools3D/./src/utilities/math/polyline/getAABB.ts","webpack://cornerstoneTools3D/./src/utilities/planar/isPlaneIntersectingAABB.ts","webpack://cornerstoneTools3D/./src/workers/polySegConverters.js","webpack://cornerstoneTools3D/external umd \"@kitware/vtk.js/Common/Core/DataArray\"","webpack://cornerstoneTools3D/external umd \"@kitware/vtk.js/Common/DataModel/ImageData\"","webpack://cornerstoneTools3D/external umd \"@kitware/vtk.js/Common/DataModel/Plane\"","webpack://cornerstoneTools3D/external umd \"@kitware/vtk.js/Common/DataModel/PolyData\"","webpack://cornerstoneTools3D/external umd \"@kitware/vtk.js/Filters/Core/Cutter\"","webpack://cornerstoneTools3D/external umd \"@kitware/vtk.js/Filters/General/ContourLoopExtraction\"","webpack://cornerstoneTools3D/external umd {\"root\":\"cornerstone3D\",\"commonjs\":\"@cornerstonejs/core\",\"commonjs2\":\"@cornerstonejs/core\",\"amd\":\"@cornerstonejs/core\"}","webpack://cornerstoneTools3D/external umd {\"root\":\"window\",\"commonjs\":\"gl-matrix\",\"commonjs2\":\"gl-matrix\",\"amd\":\"gl-matrix\"}","webpack://cornerstoneTools3D/webpack/bootstrap","webpack://cornerstoneTools3D/webpack/runtime/compat get default export","webpack://cornerstoneTools3D/webpack/runtime/define property getters","webpack://cornerstoneTools3D/webpack/runtime/ensure chunk","webpack://cornerstoneTools3D/webpack/runtime/get javascript chunk filename","webpack://cornerstoneTools3D/webpack/runtime/global","webpack://cornerstoneTools3D/webpack/runtime/hasOwnProperty shorthand","webpack://cornerstoneTools3D/webpack/runtime/publicPath","webpack://cornerstoneTools3D/webpack/runtime/importScripts chunk loading","webpack://cornerstoneTools3D/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"@cornerstonejs/core\"), require(\"@kitware/vtk.js/Common/DataModel/ImageData\"), require(\"@kitware/vtk.js/Common/Core/DataArray\"), require(\"@kitware/vtk.js/Common/DataModel/Plane\"), require(\"@kitware/vtk.js/Common/DataModel/PolyData\"), require(\"@kitware/vtk.js/Filters/General/ContourLoopExtraction\"), require(\"@kitware/vtk.js/Filters/Core/Cutter\"), require(\"gl-matrix\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"@cornerstonejs/core\", \"@kitware/vtk.js/Common/DataModel/ImageData\", \"@kitware/vtk.js/Common/Core/DataArray\", \"@kitware/vtk.js/Common/DataModel/Plane\", \"@kitware/vtk.js/Common/DataModel/PolyData\", \"@kitware/vtk.js/Filters/General/ContourLoopExtraction\", \"@kitware/vtk.js/Filters/Core/Cutter\", \"gl-matrix\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"cornerstoneTools3D\"] = factory(require(\"@cornerstonejs/core\"), require(\"@kitware/vtk.js/Common/DataModel/ImageData\"), require(\"@kitware/vtk.js/Common/Core/DataArray\"), require(\"@kitware/vtk.js/Common/DataModel/Plane\"), require(\"@kitware/vtk.js/Common/DataModel/PolyData\"), require(\"@kitware/vtk.js/Filters/General/ContourLoopExtraction\"), require(\"@kitware/vtk.js/Filters/Core/Cutter\"), require(\"gl-matrix\"));\n\telse\n\t\troot[\"cornerstoneTools3D\"] = factory(root[\"cornerstone3D\"], root[\"@kitware/vtk.js/Common/DataModel/ImageData\"], root[\"@kitware/vtk.js/Common/Core/DataArray\"], root[\"@kitware/vtk.js/Common/DataModel/Plane\"], root[\"@kitware/vtk.js/Common/DataModel/PolyData\"], root[\"@kitware/vtk.js/Filters/General/ContourLoopExtraction\"], root[\"@kitware/vtk.js/Filters/Core/Cutter\"], root[\"window\"]);\n})(self, (__WEBPACK_EXTERNAL_MODULE__953__, __WEBPACK_EXTERNAL_MODULE__283__, __WEBPACK_EXTERNAL_MODULE__785__, __WEBPACK_EXTERNAL_MODULE__864__, __WEBPACK_EXTERNAL_MODULE__70__, __WEBPACK_EXTERNAL_MODULE__336__, __WEBPACK_EXTERNAL_MODULE__481__, __WEBPACK_EXTERNAL_MODULE__976__) => {\nreturn ","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar chunkIds = deferred[i][0];\n\t\tvar fn = deferred[i][1];\n\t\tvar priority = deferred[i][2];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","var next = __webpack_require__.x;\n__webpack_require__.x = () => {\n\treturn __webpack_require__.e(78).then(next);\n};","import type { Types } from '@cornerstonejs/core';\nimport { CONSTANTS } from '@cornerstonejs/core';\n\nconst { EPSILON } = CONSTANTS;\n\n/** Bounding box type */\ntype BoundingBox =\n | [Types.Point2, Types.Point2, null]\n | [Types.Point2, Types.Point2, Types.Point2];\n\nfunction calculateBoundingBox(\n points,\n dimensions,\n isWorld = false\n): BoundingBox {\n let xMin = Infinity;\n let xMax = isWorld ? -Infinity : 0;\n let yMin = Infinity;\n let yMax = isWorld ? -Infinity : 0;\n let zMin = Infinity;\n let zMax = isWorld ? -Infinity : 0;\n\n const is3D = points[0]?.length === 3;\n\n // use for loop for performance\n for (let i = 0; i < points.length; i++) {\n const p = points[i];\n xMin = Math.min(p[0], xMin);\n xMax = Math.max(p[0], xMax);\n yMin = Math.min(p[1], yMin);\n yMax = Math.max(p[1], yMax);\n\n if (is3D) {\n zMin = Math.min(p[2] ?? zMin, zMin);\n zMax = Math.max(p[2] ?? zMax, zMax);\n }\n }\n\n if (dimensions) {\n xMin = Math.max(isWorld ? dimensions[0] + EPSILON : 0, xMin);\n xMax = Math.min(\n isWorld ? dimensions[0] - EPSILON : dimensions[0] - 1,\n xMax\n );\n yMin = Math.max(isWorld ? dimensions[1] + EPSILON : 0, yMin);\n yMax = Math.min(\n isWorld ? dimensions[1] - EPSILON : dimensions[1] - 1,\n yMax\n );\n\n if (is3D && dimensions.length === 3) {\n zMin = Math.max(isWorld ? dimensions[2] + EPSILON : 0, zMin);\n zMax = Math.min(\n isWorld ? dimensions[2] - EPSILON : dimensions[2] - 1,\n zMax\n );\n }\n } else if (!isWorld) {\n // still need to bound to 0 and Infinity if no dimensions are provided for ijk\n xMin = Math.max(0, xMin);\n xMax = Math.min(Infinity, xMax);\n yMin = Math.max(0, yMin);\n yMax = Math.min(Infinity, yMax);\n\n if (is3D) {\n zMin = Math.max(0, zMin);\n zMax = Math.min(Infinity, zMax);\n }\n }\n\n return is3D\n ? [\n [xMin, xMax],\n [yMin, yMax],\n [zMin, zMax],\n ]\n : [[xMin, xMax], [yMin, yMax], null];\n}\n\n/**\n * With a given vertices (points) coordinates in 2D or 3D in IJK, it calculates the minimum and maximum\n * coordinate in each axis, and returns them. If clipBounds are provided it also\n * clip the min, max to the provided width, height and depth\n *\n * @param points - shape corner points coordinates either in IJK (image coordinate)\n * @param dimensions - bounds to clip the min, max\n * @returns [[xMin,xMax],[yMin,yMax], [zMin,zMax]]\n */\nexport function getBoundingBoxAroundShapeIJK(\n points: Types.Point2[] | Types.Point3[],\n dimensions?: Types.Point2 | Types.Point3\n): BoundingBox {\n return calculateBoundingBox(points, dimensions, false);\n}\n\n/**\n * With a given vertices (points) coordinates in 2D or 3D in World Coordinates, it calculates the minimum and maximum\n * coordinate in each axis, and returns them. If clipBounds are provided it also\n * clip the min, max to the provided width, height and depth\n *\n * @param points - shape corner points coordinates either in IJK (image coordinate)\n * @param clipBounds - bounds to clip the min, max\n * @returns [[xMin,xMax],[yMin,yMax], [zMin,zMax]]\n */\nexport function getBoundingBoxAroundShapeWorld(\n points: Types.Point2[] | Types.Point3[],\n clipBounds?: Types.Point2 | Types.Point3\n): BoundingBox {\n return calculateBoundingBox(points, clipBounds, true);\n}\n","import { utilities } from '@cornerstonejs/core';\nimport type { Types } from '@cornerstonejs/core';\n\nconst epsilon = 1e-6;\n\n/**\n * Projects a polyline from 3D to 2D by reducing one dimension.\n *\n * @param polyline - The polyline to be projected.\n * @returns An object containing the shared dimension index and the projected polyline in 2D.\n * @throws Error if a shared dimension index cannot be found for the polyline.\n */\nexport function projectTo2D(polyline: Types.Point3[]) {\n // We need to reduce one dimension to 2D, so basically\n // we need to find the dimension index that is shared by all points\n // Use the first three points, two is enough but three is more robust\n let sharedDimensionIndex;\n\n const testPoints = utilities.getRandomSampleFromArray(polyline, 50);\n\n for (let i = 0; i < 3; i++) {\n if (\n testPoints.every(\n (point, index, array) => Math.abs(point[i] - array[0][i]) < epsilon\n )\n ) {\n sharedDimensionIndex = i;\n break;\n }\n }\n\n if (sharedDimensionIndex === undefined) {\n throw new Error(\n 'Cannot find a shared dimension index for polyline, probably oblique plane'\n );\n }\n\n // convert polyline list and point to 2D\n const points2D = [] as Types.Point2[];\n\n const firstDim = (sharedDimensionIndex + 1) % 3;\n const secondDim = (sharedDimensionIndex + 2) % 3;\n\n for (let i = 0; i < polyline.length; i++) {\n points2D.push([polyline[i][firstDim], polyline[i][secondDim]]);\n }\n\n return {\n sharedDimensionIndex,\n projectedPolyline: points2D,\n };\n}\n","import type { Types } from '@cornerstonejs/core';\nimport isClosed from './isClosed';\n\n/**\n * Checks if a 2D point is inside the polyline.\n *\n * A point is inside a curve/polygon if the number of intersections between the horizontal\n * ray emanating from the given point and to the right and the line segments is odd.\n * https://www.eecs.umich.edu/courses/eecs380/HANDOUTS/PROJ2/InsidePoly.html\n *\n * Note that a point on the polyline is considered inside.\n *\n * @param polyline - Polyline points (2D)\n * @param point - 2D Point\n * @returns True if the point is inside the polyline or false otherwise\n */\nexport default function containsPoint(\n polyline: Types.Point2[],\n point: Types.Point2,\n options: {\n closed?: boolean;\n holes?: Types.Point2[][];\n } = {\n closed: undefined,\n }\n): boolean {\n if (polyline.length < 3) {\n return false;\n }\n\n const numPolylinePoints = polyline.length;\n let numIntersections = 0;\n\n const { closed, holes } = options;\n\n if (holes?.length) {\n for (const hole of holes) {\n if (containsPoint(hole, point)) {\n return false;\n }\n }\n }\n\n // Test intersection against [end, start] line segment if it should be closed\n const shouldClose = !(closed === undefined ? isClosed(polyline) : closed);\n const maxSegmentIndex = polyline.length - (shouldClose ? 1 : 2);\n\n for (let i = 0; i <= maxSegmentIndex; i++) {\n const p1 = polyline[i];\n\n // Calculating the next point index without using % (mod) operator like in\n // `(i + 1) % numPolylinePoints` to make it 20% faster\n const p2Index = i === numPolylinePoints - 1 ? 0 : i + 1;\n const p2 = polyline[p2Index];\n\n // Calculating min/max without using Math.min/max to make it ~3% faster\n const maxX = p1[0] >= p2[0] ? p1[0] : p2[0];\n const maxY = p1[1] >= p2[1] ? p1[1] : p2[1];\n const minY = p1[1] <= p2[1] ? p1[1] : p2[1];\n\n const mayIntersectLineSegment =\n point[0] <= maxX && point[1] >= minY && point[1] < maxY;\n\n if (mayIntersectLineSegment) {\n const isVerticalLine = p1[0] === p2[0];\n let intersects = isVerticalLine;\n\n if (!intersects) {\n const xIntersection =\n ((point[1] - p1[1]) * (p2[0] - p1[0])) / (p2[1] - p1[1]) + p1[0];\n\n intersects = point[0] <= xIntersection;\n }\n\n numIntersections += intersects ? 1 : 0;\n }\n }\n\n return !!(numIntersections % 2);\n}\n","import { glMatrix } from 'gl-matrix';\nimport type { Types } from '@cornerstonejs/core';\nimport { distanceToPointSquared } from '../point';\n\n/**\n * A polyline is considered closed if the start and end points are at the same position\n *\n * @param polyline - Polyline points (2D)\n * @returns True if the polyline is already closed or false otherwise\n */\nexport default function isClosed(polyline: Types.Point2[]): boolean {\n if (polyline.length < 3) {\n return false;\n }\n\n const numPolylinePoints = polyline.length;\n\n const firstPoint = polyline[0];\n const lastPoint = polyline[numPolylinePoints - 1];\n const distFirstToLastPoints = distanceToPointSquared(firstPoint, lastPoint);\n\n return glMatrix.equals(0, distFirstToLastPoints);\n}\n","import type { Types } from '@cornerstonejs/core';\n\ntype Point = Types.Point2 | Types.Point3;\n\n/**\n * Calculates the distance squared of a point to another point\n *\n * @param p1 - x,y or x,y,z of the point\n * @param p2 - x,y or x,y,z of the point\n * @returns distance\n */\nexport default function distanceToPointSquared(p1: Point, p2: Point): number {\n if (p1.length !== p2.length) {\n throw Error('Both points should have the same dimensionality');\n }\n\n const [x1, y1, z1 = 0] = p1;\n const [x2, y2, z2 = 0] = p2;\n const dx = x2 - x1;\n const dy = y2 - y1;\n const dz = z2 - z1;\n\n // Time to square 10M numbers:\n // (n * n) = 161ms | (n ** 2) = 199ms | Math.pow(n, 2) = 29529ms\n return dx * dx + dy * dy + dz * dz;\n}\n","import type { Types } from '@cornerstonejs/core';\n\n/**\n * Calculates the axis-aligned bounding box (AABB) of a polyline.\n *\n * @param polyline - The polyline represented as an array of points.\n * @param options - Additional options for calculating the AABB.\n * @param options.isWorld - Indicates whether the polyline represents points in 3D space (true) or 2D space (false).\n *\n * @returns The AABB of the polyline. If the polyline represents points in 3D space, returns an AABB3 object with properties minX, maxX, minY, maxY, minZ, and maxZ. If the polyline represents points in 2D space, returns an AABB2 object with properties minX, maxX, minY, and maxY.\n */\nexport default function getAABB(\n polyline: Types.Point2[] | Types.Point3[] | number[],\n options?: {\n numDimensions: number;\n }\n): Types.AABB2 | Types.AABB3 {\n // need to check if the polyline is array of arrays or just\n // a flat array of numbers\n let polylineToUse = polyline;\n const numDimensions = options?.numDimensions || 2;\n const is3D = numDimensions === 3;\n\n if (!Array.isArray(polyline[0])) {\n const currentPolyline = polyline as number[];\n // check the isWorld flag is provided or not which means every\n // 3 elements in the array represent a point in 3D space\n // otherwise, every 2 elements in the array represent a point in 2D space\n const totalPoints = currentPolyline.length / numDimensions;\n\n polylineToUse = new Array(currentPolyline.length / numDimensions) as\n | Types.Point2[]\n | Types.Point3[];\n\n for (let i = 0, len = totalPoints; i < len; i++) {\n polylineToUse[i] = [\n currentPolyline[i * numDimensions],\n currentPolyline[i * numDimensions + 1],\n ];\n\n if (is3D) {\n polylineToUse[i].push(currentPolyline[i * numDimensions + 2]);\n }\n }\n }\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n let minZ = Infinity;\n let maxZ = -Infinity;\n\n polylineToUse = polylineToUse as Types.Point2[] | Types.Point3[];\n\n for (let i = 0, len = polylineToUse.length; i < len; i++) {\n const [x, y, z] = polylineToUse[i];\n\n // No Math.min/max calls for better performance\n minX = minX < x ? minX : x;\n minY = minY < y ? minY : y;\n maxX = maxX > x ? maxX : x;\n maxY = maxY > y ? maxY : y;\n\n if (is3D) {\n minZ = minZ < z ? minZ : z;\n maxZ = maxZ > z ? maxZ : z;\n }\n }\n\n return is3D\n ? { minX, maxX, minY, maxY, minZ, maxZ } // AABB3\n : { minX, maxX, minY, maxY }; // AABB2\n}\n","import { vec3 } from 'gl-matrix';\n\n/**\n * Checks if a plane intersects with an Axis-Aligned Bounding Box (AABB).\n *\n * @param origin - The origin point of the plane.\n * @param normal - The normal vector of the plane.\n * @param minX - The minimum x-coordinate of the AABB.\n * @param minY - The minimum y-coordinate of the AABB.\n * @param minZ - The minimum z-coordinate of the AABB.\n * @param maxX - The maximum x-coordinate of the AABB.\n * @param maxY - The maximum y-coordinate of the AABB.\n * @param maxZ - The maximum z-coordinate of the AABB.\n * @returns A boolean indicating whether the plane intersects with the AABB.\n */\nexport const isPlaneIntersectingAABB = (\n origin,\n normal,\n minX,\n minY,\n minZ,\n maxX,\n maxY,\n maxZ\n) => {\n const vertices = [\n vec3.fromValues(minX, minY, minZ),\n vec3.fromValues(maxX, minY, minZ),\n vec3.fromValues(minX, maxY, minZ),\n vec3.fromValues(maxX, maxY, minZ),\n vec3.fromValues(minX, minY, maxZ),\n vec3.fromValues(maxX, minY, maxZ),\n vec3.fromValues(minX, maxY, maxZ),\n vec3.fromValues(maxX, maxY, maxZ),\n ];\n\n const normalVec = vec3.fromValues(normal[0], normal[1], normal[2]);\n const originVec = vec3.fromValues(origin[0], origin[1], origin[2]);\n\n // Compute the distance from the plane to the origin using vec3.dot\n const planeDistance = -vec3.dot(normalVec, originVec);\n\n // Check if all vertices are on the same side of the plane\n let initialSign = null;\n for (const vertex of vertices) {\n // Calculate distance using vec3.dot to simplify the equation\n const distance = vec3.dot(normalVec, vertex) + planeDistance;\n if (initialSign === null) {\n initialSign = Math.sign(distance);\n } else if (Math.sign(distance) !== initialSign) {\n return true; // Found a vertex on the other side, so it intersects\n }\n }\n\n return false;\n};\n","import { expose } from 'comlink';\nimport { utilities } from '@cornerstonejs/core';\nimport vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';\nimport vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';\nimport ICRPolySeg from '@icr/polyseg-wasm';\nimport vtkPlane from '@kitware/vtk.js/Common/DataModel/Plane';\nimport vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';\nimport vtkContourLoopExtraction from '@kitware/vtk.js/Filters/General/ContourLoopExtraction';\nimport vtkCutter from '@kitware/vtk.js/Filters/Core/Cutter';\n\nimport { getBoundingBoxAroundShapeWorld } from '../utilities/boundingBox';\nimport {\n containsPoint,\n getAABB,\n projectTo2D,\n} from '../utilities/math/polyline';\nimport { isPlaneIntersectingAABB } from '../utilities/planar';\n\n/**\n * Object containing methods for converting between different representations of\n * segmentations (e.g., contour, labelmap, surface, etc.) These logics\n * are used in a webworker to avoid blocking the main thread. You can\n * search for workerManager.executeTask('polySeg', ...) to see\n * how these methods are used.\n *\n * See also the webworker docs at packages/docs/docs/concepts/cornerstone-core/web-worker.md\n * to learn more about how to use web-workers in the context of Cornerstone.\n */\nconst polySegConverters = {\n /**\n * The polySeg instance that is used to convert between different representations\n */\n polySeg: null,\n /**\n * Utilities to keep track of the initialization state of the polySeg instance\n * and avoid initializing it multiple times\n */\n polySegInitializing: false,\n polySegInitializingPromise: null,\n /**\n * This method initializes the polySeg instance and sets it to this.polySeg\n */\n async initializePolySeg(progressCallback) {\n if (this.polySegInitializing) {\n await this.polySegInitializingPromise;\n return;\n }\n\n if (this.polySeg?.instance) {\n return;\n }\n\n this.polySegInitializing = true;\n this.polySegInitializingPromise = new Promise((resolve) => {\n this.polySeg = new ICRPolySeg();\n this.polySeg\n .initialize({\n updateProgress: progressCallback,\n })\n .then(() => {\n this.polySegInitializing = false;\n resolve();\n });\n });\n\n await this.polySegInitializingPromise;\n },\n /**\n * Converts a contour to a surface using the PolySeg library.\n * @param {Object} args - The arguments for the conversion.\n * @param {Array} args.polylines - The polylines representing the contour.\n * @param {Array} args.numPointsArray - The number of points in each polyline.\n * @param {...Function} callbacks - Optional callback functions.\n * @returns {Promise} - A promise that resolves to the converted surface.\n */\n async convertContourToSurface(args, ...callbacks) {\n const { polylines, numPointsArray } = args;\n const [progressCallback] = callbacks;\n await this.initializePolySeg(progressCallback);\n const results = await this.polySeg.instance.convertContourRoiToSurface(\n polylines,\n numPointsArray\n );\n\n return results;\n },\n /**\n * Converts a labelmap to a surface using the specified arguments.\n * @param {Object} args - The arguments for the conversion.\n * @param {Array} args.scalarData - The scalar data of the labelmap.\n * @param {Array} args.dimensions - The dimensions of the labelmap.\n * @param {Array} args.spacing - The spacing of the labelmap.\n * @param {Array} args.direction - The direction of the labelmap.\n * @param {Array} args.origin - The origin of the labelmap.\n * @param {number} args.segmentIndex - The segment index of the labelmap.\n * @param {Function} progressCallback - The callback function for progress updates.\n * @returns {Promise} - A promise that resolves with the converted surface results.\n */\n async convertLabelmapToSurface(args, ...callbacks) {\n const [progressCallback] = callbacks;\n await this.initializePolySeg(progressCallback);\n\n const results = this.polySeg.instance.convertLabelmapToSurface(\n args.scalarData,\n args.dimensions,\n args.spacing,\n args.direction,\n args.origin,\n [args.segmentIndex]\n );\n return results;\n },\n /**\n * Converts a contour to a volume labelmap.\n * @param {Object} args - The arguments for the conversion.\n * @param {Array} args.segmentIndices - The indices of the segments.\n * @param {Array} args.scalarData - The scalar data.\n * @param {Map} args.annotationUIDsInSegmentMap - The map of annotation UIDs in segment.\n * @param {Array} args.dimensions - The dimensions of the image data.\n * @param {Array} args.origin - The origin of the image data.\n * @param {Array} args.direction - The direction of the image data.\n * @param {Array} args.spacing - The spacing of the image data.\n * @param {...Function} callbacks - Optional callbacks.\n * @param {Function} callbacks[0] - The progress callback.\n * @returns {Array} - The scalar data of the segmentation voxel manager.\n */\n async convertContourToVolumeLabelmap(args, ...callbacks) {\n const [progressCallback] = callbacks;\n const polySeg = await new ICRPolySeg();\n await polySeg.initialize({\n updateProgress: progressCallback,\n });\n\n const {\n segmentIndices,\n scalarData,\n annotationUIDsInSegmentMap,\n dimensions,\n origin,\n direction,\n spacing,\n } = args;\n\n const segmentationVoxelManager =\n utilities.VoxelManager.createScalarVolumeVoxelManager({\n dimensions,\n scalarData,\n });\n\n const imageData = vtkImageData.newInstance();\n imageData.setDimensions(dimensions);\n imageData.setOrigin(origin);\n imageData.setDirection(direction);\n imageData.setSpacing(spacing);\n\n const scalarArray = vtkDataArray.newInstance({\n name: 'Pixels',\n numberOfComponents: 1,\n values: scalarData,\n });\n\n imageData.getPointData().setScalars(scalarArray);\n\n imageData.modified();\n\n for (const index of segmentIndices) {\n const annotations = annotationUIDsInSegmentMap.get(index);\n\n for (const annotation of annotations) {\n if (!annotation.polyline) {\n continue;\n }\n\n const { polyline, holesPolyline } = annotation;\n const bounds = getBoundingBoxAroundShapeWorld(polyline);\n\n const [iMin, jMin, kMin] = utilities.transformWorldToIndex(imageData, [\n bounds[0][0],\n bounds[1][0],\n bounds[2][0],\n ]);\n\n const [iMax, jMax, kMax] = utilities.transformWorldToIndex(imageData, [\n bounds[0][1],\n bounds[1][1],\n bounds[2][1],\n ]);\n\n const { projectedPolyline, sharedDimensionIndex } =\n projectTo2D(polyline);\n\n const holes = holesPolyline?.map((hole) => {\n const { projectedPolyline: projectedHole } = projectTo2D(hole);\n return projectedHole;\n });\n\n const firstDim = (sharedDimensionIndex + 1) % 3;\n const secondDim = (sharedDimensionIndex + 2) % 3;\n\n const voxels = utilities.VoxelManager.createScalarVolumeVoxelManager({\n dimensions,\n scalarData,\n });\n\n voxels.forEach(\n ({ pointIJK }) => {\n segmentationVoxelManager.setAtIJKPoint(pointIJK, index);\n },\n {\n imageData,\n isInObject: (pointLPS) => {\n const point2D = [pointLPS[firstDim], pointLPS[secondDim]];\n\n // Check if the point is inside any of the polylines for this segment\n const isInside = containsPoint(projectedPolyline, point2D, {\n holes,\n });\n\n return isInside;\n },\n boundsIJK: [\n [iMin, iMax],\n [jMin, jMax],\n [kMin, kMax],\n ],\n }\n );\n }\n }\n\n return segmentationVoxelManager.scalarData;\n },\n /**\n * Converts a contour to a stack labelmap.\n * @param {Object} args - The arguments for the conversion.\n * @param {Array} callbacks - Optional callbacks for progress updates.\n * @returns {Promise<Object>} - The converted segmentations information.\n */\n async convertContourToStackLabelmap(args, ...callbacks) {\n const [progressCallback] = callbacks;\n const polySeg = await new ICRPolySeg();\n await polySeg.initialize({\n updateProgress: progressCallback,\n });\n\n const { segmentationsInfo, annotationUIDsInSegmentMap, segmentIndices } =\n args;\n\n const segmentationVoxelManagers = new Map();\n\n segmentationsInfo.forEach((segmentationInfo, referencedImageId) => {\n const { dimensions, scalarData, direction, spacing, origin } =\n segmentationInfo;\n const manager = utilities.VoxelManager.createScalarVolumeVoxelManager({\n dimensions,\n scalarData,\n });\n\n const imageData = vtkImageData.newInstance();\n imageData.setDimensions(dimensions);\n imageData.setOrigin(origin);\n imageData.setDirection(direction);\n imageData.setSpacing(spacing);\n\n const scalarArray = vtkDataArray.newInstance({\n name: 'Pixels',\n numberOfComponents: 1,\n values: scalarData,\n });\n\n imageData.getPointData().setScalars(scalarArray);\n\n imageData.modified();\n\n segmentationVoxelManagers.set(referencedImageId, { manager, imageData });\n });\n\n for (const index of segmentIndices) {\n const annotations = annotationUIDsInSegmentMap.get(index);\n\n for (const annotation of annotations) {\n if (!annotation.polyline) {\n continue;\n }\n\n const { polyline, holesPolyline, referencedImageId } = annotation;\n const bounds = getBoundingBoxAroundShapeWorld(polyline);\n\n const { manager: segmentationVoxelManager, imageData } =\n segmentationVoxelManagers.get(referencedImageId);\n\n const [iMin, jMin, kMin] = utilities.transformWorldToIndex(imageData, [\n bounds[0][0],\n bounds[1][0],\n bounds[2][0],\n ]);\n\n const [iMax, jMax, kMax] = utilities.transformWorldToIndex(imageData, [\n bounds[0][1],\n bounds[1][1],\n bounds[2][1],\n ]);\n\n const { projectedPolyline, sharedDimensionIndex } =\n projectTo2D(polyline);\n\n const holes = holesPolyline?.map((hole) => {\n const { projectedPolyline: projectedHole } = projectTo2D(hole);\n return projectedHole;\n });\n\n const firstDim = (sharedDimensionIndex + 1) % 3;\n const secondDim = (sharedDimensionIndex + 2) % 3;\n\n const voxels = utilities.VoxelManager.createScalarVolumeVoxelManager({\n dimensions: imageData.getDimensions(),\n scalarData: imageData.getPointData().getScalars().getData(),\n });\n\n voxels.forEach(\n ({ pointIJK }) => {\n segmentationVoxelManager.setAtIJKPoint(pointIJK, index);\n },\n {\n imageData,\n isInObject: (pointLPS) => {\n const point2D = [pointLPS[firstDim], pointLPS[secondDim]];\n\n // Check if the point is inside any of the polylines for this segment\n const isInside = containsPoint(projectedPolyline, point2D, {\n holes,\n });\n\n return isInside;\n },\n boundsIJK: [\n [iMin, iMax],\n [jMin, jMax],\n [kMin, kMax],\n ],\n }\n );\n }\n }\n\n segmentationsInfo.forEach((segmentationInfo, referencedImageId) => {\n const { manager: segmentationVoxelManager } =\n segmentationVoxelManagers.get(referencedImageId);\n\n segmentationInfo.scalarData = segmentationVoxelManager.scalarData;\n });\n return segmentationsInfo;\n },\n /**\n * Converts a surface to a volume labelmap.\n *\n * @param {Object} args - The arguments for the conversion.\n * @param {Array} args.points - The points defining the surface.\n * @param {Array} args.polys - The polygons defining the surface.\n * @param {Array} args.dimensions - The dimensions of the volume.\n * @param {Array} args.spacing - The spacing between voxels in the volume.\n * @param {Array} args.direction - The direction of the volume.\n * @param {Array} args.origin - The origin of the volume.\n * @param {Function} progressCallback - The callback function for reporting progress.\n * @returns {Promise} - A promise that resolves with the converted labelmap.\n */\n async convertSurfaceToVolumeLabelmap(args, ...callbacks) {\n const [progressCallback] = callbacks;\n await this.initializePolySeg(progressCallback);\n\n const results = this.polySeg.instance.convertSurfaceToLabelmap(\n args.points,\n args.polys,\n args.dimensions,\n args.spacing,\n args.direction,\n args.origin\n );\n\n return results;\n },\n /**\n * Converts surfaces to a volume labelmap.\n * @param {Object} args - The arguments for the conversion.\n * @param {Map} args.segmentsInfo - A map containing information about the segments.\n * @param {Function} progressCallback - A callback function for reporting progress.\n * @returns {Uint8Array} - The resulting volume labelmap.\n */\n async convertSurfacesToVolumeLabelmap(args, ...callbacks) {\n const [progressCallback] = callbacks;\n await this.initializePolySeg(progressCallback);\n\n const { segmentsInfo } = args;\n\n const promises = Array.from(segmentsInfo.keys()).map((segmentIndex) => {\n const { points, polys } = segmentsInfo.get(segmentIndex);\n const result = this.polySeg.instance.convertSurfaceToLabelmap(\n points,\n polys,\n args.dimensions,\n args.spacing,\n args.direction,\n args.origin\n );\n\n return {\n ...result,\n segmentIndex,\n };\n });\n\n const results = await Promise.all(promises);\n\n const targetImageData = vtkImageData.newInstance();\n targetImageData.setDimensions(args.dimensions);\n targetImageData.setOrigin(args.origin);\n targetImageData.setSpacing(args.spacing);\n targetImageData.setDirection(args.direction);\n\n const totalSize =\n args.dimensions[0] * args.dimensions[1] * args.dimensions[2];\n\n const scalarArray = vtkDataArray.newInstance({\n name: 'Pixels',\n numberOfComponents: 1,\n values: new Uint8Array(totalSize),\n });\n\n targetImageData.getPointData().setScalars(scalarArray);\n targetImageData.modified();\n\n // we need to then consolidate the results into a single volume\n // by looping into each voxel with voxelmanager for each\n // and check if the voxel is inside any of the reconstructed\n // labelmaps\n const { dimensions } = args;\n const scalarData = targetImageData.getPointData().getScalars().getData();\n const segmentationVoxelManager =\n utilities.VoxelManager.createScalarVolumeVoxelManager({\n dimensions,\n scalarData,\n });\n\n const outputVolumesInfo = results.map((result) => {\n const { data, dimensions, direction, origin, spacing } = result;\n const volume = vtkImageData.newInstance();\n volume.setDimensions(dimensions);\n volume.setOrigin(origin);\n volume.setSpacing(spacing);\n volume.setDirection(direction);\n\n const scalarArray = vtkDataArray.newInstance({\n name: 'Pixels',\n numberOfComponents: 1,\n values: data,\n });\n\n volume.getPointData().setScalars(scalarArray);\n\n volume.modified();\n\n const voxelManager =\n utilities.VoxelManager.createScalarVolumeVoxelManager({\n dimensions,\n scalarData: data,\n });\n\n const extent = volume.getExtent(); // e.g., [0, 176, 0, 268, 0, 337] for dimensions of [177, 269, 338]\n\n return {\n volume,\n voxelManager,\n extent,\n scalarData: data,\n segmentIndex: result.segmentIndex,\n };\n });\n\n const voxels = utilities.VoxelManager.createScalarVolumeVoxelManager({\n dimensions: targetImageData.getDimensions(),\n scalarData: targetImageData.getPointData().getScalars().getData(),\n });\n\n voxels.forEach(\n ({ pointIJK, pointLPS }) => {\n // Check if the point is inside any of the reconstructed labelmaps\n // Todo: we can optimize this by returning early if the bounding box\n // of the point is outside the bounding box of the labelmap\n\n try {\n for (const volumeInfo of outputVolumesInfo) {\n const { volume, extent, voxelManager, segmentIndex } = volumeInfo;\n\n const index = volume.worldToIndex(pointLPS);\n\n // check if the ijk point is inside the volume\n if (\n index[0] < extent[0] ||\n index[0] > extent[1] ||\n index[1] < extent[2] ||\n index[1] > extent[3] ||\n index[2] < extent[4] ||\n index[2] > extent[5]\n ) {\n continue;\n }\n\n const roundedIndex = index.map(Math.round);\n const value = voxelManager.getAtIJK(...roundedIndex);\n if (value > 0) {\n segmentationVoxelManager.setAtIJKPoint(pointIJK, segmentIndex);\n break;\n }\n }\n } catch (error) {\n // right now there is weird error if the point is outside the volume\n }\n },\n { imageData: targetImageData }\n );\n\n return segmentationVoxelManager.scalarData;\n },\n getSurfacesAABBs({ surfacesInfo }) {\n const aabbs = new Map();\n for (const { points, id } of surfacesInfo) {\n const aabb = getAABB(points, { numDimensions: 3 });\n aabbs.set(id, aabb);\n }\n return aabbs;\n },\n /**\n * Cuts the surfaces into planes.\n *\n * @param {Object} options - The options object.\n * @param {Array} options.planesInfo - The information about the planes.\n * @param {Array} options.surfacesInfo - The information about the surfaces.\n * @param {Function} progressCallback - The callback function for progress updates.\n * @param {Function} updateCacheCallback - The callback function for updating the cache.\n */\n cutSurfacesIntoPlanes(\n { planesInfo, surfacesInfo, surfacesAABB = new Map() },\n progressCallback,\n updateCacheCallback\n ) {\n const numberOfPlanes = planesInfo.length;\n const cutter = vtkCutter.newInstance();\n\n const plane1 = vtkPlane.newInstance();\n\n cutter.setCutFunction(plane1);\n\n const surfacePolyData = vtkPolyData.newInstance();\n\n try {\n for (const [index, planeInfo] of planesInfo.entries()) {\n const { sliceIndex, planes } = planeInfo;\n\n const polyDataResults = new Map();\n for (const polyDataInfo of surfacesInfo) {\n const { points, polys, id } = polyDataInfo;\n\n const aabb3 =\n surfacesAABB.get(id) || getAABB(points, { numDimensions: 3 });\n\n if (!surfacesAABB.has(id)) {\n surfacesAABB.set(id, aabb3);\n }\n\n const { minX, minY, minZ, maxX, maxY, maxZ } = aabb3;\n\n const { origin, normal } = planes[0];\n\n // Check if the plane intersects the AABB\n if (\n !isPlaneIntersectingAABB(\n origin,\n normal,\n minX,\n minY,\n minZ,\n maxX,\n maxY,\n maxZ\n )\n ) {\n continue;\n }\n\n surfacePolyData.getPoints().setData(points, 3);\n surfacePolyData.getPolys().setData(polys, 3);\n surfacePolyData.modified();\n\n cutter.setInputData(surfacePolyData);\n plane1.setOrigin(origin);\n plane1.setNormal(normal);\n\n try {\n cutter.update();\n } catch (e) {\n console.warn('Error during clipping', e);\n continue;\n }\n\n const polyData = cutter.getOutputData();\n\n const cutterOutput = polyData;\n cutterOutput.buildLinks();\n const loopExtraction = vtkContourLoopExtraction.newInstance();\n loopExtraction.setInputData(cutterOutput);\n\n const loopOutput = loopExtraction.getOutputData();\n if (polyData) {\n polyDataResults.set(id, {\n points: loopOutput.getPoints().getData(),\n lines: loopOutput.getLines().getData(),\n numberOfCells: loopOutput.getLines().getNumberOfCells(),\n });\n }\n }\n\n progressCallback({ progress: (index + 1) / numberOfPlanes });\n\n updateCacheCallback({ sliceIndex, polyDataResults });\n }\n } catch (e) {\n console.warn('Error during processing', e);\n } finally {\n // Cleanup on completion\n surfacesInfo = null;\n plane1.delete();\n }\n },\n};\n\nexpose(polySegConverters);\n","module.exports = __WEBPACK_EXTERNAL_MODULE__785__;","module.exports = __WEBPACK_EXTERNAL_MODULE__283__;","module.exports = __WEBPACK_EXTERNAL_MODULE__864__;","module.exports = __WEBPACK_EXTERNAL_MODULE__70__;","module.exports = __WEBPACK_EXTERNAL_MODULE__481__;","module.exports = __WEBPACK_EXTERNAL_MODULE__336__;","module.exports = __WEBPACK_EXTERNAL_MODULE__953__;","module.exports = __WEBPACK_EXTERNAL_MODULE__976__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n// the startup function\n__webpack_require__.x = () => {\n\t// Load entry module and return exports\n\t// This entry module depends on other loaded chunks and execution need to be delayed\n\tvar __webpack_exports__ = __webpack_require__.O(undefined, [78], () => (__webpack_require__(280)))\n\t__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n\treturn __webpack_exports__;\n};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.f = {};\n// This file contains only the entry chunk.\n// The chunk loading function for additional chunks\n__webpack_require__.e = (chunkId) => {\n\treturn Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {\n\t\t__webpack_require__.f[key](chunkId, promises);\n\t\treturn promises;\n\t}, []));\n};","// This function allow to reference async chunks and sibling chunks for the entrypoint\n__webpack_require__.u = (chunkId) => {\n\t// return url for filenames based on template\n\treturn \"\" + chunkId + \".index.js\";\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","var scriptUrl;\nif (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + \"\";\nvar document = __webpack_require__.g.document;\nif (!scriptUrl && document) {\n\tif (document.currentScript)\n\t\tscriptUrl = document.currentScript.src;\n\tif (!scriptUrl) {\n\t\tvar scripts = document.getElementsByTagName(\"script\");\n\t\tif(scripts.length) {\n\t\t\tvar i = scripts.length - 1;\n\t\t\twhile (i > -1 && !scriptUrl) scriptUrl = scripts[i--].src;\n\t\t}\n\t}\n}\n// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration\n// or pass an empty string (\"\") and set the __webpack_public_path__ variable from your code to use your own logic.\nif (!scriptUrl) throw new Error(\"Automatic publicPath is not supported in this browser\");\nscriptUrl = scriptUrl.replace(/#.*$/, \"\").replace(/\\?.*$/, \"\").replace(/\\/[^\\/]+$/, \"/\");\n__webpack_require__.p = scriptUrl;","// no baseURI\n\n// object to store loaded chunks\n// \"1\" means \"already loaded\"\nvar installedChunks = {\n\t985: 1\n};\n\n// importScripts chunk loading\nvar installChunk = (data) => {\n\tvar chunkIds = data[0];\n\tvar moreModules = data[1];\n\tvar runtime = data[2];\n\tfor(var moduleId in moreModules) {\n\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t}\n\t}\n\tif(runtime) runtime(__webpack_require__);\n\twhile(chunkIds.length)\n\t\tinstalledChunks[chunkIds.pop()] = 1;\n\tparentChunkLoadingFunction(data);\n};\n__webpack_require__.f.i = (chunkId, promises) => {\n\t// \"1\" is the signal for \"already loaded\"\n\tif(!installedChunks[chunkId]) {\n\t\tif(true) { // all chunks have JS\n\t\t\timportScripts(__webpack_require__.p + __webpack_require__.u(chunkId));\n\t\t}\n\t}\n};\n\nvar chunkLoadingGlobal = self[\"webpackChunkcornerstoneTools3D\"] = self[\"webpackChunkcornerstoneTools3D\"] || [];\nvar parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);\nchunkLoadingGlobal.push = installChunk;\n\n// no HMR\n\n// no HMR manifest","// run startup\nvar __webpack_exports__ = __webpack_require__.x();\n"],"names":["root","factory","exports","module","require","define","amd","self","__WEBPACK_EXTERNAL_MODULE__953__","__WEBPACK_EXTERNAL_MODULE__283__","__WEBPACK_EXTERNAL_MODULE__785__","__WEBPACK_EXTERNAL_MODULE__864__","__WEBPACK_EXTERNAL_MODULE__70__","__WEBPACK_EXTERNAL_MODULE__336__","__WEBPACK_EXTERNAL_MODULE__481__","__WEBPACK_EXTERNAL_MODULE__976__","deferred","next","EPSILON","CONSTANTS","getBoundingBoxAroundShapeWorld","points","clipBounds","dimensions","isWorld","arguments","length","undefined","xMin","Infinity","xMax","yMin","yMax","zMin","zMax","is3D","i","p","Math","min","max","calculateBoundingBox","projectTo2D","polyline","sharedDimensionIndex","testPoints","utilities","every","point","index","array","abs","Error","points2D","firstDim","secondDim","push","projectedPolyline","containsPoint","options","closed","numPolylinePoints","numIntersections","holes","hole","shouldClose","distFirstToLastPoints","p1","p2","x1","y1","z1","x2","y2","z2","dx","dy","dz","distanceToPointSquared","glMatrix","isClosed","maxSegmentIndex","maxX","maxY","minY","intersects","xIntersection","getAABB","polylineToUse","numDimensions","Array","isArray","currentPolyline","totalPoints","len","minX","minZ","maxZ","x","y","z","isPlaneIntersectingAABB","origin","normal","vertices","vec3","normalVec","originVec","planeDistance","initialSign","vertex","distance","sign","polySegConverters","polySeg","polySegInitializing","polySegInitializingPromise","initializePolySeg","progressCallback","this","instance","Promise","resolve","ICRPolySeg","initialize","updateProgress","then","convertContourToSurface","args","polylines","numPointsArray","_len","callbacks","_key","convertContourRoiToSurface","convertLabelmapToSurface","_len2","_key2","scalarData","spacing","direction","segmentIndex","convertContourToVolumeLabelmap","_len3","_key3","segmentIndices","annotationUIDsInSegmentMap","segmentationVoxelManager","imageData","vtkImageData","setDimensions","setOrigin","setDirection","setSpacing","scalarArray","vtkDataArray","name","numberOfComponents","values","getPointData","setScalars","modified","annotations","get","annotation","holesPolyline","bounds","iMin","jMin","kMin","iMax","jMax","kMax","map","projectedHole","forEach","_ref","pointIJK","setAtIJKPoint","isInObject","pointLPS","point2D","boundsIJK","convertContourToStackLabelmap","_len4","_key4","segmentationsInfo","segmentationVoxelManagers","Map","segmentationInfo","referencedImageId","manager","set","getDimensions","getScalars","getData","_ref2","convertSurfaceToVolumeLabelmap","_len5","_key5","convertSurfaceToLabelmap","polys","convertSurfacesToVolumeLabelmap","_len6","_key6","segmentsInfo","promises","from","keys","results","all","targetImageData","totalSize","Uint8Array","outputVolumesInfo","result","data","volume","voxelManager","extent","getExtent","_ref3","volumeInfo","worldToIndex","roundedIndex","round","getAtIJK","error","getSurfacesAABBs","_ref4","surfacesInfo","aabbs","id","aabb","cutSurfacesIntoPlanes","_ref5","updateCacheCallback","planesInfo","surfacesAABB","numberOfPlanes","cutter","vtkCutter","plane1","vtkPlane","setCutFunction","surfacePolyData","vtkPolyData","planeInfo","entries","sliceIndex","planes","polyDataResults","polyDataInfo","aabb3","has","getPoints","setData","getPolys","setInputData","setNormal","update","e","console","warn","polyData","getOutputData","cutterOutput","buildLinks","loopExtraction","vtkContourLoopExtraction","loopOutput","lines","getLines","numberOfCells","getNumberOfCells","progress","delete","expose","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","m","__webpack_exports__","O","chunkIds","fn","priority","notFulfilled","fulfilled","j","Object","key","splice","r","n","getter","__esModule","d","a","definition","o","defineProperty","enumerable","f","chunkId","reduce","u","g","globalThis","Function","window","obj","prop","prototype","hasOwnProperty","call","scriptUrl","importScripts","location","document","currentScript","src","scripts","getElementsByTagName","replace","installedChunks","chunkLoadingGlobal","parentChunkLoadingFunction","bind","moreModules","runtime","pop"],"sourceRoot":""}