@cornerstonejs/tools 1.57.1 → 1.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dist/cjs/drawingSvg/drawPath.js +1 -1
  2. package/dist/cjs/drawingSvg/drawPath.js.map +1 -1
  3. package/dist/cjs/enums/WorkerTypes.d.ts +1 -1
  4. package/dist/cjs/enums/WorkerTypes.js +1 -1
  5. package/dist/cjs/enums/WorkerTypes.js.map +1 -1
  6. package/dist/cjs/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.d.ts +17 -0
  7. package/dist/cjs/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.js +112 -0
  8. package/dist/cjs/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.js.map +1 -0
  9. package/dist/cjs/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.d.ts +3 -1
  10. package/dist/cjs/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.js +4 -1
  11. package/dist/cjs/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.js.map +1 -1
  12. package/dist/cjs/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.d.ts +8 -0
  13. package/dist/cjs/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js +121 -0
  14. package/dist/cjs/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js.map +1 -0
  15. package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.d.ts +3 -0
  16. package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.js +73 -0
  17. package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.js.map +1 -0
  18. package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.d.ts +3 -0
  19. package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.js +25 -0
  20. package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.js.map +1 -0
  21. package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.d.ts +1 -0
  22. package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.js +41 -0
  23. package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.js.map +1 -0
  24. package/dist/cjs/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.js +2 -2
  25. package/dist/cjs/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.js.map +1 -1
  26. package/dist/cjs/stateManagement/segmentation/polySeg/Labelmap/convertSurfaceToLabelmap.js +1 -1
  27. package/dist/cjs/stateManagement/segmentation/polySeg/Labelmap/convertSurfaceToLabelmap.js.map +1 -1
  28. package/dist/cjs/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.js.map +1 -1
  29. package/dist/cjs/stateManagement/segmentation/polySeg/Surface/convertContourToSurface.js +1 -1
  30. package/dist/cjs/stateManagement/segmentation/polySeg/Surface/convertContourToSurface.js.map +1 -1
  31. package/dist/cjs/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.js +1 -1
  32. package/dist/cjs/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.js.map +1 -1
  33. package/dist/cjs/stateManagement/segmentation/polySeg/computeAndAddRepresentation.js +1 -1
  34. package/dist/cjs/stateManagement/segmentation/polySeg/computeAndAddRepresentation.js.map +1 -1
  35. package/dist/cjs/stateManagement/segmentation/triggerSegmentationEvents.js +2 -0
  36. package/dist/cjs/stateManagement/segmentation/triggerSegmentationEvents.js.map +1 -1
  37. package/dist/cjs/store/ToolGroupManager/getToolGroupForViewport.d.ts +1 -1
  38. package/dist/cjs/store/ToolGroupManager/getToolGroupForViewport.js +5 -0
  39. package/dist/cjs/store/ToolGroupManager/getToolGroupForViewport.js.map +1 -1
  40. package/dist/cjs/tools/annotation/SplineROITool.js +25 -20
  41. package/dist/cjs/tools/annotation/SplineROITool.js.map +1 -1
  42. package/dist/cjs/tools/base/BaseTool.js +3 -0
  43. package/dist/cjs/tools/base/BaseTool.js.map +1 -1
  44. package/dist/cjs/tools/base/ContourSegmentationBaseTool.js.map +1 -1
  45. package/dist/cjs/tools/displayTools/Contour/contourDisplay.js +13 -5
  46. package/dist/cjs/tools/displayTools/Contour/contourDisplay.js.map +1 -1
  47. package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js +1 -1
  48. package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
  49. package/dist/cjs/tools/displayTools/SegmentationDisplayTool.d.ts +1 -0
  50. package/dist/cjs/tools/displayTools/SegmentationDisplayTool.js +17 -0
  51. package/dist/cjs/tools/displayTools/SegmentationDisplayTool.js.map +1 -1
  52. package/dist/cjs/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js +4 -47
  53. package/dist/cjs/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js.map +1 -1
  54. package/dist/cjs/tools/displayTools/Surface/surfaceDisplay.d.ts +3 -9
  55. package/dist/cjs/tools/displayTools/Surface/surfaceDisplay.js +7 -148
  56. package/dist/cjs/tools/displayTools/Surface/surfaceDisplay.js.map +1 -1
  57. package/dist/cjs/types/PolySeg.d.ts +1 -1
  58. package/dist/cjs/utilities/contourSegmentation/addContourSegmentationAnnotation.js +4 -1
  59. package/dist/cjs/utilities/contourSegmentation/addContourSegmentationAnnotation.js.map +1 -1
  60. package/dist/cjs/utilities/contourSegmentation/removeContourSegmentationAnnotation.js +3 -0
  61. package/dist/cjs/utilities/contourSegmentation/removeContourSegmentationAnnotation.js.map +1 -1
  62. package/dist/cjs/utilities/math/polyline/getAABB.d.ts +3 -1
  63. package/dist/cjs/utilities/math/polyline/getAABB.js +30 -4
  64. package/dist/cjs/utilities/math/polyline/getAABB.js.map +1 -1
  65. package/dist/cjs/utilities/planar/index.d.ts +3 -1
  66. package/dist/cjs/utilities/planar/index.js +4 -1
  67. package/dist/cjs/utilities/planar/index.js.map +1 -1
  68. package/dist/cjs/utilities/planar/isPlaneIntersectingAABB.d.ts +1 -0
  69. package/dist/cjs/utilities/planar/isPlaneIntersectingAABB.js +32 -0
  70. package/dist/cjs/utilities/planar/isPlaneIntersectingAABB.js.map +1 -0
  71. package/dist/cjs/utilities/segmentation/getUniqueSegmentIndices.d.ts +3 -1
  72. package/dist/cjs/utilities/segmentation/getUniqueSegmentIndices.js +97 -47
  73. package/dist/cjs/utilities/segmentation/getUniqueSegmentIndices.js.map +1 -1
  74. package/dist/cjs/workers/polySegConverters.js +73 -0
  75. package/dist/cjs/workers/polySegConverters.js.map +1 -1
  76. package/dist/esm/drawingSvg/drawPath.js +1 -1
  77. package/dist/esm/drawingSvg/drawPath.js.map +1 -1
  78. package/dist/esm/enums/WorkerTypes.js +1 -1
  79. package/dist/esm/enums/WorkerTypes.js.map +1 -1
  80. package/dist/esm/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.js +91 -0
  81. package/dist/esm/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.js.map +1 -0
  82. package/dist/esm/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.js +4 -1
  83. package/dist/esm/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.js.map +1 -1
  84. package/dist/esm/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js +105 -0
  85. package/dist/esm/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js.map +1 -0
  86. package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.js +72 -0
  87. package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.js.map +1 -0
  88. package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.js +21 -0
  89. package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.js.map +1 -0
  90. package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.js +26 -0
  91. package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.js.map +1 -0
  92. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.js +2 -2
  93. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.js.map +1 -1
  94. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertSurfaceToLabelmap.js +1 -1
  95. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertSurfaceToLabelmap.js.map +1 -1
  96. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.js +1 -1
  97. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.js.map +1 -1
  98. package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertContourToSurface.js +1 -1
  99. package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertContourToSurface.js.map +1 -1
  100. package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.js +1 -1
  101. package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.js.map +1 -1
  102. package/dist/esm/stateManagement/segmentation/polySeg/computeAndAddRepresentation.js +1 -1
  103. package/dist/esm/stateManagement/segmentation/polySeg/computeAndAddRepresentation.js.map +1 -1
  104. package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.js +2 -0
  105. package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.js.map +1 -1
  106. package/dist/esm/store/ToolGroupManager/getToolGroupForViewport.js +4 -0
  107. package/dist/esm/store/ToolGroupManager/getToolGroupForViewport.js.map +1 -1
  108. package/dist/esm/tools/annotation/SplineROITool.js +25 -20
  109. package/dist/esm/tools/annotation/SplineROITool.js.map +1 -1
  110. package/dist/esm/tools/base/BaseTool.js +3 -0
  111. package/dist/esm/tools/base/BaseTool.js.map +1 -1
  112. package/dist/esm/tools/base/ContourSegmentationBaseTool.js.map +1 -1
  113. package/dist/esm/tools/displayTools/Contour/contourDisplay.js +13 -5
  114. package/dist/esm/tools/displayTools/Contour/contourDisplay.js.map +1 -1
  115. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +1 -1
  116. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
  117. package/dist/esm/tools/displayTools/SegmentationDisplayTool.js +17 -0
  118. package/dist/esm/tools/displayTools/SegmentationDisplayTool.js.map +1 -1
  119. package/dist/esm/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js +3 -46
  120. package/dist/esm/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js.map +1 -1
  121. package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js +8 -139
  122. package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js.map +1 -1
  123. package/dist/esm/utilities/contourSegmentation/addContourSegmentationAnnotation.js +4 -1
  124. package/dist/esm/utilities/contourSegmentation/addContourSegmentationAnnotation.js.map +1 -1
  125. package/dist/esm/utilities/contourSegmentation/removeContourSegmentationAnnotation.js +3 -0
  126. package/dist/esm/utilities/contourSegmentation/removeContourSegmentationAnnotation.js.map +1 -1
  127. package/dist/esm/utilities/math/polyline/getAABB.js +30 -4
  128. package/dist/esm/utilities/math/polyline/getAABB.js.map +1 -1
  129. package/dist/esm/utilities/planar/index.js +3 -1
  130. package/dist/esm/utilities/planar/index.js.map +1 -1
  131. package/dist/esm/utilities/planar/isPlaneIntersectingAABB.js +28 -0
  132. package/dist/esm/utilities/planar/isPlaneIntersectingAABB.js.map +1 -0
  133. package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.js +92 -44
  134. package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.js.map +1 -1
  135. package/dist/esm/workers/polySegConverters.js +74 -1
  136. package/dist/esm/workers/polySegConverters.js.map +1 -1
  137. package/dist/types/drawingSvg/drawPath.d.ts.map +1 -1
  138. package/dist/types/enums/WorkerTypes.d.ts +1 -1
  139. package/dist/types/enums/WorkerTypes.d.ts.map +1 -1
  140. package/dist/types/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.d.ts +18 -0
  141. package/dist/types/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.d.ts.map +1 -0
  142. package/dist/types/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.d.ts +3 -1
  143. package/dist/types/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.d.ts.map +1 -1
  144. package/dist/types/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.d.ts +9 -0
  145. package/dist/types/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.d.ts.map +1 -0
  146. package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.d.ts +4 -0
  147. package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.d.ts.map +1 -0
  148. package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.d.ts +4 -0
  149. package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.d.ts.map +1 -0
  150. package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.d.ts +2 -0
  151. package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.d.ts.map +1 -0
  152. package/dist/types/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.d.ts.map +1 -1
  153. package/dist/types/stateManagement/segmentation/triggerSegmentationEvents.d.ts.map +1 -1
  154. package/dist/types/store/ToolGroupManager/getToolGroupForViewport.d.ts +1 -1
  155. package/dist/types/store/ToolGroupManager/getToolGroupForViewport.d.ts.map +1 -1
  156. package/dist/types/tools/annotation/SplineROITool.d.ts.map +1 -1
  157. package/dist/types/tools/base/BaseTool.d.ts.map +1 -1
  158. package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts.map +1 -1
  159. package/dist/types/tools/displayTools/Contour/contourDisplay.d.ts.map +1 -1
  160. package/dist/types/tools/displayTools/SegmentationDisplayTool.d.ts +1 -0
  161. package/dist/types/tools/displayTools/SegmentationDisplayTool.d.ts.map +1 -1
  162. package/dist/types/tools/displayTools/Surface/addOrUpdateSurfaceToElement.d.ts.map +1 -1
  163. package/dist/types/tools/displayTools/Surface/surfaceDisplay.d.ts +3 -9
  164. package/dist/types/tools/displayTools/Surface/surfaceDisplay.d.ts.map +1 -1
  165. package/dist/types/types/PolySeg.d.ts +1 -1
  166. package/dist/types/types/PolySeg.d.ts.map +1 -1
  167. package/dist/types/utilities/contourSegmentation/addContourSegmentationAnnotation.d.ts.map +1 -1
  168. package/dist/types/utilities/contourSegmentation/removeContourSegmentationAnnotation.d.ts.map +1 -1
  169. package/dist/types/utilities/math/polyline/getAABB.d.ts +3 -1
  170. package/dist/types/utilities/math/polyline/getAABB.d.ts.map +1 -1
  171. package/dist/types/utilities/planar/index.d.ts +3 -1
  172. package/dist/types/utilities/planar/index.d.ts.map +1 -1
  173. package/dist/types/utilities/planar/isPlaneIntersectingAABB.d.ts +2 -0
  174. package/dist/types/utilities/planar/isPlaneIntersectingAABB.d.ts.map +1 -0
  175. package/dist/types/utilities/segmentation/getUniqueSegmentIndices.d.ts +3 -1
  176. package/dist/types/utilities/segmentation/getUniqueSegmentIndices.d.ts.map +1 -1
  177. package/dist/umd/985.index.js +1 -1
  178. package/dist/umd/985.index.js.map +1 -1
  179. package/dist/umd/index.js +1 -1
  180. package/dist/umd/index.js.map +1 -1
  181. package/package.json +4 -4
  182. package/src/drawingSvg/drawPath.ts +3 -1
  183. package/src/enums/WorkerTypes.ts +1 -1
  184. package/src/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.ts +203 -0
  185. package/src/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.ts +9 -2
  186. package/src/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.ts +201 -0
  187. package/src/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.ts +103 -0
  188. package/src/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.ts +38 -0
  189. package/src/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.ts +58 -0
  190. package/src/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.ts +2 -2
  191. package/src/stateManagement/segmentation/polySeg/Labelmap/convertSurfaceToLabelmap.ts +1 -1
  192. package/src/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.ts +3 -8
  193. package/src/stateManagement/segmentation/polySeg/Surface/convertContourToSurface.ts +1 -1
  194. package/src/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.ts +1 -1
  195. package/src/stateManagement/segmentation/polySeg/computeAndAddRepresentation.ts +1 -1
  196. package/src/stateManagement/segmentation/triggerSegmentationEvents.ts +5 -0
  197. package/src/store/ToolGroupManager/getToolGroupForViewport.ts +8 -1
  198. package/src/tools/annotation/SplineROITool.ts +34 -27
  199. package/src/tools/base/BaseTool.ts +7 -0
  200. package/src/tools/base/ContourSegmentationBaseTool.ts +5 -0
  201. package/src/tools/displayTools/Contour/contourDisplay.ts +29 -11
  202. package/src/tools/displayTools/Labelmap/labelmapDisplay.ts +1 -1
  203. package/src/tools/displayTools/SegmentationDisplayTool.ts +26 -0
  204. package/src/tools/displayTools/Surface/addOrUpdateSurfaceToElement.ts +3 -65
  205. package/src/tools/displayTools/Surface/surfaceDisplay.ts +12 -247
  206. package/src/types/PolySeg.ts +1 -1
  207. package/src/utilities/contourSegmentation/addContourSegmentationAnnotation.ts +9 -1
  208. package/src/utilities/contourSegmentation/removeContourSegmentationAnnotation.ts +4 -0
  209. package/src/utilities/math/polyline/getAABB.ts +58 -4
  210. package/src/utilities/planar/index.ts +3 -0
  211. package/src/utilities/planar/isPlaneIntersectingAABB.ts +56 -0
  212. package/src/utilities/segmentation/getUniqueSegmentIndices.ts +115 -49
  213. package/src/workers/polySegConverters.js +117 -1
  214. package/dist/cjs/tools/displayTools/registerDisplayToolsWorker.d.ts +0 -1
  215. package/dist/cjs/tools/displayTools/registerDisplayToolsWorker.js +0 -27
  216. package/dist/cjs/tools/displayTools/registerDisplayToolsWorker.js.map +0 -1
  217. package/dist/cjs/workers/clippingPlaneWorker.d.ts +0 -1
  218. package/dist/cjs/workers/clippingPlaneWorker.js +0 -63
  219. package/dist/cjs/workers/clippingPlaneWorker.js.map +0 -1
  220. package/dist/esm/tools/displayTools/registerDisplayToolsWorker.js +0 -23
  221. package/dist/esm/tools/displayTools/registerDisplayToolsWorker.js.map +0 -1
  222. package/dist/esm/workers/clippingPlaneWorker.js +0 -58
  223. package/dist/esm/workers/clippingPlaneWorker.js.map +0 -1
  224. package/dist/types/tools/displayTools/registerDisplayToolsWorker.d.ts +0 -2
  225. package/dist/types/tools/displayTools/registerDisplayToolsWorker.d.ts.map +0 -1
  226. package/dist/types/workers/clippingPlaneWorker.d.ts +0 -2
  227. package/dist/types/workers/clippingPlaneWorker.d.ts.map +0 -1
  228. package/dist/umd/444.index.js +0 -3
  229. package/dist/umd/444.index.js.LICENSE.txt +0 -5
  230. package/dist/umd/444.index.js.map +0 -1
  231. package/src/tools/displayTools/registerDisplayToolsWorker.ts +0 -34
  232. package/src/workers/clippingPlaneWorker.js +0 -87
