@cornerstonejs/tools 1.57.2 → 1.58.1

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 (226) 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/base/BaseTool.js +3 -0
  41. package/dist/cjs/tools/base/BaseTool.js.map +1 -1
  42. package/dist/cjs/tools/base/ContourSegmentationBaseTool.js.map +1 -1
  43. package/dist/cjs/tools/displayTools/Contour/contourDisplay.js +13 -5
  44. package/dist/cjs/tools/displayTools/Contour/contourDisplay.js.map +1 -1
  45. package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js +1 -1
  46. package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
  47. package/dist/cjs/tools/displayTools/SegmentationDisplayTool.d.ts +1 -0
  48. package/dist/cjs/tools/displayTools/SegmentationDisplayTool.js +17 -0
  49. package/dist/cjs/tools/displayTools/SegmentationDisplayTool.js.map +1 -1
  50. package/dist/cjs/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js +4 -47
  51. package/dist/cjs/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js.map +1 -1
  52. package/dist/cjs/tools/displayTools/Surface/surfaceDisplay.d.ts +3 -9
  53. package/dist/cjs/tools/displayTools/Surface/surfaceDisplay.js +7 -148
  54. package/dist/cjs/tools/displayTools/Surface/surfaceDisplay.js.map +1 -1
  55. package/dist/cjs/types/PolySeg.d.ts +1 -1
  56. package/dist/cjs/utilities/contourSegmentation/addContourSegmentationAnnotation.js +4 -1
  57. package/dist/cjs/utilities/contourSegmentation/addContourSegmentationAnnotation.js.map +1 -1
  58. package/dist/cjs/utilities/contourSegmentation/removeContourSegmentationAnnotation.js +3 -0
  59. package/dist/cjs/utilities/contourSegmentation/removeContourSegmentationAnnotation.js.map +1 -1
  60. package/dist/cjs/utilities/math/polyline/getAABB.d.ts +3 -1
  61. package/dist/cjs/utilities/math/polyline/getAABB.js +30 -4
  62. package/dist/cjs/utilities/math/polyline/getAABB.js.map +1 -1
  63. package/dist/cjs/utilities/planar/index.d.ts +3 -1
  64. package/dist/cjs/utilities/planar/index.js +4 -1
  65. package/dist/cjs/utilities/planar/index.js.map +1 -1
  66. package/dist/cjs/utilities/planar/isPlaneIntersectingAABB.d.ts +1 -0
  67. package/dist/cjs/utilities/planar/isPlaneIntersectingAABB.js +32 -0
  68. package/dist/cjs/utilities/planar/isPlaneIntersectingAABB.js.map +1 -0
  69. package/dist/cjs/utilities/segmentation/getUniqueSegmentIndices.d.ts +3 -1
  70. package/dist/cjs/utilities/segmentation/getUniqueSegmentIndices.js +97 -47
  71. package/dist/cjs/utilities/segmentation/getUniqueSegmentIndices.js.map +1 -1
  72. package/dist/cjs/workers/polySegConverters.js +73 -0
  73. package/dist/cjs/workers/polySegConverters.js.map +1 -1
  74. package/dist/esm/drawingSvg/drawPath.js +1 -1
  75. package/dist/esm/drawingSvg/drawPath.js.map +1 -1
  76. package/dist/esm/enums/WorkerTypes.js +1 -1
  77. package/dist/esm/enums/WorkerTypes.js.map +1 -1
  78. package/dist/esm/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.js +91 -0
  79. package/dist/esm/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.js.map +1 -0
  80. package/dist/esm/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.js +4 -1
  81. package/dist/esm/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.js.map +1 -1
  82. package/dist/esm/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js +105 -0
  83. package/dist/esm/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js.map +1 -0
  84. package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.js +72 -0
  85. package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.js.map +1 -0
  86. package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.js +21 -0
  87. package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.js.map +1 -0
  88. package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.js +26 -0
  89. package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.js.map +1 -0
  90. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.js +2 -2
  91. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.js.map +1 -1
  92. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertSurfaceToLabelmap.js +1 -1
  93. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertSurfaceToLabelmap.js.map +1 -1
  94. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.js +1 -1
  95. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.js.map +1 -1
  96. package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertContourToSurface.js +1 -1
  97. package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertContourToSurface.js.map +1 -1
  98. package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.js +1 -1
  99. package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.js.map +1 -1
  100. package/dist/esm/stateManagement/segmentation/polySeg/computeAndAddRepresentation.js +1 -1
  101. package/dist/esm/stateManagement/segmentation/polySeg/computeAndAddRepresentation.js.map +1 -1
  102. package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.js +2 -0
  103. package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.js.map +1 -1
  104. package/dist/esm/store/ToolGroupManager/getToolGroupForViewport.js +4 -0
  105. package/dist/esm/store/ToolGroupManager/getToolGroupForViewport.js.map +1 -1
  106. package/dist/esm/tools/base/BaseTool.js +3 -0
  107. package/dist/esm/tools/base/BaseTool.js.map +1 -1
  108. package/dist/esm/tools/base/ContourSegmentationBaseTool.js.map +1 -1
  109. package/dist/esm/tools/displayTools/Contour/contourDisplay.js +13 -5
  110. package/dist/esm/tools/displayTools/Contour/contourDisplay.js.map +1 -1
  111. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +1 -1
  112. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
  113. package/dist/esm/tools/displayTools/SegmentationDisplayTool.js +17 -0
  114. package/dist/esm/tools/displayTools/SegmentationDisplayTool.js.map +1 -1
  115. package/dist/esm/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js +3 -46
  116. package/dist/esm/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js.map +1 -1
  117. package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js +8 -139
  118. package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js.map +1 -1
  119. package/dist/esm/utilities/contourSegmentation/addContourSegmentationAnnotation.js +4 -1
  120. package/dist/esm/utilities/contourSegmentation/addContourSegmentationAnnotation.js.map +1 -1
  121. package/dist/esm/utilities/contourSegmentation/removeContourSegmentationAnnotation.js +3 -0
  122. package/dist/esm/utilities/contourSegmentation/removeContourSegmentationAnnotation.js.map +1 -1
  123. package/dist/esm/utilities/math/polyline/getAABB.js +30 -4
  124. package/dist/esm/utilities/math/polyline/getAABB.js.map +1 -1
  125. package/dist/esm/utilities/planar/index.js +3 -1
  126. package/dist/esm/utilities/planar/index.js.map +1 -1
  127. package/dist/esm/utilities/planar/isPlaneIntersectingAABB.js +28 -0
  128. package/dist/esm/utilities/planar/isPlaneIntersectingAABB.js.map +1 -0
  129. package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.js +92 -44
  130. package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.js.map +1 -1
  131. package/dist/esm/workers/polySegConverters.js +74 -1
  132. package/dist/esm/workers/polySegConverters.js.map +1 -1
  133. package/dist/types/drawingSvg/drawPath.d.ts.map +1 -1
  134. package/dist/types/enums/WorkerTypes.d.ts +1 -1
  135. package/dist/types/enums/WorkerTypes.d.ts.map +1 -1
  136. package/dist/types/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.d.ts +18 -0
  137. package/dist/types/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.d.ts.map +1 -0
  138. package/dist/types/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.d.ts +3 -1
  139. package/dist/types/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.d.ts.map +1 -1
  140. package/dist/types/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.d.ts +9 -0
  141. package/dist/types/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.d.ts.map +1 -0
  142. package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.d.ts +4 -0
  143. package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.d.ts.map +1 -0
  144. package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.d.ts +4 -0
  145. package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.d.ts.map +1 -0
  146. package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.d.ts +2 -0
  147. package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.d.ts.map +1 -0
  148. package/dist/types/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.d.ts.map +1 -1
  149. package/dist/types/stateManagement/segmentation/triggerSegmentationEvents.d.ts.map +1 -1
  150. package/dist/types/store/ToolGroupManager/getToolGroupForViewport.d.ts +1 -1
  151. package/dist/types/store/ToolGroupManager/getToolGroupForViewport.d.ts.map +1 -1
  152. package/dist/types/tools/base/BaseTool.d.ts.map +1 -1
  153. package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts.map +1 -1
  154. package/dist/types/tools/displayTools/Contour/contourDisplay.d.ts.map +1 -1
  155. package/dist/types/tools/displayTools/SegmentationDisplayTool.d.ts +1 -0
  156. package/dist/types/tools/displayTools/SegmentationDisplayTool.d.ts.map +1 -1
  157. package/dist/types/tools/displayTools/Surface/addOrUpdateSurfaceToElement.d.ts.map +1 -1
  158. package/dist/types/tools/displayTools/Surface/surfaceDisplay.d.ts +3 -9
  159. package/dist/types/tools/displayTools/Surface/surfaceDisplay.d.ts.map +1 -1
  160. package/dist/types/types/PolySeg.d.ts +1 -1
  161. package/dist/types/types/PolySeg.d.ts.map +1 -1
  162. package/dist/types/utilities/contourSegmentation/addContourSegmentationAnnotation.d.ts.map +1 -1
  163. package/dist/types/utilities/contourSegmentation/removeContourSegmentationAnnotation.d.ts.map +1 -1
  164. package/dist/types/utilities/math/polyline/getAABB.d.ts +3 -1
  165. package/dist/types/utilities/math/polyline/getAABB.d.ts.map +1 -1
  166. package/dist/types/utilities/planar/index.d.ts +3 -1
  167. package/dist/types/utilities/planar/index.d.ts.map +1 -1
  168. package/dist/types/utilities/planar/isPlaneIntersectingAABB.d.ts +2 -0
  169. package/dist/types/utilities/planar/isPlaneIntersectingAABB.d.ts.map +1 -0
  170. package/dist/types/utilities/segmentation/getUniqueSegmentIndices.d.ts +3 -1
  171. package/dist/types/utilities/segmentation/getUniqueSegmentIndices.d.ts.map +1 -1
  172. package/dist/umd/985.index.js +1 -1
  173. package/dist/umd/985.index.js.map +1 -1
  174. package/dist/umd/index.js +1 -1
  175. package/dist/umd/index.js.map +1 -1
  176. package/package.json +4 -4
  177. package/src/drawingSvg/drawPath.ts +3 -1
  178. package/src/enums/WorkerTypes.ts +1 -1
  179. package/src/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.ts +203 -0
  180. package/src/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.ts +9 -2
  181. package/src/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.ts +201 -0
  182. package/src/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.ts +103 -0
  183. package/src/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.ts +38 -0
  184. package/src/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.ts +58 -0
  185. package/src/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.ts +2 -2
  186. package/src/stateManagement/segmentation/polySeg/Labelmap/convertSurfaceToLabelmap.ts +1 -1
  187. package/src/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.ts +3 -8
  188. package/src/stateManagement/segmentation/polySeg/Surface/convertContourToSurface.ts +1 -1
  189. package/src/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.ts +1 -1
  190. package/src/stateManagement/segmentation/polySeg/computeAndAddRepresentation.ts +1 -1
  191. package/src/stateManagement/segmentation/triggerSegmentationEvents.ts +5 -0
  192. package/src/store/ToolGroupManager/getToolGroupForViewport.ts +8 -1
  193. package/src/tools/base/BaseTool.ts +7 -0
  194. package/src/tools/base/ContourSegmentationBaseTool.ts +5 -0
  195. package/src/tools/displayTools/Contour/contourDisplay.ts +29 -11
  196. package/src/tools/displayTools/Labelmap/labelmapDisplay.ts +1 -1
  197. package/src/tools/displayTools/SegmentationDisplayTool.ts +26 -0
  198. package/src/tools/displayTools/Surface/addOrUpdateSurfaceToElement.ts +3 -65
  199. package/src/tools/displayTools/Surface/surfaceDisplay.ts +12 -247
  200. package/src/types/PolySeg.ts +1 -1
  201. package/src/utilities/contourSegmentation/addContourSegmentationAnnotation.ts +9 -1
  202. package/src/utilities/contourSegmentation/removeContourSegmentationAnnotation.ts +4 -0
  203. package/src/utilities/math/polyline/getAABB.ts +58 -4
  204. package/src/utilities/planar/index.ts +3 -0
  205. package/src/utilities/planar/isPlaneIntersectingAABB.ts +56 -0
  206. package/src/utilities/segmentation/getUniqueSegmentIndices.ts +115 -49
  207. package/src/workers/polySegConverters.js +117 -1
  208. package/dist/cjs/tools/displayTools/registerDisplayToolsWorker.d.ts +0 -1
  209. package/dist/cjs/tools/displayTools/registerDisplayToolsWorker.js +0 -27
  210. package/dist/cjs/tools/displayTools/registerDisplayToolsWorker.js.map +0 -1
  211. package/dist/cjs/workers/clippingPlaneWorker.d.ts +0 -1
  212. package/dist/cjs/workers/clippingPlaneWorker.js +0 -63
  213. package/dist/cjs/workers/clippingPlaneWorker.js.map +0 -1
  214. package/dist/esm/tools/displayTools/registerDisplayToolsWorker.js +0 -23
  215. package/dist/esm/tools/displayTools/registerDisplayToolsWorker.js.map +0 -1
  216. package/dist/esm/workers/clippingPlaneWorker.js +0 -58
  217. package/dist/esm/workers/clippingPlaneWorker.js.map +0 -1
  218. package/dist/types/tools/displayTools/registerDisplayToolsWorker.d.ts +0 -2
  219. package/dist/types/tools/displayTools/registerDisplayToolsWorker.d.ts.map +0 -1
  220. package/dist/types/workers/clippingPlaneWorker.d.ts +0 -2
  221. package/dist/types/workers/clippingPlaneWorker.d.ts.map +0 -1
  222. package/dist/umd/444.index.js +0 -3
  223. package/dist/umd/444.index.js.LICENSE.txt +0 -5
  224. package/dist/umd/444.index.js.map +0 -1
  225. package/src/tools/displayTools/registerDisplayToolsWorker.ts +0 -34
  226. package/src/workers/clippingPlaneWorker.js +0 -87
@@ -16,6 +16,11 @@ export function addContourSegmentationAnnotation(
16
16
 
17
17
  const { segmentationId, segmentIndex } = annotation.data.segmentation;
18
18
  const segmentation = getSegmentation(segmentationId);
19
+
20
+ if (!segmentation.representationData.CONTOUR) {
21
+ segmentation.representationData.CONTOUR = { annotationUIDsMap: new Map() };
22
+ }
23
+
19
24
  const { annotationUIDsMap } = segmentation.representationData.CONTOUR;
20
25
 
21
26
  let annotationsUIDsSet = annotationUIDsMap.get(segmentIndex);
@@ -25,5 +30,8 @@ export function addContourSegmentationAnnotation(
25
30
  annotationUIDsMap.set(segmentIndex, annotationsUIDsSet);
26
31
  }
27
32
 
28
- annotationsUIDsSet.add(annotation.annotationUID);
33
+ annotationUIDsMap.set(
34
+ segmentIndex,
35
+ annotationsUIDsSet.add(annotation.annotationUID)
36
+ );
29
37
  }
@@ -21,6 +21,10 @@ export function removeContourSegmentationAnnotation(
21
21
  const { annotationUIDsMap } = segmentation.representationData.CONTOUR;
22
22
  const annotationsUIDsSet = annotationUIDsMap.get(segmentIndex);
23
23
 
24
+ if (!annotationsUIDsSet) {
25
+ return;
26
+ }
27
+
24
28
  annotationsUIDsSet.delete(annotation.annotationUID);
25
29
 
26
30
  // Delete segmentIndex Set if there is no more annotations
@@ -1,20 +1,74 @@
1
1
  import { Types } from '@cornerstonejs/core';
2
2
 
3
- export default function getAABB(polyline: Types.Point2[]): Types.AABB2 {
3
+ /**
4
+ * Calculates the axis-aligned bounding box (AABB) of a polyline.
5
+ *
6
+ * @param polyline - The polyline represented as an array of points.
7
+ * @param options - Additional options for calculating the AABB.
8
+ * @param options.isWorld - Indicates whether the polyline represents points in 3D space (true) or 2D space (false).
9
+ *
10
+ * @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.
11
+ */
12
+ export default function getAABB(
13
+ polyline: Types.Point2[] | Types.Point3[] | number[],
14
+ options?: {
15
+ numDimensions: number;
16
+ }
17
+ ): Types.AABB2 | Types.AABB3 {
18
+ // need to check if the polyline is array of arrays or just
19
+ // a flat array of numbers
20
+ let polylineToUse = polyline;
21
+ const numDimensions = options?.numDimensions || 2;
22
+ const is3D = numDimensions === 3;
23
+
24
+ if (!Array.isArray(polyline[0])) {
25
+ const currentPolyline = polyline as number[];
26
+ // check the isWorld flag is provided or not which means every
27
+ // 3 elements in the array represent a point in 3D space
28
+ // otherwise, every 2 elements in the array represent a point in 2D space
29
+ const totalPoints = currentPolyline.length / numDimensions;
30
+
31
+ polylineToUse = new Array(currentPolyline.length / numDimensions) as
32
+ | Types.Point2[]
33
+ | Types.Point3[];
34
+
35
+ for (let i = 0, len = totalPoints; i < len; i++) {
36
+ polylineToUse[i] = [
37
+ currentPolyline[i * numDimensions],
38
+ currentPolyline[i * numDimensions + 1],
39
+ ];
40
+
41
+ if (is3D) {
42
+ polylineToUse[i].push(currentPolyline[i * numDimensions + 2]);
43
+ }
44
+ }
45
+ }
46
+
4
47
  let minX = Infinity;
5
48
  let minY = Infinity;
6
49
  let maxX = -Infinity;
7
50
  let maxY = -Infinity;
51
+ let minZ = Infinity;
52
+ let maxZ = -Infinity;
8
53
 
9
- for (let i = 0, len = polyline.length; i < len; i++) {
10
- const [x, y] = polyline[i];
54
+ polylineToUse = polylineToUse as Types.Point2[] | Types.Point3[];
55
+
56
+ for (let i = 0, len = polylineToUse.length; i < len; i++) {
57
+ const [x, y, z] = polylineToUse[i];
11
58
 
12
59
  // No Math.min/max calls for better performance
13
60
  minX = minX < x ? minX : x;
14
61
  minY = minY < y ? minY : y;
15
62
  maxX = maxX > x ? maxX : x;
16
63
  maxY = maxY > y ? maxY : y;
64
+
65
+ if (is3D) {
66
+ minZ = minZ < z ? minZ : z;
67
+ maxZ = maxZ > z ? maxZ : z;
68
+ }
17
69
  }
18
70
 
19
- return { minX, maxX, minY, maxY };
71
+ return is3D
72
+ ? { minX, maxX, minY, maxY, minZ, maxZ } // AABB3
73
+ : { minX, maxX, minY, maxY }; // AABB2
20
74
  }
@@ -2,12 +2,14 @@ import filterAnnotationsWithinSlice from './filterAnnotationsWithinSlice';
2
2
  import getWorldWidthAndHeightFromCorners from './getWorldWidthAndHeightFromCorners';
3
3
  import filterAnnotationsForDisplay from './filterAnnotationsForDisplay';
4
4
  import getPointInLineOfSightWithCriteria from './getPointInLineOfSightWithCriteria';
5
+ import { isPlaneIntersectingAABB } from './isPlaneIntersectingAABB';
5
6
 
6
7
  export default {
7
8
  filterAnnotationsWithinSlice,
8
9
  getWorldWidthAndHeightFromCorners,
9
10
  filterAnnotationsForDisplay,
10
11
  getPointInLineOfSightWithCriteria,
12
+ isPlaneIntersectingAABB,
11
13
  };
12
14
 
13
15
  export {
@@ -15,4 +17,5 @@ export {
15
17
  getWorldWidthAndHeightFromCorners,
16
18
  filterAnnotationsForDisplay,
17
19
  getPointInLineOfSightWithCriteria,
20
+ isPlaneIntersectingAABB,
18
21
  };
@@ -0,0 +1,56 @@
1
+ import { vec3 } from 'gl-matrix';
2
+
3
+ /**
4
+ * Checks if a plane intersects with an Axis-Aligned Bounding Box (AABB).
5
+ *
6
+ * @param origin - The origin point of the plane.
7
+ * @param normal - The normal vector of the plane.
8
+ * @param minX - The minimum x-coordinate of the AABB.
9
+ * @param minY - The minimum y-coordinate of the AABB.
10
+ * @param minZ - The minimum z-coordinate of the AABB.
11
+ * @param maxX - The maximum x-coordinate of the AABB.
12
+ * @param maxY - The maximum y-coordinate of the AABB.
13
+ * @param maxZ - The maximum z-coordinate of the AABB.
14
+ * @returns A boolean indicating whether the plane intersects with the AABB.
15
+ */
16
+ export const isPlaneIntersectingAABB = (
17
+ origin,
18
+ normal,
19
+ minX,
20
+ minY,
21
+ minZ,
22
+ maxX,
23
+ maxY,
24
+ maxZ
25
+ ) => {
26
+ const vertices = [
27
+ vec3.fromValues(minX, minY, minZ),
28
+ vec3.fromValues(maxX, minY, minZ),
29
+ vec3.fromValues(minX, maxY, minZ),
30
+ vec3.fromValues(maxX, maxY, minZ),
31
+ vec3.fromValues(minX, minY, maxZ),
32
+ vec3.fromValues(maxX, minY, maxZ),
33
+ vec3.fromValues(minX, maxY, maxZ),
34
+ vec3.fromValues(maxX, maxY, maxZ),
35
+ ];
36
+
37
+ const normalVec = vec3.fromValues(normal[0], normal[1], normal[2]);
38
+ const originVec = vec3.fromValues(origin[0], origin[1], origin[2]);
39
+
40
+ // Compute the distance from the plane to the origin using vec3.dot
41
+ const planeDistance = -vec3.dot(normalVec, originVec);
42
+
43
+ // Check if all vertices are on the same side of the plane
44
+ let initialSign = null;
45
+ for (const vertex of vertices) {
46
+ // Calculate distance using vec3.dot to simplify the equation
47
+ const distance = vec3.dot(normalVec, vertex) + planeDistance;
48
+ if (initialSign === null) {
49
+ initialSign = Math.sign(distance);
50
+ } else if (Math.sign(distance) !== initialSign) {
51
+ return true; // Found a vertex on the other side, so it intersects
52
+ }
53
+ }
54
+
55
+ return false;
56
+ };
@@ -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":"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"}
@@ -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"}