@@ -1,7 +1,38 @@
1
1
  import { Types, cache } from '@cornerstonejs/core';
2
- import { SegmentationRepresentations } from '../../enums';
3
2
  import { getSegmentation } from '../../stateManagement/segmentation/segmentationState';
4
3
  import { isVolumeSegmentation } from '../../tools/segmentation/strategies/utils/stackVolumeCheck';
4
+ import { SegmentationRepresentations } from '../../enums';
5
+
6
+ const segmentIndicesCache = new Map<
7
+ string,
8
+ { indices: number[]; isDirty: boolean }
9
+ >();
10
+
11
+ /**
12
+ * Sets the segmentation as dirty, indicating that it needs to be updated.
13
+ * @param segmentationId - The ID of the segmentation.
14
+ */
15
+ export const setSegmentationDirty = (segmentationId: string) => {
16
+ const cached = segmentIndicesCache.get(segmentationId);
17
+ if (cached) {
18
+ cached.isDirty = true;
19
+ }
20
+ };
21
+
22
+ export const setSegmentationClean = (segmentationId: string) => {
23
+ const cached = segmentIndicesCache.get(segmentationId);
24
+ if (cached) {
25
+ cached.isDirty = false;
26
+ }
27
+ };
28
+
29
+ function getCachedSegmentIndices(segmentationId) {
30
+ const cached = segmentIndicesCache.get(segmentationId);
31
+ if (cached && !cached.isDirty) {
32
+ return cached.indices;
33
+ }
34
+ return null;
35
+ }
5
36
 
6
37
  /**
7
38
  * Retrieves the unique segment indices from a given segmentation.
@@ -11,66 +42,101 @@ import { isVolumeSegmentation } from '../../tools/segmentation/strategies/utils/
11
42
  * @throws If no geometryIds are found for the segmentationId.
12
43
  */
13
44
  function getUniqueSegmentIndices(segmentationId) {
14
- const segmentation = getSegmentation(segmentationId);
45
+ // Attempt to fetch from cache first
46
+ const cachedResult = getCachedSegmentIndices(segmentationId);
47
+ if (cachedResult) {
48
+ return cachedResult;
49
+ }
15
50
 
16
- if (segmentation.type === SegmentationRepresentations.Labelmap) {
17
- const labelmapData =
18
- segmentation.representationData[SegmentationRepresentations.Labelmap];
51
+ const segmentation = getSegmentation(segmentationId);
52
+ if (!segmentation) {
53
+ throw new Error(
54
+ `No segmentation found for segmentationId ${segmentationId}`
55
+ );
56
+ }
19
57
 
20
- const keySet = new Set();
58
+ let indices;
59
+ switch (segmentation.type) {
60
+ case SegmentationRepresentations.Labelmap:
61
+ indices = handleLabelmapSegmentation(segmentation, segmentationId);
62
+ break;
63
+ case SegmentationRepresentations.Contour:
64
+ indices = handleContourSegmentation(segmentation);
65
+ break;
66
+ case SegmentationRepresentations.Surface:
67
+ indices = handleSurfaceSegmentation(segmentation);
68
+ break;
69
+ default:
70
+ throw new Error(`Unsupported segmentation type: ${segmentation.type}`);
71
+ }
21
72
 
22
- if (isVolumeSegmentation(labelmapData)) {
23
- const volume = cache.getVolume(segmentationId);
24
- const scalarData = volume.getScalarData();
73
+ // Update cache
74
+ segmentIndicesCache.set(segmentationId, { indices, isDirty: false });
75
+ return indices;
76
+ }
25
77
 
26
- for (let i = 0; i < scalarData.length; i++) {
27
- const segmentIndex = scalarData[i];
28
- if (segmentIndex !== 0) {
29
- keySet.add(segmentIndex);
30
- }
31
- }
32
- } else {
33
- labelmapData.imageIdReferenceMap.forEach((segmentationImageId) => {
34
- const image = cache.getImage(segmentationImageId);
35
- const scalarData = image.getPixelData();
36
-
37
- for (let i = 0; i < scalarData.length; i++) {
38
- const segmentIndex = scalarData[i];
39
- if (segmentIndex !== 0) {
40
- keySet.add(segmentIndex);
41
- }
42
- }
43
- });
44
- }
78
+ function handleLabelmapSegmentation(segmentation, segmentationId) {
79
+ const labelmapData =
80
+ segmentation.representationData[SegmentationRepresentations.Labelmap];
81
+ const keySet = new Set();
45
82
 
46
- return Array.from(keySet)
47
- .map((it) => parseInt(it as string))
48
- .sort();
49
- } else if (segmentation.type === SegmentationRepresentations.Contour) {
50
- const annotationUIDsMap =
51
- segmentation.representationData.CONTOUR?.annotationUIDsMap;
83
+ if (isVolumeSegmentation(labelmapData)) {
84
+ addVolumeSegmentIndices(keySet, segmentationId);
85
+ } else {
86
+ addImageSegmentIndices(keySet, labelmapData.imageIdReferenceMap);
87
+ }
52
88
 
53
- const indices = new Set(annotationUIDsMap.keys());
54
- const geometryIds = segmentation.representationData.CONTOUR?.geometryIds;
89
+ return Array.from(keySet)
90
+ .map(Number)
91
+ .sort((a, b) => a - b);
92
+ }
55
93
 
56
- if (!geometryIds) {
57
- throw new Error(
58
- `No geometryIds found for segmentationId ${segmentationId}`
59
- );
94
+ function addVolumeSegmentIndices(keySet, segmentationId) {
95
+ const volume = cache.getVolume(segmentationId);
96
+ const scalarData = volume.getScalarData();
97
+ scalarData.forEach((segmentIndex) => {
98
+ if (segmentIndex !== 0) {
99
+ keySet.add(segmentIndex);
60
100
  }
101
+ });
102
+ }
61
103
 
62
- geometryIds.forEach((geometryId) => {
63
- const geometry = cache.getGeometry(geometryId) as Types.IGeometry;
64
- indices.add((geometry.data as Types.IContourSet).getSegmentIndex());
104
+ function addImageSegmentIndices(keySet, imageIdReferenceMap) {
105
+ imageIdReferenceMap.forEach((segmentationImageId) => {
106
+ const image = cache.getImage(segmentationImageId);
107
+ const scalarData = image.getPixelData();
108
+ scalarData.forEach((segmentIndex) => {
109
+ if (segmentIndex !== 0) {
110
+ keySet.add(segmentIndex);
111
+ }
65
112
  });
113
+ });
114
+ }
66
115
 
67
- return Array.from(indices.values()).sort();
68
- } else if (segmentation.type === SegmentationRepresentations.Surface) {
69
- const geometryIds =
70
- segmentation.representationData.SURFACE?.geometryIds ?? [];
71
-
72
- return Array.from(geometryIds.keys());
116
+ function handleContourSegmentation(segmentation) {
117
+ const { annotationUIDsMap, geometryIds } =
118
+ segmentation.representationData.CONTOUR || {};
119
+ if (!geometryIds) {
120
+ throw new Error(
121
+ `No geometryIds found for segmentationId ${segmentation.segmentationId}`
122
+ );
73
123
  }
124
+
125
+ const indices = new Set([...annotationUIDsMap.keys()]);
126
+ geometryIds.forEach((geometryId) => {
127
+ const geometry = cache.getGeometry(geometryId);
128
+ indices.add((geometry.data as Types.IContourSet).getSegmentIndex());
129
+ });
130
+
131
+ return Array.from(indices).sort((a, b) => a - b);
132
+ }
133
+
134
+ function handleSurfaceSegmentation(segmentation) {
135
+ const geometryIds =
136
+ segmentation.representationData.SURFACE?.geometryIds ?? [];
137
+ return Array.from(geometryIds.keys())
138
+ .map(Number)
139
+ .sort((a, b) => a - b);
74
140
  }
75
141
 
76
142
  export { getUniqueSegmentIndices };
@@ -3,9 +3,15 @@ import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
3
3
  import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
4
4
  import ICRPolySeg from '@icr/polyseg-wasm';
5
5
  import { utilities } from '@cornerstonejs/core';
6
+ import vtkPlane from '@kitware/vtk.js/Common/DataModel/Plane';
7
+ import vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';
8
+ import vtkContourLoopExtraction from '@kitware/vtk.js/Filters/General/ContourLoopExtraction';
9
+ import vtkCutter from '@kitware/vtk.js/Filters/Core/Cutter';
10
+
6
11
  import { getBoundingBoxAroundShapeWorld } from '../utilities/boundingBox';
7
12
  import { pointInShapeCallback } from '../utilities';
8
- import { isPointInsidePolyline3D } from '../utilities/math/polyline';
13
+ import { getAABB, isPointInsidePolyline3D } from '../utilities/math/polyline';
14
+ import { isPlaneIntersectingAABB } from '../utilities/planar';
9
15
 
10
16
  /**
11
17
  * Object containing methods for converting between different representations of
@@ -462,6 +468,116 @@ const polySegConverters = {
462
468
 
463
469
  return segmentationVoxelManager.scalarData;
464
470
  },
471
+ getSurfacesAABBs({ surfacesInfo }) {
472
+ const aabbs = new Map();
473
+ for (const { points, id } of surfacesInfo) {
474
+ const aabb = getAABB(points, { numDimensions: 3 });
475
+ aabbs.set(id, aabb);
476
+ }
477
+ return aabbs;
478
+ },
479
+ /**
480
+ * Cuts the surfaces into planes.
481
+ *
482
+ * @param {Object} options - The options object.
483
+ * @param {Array} options.planesInfo - The information about the planes.
484
+ * @param {Array} options.surfacesInfo - The information about the surfaces.
485
+ * @param {Function} progressCallback - The callback function for progress updates.
486
+ * @param {Function} updateCacheCallback - The callback function for updating the cache.
487
+ */
488
+ cutSurfacesIntoPlanes(
489
+ { planesInfo, surfacesInfo, surfacesAABB = new Map() },
490
+ progressCallback,
491
+ updateCacheCallback
492
+ ) {
493
+ const numberOfPlanes = planesInfo.length;
494
+ const cutter = vtkCutter.newInstance();
495
+
496
+ const plane1 = vtkPlane.newInstance();
497
+
498
+ cutter.setCutFunction(plane1);
499
+
500
+ const surfacePolyData = vtkPolyData.newInstance();
501
+
502
+ try {
503
+ for (const [index, planeInfo] of planesInfo.entries()) {
504
+ const { sliceIndex, planes } = planeInfo;
505
+
506
+ const polyDataResults = new Map();
507
+ for (const polyDataInfo of surfacesInfo) {
508
+ const { points, polys, id } = polyDataInfo;
509
+
510
+ const aabb3 =
511
+ surfacesAABB.get(id) || getAABB(points, { numDimensions: 3 });
512
+
513
+ if (!surfacesAABB.has(id)) {
514
+ surfacesAABB.set(id, aabb3);
515
+ }
516
+
517
+ const { minX, minY, minZ, maxX, maxY, maxZ } = aabb3;
518
+
519
+ const { origin, normal } = planes[0];
520
+
521
+ // Check if the plane intersects the AABB
522
+ if (
523
+ !isPlaneIntersectingAABB(
524
+ origin,
525
+ normal,
526
+ minX,
527
+ minY,
528
+ minZ,
529
+ maxX,
530
+ maxY,
531
+ maxZ
532
+ )
533
+ ) {
534
+ continue;
535
+ }
536
+
537
+ surfacePolyData.getPoints().setData(points, 3);
538
+ surfacePolyData.getPolys().setData(polys, 3);
539
+ surfacePolyData.modified();
540
+
541
+ cutter.setInputData(surfacePolyData);
542
+ plane1.setOrigin(origin);
543
+ plane1.setNormal(normal);
544
+
545
+ try {
546
+ cutter.update();
547
+ } catch (e) {
548
+ console.warn('Error during clipping', e);
549
+ continue;
550
+ }
551
+
552
+ const polyData = cutter.getOutputData();
553
+
554
+ const cutterOutput = polyData;
555
+ cutterOutput.buildLinks();
556
+ const loopExtraction = vtkContourLoopExtraction.newInstance();
557
+ loopExtraction.setInputData(cutterOutput);
558
+
559
+ const loopOutput = loopExtraction.getOutputData();
560
+ if (polyData) {
561
+ polyDataResults.set(id, {
562
+ points: loopOutput.getPoints().getData(),
563
+ lines: loopOutput.getLines().getData(),
564
+ numberOfCells: loopOutput.getLines().getNumberOfCells(),
565
+ });
566
+ }
567
+ }
568
+
569
+ progressCallback({ progress: (index + 1) / numberOfPlanes });
570
+
571
+ updateCacheCallback({ sliceIndex, polyDataResults });
572
+ }
573
+ } catch (e) {
574
+ console.warn('Error during processing', e);
575
+ } finally {
576
+ // Cleanup on completion
577
+ surfacesInfo = null;
578
+ plane1.delete();
579
+ }
580
+ },
465
581
  };
466
582
 
467
583
  expose(polySegConverters);
@@ -1 +0,0 @@
1
- export declare function registerDisplayToolsWorker(): void;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerDisplayToolsWorker = void 0;
4
- const core_1 = require("@cornerstonejs/core");
5
- let registered = false;
6
- function registerDisplayToolsWorker() {
7
- if (registered) {
8
- return;
9
- }
10
- registered = true;
11
- const workerFn = () => {
12
- return new Worker(new URL('../../workers/clippingPlaneWorker', import.meta.url), {
13
- name: 'displayTools',
14
- });
15
- };
16
- const workerManager = (0, core_1.getWebWorkerManager)();
17
- const options = {
18
- maxWorkerInstances: 1,
19
- autoTerminateOnIdle: {
20
- enabled: true,
21
- idleTimeThreshold: 2000,
22
- },
23
- };
24
- workerManager.registerWorker('displayTools', workerFn, options);
25
- }
26
- exports.registerDisplayToolsWorker = registerDisplayToolsWorker;
27
- //# sourceMappingURL=registerDisplayToolsWorker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registerDisplayToolsWorker.js","sourceRoot":"","sources":["../../../../src/tools/displayTools/registerDisplayToolsWorker.ts"],"names":[],"mappings":";;;AAAA,8CAA0D;AAE1D,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB,SAAgB,0BAA0B;IACxC,IAAI,UAAU,EAAE;QACd,OAAO;KACR;IAED,UAAU,GAAG,IAAI,CAAC;IAElB,MAAM,QAAQ,GAAG,GAAG,EAAE;QAEpB,OAAO,IAAI,MAAM,CAEf,IAAI,GAAG,CAAC,mCAAmC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAC7D;YACE,IAAI,EAAE,cAAc;SACrB,CACF,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,IAAA,0BAAmB,GAAE,CAAC;IAE5C,MAAM,OAAO,GAAG;QACd,kBAAkB,EAAE,CAAC;QACrB,mBAAmB,EAAE;YACnB,OAAO,EAAE,IAAI;YACb,iBAAiB,EAAE,IAAI;SACxB;KACF,CAAC;IAEF,aAAa,CAAC,cAAc,CAAC,cAAc,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC;AA7BD,gEA6BC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,63 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const comlink_1 = require("comlink");
7
- const Plane_1 = __importDefault(require("@kitware/vtk.js/Common/DataModel/Plane"));
8
- const ClipClosedSurface_1 = __importDefault(require("@kitware/vtk.js/Filters/General/ClipClosedSurface"));
9
- const PolyData_1 = __importDefault(require("@kitware/vtk.js/Common/DataModel/PolyData"));
10
- const obj = {
11
- clipSurfaceWithPlanes({ planesInfo, pointsAndPolys }, progressCallback, updateCacheCallback) {
12
- const numberOfPlanes = planesInfo.length;
13
- const clippingFilter = ClipClosedSurface_1.default.newInstance({
14
- clippingPlanes: [],
15
- activePlaneId: 2,
16
- passPointData: false,
17
- });
18
- clippingFilter.setGenerateOutline(true);
19
- clippingFilter.setGenerateFaces(false);
20
- const plane1 = Plane_1.default.newInstance();
21
- const plane2 = Plane_1.default.newInstance();
22
- try {
23
- for (const [index, planeInfo] of planesInfo.entries()) {
24
- const { sliceIndex, planes } = planeInfo;
25
- const polyDataResults = new Map();
26
- for (const polyDataInfo of pointsAndPolys) {
27
- const { points, polys, id } = polyDataInfo;
28
- const surfacePolyData = PolyData_1.default.newInstance();
29
- surfacePolyData.getPoints().setData(points, 3);
30
- surfacePolyData.getPolys().setData(polys, 3);
31
- clippingFilter.setInputData(surfacePolyData);
32
- const clippingPlanes = [plane1, plane2];
33
- plane1.setOrigin(planes[0].origin);
34
- plane1.setNormal(planes[0].normal);
35
- plane2.setOrigin(planes[1].origin);
36
- plane2.setNormal(planes[1].normal);
37
- clippingFilter.setClippingPlanes(clippingPlanes);
38
- clippingFilter.update();
39
- const polyData = clippingFilter.getOutputData();
40
- if (polyData) {
41
- polyDataResults.set(id, {
42
- points: polyData.getPoints().getData(),
43
- lines: polyData.getLines().getData(),
44
- });
45
- }
46
- }
47
- progressCallback({ progress: (index + 1) / numberOfPlanes });
48
- updateCacheCallback({ sliceIndex, polyDataResults });
49
- }
50
- }
51
- catch (e) {
52
- console.error('Error during processing', e);
53
- }
54
- finally {
55
- pointsAndPolys = null;
56
- clippingFilter.delete();
57
- plane1.delete();
58
- plane2.delete();
59
- }
60
- },
61
- };
62
- (0, comlink_1.expose)(obj);
63
- //# sourceMappingURL=clippingPlaneWorker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clippingPlaneWorker.js","sourceRoot":"","sources":["../../../src/workers/clippingPlaneWorker.js"],"names":[],"mappings":";;;;;AAAA,qCAAiC;AACjC,mFAA8D;AAC9D,0GAAqF;AACrF,yFAAoE;AAEpE,MAAM,GAAG,GAAG;IAYV,qBAAqB,CACnB,EAAE,UAAU,EAAE,cAAc,EAAE,EAC9B,gBAAgB,EAChB,mBAAmB;QAEnB,MAAM,cAAc,GAAG,UAAU,CAAC,MAAM,CAAC;QACzC,MAAM,cAAc,GAAG,2BAAoB,CAAC,WAAW,CAAC;YACtD,cAAc,EAAE,EAAE;YAClB,aAAa,EAAE,CAAC;YAChB,aAAa,EAAE,KAAK;SACrB,CAAC,CAAC;QACH,cAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACxC,cAAc,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAEvC,MAAM,MAAM,GAAG,eAAQ,CAAC,WAAW,EAAE,CAAC;QACtC,MAAM,MAAM,GAAG,eAAQ,CAAC,WAAW,EAAE,CAAC;QAEtC,IAAI;YACF,KAAK,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE;gBACrD,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;gBAEzC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAE,CAAC;gBAClC,KAAK,MAAM,YAAY,IAAI,cAAc,EAAE;oBACzC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,EAA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AC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,CAAC,CAAC;SAC7C;gBAAS;YAER,cAAc,GAAG,IAAI,CAAC;YACtB,cAAc,CAAC,MAAM,EAAE,CAAC;YACxB,MAAM,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,CAAC,MAAM,EAAE,CAAC;SACjB;IACH,CAAC;CACF,CAAC;AAEF,IAAA,gBAAM,EAAC,GAAG,CAAC,CAAC"}
@@ -1,23 +0,0 @@
1
- import { getWebWorkerManager } from '@cornerstonejs/core';
2
- let registered = false;
3
- export function registerDisplayToolsWorker() {
4
- if (registered) {
5
- return;
6
- }
7
- registered = true;
8
- const workerFn = () => {
9
- return new Worker(new URL('../../workers/clippingPlaneWorker', import.meta.url), {
10
- name: 'displayTools',
11
- });
12
- };
13
- const workerManager = getWebWorkerManager();
14
- const options = {
15
- maxWorkerInstances: 1,
16
- autoTerminateOnIdle: {
17
- enabled: true,
18
- idleTimeThreshold: 2000,
19
- },
20
- };
21
- workerManager.registerWorker('displayTools', workerFn, options);
22
- }
23
- //# sourceMappingURL=registerDisplayToolsWorker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registerDisplayToolsWorker.js","sourceRoot":"","sources":["../../../../src/tools/displayTools/registerDisplayToolsWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB,MAAM,UAAU,0BAA0B;IACxC,IAAI,UAAU,EAAE;QACd,OAAO;KACR;IAED,UAAU,GAAG,IAAI,CAAC;IAElB,MAAM,QAAQ,GAAG,GAAG,EAAE;QAEpB,OAAO,IAAI,MAAM,CAEf,IAAI,GAAG,CAAC,mCAAmC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAC7D;YACE,IAAI,EAAE,cAAc;SACrB,CACF,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,mBAAmB,EAAE,CAAC;IAE5C,MAAM,OAAO,GAAG;QACd,kBAAkB,EAAE,CAAC;QACrB,mBAAmB,EAAE;YACnB,OAAO,EAAE,IAAI;YACb,iBAAiB,EAAE,IAAI;SACxB;KACF,CAAC;IAEF,aAAa,CAAC,cAAc,CAAC,cAAc,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAClE,CAAC"}
@@ -1,58 +0,0 @@
1
- import { expose } from 'comlink';
2
- import vtkPlane from '@kitware/vtk.js/Common/DataModel/Plane';
3
- import vtkClipClosedSurface from '@kitware/vtk.js/Filters/General/ClipClosedSurface';
4
- import vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';
5
- const obj = {
6
- clipSurfaceWithPlanes({ planesInfo, pointsAndPolys }, progressCallback, updateCacheCallback) {
7
- const numberOfPlanes = planesInfo.length;
8
- const clippingFilter = vtkClipClosedSurface.newInstance({
9
- clippingPlanes: [],
10
- activePlaneId: 2,
11
- passPointData: false,
12
- });
13
- clippingFilter.setGenerateOutline(true);
14
- clippingFilter.setGenerateFaces(false);
15
- const plane1 = vtkPlane.newInstance();
16
- const plane2 = vtkPlane.newInstance();
17
- try {
18
- for (const [index, planeInfo] of planesInfo.entries()) {
19
- const { sliceIndex, planes } = planeInfo;
20
- const polyDataResults = new Map();
21
- for (const polyDataInfo of pointsAndPolys) {
22
- const { points, polys, id } = polyDataInfo;
23
- const surfacePolyData = vtkPolyData.newInstance();
24
- surfacePolyData.getPoints().setData(points, 3);
25
- surfacePolyData.getPolys().setData(polys, 3);
26
- clippingFilter.setInputData(surfacePolyData);
27
- const clippingPlanes = [plane1, plane2];
28
- plane1.setOrigin(planes[0].origin);
29
- plane1.setNormal(planes[0].normal);
30
- plane2.setOrigin(planes[1].origin);
31
- plane2.setNormal(planes[1].normal);
32
- clippingFilter.setClippingPlanes(clippingPlanes);
33
- clippingFilter.update();
34
- const polyData = clippingFilter.getOutputData();
35
- if (polyData) {
36
- polyDataResults.set(id, {
37
- points: polyData.getPoints().getData(),
38
- lines: polyData.getLines().getData(),
39
- });
40
- }
41
- }
42
- progressCallback({ progress: (index + 1) / numberOfPlanes });
43
- updateCacheCallback({ sliceIndex, polyDataResults });
44
- }
45
- }
46
- catch (e) {
47
- console.error('Error during processing', e);
48
- }
49
- finally {
50
- pointsAndPolys = null;
51
- clippingFilter.delete();
52
- plane1.delete();
53
- plane2.delete();
54
- }
55
- },
56
- };
57
- expose(obj);
58
- //# sourceMappingURL=clippingPlaneWorker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clippingPlaneWorker.js","sourceRoot":"","sources":["../../../src/workers/clippingPlaneWorker.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,QAAQ,MAAM,wCAAwC,CAAC;AAC9D,OAAO,oBAAoB,MAAM,mDAAmD,CAAC;AACrF,OAAO,WAAW,MAAM,2CAA2C,CAAC;AAEpE,MAAM,GAAG,GAAG;IAYV,qBAAqB,CACnB,EAAE,UAAU,EAAE,cAAc,EAAE,EAC9B,gBAAgB,EAChB,mBAAmB;QAEnB,MAAM,cAAc,GAAG,UAAU,CAAC,MAAM,CAAC;QACzC,MAAM,cAAc,GAAG,oBAAoB,CAAC,WAAW,CAAC;YACtD,cAAc,EAAE,EAAE;YAClB,aAAa,EAAE,CAAC;YAChB,aAAa,EAAE,KAAK;SACrB,CAAC,CAAC;QACH,cAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACxC,cAAc,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAEvC,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QACtC,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QAEtC,IAAI;YACF,KAAK,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE;gBACrD,MAAM,EAAE,UAAU,EAAE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BAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC,CAAC;gBAE7D,mBAAmB,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC;aACtD;SACF;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,CAAC,CAAC;SAC7C;gBAAS;YAER,cAAc,GAAG,IAAI,CAAC;YACtB,cAAc,CAAC,MAAM,EAAE,CAAC;YACxB,MAAM,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,CAAC,MAAM,EAAE,CAAC;SACjB;IACH,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,GAAG,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function registerDisplayToolsWorker(): void;
2
- //# sourceMappingURL=registerDisplayToolsWorker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registerDisplayToolsWorker.d.ts","sourceRoot":"","sources":["../../../../src/tools/displayTools/registerDisplayToolsWorker.ts"],"names":[],"mappings":"AAIA,wBAAgB,0BAA0B,SA6BzC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=clippingPlaneWorker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clippingPlaneWorker.d.ts","sourceRoot":"","sources":["../../../src/workers/clippingPlaneWorker.js"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- /*! For license information please see 444.index.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@kitware/vtk.js/Common/DataModel/Plane"),require("@kitware/vtk.js/Filters/General/ClipClosedSurface"),require("@kitware/vtk.js/Common/DataModel/PolyData")):"function"==typeof define&&define.amd?define(["@kitware/vtk.js/Common/DataModel/Plane","@kitware/vtk.js/Filters/General/ClipClosedSurface","@kitware/vtk.js/Common/DataModel/PolyData"],t):"object"==typeof exports?exports.cornerstoneTools3D=t(require("@kitware/vtk.js/Common/DataModel/Plane"),require("@kitware/vtk.js/Filters/General/ClipClosedSurface"),require("@kitware/vtk.js/Common/DataModel/PolyData")):e.cornerstoneTools3D=t(e["@kitware/vtk.js/Common/DataModel/Plane"],e["@kitware/vtk.js/Filters/General/ClipClosedSurface"],e["@kitware/vtk.js/Common/DataModel/PolyData"])}(self,((e,t,n)=>(()=>{"use strict";var r={864:t=>{t.exports=e},70:e=>{e.exports=n},448:e=>{e.exports=t}},a={};function o(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return r[e](n,n.exports,o),n.exports}return o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{const e=Symbol("Comlink.proxy"),t=Symbol("Comlink.endpoint"),n=Symbol("Comlink.releaseProxy"),r=Symbol("Comlink.finalizer"),a=Symbol("Comlink.thrown"),s=e=>"object"==typeof e&&null!==e||"function"==typeof e,i=new Map([["proxy",{canHandle:t=>s(t)&&t[e],serialize(e){const{port1:t,port2:n}=new MessageChannel;return l(e,t),[n,[n]]},deserialize:e=>(e.start(),m(e,[],undefined))}],["throw",{canHandle:e=>s(e)&&a in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function l(t,n=globalThis,o=["*"]){n.addEventListener("message",(function s(i){if(!i||!i.data)return;if(!function(e,t){for(const n of e){if(t===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(t))return!0}return!1}(o,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);const{id:u,type:p,path:f}=Object.assign({path:[]},i.data),d=(i.data.argumentList||[]).map(k);let m;try{const n=f.slice(0,-1).reduce(((e,t)=>e[t]),t),r=f.reduce(((e,t)=>e[t]),t);switch(p){case"GET":m=r;break;case"SET":n[f.slice(-1)[0]]=k(i.data.value),m=!0;break;case"APPLY":m=r.apply(n,d);break;case"CONSTRUCT":m=function(t){return Object.assign(t,{[e]:!0})}(new r(...d));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;l(t,n),m=function(e,t){return y.set(e,t),e}(e,[e])}break;case"RELEASE":m=void 0;break;default:return}}catch(e){m={value:e,[a]:0}}Promise.resolve(m).catch((e=>({value:e,[a]:0}))).then((e=>{const[a,o]=v(e);n.postMessage(Object.assign(Object.assign({},a),{id:u}),o),"RELEASE"===p&&(n.removeEventListener("message",s),c(n),r in t&&"function"==typeof t[r]&&t[r]())})).catch((e=>{const[t,r]=v({value:new TypeError("Unserializable return value"),[a]:0});n.postMessage(Object.assign(Object.assign({},t),{id:u}),r)}))})),n.start&&n.start()}function c(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function u(e){if(e)throw new Error("Proxy has been released and is not useable")}function p(e){return h(e,{type:"RELEASE"}).then((()=>{c(e)}))}const f=new WeakMap,d="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(f.get(e)||0)-1;f.set(e,t),0===t&&p(e)}));function m(e,r=[],a=function(){}){let o=!1;const s=new Proxy(a,{get(t,a){if(u(o),a===n)return()=>{!function(e){d&&d.unregister(e)}(s),p(e),o=!0};if("then"===a){if(0===r.length)return{then:()=>s};const t=h(e,{type:"GET",path:r.map((e=>e.toString()))}).then(k);return t.then.bind(t)}return m(e,[...r,a])},set(t,n,a){u(o);const[s,i]=v(a);return h(e,{type:"SET",path:[...r,n].map((e=>e.toString())),value:s},i).then(k)},apply(n,a,s){u(o);const i=r[r.length-1];if(i===t)return h(e,{type:"ENDPOINT"}).then(k);if("bind"===i)return m(e,r.slice(0,-1));const[l,c]=g(s);return h(e,{type:"APPLY",path:r.map((e=>e.toString())),argumentList:l},c).then(k)},construct(t,n){u(o);const[a,s]=g(n);return h(e,{type:"CONSTRUCT",path:r.map((e=>e.toString())),argumentList:a},s).then(k)}});return function(e,t){const n=(f.get(t)||0)+1;f.set(t,n),d&&d.register(e,t,e)}(s,e),s}function g(e){const t=e.map(v);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const y=new WeakMap;function v(e){for(const[t,n]of i)if(n.canHandle(e)){const[r,a]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},a]}return[{type:"RAW",value:e},y.get(e)||[]]}function k(e){switch(e.type){case"HANDLER":return i.get(e.name).deserialize(e.value);case"RAW":return e.value}}function h(e,t,n){return new Promise((r=>{const a=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.addEventListener("message",(function t(n){n.data&&n.data.id&&n.data.id===a&&(e.removeEventListener("message",t),r(n.data))})),e.start&&e.start(),e.postMessage(Object.assign({id:a},t),n)}))}var w=o(864),b=o.n(w),E=o(448),P=o.n(E),C=o(70),j=o.n(C);l({clipSurfaceWithPlanes(e,t,n){let{planesInfo:r,pointsAndPolys:a}=e;const o=r.length,s=P().newInstance({clippingPlanes:[],activePlaneId:2,passPointData:!1});s.setGenerateOutline(!0),s.setGenerateFaces(!1);const i=b().newInstance(),l=b().newInstance();try{for(const[e,c]of r.entries()){const{sliceIndex:r,planes:u}=c,p=new Map;for(const e of a){const{points:t,polys:n,id:r}=e,a=j().newInstance();a.getPoints().setData(t,3),a.getPolys().setData(n,3),s.setInputData(a);const o=[i,l];i.setOrigin(u[0].origin),i.setNormal(u[0].normal),l.setOrigin(u[1].origin),l.setNormal(u[1].normal),s.setClippingPlanes(o),s.update();const c=s.getOutputData();c&&p.set(r,{points:c.getPoints().getData(),lines:c.getLines().getData()})}t({progress:(e+1)/o}),n({sliceIndex:r,polyDataResults:p})}}catch(e){console.error("Error during processing",e)}finally{a=null,s.delete(),i.delete(),l.delete()}}})})(),{}})()));
3
- //# sourceMappingURL=444.index.js.map
@@ -1,5 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
@@ -1 +0,0 @@
1
- {"version":3,"file":"444.index.js","mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,0CAA2CA,QAAQ,qDAAsDA,QAAQ,8CACzH,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,yCAA0C,oDAAqD,6CAA8CJ,GAC3H,iBAAZC,QACdA,QAA4B,mBAAID,EAAQG,QAAQ,0CAA2CA,QAAQ,qDAAsDA,QAAQ,8CAEjKJ,EAAyB,mBAAIC,EAAQD,EAAK,0CAA2CA,EAAK,qDAAsDA,EAAK,6CACtJ,CATD,CASGO,MAAM,CAACC,EAAkCC,EAAkCC,sCCT9EP,EAAOD,QAAUM,UCAjBL,EAAOD,QAAUQ,WCAjBP,EAAOD,QAAUO,ICCbE,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaZ,QAGrB,IAAIC,EAASQ,EAAyBE,GAAY,CAGjDX,QAAS,CAAC,GAOX,OAHAc,EAAoBH,GAAUV,EAAQA,EAAOD,QAASU,GAG/CT,EAAOD,OACf,QCrBAU,EAAoBK,EAAKd,IACxB,IAAIe,EAASf,GAAUA,EAAOgB,WAC7B,IAAOhB,EAAiB,QACxB,IAAM,EAEP,OADAS,EAAoBQ,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdN,EAAoBQ,EAAI,CAAClB,EAASoB,KACjC,IAAI,IAAIC,KAAOD,EACXV,EAAoBY,EAAEF,EAAYC,KAASX,EAAoBY,EAAEtB,EAASqB,IAC5EE,OAAOC,eAAexB,EAASqB,EAAK,CAAEI,YAAY,EAAMC,IAAKN,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,EAC3C,CAAE,QAEAtC,EAAiB,KACjBE,EAAeqC,SACf9B,EAAO8B,SACP5B,EAAO4B,QACT,CACF","sources":["webpack://cornerstoneTools3D/webpack/universalModuleDefinition","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/General/ClipClosedSurface\"","webpack://cornerstoneTools3D/webpack/bootstrap","webpack://cornerstoneTools3D/webpack/runtime/compat get default export","webpack://cornerstoneTools3D/webpack/runtime/define property getters","webpack://cornerstoneTools3D/webpack/runtime/hasOwnProperty shorthand","webpack://cornerstoneTools3D/../../node_modules/comlink/dist/esm/comlink.mjs","webpack://cornerstoneTools3D/./src/workers/clippingPlaneWorker.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"@kitware/vtk.js/Common/DataModel/Plane\"), require(\"@kitware/vtk.js/Filters/General/ClipClosedSurface\"), require(\"@kitware/vtk.js/Common/DataModel/PolyData\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"@kitware/vtk.js/Common/DataModel/Plane\", \"@kitware/vtk.js/Filters/General/ClipClosedSurface\", \"@kitware/vtk.js/Common/DataModel/PolyData\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"cornerstoneTools3D\"] = factory(require(\"@kitware/vtk.js/Common/DataModel/Plane\"), require(\"@kitware/vtk.js/Filters/General/ClipClosedSurface\"), require(\"@kitware/vtk.js/Common/DataModel/PolyData\"));\n\telse\n\t\troot[\"cornerstoneTools3D\"] = factory(root[\"@kitware/vtk.js/Common/DataModel/Plane\"], root[\"@kitware/vtk.js/Filters/General/ClipClosedSurface\"], root[\"@kitware/vtk.js/Common/DataModel/PolyData\"]);\n})(self, (__WEBPACK_EXTERNAL_MODULE__864__, __WEBPACK_EXTERNAL_MODULE__448__, __WEBPACK_EXTERNAL_MODULE__70__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__864__;","module.exports = __WEBPACK_EXTERNAL_MODULE__70__;","module.exports = __WEBPACK_EXTERNAL_MODULE__448__;","// 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","// 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__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\nconst proxyMarker = Symbol(\"Comlink.proxy\");\nconst createEndpoint = Symbol(\"Comlink.endpoint\");\nconst releaseProxy = Symbol(\"Comlink.releaseProxy\");\nconst finalizer = Symbol(\"Comlink.finalizer\");\nconst throwMarker = Symbol(\"Comlink.thrown\");\nconst isObject = (val) => (typeof val === \"object\" && val !== null) || typeof val === \"function\";\n/**\n * Internal transfer handle to handle objects marked to proxy.\n */\nconst proxyTransferHandler = {\n canHandle: (val) => isObject(val) && val[proxyMarker],\n serialize(obj) {\n const { port1, port2 } = new MessageChannel();\n expose(obj, port1);\n return [port2, [port2]];\n },\n deserialize(port) {\n port.start();\n return wrap(port);\n },\n};\n/**\n * Internal transfer handler to handle thrown exceptions.\n */\nconst throwTransferHandler = {\n canHandle: (value) => isObject(value) && throwMarker in value,\n serialize({ value }) {\n let serialized;\n if (value instanceof Error) {\n serialized = {\n isError: true,\n value: {\n message: value.message,\n name: value.name,\n stack: value.stack,\n },\n };\n }\n else {\n serialized = { isError: false, value };\n }\n return [serialized, []];\n },\n deserialize(serialized) {\n if (serialized.isError) {\n throw Object.assign(new Error(serialized.value.message), serialized.value);\n }\n throw serialized.value;\n },\n};\n/**\n * Allows customizing the serialization of certain values.\n */\nconst transferHandlers = new Map([\n [\"proxy\", proxyTransferHandler],\n [\"throw\", throwTransferHandler],\n]);\nfunction isAllowedOrigin(allowedOrigins, origin) {\n for (const allowedOrigin of allowedOrigins) {\n if (origin === allowedOrigin || allowedOrigin === \"*\") {\n return true;\n }\n if (allowedOrigin instanceof RegExp && allowedOrigin.test(origin)) {\n return true;\n }\n }\n return false;\n}\nfunction expose(obj, ep = globalThis, allowedOrigins = [\"*\"]) {\n ep.addEventListener(\"message\", function callback(ev) {\n if (!ev || !ev.data) {\n return;\n }\n if (!isAllowedOrigin(allowedOrigins, ev.origin)) {\n console.warn(`Invalid origin '${ev.origin}' for comlink proxy`);\n return;\n }\n const { id, type, path } = Object.assign({ path: [] }, ev.data);\n const argumentList = (ev.data.argumentList || []).map(fromWireValue);\n let returnValue;\n try {\n const parent = path.slice(0, -1).reduce((obj, prop) => obj[prop], obj);\n const rawValue = path.reduce((obj, prop) => obj[prop], obj);\n switch (type) {\n case \"GET\" /* MessageType.GET */:\n {\n returnValue = rawValue;\n }\n break;\n case \"SET\" /* MessageType.SET */:\n {\n parent[path.slice(-1)[0]] = fromWireValue(ev.data.value);\n returnValue = true;\n }\n break;\n case \"APPLY\" /* MessageType.APPLY */:\n {\n returnValue = rawValue.apply(parent, argumentList);\n }\n break;\n case \"CONSTRUCT\" /* MessageType.CONSTRUCT */:\n {\n const value = new rawValue(...argumentList);\n returnValue = proxy(value);\n }\n break;\n case \"ENDPOINT\" /* MessageType.ENDPOINT */:\n {\n const { port1, port2 } = new MessageChannel();\n expose(obj, port2);\n returnValue = transfer(port1, [port1]);\n }\n break;\n case \"RELEASE\" /* MessageType.RELEASE */:\n {\n returnValue = undefined;\n }\n break;\n default:\n return;\n }\n }\n catch (value) {\n returnValue = { value, [throwMarker]: 0 };\n }\n Promise.resolve(returnValue)\n .catch((value) => {\n return { value, [throwMarker]: 0 };\n })\n .then((returnValue) => {\n const [wireValue, transferables] = toWireValue(returnValue);\n ep.postMessage(Object.assign(Object.assign({}, wireValue), { id }), transferables);\n if (type === \"RELEASE\" /* MessageType.RELEASE */) {\n // detach and deactive after sending release response above.\n ep.removeEventListener(\"message\", callback);\n closeEndPoint(ep);\n if (finalizer in obj && typeof obj[finalizer] === \"function\") {\n obj[finalizer]();\n }\n }\n })\n .catch((error) => {\n // Send Serialization Error To Caller\n const [wireValue, transferables] = toWireValue({\n value: new TypeError(\"Unserializable return value\"),\n [throwMarker]: 0,\n });\n ep.postMessage(Object.assign(Object.assign({}, wireValue), { id }), transferables);\n });\n });\n if (ep.start) {\n ep.start();\n }\n}\nfunction isMessagePort(endpoint) {\n return endpoint.constructor.name === \"MessagePort\";\n}\nfunction closeEndPoint(endpoint) {\n if (isMessagePort(endpoint))\n endpoint.close();\n}\nfunction wrap(ep, target) {\n return createProxy(ep, [], target);\n}\nfunction throwIfProxyReleased(isReleased) {\n if (isReleased) {\n throw new Error(\"Proxy has been released and is not useable\");\n }\n}\nfunction releaseEndpoint(ep) {\n return requestResponseMessage(ep, {\n type: \"RELEASE\" /* MessageType.RELEASE */,\n }).then(() => {\n closeEndPoint(ep);\n });\n}\nconst proxyCounter = new WeakMap();\nconst proxyFinalizers = \"FinalizationRegistry\" in globalThis &&\n new FinalizationRegistry((ep) => {\n const newCount = (proxyCounter.get(ep) || 0) - 1;\n proxyCounter.set(ep, newCount);\n if (newCount === 0) {\n releaseEndpoint(ep);\n }\n });\nfunction registerProxy(proxy, ep) {\n const newCount = (proxyCounter.get(ep) || 0) + 1;\n proxyCounter.set(ep, newCount);\n if (proxyFinalizers) {\n proxyFinalizers.register(proxy, ep, proxy);\n }\n}\nfunction unregisterProxy(proxy) {\n if (proxyFinalizers) {\n proxyFinalizers.unregister(proxy);\n }\n}\nfunction createProxy(ep, path = [], target = function () { }) {\n let isProxyReleased = false;\n const proxy = new Proxy(target, {\n get(_target, prop) {\n throwIfProxyReleased(isProxyReleased);\n if (prop === releaseProxy) {\n return () => {\n unregisterProxy(proxy);\n releaseEndpoint(ep);\n isProxyReleased = true;\n };\n }\n if (prop === \"then\") {\n if (path.length === 0) {\n return { then: () => proxy };\n }\n const r = requestResponseMessage(ep, {\n type: \"GET\" /* MessageType.GET */,\n path: path.map((p) => p.toString()),\n }).then(fromWireValue);\n return r.then.bind(r);\n }\n return createProxy(ep, [...path, prop]);\n },\n set(_target, prop, rawValue) {\n throwIfProxyReleased(isProxyReleased);\n // FIXME: ES6 Proxy Handler `set` methods are supposed to return a\n // boolean. To show good will, we return true asynchronously ¯\\_(ツ)_/¯\n const [value, transferables] = toWireValue(rawValue);\n return requestResponseMessage(ep, {\n type: \"SET\" /* MessageType.SET */,\n path: [...path, prop].map((p) => p.toString()),\n value,\n }, transferables).then(fromWireValue);\n },\n apply(_target, _thisArg, rawArgumentList) {\n throwIfProxyReleased(isProxyReleased);\n const last = path[path.length - 1];\n if (last === createEndpoint) {\n return requestResponseMessage(ep, {\n type: \"ENDPOINT\" /* MessageType.ENDPOINT */,\n }).then(fromWireValue);\n }\n // We just pretend that `bind()` didn’t happen.\n if (last === \"bind\") {\n return createProxy(ep, path.slice(0, -1));\n }\n const [argumentList, transferables] = processArguments(rawArgumentList);\n return requestResponseMessage(ep, {\n type: \"APPLY\" /* MessageType.APPLY */,\n path: path.map((p) => p.toString()),\n argumentList,\n }, transferables).then(fromWireValue);\n },\n construct(_target, rawArgumentList) {\n throwIfProxyReleased(isProxyReleased);\n const [argumentList, transferables] = processArguments(rawArgumentList);\n return requestResponseMessage(ep, {\n type: \"CONSTRUCT\" /* MessageType.CONSTRUCT */,\n path: path.map((p) => p.toString()),\n argumentList,\n }, transferables).then(fromWireValue);\n },\n });\n registerProxy(proxy, ep);\n return proxy;\n}\nfunction myFlat(arr) {\n return Array.prototype.concat.apply([], arr);\n}\nfunction processArguments(argumentList) {\n const processed = argumentList.map(toWireValue);\n return [processed.map((v) => v[0]), myFlat(processed.map((v) => v[1]))];\n}\nconst transferCache = new WeakMap();\nfunction transfer(obj, transfers) {\n transferCache.set(obj, transfers);\n return obj;\n}\nfunction proxy(obj) {\n return Object.assign(obj, { [proxyMarker]: true });\n}\nfunction windowEndpoint(w, context = globalThis, targetOrigin = \"*\") {\n return {\n postMessage: (msg, transferables) => w.postMessage(msg, targetOrigin, transferables),\n addEventListener: context.addEventListener.bind(context),\n removeEventListener: context.removeEventListener.bind(context),\n };\n}\nfunction toWireValue(value) {\n for (const [name, handler] of transferHandlers) {\n if (handler.canHandle(value)) {\n const [serializedValue, transferables] = handler.serialize(value);\n return [\n {\n type: \"HANDLER\" /* WireValueType.HANDLER */,\n name,\n value: serializedValue,\n },\n transferables,\n ];\n }\n }\n return [\n {\n type: \"RAW\" /* WireValueType.RAW */,\n value,\n },\n transferCache.get(value) || [],\n ];\n}\nfunction fromWireValue(value) {\n switch (value.type) {\n case \"HANDLER\" /* WireValueType.HANDLER */:\n return transferHandlers.get(value.name).deserialize(value.value);\n case \"RAW\" /* WireValueType.RAW */:\n return value.value;\n }\n}\nfunction requestResponseMessage(ep, msg, transfers) {\n return new Promise((resolve) => {\n const id = generateUUID();\n ep.addEventListener(\"message\", function l(ev) {\n if (!ev.data || !ev.data.id || ev.data.id !== id) {\n return;\n }\n ep.removeEventListener(\"message\", l);\n resolve(ev.data);\n });\n if (ep.start) {\n ep.start();\n }\n ep.postMessage(Object.assign({ id }, msg), transfers);\n });\n}\nfunction generateUUID() {\n return new Array(4)\n .fill(0)\n .map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16))\n .join(\"-\");\n}\n\nexport { createEndpoint, expose, finalizer, proxy, proxyMarker, releaseProxy, transfer, transferHandlers, windowEndpoint, wrap };\n//# sourceMappingURL=comlink.mjs.map\n","import { expose } from 'comlink';\nimport vtkPlane from '@kitware/vtk.js/Common/DataModel/Plane';\nimport vtkClipClosedSurface from '@kitware/vtk.js/Filters/General/ClipClosedSurface';\nimport vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';\n\nconst obj = {\n /**\n * Clips a 3D surface using provided planes and updates the cache and progress.\n * The function takes in information about the planes and the polygon data, and applies a clipping filter.\n * It then updates the cache and progress based on the processed data.\n *\n * @param clipInfo - Contains information about the planes and the polygon data.\n * @param updateProgress - Callback function to update the progress of the clipping process.\n * @param updateCache - Callback function to update the cache with the clipped data.\n *\n * @throws Will throw an error if the clipping process encounters an issue.\n */\n clipSurfaceWithPlanes(\n { planesInfo, pointsAndPolys },\n progressCallback,\n updateCacheCallback\n ) {\n const numberOfPlanes = planesInfo.length;\n const clippingFilter = vtkClipClosedSurface.newInstance({\n clippingPlanes: [],\n activePlaneId: 2,\n passPointData: false,\n });\n clippingFilter.setGenerateOutline(true);\n clippingFilter.setGenerateFaces(false);\n\n const plane1 = vtkPlane.newInstance();\n const plane2 = vtkPlane.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 pointsAndPolys) {\n const { points, polys, id } = polyDataInfo;\n\n const surfacePolyData = vtkPolyData.newInstance();\n surfacePolyData.getPoints().setData(points, 3);\n surfacePolyData.getPolys().setData(polys, 3);\n\n clippingFilter.setInputData(surfacePolyData);\n\n // Reusable array for clipping planes\n const clippingPlanes = [plane1, plane2];\n\n // Directly update plane instances\n plane1.setOrigin(planes[0].origin);\n plane1.setNormal(planes[0].normal);\n plane2.setOrigin(planes[1].origin);\n plane2.setNormal(planes[1].normal);\n\n clippingFilter.setClippingPlanes(clippingPlanes);\n clippingFilter.update();\n\n const polyData = clippingFilter.getOutputData();\n\n if (polyData) {\n polyDataResults.set(id, {\n points: polyData.getPoints().getData(),\n lines: polyData.getLines().getData(),\n });\n }\n }\n\n progressCallback({ progress: (index + 1) / numberOfPlanes });\n\n updateCacheCallback({ sliceIndex, polyDataResults });\n }\n } catch (e) {\n console.error('Error during processing', e);\n } finally {\n // Cleanup on completion\n pointsAndPolys = null;\n clippingFilter.delete();\n plane1.delete();\n plane2.delete();\n }\n },\n};\n\nexpose(obj);\n"],"names":["root","factory","exports","module","require","define","amd","self","__WEBPACK_EXTERNAL_MODULE__864__","__WEBPACK_EXTERNAL_MODULE__448__","__WEBPACK_EXTERNAL_MODULE__70__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","proxyMarker","Symbol","createEndpoint","releaseProxy","finalizer","throwMarker","isObject","val","transferHandlers","Map","canHandle","serialize","port1","port2","MessageChannel","expose","deserialize","port","start","createProxy","target","value","serialized","Error","isError","message","name","stack","assign","ep","globalThis","allowedOrigins","addEventListener","callback","ev","data","origin","allowedOrigin","RegExp","test","isAllowedOrigin","console","warn","id","type","path","argumentList","map","fromWireValue","returnValue","parent","slice","reduce","rawValue","apply","proxy","transfers","transferCache","set","transfer","Promise","resolve","catch","then","wireValue","transferables","toWireValue","postMessage","removeEventListener","closeEndPoint","error","TypeError","endpoint","constructor","isMessagePort","close","throwIfProxyReleased","isReleased","releaseEndpoint","requestResponseMessage","proxyCounter","WeakMap","proxyFinalizers","FinalizationRegistry","newCount","isProxyReleased","Proxy","_target","unregister","unregisterProxy","length","r","p","toString","bind","_thisArg","rawArgumentList","last","processArguments","construct","register","registerProxy","processed","v","arr","Array","concat","handler","serializedValue","msg","fill","Math","floor","random","Number","MAX_SAFE_INTEGER","join","l","clipSurfaceWithPlanes","_ref","progressCallback","updateCacheCallback","planesInfo","pointsAndPolys","numberOfPlanes","clippingFilter","vtkClipClosedSurface","clippingPlanes","activePlaneId","passPointData","setGenerateOutline","setGenerateFaces","plane1","vtkPlane","plane2","index","planeInfo","entries","sliceIndex","planes","polyDataResults","polyDataInfo","points","polys","surfacePolyData","vtkPolyData","getPoints","setData","getPolys","setInputData","setOrigin","setNormal","normal","setClippingPlanes","update","polyData","getOutputData","getData","lines","getLines","progress","e","delete"],"sourceRoot":""}