@cornerstonejs/tools 1.48.2 → 1.49.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 (333) hide show
  1. package/dist/cjs/enums/AnnotationStyleStates.d.ts +2 -1
  2. package/dist/cjs/enums/AnnotationStyleStates.js +1 -0
  3. package/dist/cjs/enums/AnnotationStyleStates.js.map +1 -1
  4. package/dist/cjs/enums/ChangeTypes.d.ts +8 -0
  5. package/dist/cjs/enums/ChangeTypes.js +12 -0
  6. package/dist/cjs/enums/ChangeTypes.js.map +1 -0
  7. package/dist/cjs/enums/Events.d.ts +2 -0
  8. package/dist/cjs/enums/Events.js +2 -0
  9. package/dist/cjs/enums/Events.js.map +1 -1
  10. package/dist/cjs/enums/index.d.ts +2 -1
  11. package/dist/cjs/enums/index.js +3 -1
  12. package/dist/cjs/enums/index.js.map +1 -1
  13. package/dist/cjs/eventDispatchers/annotationInterpolationEventDispatcher.d.ts +5 -0
  14. package/dist/cjs/eventDispatchers/annotationInterpolationEventDispatcher.js +23 -0
  15. package/dist/cjs/eventDispatchers/annotationInterpolationEventDispatcher.js.map +1 -0
  16. package/dist/cjs/eventDispatchers/index.d.ts +2 -1
  17. package/dist/cjs/eventDispatchers/index.js +3 -1
  18. package/dist/cjs/eventDispatchers/index.js.map +1 -1
  19. package/dist/cjs/init.js +3 -0
  20. package/dist/cjs/init.js.map +1 -1
  21. package/dist/cjs/stateManagement/annotation/config/getState.js +3 -0
  22. package/dist/cjs/stateManagement/annotation/config/getState.js.map +1 -1
  23. package/dist/cjs/tools/annotation/LivewireContourTool.d.ts +1 -1
  24. package/dist/cjs/tools/annotation/LivewireContourTool.js +1 -1
  25. package/dist/cjs/tools/annotation/LivewireContourTool.js.map +1 -1
  26. package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.js +1 -0
  27. package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.js.map +1 -1
  28. package/dist/cjs/tools/annotation/PlanarFreehandROITool.d.ts +2 -2
  29. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +9 -4
  30. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  31. package/dist/cjs/tools/annotation/SplineROITool.d.ts +4 -1
  32. package/dist/cjs/tools/annotation/SplineROITool.js +50 -20
  33. package/dist/cjs/tools/annotation/SplineROITool.js.map +1 -1
  34. package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +12 -3
  35. package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
  36. package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js +9 -5
  37. package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
  38. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js +3 -3
  39. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
  40. package/dist/cjs/tools/base/ContourBaseTool.js +4 -0
  41. package/dist/cjs/tools/base/ContourBaseTool.js.map +1 -1
  42. package/dist/cjs/tools/base/ContourSegmentationBaseTool.js +21 -9
  43. package/dist/cjs/tools/base/ContourSegmentationBaseTool.js.map +1 -1
  44. package/dist/cjs/tools/displayTools/Contour/contourConfig.js +8 -3
  45. package/dist/cjs/tools/displayTools/Contour/contourConfig.js.map +1 -1
  46. package/dist/cjs/tools/displayTools/Contour/contourDisplay.js +0 -1
  47. package/dist/cjs/tools/displayTools/Contour/contourDisplay.js.map +1 -1
  48. package/dist/cjs/types/AnnotationStyle.d.ts +2 -2
  49. package/dist/cjs/types/AnnotationTypes.d.ts +1 -0
  50. package/dist/cjs/types/ContourSegmentationAnnotation.d.ts +1 -0
  51. package/dist/cjs/types/ContourTypes.d.ts +3 -0
  52. package/dist/cjs/types/EventTypes.d.ts +19 -1
  53. package/dist/cjs/types/InterpolationTypes.d.ts +18 -0
  54. package/dist/cjs/types/InterpolationTypes.js +3 -0
  55. package/dist/cjs/types/InterpolationTypes.js.map +1 -0
  56. package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +14 -0
  57. package/dist/cjs/types/index.d.ts +2 -1
  58. package/dist/cjs/utilities/contours/PointsArray.d.ts +29 -0
  59. package/dist/cjs/utilities/contours/PointsArray.js +104 -0
  60. package/dist/cjs/utilities/contours/PointsArray.js.map +1 -0
  61. package/dist/cjs/utilities/contours/index.d.ts +3 -1
  62. package/dist/cjs/utilities/contours/index.js +28 -1
  63. package/dist/cjs/utilities/contours/index.js.map +1 -1
  64. package/dist/cjs/utilities/contours/interpolation/acceptAutogeneratedInterpolations.d.ts +3 -0
  65. package/dist/cjs/utilities/contours/interpolation/acceptAutogeneratedInterpolations.js +11 -0
  66. package/dist/cjs/utilities/contours/interpolation/acceptAutogeneratedInterpolations.js.map +1 -0
  67. package/dist/cjs/utilities/contours/interpolation/createPolylineToolData.d.ts +2 -0
  68. package/dist/cjs/utilities/contours/interpolation/createPolylineToolData.js +39 -0
  69. package/dist/cjs/utilities/contours/interpolation/createPolylineToolData.js.map +1 -0
  70. package/dist/cjs/utilities/contours/interpolation/findAnnotationForInterpolation.d.ts +7 -0
  71. package/dist/cjs/utilities/contours/interpolation/findAnnotationForInterpolation.js +107 -0
  72. package/dist/cjs/utilities/contours/interpolation/findAnnotationForInterpolation.js.map +1 -0
  73. package/dist/cjs/utilities/contours/interpolation/getInterpolationData.d.ts +7 -0
  74. package/dist/cjs/utilities/contours/interpolation/getInterpolationData.js +30 -0
  75. package/dist/cjs/utilities/contours/interpolation/getInterpolationData.js.map +1 -0
  76. package/dist/cjs/utilities/contours/interpolation/getInterpolationDataCollection.d.ts +4 -0
  77. package/dist/cjs/utilities/contours/interpolation/getInterpolationDataCollection.js +21 -0
  78. package/dist/cjs/utilities/contours/interpolation/getInterpolationDataCollection.js.map +1 -0
  79. package/dist/cjs/utilities/contours/interpolation/index.d.ts +2 -0
  80. package/dist/cjs/utilities/contours/interpolation/index.js +9 -0
  81. package/dist/cjs/utilities/contours/interpolation/index.js.map +1 -0
  82. package/dist/cjs/utilities/contours/interpolation/interpolate.d.ts +3 -0
  83. package/dist/cjs/utilities/contours/interpolation/interpolate.js +343 -0
  84. package/dist/cjs/utilities/contours/interpolation/interpolate.js.map +1 -0
  85. package/dist/cjs/utilities/contours/reverseIfAntiClockwise.d.ts +2 -0
  86. package/dist/cjs/utilities/contours/reverseIfAntiClockwise.js +34 -0
  87. package/dist/cjs/utilities/contours/reverseIfAntiClockwise.js.map +1 -0
  88. package/dist/cjs/utilities/getViewportForAnnotation.d.ts +2 -0
  89. package/dist/cjs/utilities/getViewportForAnnotation.js +19 -0
  90. package/dist/cjs/utilities/getViewportForAnnotation.js.map +1 -0
  91. package/dist/cjs/utilities/index.d.ts +2 -1
  92. package/dist/cjs/utilities/index.js +3 -1
  93. package/dist/cjs/utilities/index.js.map +1 -1
  94. package/dist/cjs/utilities/planar/filterAnnotationsForDisplay.js +2 -1
  95. package/dist/cjs/utilities/planar/filterAnnotationsForDisplay.js.map +1 -1
  96. package/dist/cjs/utilities/planarFreehandROITool/index.d.ts +3 -3
  97. package/dist/cjs/utilities/planarFreehandROITool/index.js +4 -4
  98. package/dist/cjs/utilities/planarFreehandROITool/index.js.map +1 -1
  99. package/dist/cjs/utilities/planarFreehandROITool/smoothAnnotation.d.ts +3 -0
  100. package/dist/cjs/utilities/planarFreehandROITool/{interpolateAnnotation.js → smoothAnnotation.js} +5 -5
  101. package/dist/cjs/utilities/planarFreehandROITool/smoothAnnotation.js.map +1 -0
  102. package/dist/cjs/utilities/planarFreehandROITool/{interpolatePoints.d.ts → smoothPoints.d.ts} +1 -1
  103. package/dist/cjs/utilities/planarFreehandROITool/{interpolatePoints.js → smoothPoints.js} +11 -8
  104. package/dist/cjs/utilities/planarFreehandROITool/smoothPoints.js.map +1 -0
  105. package/dist/cjs/utilities/polyData/utils.d.ts +2 -1
  106. package/dist/cjs/utilities/polyData/utils.js +4 -2
  107. package/dist/cjs/utilities/polyData/utils.js.map +1 -1
  108. package/dist/cjs/utilities/segmentation/InterpolationManager/InterpolationManager.d.ts +11 -0
  109. package/dist/cjs/utilities/segmentation/InterpolationManager/InterpolationManager.js +159 -0
  110. package/dist/cjs/utilities/segmentation/InterpolationManager/InterpolationManager.js.map +1 -0
  111. package/dist/cjs/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.d.ts +2 -0
  112. package/dist/cjs/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.js +96 -0
  113. package/dist/cjs/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.js.map +1 -0
  114. package/dist/cjs/utilities/triggerAnnotationRenderForViewportIds.js +7 -2
  115. package/dist/cjs/utilities/triggerAnnotationRenderForViewportIds.js.map +1 -1
  116. package/dist/esm/enums/AnnotationStyleStates.js +1 -0
  117. package/dist/esm/enums/AnnotationStyleStates.js.map +1 -1
  118. package/dist/esm/enums/ChangeTypes.js +10 -0
  119. package/dist/esm/enums/ChangeTypes.js.map +1 -0
  120. package/dist/esm/enums/Events.js +2 -0
  121. package/dist/esm/enums/Events.js.map +1 -1
  122. package/dist/esm/enums/index.js +2 -1
  123. package/dist/esm/enums/index.js.map +1 -1
  124. package/dist/esm/eventDispatchers/annotationInterpolationEventDispatcher.js +18 -0
  125. package/dist/esm/eventDispatchers/annotationInterpolationEventDispatcher.js.map +1 -0
  126. package/dist/esm/eventDispatchers/index.js +2 -1
  127. package/dist/esm/eventDispatchers/index.js.map +1 -1
  128. package/dist/esm/init.js +3 -0
  129. package/dist/esm/init.js.map +1 -1
  130. package/dist/esm/stateManagement/annotation/config/getState.js +3 -0
  131. package/dist/esm/stateManagement/annotation/config/getState.js.map +1 -1
  132. package/dist/esm/tools/annotation/LivewireContourTool.js +2 -2
  133. package/dist/esm/tools/annotation/LivewireContourTool.js.map +1 -1
  134. package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js +1 -0
  135. package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js.map +1 -1
  136. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +9 -4
  137. package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  138. package/dist/esm/tools/annotation/SplineROITool.js +49 -21
  139. package/dist/esm/tools/annotation/SplineROITool.js.map +1 -1
  140. package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +11 -2
  141. package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
  142. package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js +8 -4
  143. package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
  144. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js +2 -2
  145. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
  146. package/dist/esm/tools/base/ContourBaseTool.js +4 -0
  147. package/dist/esm/tools/base/ContourBaseTool.js.map +1 -1
  148. package/dist/esm/tools/base/ContourSegmentationBaseTool.js +12 -1
  149. package/dist/esm/tools/base/ContourSegmentationBaseTool.js.map +1 -1
  150. package/dist/esm/tools/displayTools/Contour/contourConfig.js +8 -3
  151. package/dist/esm/tools/displayTools/Contour/contourConfig.js.map +1 -1
  152. package/dist/esm/tools/displayTools/Contour/contourDisplay.js +0 -1
  153. package/dist/esm/tools/displayTools/Contour/contourDisplay.js.map +1 -1
  154. package/dist/esm/types/InterpolationTypes.js +2 -0
  155. package/dist/esm/types/InterpolationTypes.js.map +1 -0
  156. package/dist/esm/utilities/contours/PointsArray.js +98 -0
  157. package/dist/esm/utilities/contours/PointsArray.js.map +1 -0
  158. package/dist/esm/utilities/contours/index.js +3 -1
  159. package/dist/esm/utilities/contours/index.js.map +1 -1
  160. package/dist/esm/utilities/contours/interpolation/acceptAutogeneratedInterpolations.js +5 -0
  161. package/dist/esm/utilities/contours/interpolation/acceptAutogeneratedInterpolations.js.map +1 -0
  162. package/dist/esm/utilities/contours/interpolation/createPolylineToolData.js +36 -0
  163. package/dist/esm/utilities/contours/interpolation/createPolylineToolData.js.map +1 -0
  164. package/dist/esm/utilities/contours/interpolation/findAnnotationForInterpolation.js +102 -0
  165. package/dist/esm/utilities/contours/interpolation/findAnnotationForInterpolation.js.map +1 -0
  166. package/dist/esm/utilities/contours/interpolation/getInterpolationData.js +27 -0
  167. package/dist/esm/utilities/contours/interpolation/getInterpolationData.js.map +1 -0
  168. package/dist/esm/utilities/contours/interpolation/getInterpolationDataCollection.js +15 -0
  169. package/dist/esm/utilities/contours/interpolation/getInterpolationDataCollection.js.map +1 -0
  170. package/dist/esm/utilities/contours/interpolation/index.js +3 -0
  171. package/dist/esm/utilities/contours/interpolation/index.js.map +1 -0
  172. package/dist/esm/utilities/contours/interpolation/interpolate.js +314 -0
  173. package/dist/esm/utilities/contours/interpolation/interpolate.js.map +1 -0
  174. package/dist/esm/utilities/contours/reverseIfAntiClockwise.js +31 -0
  175. package/dist/esm/utilities/contours/reverseIfAntiClockwise.js.map +1 -0
  176. package/dist/esm/utilities/getViewportForAnnotation.js +16 -0
  177. package/dist/esm/utilities/getViewportForAnnotation.js.map +1 -0
  178. package/dist/esm/utilities/index.js +2 -1
  179. package/dist/esm/utilities/index.js.map +1 -1
  180. package/dist/esm/utilities/planar/filterAnnotationsForDisplay.js +1 -1
  181. package/dist/esm/utilities/planar/filterAnnotationsForDisplay.js.map +1 -1
  182. package/dist/esm/utilities/planarFreehandROITool/index.js +3 -3
  183. package/dist/esm/utilities/planarFreehandROITool/index.js.map +1 -1
  184. package/dist/esm/utilities/planarFreehandROITool/{interpolateAnnotation.js → smoothAnnotation.js} +4 -4
  185. package/dist/esm/utilities/planarFreehandROITool/smoothAnnotation.js.map +1 -0
  186. package/dist/esm/utilities/planarFreehandROITool/{interpolatePoints.js → smoothPoints.js} +9 -6
  187. package/dist/esm/utilities/planarFreehandROITool/smoothPoints.js.map +1 -0
  188. package/dist/esm/utilities/polyData/utils.js +4 -2
  189. package/dist/esm/utilities/polyData/utils.js.map +1 -1
  190. package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js +150 -0
  191. package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js.map +1 -0
  192. package/dist/esm/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.js +67 -0
  193. package/dist/esm/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.js.map +1 -0
  194. package/dist/esm/utilities/triggerAnnotationRenderForViewportIds.js +7 -2
  195. package/dist/esm/utilities/triggerAnnotationRenderForViewportIds.js.map +1 -1
  196. package/dist/types/enums/AnnotationStyleStates.d.ts +2 -1
  197. package/dist/types/enums/AnnotationStyleStates.d.ts.map +1 -1
  198. package/dist/types/enums/ChangeTypes.d.ts +9 -0
  199. package/dist/types/enums/ChangeTypes.d.ts.map +1 -0
  200. package/dist/types/enums/Events.d.ts +2 -0
  201. package/dist/types/enums/Events.d.ts.map +1 -1
  202. package/dist/types/enums/index.d.ts +2 -1
  203. package/dist/types/eventDispatchers/annotationInterpolationEventDispatcher.d.ts +6 -0
  204. package/dist/types/eventDispatchers/annotationInterpolationEventDispatcher.d.ts.map +1 -0
  205. package/dist/types/eventDispatchers/index.d.ts +2 -1
  206. package/dist/types/init.d.ts.map +1 -1
  207. package/dist/types/stateManagement/annotation/config/getState.d.ts.map +1 -1
  208. package/dist/types/tools/annotation/LivewireContourTool.d.ts +1 -1
  209. package/dist/types/tools/annotation/LivewireContourTool.d.ts.map +1 -1
  210. package/dist/types/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts.map +1 -1
  211. package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts +2 -2
  212. package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts.map +1 -1
  213. package/dist/types/tools/annotation/SplineROITool.d.ts +4 -1
  214. package/dist/types/tools/annotation/SplineROITool.d.ts.map +1 -1
  215. package/dist/types/tools/annotation/planarFreehandROITool/closedContourEditLoop.d.ts.map +1 -1
  216. package/dist/types/tools/annotation/planarFreehandROITool/drawLoop.d.ts.map +1 -1
  217. package/dist/types/tools/base/ContourBaseTool.d.ts.map +1 -1
  218. package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts.map +1 -1
  219. package/dist/types/tools/displayTools/Contour/contourConfig.d.ts.map +1 -1
  220. package/dist/types/tools/displayTools/Contour/contourDisplay.d.ts.map +1 -1
  221. package/dist/types/types/AnnotationStyle.d.ts +2 -2
  222. package/dist/types/types/AnnotationStyle.d.ts.map +1 -1
  223. package/dist/types/types/AnnotationTypes.d.ts +1 -0
  224. package/dist/types/types/AnnotationTypes.d.ts.map +1 -1
  225. package/dist/types/types/ContourSegmentationAnnotation.d.ts +1 -0
  226. package/dist/types/types/ContourSegmentationAnnotation.d.ts.map +1 -1
  227. package/dist/types/types/ContourTypes.d.ts +3 -0
  228. package/dist/types/types/ContourTypes.d.ts.map +1 -1
  229. package/dist/types/types/EventTypes.d.ts +19 -1
  230. package/dist/types/types/EventTypes.d.ts.map +1 -1
  231. package/dist/types/types/InterpolationTypes.d.ts +19 -0
  232. package/dist/types/types/InterpolationTypes.d.ts.map +1 -0
  233. package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +14 -0
  234. package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
  235. package/dist/types/types/index.d.ts +2 -1
  236. package/dist/types/types/index.d.ts.map +1 -1
  237. package/dist/types/utilities/contours/PointsArray.d.ts +30 -0
  238. package/dist/types/utilities/contours/PointsArray.d.ts.map +1 -0
  239. package/dist/types/utilities/contours/index.d.ts +3 -1
  240. package/dist/types/utilities/contours/index.d.ts.map +1 -1
  241. package/dist/types/utilities/contours/interpolation/acceptAutogeneratedInterpolations.d.ts +4 -0
  242. package/dist/types/utilities/contours/interpolation/acceptAutogeneratedInterpolations.d.ts.map +1 -0
  243. package/dist/types/utilities/contours/interpolation/createPolylineToolData.d.ts +3 -0
  244. package/dist/types/utilities/contours/interpolation/createPolylineToolData.d.ts.map +1 -0
  245. package/dist/types/utilities/contours/interpolation/findAnnotationForInterpolation.d.ts +8 -0
  246. package/dist/types/utilities/contours/interpolation/findAnnotationForInterpolation.d.ts.map +1 -0
  247. package/dist/types/utilities/contours/interpolation/getInterpolationData.d.ts +8 -0
  248. package/dist/types/utilities/contours/interpolation/getInterpolationData.d.ts.map +1 -0
  249. package/dist/types/utilities/contours/interpolation/getInterpolationDataCollection.d.ts +5 -0
  250. package/dist/types/utilities/contours/interpolation/getInterpolationDataCollection.d.ts.map +1 -0
  251. package/dist/types/utilities/contours/interpolation/index.d.ts +3 -0
  252. package/dist/types/utilities/contours/interpolation/index.d.ts.map +1 -0
  253. package/dist/types/utilities/contours/interpolation/interpolate.d.ts +4 -0
  254. package/dist/types/utilities/contours/interpolation/interpolate.d.ts.map +1 -0
  255. package/dist/types/utilities/contours/reverseIfAntiClockwise.d.ts +3 -0
  256. package/dist/types/utilities/contours/reverseIfAntiClockwise.d.ts.map +1 -0
  257. package/dist/types/utilities/getViewportForAnnotation.d.ts +3 -0
  258. package/dist/types/utilities/getViewportForAnnotation.d.ts.map +1 -0
  259. package/dist/types/utilities/index.d.ts +2 -1
  260. package/dist/types/utilities/index.d.ts.map +1 -1
  261. package/dist/types/utilities/planar/filterAnnotationsForDisplay.d.ts.map +1 -1
  262. package/dist/types/utilities/planarFreehandROITool/index.d.ts +3 -3
  263. package/dist/types/utilities/planarFreehandROITool/index.d.ts.map +1 -1
  264. package/dist/types/utilities/planarFreehandROITool/smoothAnnotation.d.ts +4 -0
  265. package/dist/types/utilities/planarFreehandROITool/smoothAnnotation.d.ts.map +1 -0
  266. package/dist/types/utilities/planarFreehandROITool/{interpolatePoints.d.ts → smoothPoints.d.ts} +2 -2
  267. package/dist/types/utilities/planarFreehandROITool/smoothPoints.d.ts.map +1 -0
  268. package/dist/types/utilities/polyData/utils.d.ts +2 -1
  269. package/dist/types/utilities/polyData/utils.d.ts.map +1 -1
  270. package/dist/types/utilities/segmentation/InterpolationManager/InterpolationManager.d.ts +12 -0
  271. package/dist/types/utilities/segmentation/InterpolationManager/InterpolationManager.d.ts.map +1 -0
  272. package/dist/types/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.d.ts +3 -0
  273. package/dist/types/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.d.ts.map +1 -0
  274. package/dist/types/utilities/triggerAnnotationRenderForViewportIds.d.ts.map +1 -1
  275. package/dist/umd/index.js +1 -1
  276. package/dist/umd/index.js.map +1 -1
  277. package/package.json +3 -3
  278. package/src/enums/AnnotationStyleStates.ts +3 -0
  279. package/src/enums/ChangeTypes.ts +32 -0
  280. package/src/enums/Events.ts +16 -0
  281. package/src/enums/index.js +2 -0
  282. package/src/eventDispatchers/annotationInterpolationEventDispatcher.ts +42 -0
  283. package/src/eventDispatchers/index.js +2 -0
  284. package/src/init.ts +3 -0
  285. package/src/stateManagement/annotation/config/getState.ts +16 -2
  286. package/src/tools/annotation/LivewireContourTool.ts +3 -8
  287. package/src/tools/annotation/PlanarFreehandContourSegmentationTool.ts +6 -0
  288. package/src/tools/annotation/PlanarFreehandROITool.ts +47 -25
  289. package/src/tools/annotation/SplineROITool.ts +80 -28
  290. package/src/tools/annotation/planarFreehandROITool/closedContourEditLoop.ts +15 -3
  291. package/src/tools/annotation/planarFreehandROITool/drawLoop.ts +10 -6
  292. package/src/tools/annotation/planarFreehandROITool/openContourEditLoop.ts +3 -3
  293. package/src/tools/base/ContourBaseTool.ts +4 -0
  294. package/src/tools/base/ContourSegmentationBaseTool.ts +11 -1
  295. package/src/tools/displayTools/Contour/contourConfig.ts +8 -3
  296. package/src/tools/displayTools/Contour/contourDisplay.ts +1 -3
  297. package/src/types/AnnotationStyle.ts +3 -1
  298. package/src/types/AnnotationTypes.ts +2 -0
  299. package/src/types/ContourSegmentationAnnotation.ts +1 -0
  300. package/src/types/ContourTypes.ts +8 -0
  301. package/src/types/EventTypes.ts +43 -0
  302. package/src/types/InterpolationTypes.ts +42 -0
  303. package/src/types/ToolSpecificAnnotationTypes.ts +15 -0
  304. package/src/types/index.ts +6 -0
  305. package/src/utilities/contours/PointsArray.ts +165 -0
  306. package/src/utilities/contours/index.ts +4 -1
  307. package/src/utilities/contours/interpolation/acceptAutogeneratedInterpolations.ts +16 -0
  308. package/src/utilities/contours/interpolation/createPolylineToolData.ts +56 -0
  309. package/src/utilities/contours/interpolation/findAnnotationForInterpolation.ts +225 -0
  310. package/src/utilities/contours/interpolation/getInterpolationData.ts +75 -0
  311. package/src/utilities/contours/interpolation/getInterpolationDataCollection.ts +31 -0
  312. package/src/utilities/contours/interpolation/index.ts +3 -0
  313. package/src/utilities/contours/interpolation/interpolate.ts +695 -0
  314. package/src/utilities/contours/reverseIfAntiClockwise.ts +50 -0
  315. package/src/utilities/getViewportForAnnotation.ts +29 -0
  316. package/src/utilities/index.ts +2 -0
  317. package/src/utilities/livewire/LivewireScissors.ts +1 -1
  318. package/src/utilities/planar/filterAnnotationsForDisplay.ts +6 -1
  319. package/src/utilities/planarFreehandROITool/index.ts +3 -3
  320. package/src/utilities/planarFreehandROITool/{interpolateAnnotation.ts → smoothAnnotation.ts} +5 -3
  321. package/src/utilities/planarFreehandROITool/{interpolatePoints.ts → smoothPoints.ts} +12 -6
  322. package/src/utilities/polyData/utils.ts +12 -5
  323. package/src/utilities/segmentation/InterpolationManager/InterpolationManager.ts +207 -0
  324. package/src/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.ts +97 -0
  325. package/src/utilities/triggerAnnotationRenderForViewportIds.ts +7 -2
  326. package/dist/cjs/utilities/planarFreehandROITool/interpolateAnnotation.d.ts +0 -3
  327. package/dist/cjs/utilities/planarFreehandROITool/interpolateAnnotation.js.map +0 -1
  328. package/dist/cjs/utilities/planarFreehandROITool/interpolatePoints.js.map +0 -1
  329. package/dist/esm/utilities/planarFreehandROITool/interpolateAnnotation.js.map +0 -1
  330. package/dist/esm/utilities/planarFreehandROITool/interpolatePoints.js.map +0 -1
  331. package/dist/types/utilities/planarFreehandROITool/interpolateAnnotation.d.ts +0 -4
  332. package/dist/types/utilities/planarFreehandROITool/interpolateAnnotation.d.ts.map +0 -1
  333. package/dist/types/utilities/planarFreehandROITool/interpolatePoints.d.ts.map +0 -1
@@ -0,0 +1,98 @@
1
+ import { vec2, vec3 } from 'gl-matrix';
2
+ export class PointsArray {
3
+ constructor(configuration = {}) {
4
+ this.dimensions = 3;
5
+ this.length = 0;
6
+ const { initialSize = 1024, dimensions = 3 } = configuration;
7
+ this.data = new Float32Array(initialSize * dimensions);
8
+ this.dimensions = dimensions;
9
+ }
10
+ forEach(func, point) {
11
+ for (let i = 0; i < this.length; i++) {
12
+ func(this.getPoint(i, point), i);
13
+ }
14
+ }
15
+ reverse() {
16
+ const midLength = Math.floor(this.length / 2);
17
+ for (let i = 0; i < midLength; i++) {
18
+ const indexStart = i * this.dimensions;
19
+ const indexEnd = (this.length - 1 - i) * this.dimensions;
20
+ for (let dimension = 0; dimension < this.dimensions; dimension++) {
21
+ const valueStart = this.data[indexStart + dimension];
22
+ this.data[indexStart + dimension] = this.data[indexEnd + dimension];
23
+ this.data[indexEnd + dimension] = valueStart;
24
+ }
25
+ }
26
+ }
27
+ map(f, factory) {
28
+ const mapData = [];
29
+ for (let i = 0; i < this.length; i++) {
30
+ mapData.push(f(this.getPoint(i, factory(i)), i));
31
+ }
32
+ return mapData;
33
+ }
34
+ static fromXYZ({ x, y, z }) {
35
+ const array = new PointsArray3({ initialSize: x.length });
36
+ let offset = 0;
37
+ for (let i = 0; i < x.length; i++) {
38
+ array.data[offset++] = x[i];
39
+ array.data[offset++] = y[i];
40
+ array.data[offset++] = z[i];
41
+ }
42
+ array.length = x.length;
43
+ return array;
44
+ }
45
+ }
46
+ export class PointsArray2 extends PointsArray {
47
+ constructor(configuration = {}) {
48
+ super({ ...configuration, dimensions: 2 });
49
+ }
50
+ forEach(func, point = vec2.create()) {
51
+ super.forEach(func, point);
52
+ }
53
+ getPoint(index, point = vec2.create()) {
54
+ if (index >= this.length) {
55
+ return;
56
+ }
57
+ const index2 = index * 2;
58
+ point[0] = this.data[index2];
59
+ point[1] = this.data[index2 + 1];
60
+ return point;
61
+ }
62
+ get points() {
63
+ return this.map((point) => point, () => vec2.create());
64
+ }
65
+ }
66
+ export class PointsArray3 extends PointsArray {
67
+ constructor(configuration = {}) {
68
+ super({ ...configuration, dimensions: 3 });
69
+ }
70
+ forEach(func, point = vec3.create()) {
71
+ super.forEach(func, point);
72
+ }
73
+ getPoint(index, point = vec3.create()) {
74
+ if (index >= this.length) {
75
+ return;
76
+ }
77
+ const index2 = index * 3;
78
+ point[0] = this.data[index2];
79
+ point[1] = this.data[index2 + 1];
80
+ point[2] = this.data[index2 + 2];
81
+ return point;
82
+ }
83
+ get points() {
84
+ return this.map((point) => point, () => vec3.create());
85
+ }
86
+ getXYZ() {
87
+ const x = [];
88
+ const y = [];
89
+ const z = [];
90
+ this.forEach((point) => {
91
+ x.push(point[0]);
92
+ y.push(point[1]);
93
+ z.push(point[2]);
94
+ });
95
+ return { x, y, z };
96
+ }
97
+ }
98
+ //# sourceMappingURL=PointsArray.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PointsArray.js","sourceRoot":"","sources":["../../../../src/utilities/contours/PointsArray.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAevC,MAAM,OAAgB,WAAW;IAK/B,YAAY,gBAA4C,EAAE;QAH1D,eAAU,GAAG,CAAC,CAAC;QACR,WAAM,GAAG,CAAC,CAAC;QAGhB,MAAM,EAAE,WAAW,GAAG,IAAI,EAAE,UAAU,GAAG,CAAC,EAAE,GAAG,aAAa,CAAC;QAC7D,IAAI,CAAC,IAAI,GAAG,IAAI,YAAY,CAAC,WAAW,GAAG,UAAU,CAAC,CAAC;QACvD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAES,OAAO,CAAC,IAAuC,EAAE,KAAQ;QACjE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpC,IAAI,CAAC,IAAI,CAAC,QA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AAC,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACrB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;QACH,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACrB,CAAC;CACF"}
@@ -3,5 +3,7 @@ import mergePoints from './mergePoints';
3
3
  import detectContourHoles from './detectContourHoles';
4
4
  import { generateContourSetsFromLabelmap } from './generateContourSetsFromLabelmap';
5
5
  import AnnotationToPointData from './AnnotationToPointData';
6
- export { contourFinder, mergePoints, detectContourHoles, generateContourSetsFromLabelmap, AnnotationToPointData, };
6
+ import acceptAutogeneratedInterpolations from './interpolation/acceptAutogeneratedInterpolations';
7
+ import * as interpolation from './interpolation';
8
+ export { contourFinder, mergePoints, detectContourHoles, generateContourSetsFromLabelmap, AnnotationToPointData, interpolation, acceptAutogeneratedInterpolations, };
7
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/contours/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAEpF,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EACL,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,+BAA+B,EAC/B,qBAAqB,GACtB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/contours/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,iCAAiC,MAAM,mDAAmD,CAAC;AAClG,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EACL,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,+BAA+B,EAC/B,qBAAqB,EACrB,aAAa,EACb,iCAAiC,GAClC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import InterpolationManager from '../../segmentation/InterpolationManager/InterpolationManager';
2
+ export default function acceptAutogeneratedInterpolations(annotationGroupSelector, selector) {
3
+ InterpolationManager.acceptAutoGenerated(annotationGroupSelector, selector);
4
+ }
5
+ //# sourceMappingURL=acceptAutogeneratedInterpolations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acceptAutogeneratedInterpolations.js","sourceRoot":"","sources":["../../../../../src/utilities/contours/interpolation/acceptAutogeneratedInterpolations.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,8DAA8D,CAAC;AAUhG,MAAM,CAAC,OAAO,UAAU,iCAAiC,CACvD,uBAAgD,EAChD,QAAqC;IAErC,oBAAoB,CAAC,mBAAmB,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { utilities as csUtils } from '@cornerstonejs/core';
2
+ export default function createPolylineToolData(polyline, handlePoints, referencedToolData) {
3
+ const annotation = csUtils.deepMerge({
4
+ data: {},
5
+ metadata: {},
6
+ }, referencedToolData);
7
+ Object.assign(annotation, {
8
+ highlighted: false,
9
+ invalidated: true,
10
+ autoGenerated: true,
11
+ annotationUID: undefined,
12
+ cachedStats: {},
13
+ });
14
+ Object.assign(annotation.data, {
15
+ handles: {
16
+ points: handlePoints || [],
17
+ activeHandleIndex: null,
18
+ textBox: {
19
+ hasMoved: false,
20
+ worldPosition: [0, 0, 0],
21
+ worldBoundingBox: {
22
+ topLeft: [0, 0, 0],
23
+ topRight: [0, 0, 0],
24
+ bottomLeft: [0, 0, 0],
25
+ bottomRight: [0, 0, 0],
26
+ },
27
+ },
28
+ },
29
+ contour: {
30
+ polyline,
31
+ closed: true,
32
+ },
33
+ });
34
+ return annotation;
35
+ }
36
+ //# sourceMappingURL=createPolylineToolData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createPolylineToolData.js","sourceRoot":"","sources":["../../../../../src/utilities/contours/interpolation/createPolylineToolData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,SAAS,IAAI,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAclE,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,QAAQ,EACR,YAAY,EACZ,kBAAkB;IAElB,MAAM,UAAU,GAA+B,OAAO,CAAC,SAAS,CAC9D;QACE,IAAI,EAAE,EAAE;QACR,QAAQ,EAAE,EAAE;KACb,EACD,kBAAkB,CACnB,CAAC;IACF,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE;QACxB,WAAW,EAAE,KAAK;QAClB,WAAW,EAAE,IAAI;QACjB,aAAa,EAAE,IAAI;QACnB,aAAa,EAAE,SAAS;QACxB,WAAW,EAAE,EAAE;KAChB,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;QAC7B,OAAO,EAAE;YACP,MAAM,EAAE,YAAY,IAAI,EAAE;YAC1B,iBAAiB,EAAE,IAAI;YACvB,OAAO,EAAE;gBACP,QAAQ,EAAE,KAAK;gBACf,aAAa,EAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACtC,gBAAgB,EAAE;oBAChB,OAAO,EAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;oBAChC,QAAQ,EAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;oBACjC,UAAU,EAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;oBACnC,WAAW,EAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;iBACrC;aACF;SACF;QACD,OAAO,EAAE;YACP,QAAQ;YACR,MAAM,EAAE,IAAI;SACb;KACF,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,102 @@
1
+ import getInterpolationData from './getInterpolationData';
2
+ function findAnnotationsForInterpolation(toolData, viewportData) {
3
+ const interpolationData = getInterpolationData(viewportData, [
4
+ {
5
+ key: 'interpolationUID',
6
+ value: viewportData.interpolationUID,
7
+ },
8
+ ]);
9
+ const rangeToInterpolate = getRangeToInterpolate(interpolationData);
10
+ const sliceEdited = _getSlicePositionOfToolData(interpolationData, toolData.annotationUID);
11
+ const interpolationList = [];
12
+ for (let i = rangeToInterpolate[0] + 1; i < rangeToInterpolate[1]; i++) {
13
+ if (_sliceNeedsInterpolating(interpolationData, i)) {
14
+ const contourPair = _getBoundingPair(i, rangeToInterpolate, interpolationData);
15
+ if (contourPair?.[0] === sliceEdited ||
16
+ contourPair?.[1] === sliceEdited) {
17
+ _appendInterpolationList(contourPair, interpolationList, i);
18
+ }
19
+ }
20
+ }
21
+ return {
22
+ interpolationData,
23
+ interpolationList,
24
+ };
25
+ }
26
+ function getRangeToInterpolate(interpolationData) {
27
+ let first = Infinity;
28
+ let last = -Infinity;
29
+ let found = false;
30
+ for (const [sliceIndex, annotations] of interpolationData.entries()) {
31
+ if (annotations.length) {
32
+ first = Math.min(sliceIndex, first);
33
+ last = Math.max(sliceIndex, last);
34
+ found = true;
35
+ }
36
+ }
37
+ if (!found) {
38
+ return;
39
+ }
40
+ return [first, last];
41
+ }
42
+ function _getSlicePositionOfToolData(interpolationData, annotationUID) {
43
+ for (const [sliceIndex, annotations] of interpolationData) {
44
+ for (let j = 0; j < annotations.length; j++) {
45
+ if (annotations[j].annotationUID === annotationUID) {
46
+ return sliceIndex;
47
+ }
48
+ }
49
+ }
50
+ return;
51
+ }
52
+ function _sliceNeedsInterpolating(interpolationData, sliceIndex) {
53
+ const annotations = interpolationData.get(sliceIndex);
54
+ return (!annotations || (annotations.length === 1 && annotations[0].autoGenerated));
55
+ }
56
+ function _appendInterpolationList(contourPair, interpolationList, itemIndex) {
57
+ const [startIndex] = contourPair;
58
+ interpolationList[startIndex] ||= {
59
+ pair: contourPair,
60
+ list: [],
61
+ };
62
+ interpolationList[startIndex].list.push(itemIndex);
63
+ }
64
+ function _getBoundingPair(sliceIndex, sliceRange, interpolationData) {
65
+ const annotationPair = [];
66
+ let canInterpolate = true;
67
+ for (let i = sliceIndex - 1; i >= sliceRange[0]; i--) {
68
+ const annotations = interpolationData.get(i);
69
+ if (annotations?.length) {
70
+ if (annotations[0].autoGenerated) {
71
+ continue;
72
+ }
73
+ if (annotations.length > 1) {
74
+ canInterpolate = false;
75
+ }
76
+ annotationPair.push(i);
77
+ break;
78
+ }
79
+ }
80
+ if (!canInterpolate || !annotationPair.length) {
81
+ return;
82
+ }
83
+ for (let i = sliceIndex + 1; i <= sliceRange[1]; i++) {
84
+ const annotations = interpolationData.get(i);
85
+ if (annotations?.length) {
86
+ if (annotations[0].autoGenerated) {
87
+ continue;
88
+ }
89
+ if (annotations.length > 1) {
90
+ canInterpolate = false;
91
+ }
92
+ annotationPair.push(i);
93
+ break;
94
+ }
95
+ }
96
+ if (!canInterpolate || annotationPair.length < 2) {
97
+ return;
98
+ }
99
+ return annotationPair;
100
+ }
101
+ export default findAnnotationsForInterpolation;
102
+ //# sourceMappingURL=findAnnotationForInterpolation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findAnnotationForInterpolation.js","sourceRoot":"","sources":["../../../../../src/utilities/contours/interpolation/findAnnotationForInterpolation.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,wBA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/annotation/annotationState';
2
+ export default function getInterpolationData(viewportData, filterParams = []) {
3
+ const { viewport, sliceData, annotation } = viewportData;
4
+ const interpolationDatas = new Map();
5
+ const annotations = getAnnotations(annotation.metadata.toolName, viewport.element);
6
+ for (let i = 0; i < sliceData.numberOfSlices; i++) {
7
+ const imageAnnotations = annotations.filter((x) => x.metadata.referencedSliceIndex === i);
8
+ if (!imageAnnotations?.length) {
9
+ continue;
10
+ }
11
+ const filteredInterpolatedAnnotations = imageAnnotations.filter((imageAnnotation) => {
12
+ return filterParams.every((x) => {
13
+ const parent = x.parentKey
14
+ ? x.parentKey(imageAnnotation)
15
+ : imageAnnotation;
16
+ const value = parent?.[x.key];
17
+ if (Array.isArray(value)) {
18
+ return value.every((item, index) => item === x.value[index]);
19
+ }
20
+ return value === x.value;
21
+ });
22
+ });
23
+ interpolationDatas.set(i, filteredInterpolatedAnnotations);
24
+ }
25
+ return interpolationDatas;
26
+ }
27
+ //# sourceMappingURL=getInterpolationData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getInterpolationData.js","sourceRoot":"","sources":["../../../../../src/utilities/contours/interpolation/getInterpolationData.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qDAAqD,CAAC;AAiCrF,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,YAAuC,EACvC,YAAY,GAAG,EAAE;IAEjB,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,YAAY,CAAC;IACzD,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC3D,MAAM,WAAW,GAAG,cAAc,CAChC,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAC5B,QAAQ,CAAC,OAAO,CACjB,CAAC;IAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,cAAc,EAAE,CAAC,EAAE,EAAE;QACjD,MAAM,gBAAgB,GAAG,WAAW,CAAC,MAAM,CACzC,CAAC,CAAC,EAAE,EAAE,CACH,CAAgC,CAAC,QAAQ,CAAC,oBAAoB,KAAK,CAAC,CACxE,CAAC;QAEF,IAAI,CAAC,gBAAgB,EAAE,MAAM,EAAE;YAC7B,SAAS;SACV;QAED,MAAM,+BAA+B,GAAG,gBAAgB,CAAC,MAAM,CAC7D,CAAC,eAAe,EAAE,EAAE;YAClB,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBAC9B,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS;oBACxB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC;oBAC9B,CAAC,CAAC,eAAe,CAAC;gBACpB,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBAC9B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;oBACxB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;iBAC9D;gBACD,OAAO,KAAK,KAAK,CAAC,CAAC,KAAK,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC,CACF,CAAC;QAEF,kBAAkB,CAAC,GAAG,CAAC,CAAC,EAAE,+BAA+B,CAAC,CAAC;KAC5D;IAED,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,15 @@
1
+ import getInterpolationData from './getInterpolationData';
2
+ export default function getInterpolationDataCollection(viewportData, filterParams) {
3
+ const imageAnnotations = getInterpolationData(viewportData, filterParams);
4
+ const interpolatedDataCollection = [];
5
+ if (!imageAnnotations?.size) {
6
+ return interpolatedDataCollection;
7
+ }
8
+ for (const annotations of imageAnnotations.values()) {
9
+ annotations.forEach((annotation) => {
10
+ interpolatedDataCollection.push(annotation);
11
+ });
12
+ }
13
+ return interpolatedDataCollection;
14
+ }
15
+ //# sourceMappingURL=getInterpolationDataCollection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getInterpolationDataCollection.js","sourceRoot":"","sources":["../../../../../src/utilities/contours/interpolation/getInterpolationDataCollection.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAe1D,MAAM,CAAC,OAAO,UAAU,8BAA8B,CACpD,YAAuC,EACvC,YAA2B;IAE3B,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IAC1E,MAAM,0BAA0B,GAAG,EAAE,CAAC;IACtC,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE;QAC3B,OAAO,0BAA0B,CAAC;KACnC;IACD,KAAK,MAAM,WAAW,IAAI,gBAAgB,CAAC,MAAM,EAAE,EAAE;QACnD,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACjC,0BAA0B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;KACJ;IACD,OAAO,0BAA0B,CAAC;AACpC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import InterpolationManager from '../../segmentation/InterpolationManager/InterpolationManager';
2
+ export { InterpolationManager };
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/utilities/contours/interpolation/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,8DAA8D,CAAC;AAEhG,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,314 @@
1
+ import { triggerEvent } from '@cornerstonejs/core';
2
+ import { vec3 } from 'gl-matrix';
3
+ import createPolylineToolData from './createPolylineToolData';
4
+ import findAnnotationsForInterpolation from './findAnnotationForInterpolation';
5
+ import EventTypes from '../../../enums/Events';
6
+ import * as annotationState from '../../../stateManagement/annotation';
7
+ import { PointsArray } from '../PointsArray';
8
+ const dP = 0.2;
9
+ let interpolating = false;
10
+ function interpolate(viewportData) {
11
+ if (interpolating || !viewportData.annotation) {
12
+ return;
13
+ }
14
+ interpolating = true;
15
+ try {
16
+ startInterpolation(viewportData);
17
+ }
18
+ finally {
19
+ interpolating = false;
20
+ }
21
+ }
22
+ function startInterpolation(viewportData) {
23
+ const toolData = viewportData.annotation;
24
+ const { interpolationData, interpolationList } = findAnnotationsForInterpolation(toolData, viewportData);
25
+ const eventData = {
26
+ toolName: toolData.metadata.toolName,
27
+ toolType: toolData.metadata.toolName,
28
+ viewport: viewportData.viewport,
29
+ };
30
+ for (let i = 0; i < interpolationList.length; i++) {
31
+ if (interpolationList[i]) {
32
+ _linearlyInterpolateBetween(interpolationList[i].list, interpolationList[i].pair, interpolationData, eventData);
33
+ }
34
+ }
35
+ const { id, renderingEngineId, element } = viewportData.viewport;
36
+ const eventDetails = {
37
+ annotation: toolData,
38
+ element,
39
+ viewportId: id,
40
+ renderingEngineId,
41
+ };
42
+ if (interpolationList.length) {
43
+ triggerEvent(viewportData.viewport.element, EventTypes.ANNOTATION_INTERPOLATION_PROCESS_COMPLETED, eventDetails);
44
+ }
45
+ }
46
+ function _linearlyInterpolateBetween(indices, annotationPair, interpolationData, eventData) {
47
+ const c1 = _generateClosedContour(interpolationData.get(annotationPair[0])[0].data.contour.polyline);
48
+ const c2 = _generateClosedContour(interpolationData.get(annotationPair[1])[0].data.contour.polyline);
49
+ const { c1Interp, c2Interp } = _generateInterpolationContourPair(c1, c2);
50
+ indices.forEach(function (index) {
51
+ _linearlyInterpolateContour(c1Interp, c2Interp, index, annotationPair, interpolationData, c1.x.length > c2.x.length, eventData);
52
+ });
53
+ }
54
+ function _linearlyInterpolateContour(c1Interp, c2Interp, sliceIndex, annotationPair, interpolationData, c1HasMoreNodes, eventData) {
55
+ const [startIndex, endIndex] = annotationPair;
56
+ const zInterp = (sliceIndex - startIndex) / (endIndex - startIndex);
57
+ const interpolated3DPoints = _generateInterpolatedOpenContour(c1Interp, c2Interp, zInterp, c1HasMoreNodes);
58
+ const nearestAnnotation = interpolationData.get(annotationPair[zInterp > 0.5 ? 1 : 0])[0];
59
+ const handleCount = Math.round(Math.max(8, interpolationData.get(startIndex)[0].data.handles.points.length * 2, interpolationData.get(endIndex)[0].data.handles.points.length * 2));
60
+ const handlePoints = _subselect(interpolated3DPoints, handleCount);
61
+ if (interpolationData.has(sliceIndex)) {
62
+ _editInterpolatedContour(interpolated3DPoints, handlePoints, sliceIndex, nearestAnnotation, eventData);
63
+ }
64
+ else {
65
+ _addInterpolatedContour(interpolated3DPoints, handlePoints, sliceIndex, nearestAnnotation, eventData);
66
+ }
67
+ }
68
+ function _subselect(points, count = 10) {
69
+ const handles = [];
70
+ const { length } = points.x;
71
+ if (!length) {
72
+ return handles;
73
+ }
74
+ for (let i = 0; i < count; i++) {
75
+ const handleIndex = Math.floor((length * i) / count);
76
+ handles.push(vec3.fromValues(points.x[handleIndex], points.y[handleIndex], points.z[handleIndex]));
77
+ }
78
+ return handles;
79
+ }
80
+ function _addInterpolatedContour(interpolated3DPoints, handlePoints, sliceIndex, referencedToolData, eventData) {
81
+ const points = PointsArray.fromXYZ(interpolated3DPoints).points;
82
+ const { viewport } = eventData;
83
+ const interpolatedAnnotation = createPolylineToolData(points, handlePoints, referencedToolData);
84
+ const targetId = viewport.getTargetId({ sliceIndex });
85
+ interpolatedAnnotation.metadata.referencedImageId = targetId;
86
+ interpolatedAnnotation.metadata.referencedSliceIndex = sliceIndex;
87
+ annotationState.state.addAnnotation(interpolatedAnnotation, viewport.element);
88
+ referencedToolData.postInterpolateAction?.(interpolatedAnnotation, referencedToolData);
89
+ }
90
+ function _editInterpolatedContour(interpolated3DPoints, handlePoints, sliceIndex, referencedToolData, eventData) {
91
+ const { viewport } = eventData;
92
+ const annotations = annotationState.state.getAnnotations(referencedToolData.metadata.toolName, viewport.element);
93
+ let toolDataIndex;
94
+ for (let i = 0; i < annotations.length; i++) {
95
+ const annotation = annotations[i];
96
+ if (annotation.interpolationUID === referencedToolData.interpolationUID &&
97
+ annotation.metadata.referencedSliceIndex === sliceIndex) {
98
+ toolDataIndex = i;
99
+ break;
100
+ }
101
+ }
102
+ if (toolDataIndex === undefined) {
103
+ console.warn('Unable to find referenced slice index in the tool data', sliceIndex, annotations);
104
+ return;
105
+ }
106
+ const oldToolData = annotations[toolDataIndex];
107
+ const points = PointsArray.fromXYZ(interpolated3DPoints).points;
108
+ const interpolatedAnnotation = createPolylineToolData(points, handlePoints, oldToolData);
109
+ interpolatedAnnotation.annotationUID = oldToolData.annotationUID;
110
+ annotationState.state.removeAnnotation(oldToolData.annotationUID);
111
+ annotationState.state.addAnnotation(interpolatedAnnotation, viewport.element);
112
+ }
113
+ function _generateInterpolatedOpenContour(c1ir, c2ir, zInterp, c1HasMoreNodes) {
114
+ const cInterp = {
115
+ x: [],
116
+ y: [],
117
+ z: [],
118
+ };
119
+ const indices = c1HasMoreNodes ? c1ir.I : c2ir.I;
120
+ for (let i = 0; i < c1ir.x.length; i++) {
121
+ if (indices[i]) {
122
+ cInterp.x.push(c1ir.x[i] + (c2ir.x[i] - c1ir.x[i]) * zInterp);
123
+ cInterp.y.push(c1ir.y[i] + (c2ir.y[i] - c1ir.y[i]) * zInterp);
124
+ cInterp.z.push(c1ir.z[i] + (c2ir.z[i] - c1ir.z[i]) * zInterp);
125
+ }
126
+ }
127
+ return cInterp;
128
+ }
129
+ function _generateInterpolationContourPair(c1, c2) {
130
+ const cumPerim1 = _getCumulativePerimeter(c1);
131
+ const cumPerim2 = _getCumulativePerimeter(c2);
132
+ const interpNodes = Math.max(Math.ceil(cumPerim1[cumPerim1.length - 1] / dP), Math.ceil(cumPerim2[cumPerim2.length - 1] / dP));
133
+ const cumPerim1Norm = _normalisedCumulativePerimeter(cumPerim1);
134
+ const cumPerim2Norm = _normalisedCumulativePerimeter(cumPerim2);
135
+ const numNodes1 = interpNodes + c2.x.length;
136
+ const numNodes2 = interpNodes + c1.x.length;
137
+ const perim1Interp = _getInterpolatedPerim(numNodes1, cumPerim1Norm);
138
+ const perim2Interp = _getInterpolatedPerim(numNodes2, cumPerim2Norm);
139
+ const perim1Ind = _getIndicatorArray(c1, numNodes1);
140
+ const perim2Ind = _getIndicatorArray(c2, numNodes2);
141
+ const nodesPerSegment1 = _getNodesPerSegment(perim1Interp, perim1Ind);
142
+ const nodesPerSegment2 = _getNodesPerSegment(perim2Interp, perim2Ind);
143
+ const c1i = _getSuperSampledContour(c1, nodesPerSegment1);
144
+ const c2i = _getSuperSampledContour(c2, nodesPerSegment2);
145
+ _shiftSuperSampledContourInPlace(c1i, c2i);
146
+ return _reduceContoursToOriginNodes(c1i, c2i);
147
+ }
148
+ function _reduceContoursToOriginNodes(c1i, c2i) {
149
+ const c1Interp = {
150
+ x: [],
151
+ y: [],
152
+ z: [],
153
+ I: [],
154
+ };
155
+ const c2Interp = {
156
+ x: [],
157
+ y: [],
158
+ z: [],
159
+ I: [],
160
+ };
161
+ for (let i = 0; i < c1i.x.length; i++) {
162
+ if (c1i.I[i] || c2i.I[i]) {
163
+ c1Interp.x.push(c1i.x[i]);
164
+ c1Interp.y.push(c1i.y[i]);
165
+ c1Interp.z.push(c1i.z[i]);
166
+ c1Interp.I.push(c1i.I[i]);
167
+ c2Interp.x.push(c2i.x[i]);
168
+ c2Interp.y.push(c2i.y[i]);
169
+ c2Interp.z.push(c2i.z[i]);
170
+ c2Interp.I.push(c2i.I[i]);
171
+ }
172
+ }
173
+ return {
174
+ c1Interp,
175
+ c2Interp,
176
+ };
177
+ }
178
+ function _shiftSuperSampledContourInPlace(c1i, c2i) {
179
+ const c1iLength = c1i.x.length;
180
+ const optimal = {
181
+ startingNode: 0,
182
+ totalSquaredXYLengths: Infinity,
183
+ };
184
+ for (let startingNode = 0; startingNode < c1iLength; startingNode++) {
185
+ let node = startingNode;
186
+ let totalSquaredXYLengths = 0;
187
+ for (let iteration = 0; iteration < c1iLength; iteration++) {
188
+ totalSquaredXYLengths +=
189
+ (c1i.x[node] - c2i.x[iteration]) ** 2 +
190
+ (c1i.y[node] - c2i.y[iteration]) ** 2 +
191
+ (c1i.z[node] - c2i.z[iteration]) ** 2;
192
+ node++;
193
+ if (node === c1iLength) {
194
+ node = 0;
195
+ }
196
+ }
197
+ if (totalSquaredXYLengths < optimal.totalSquaredXYLengths) {
198
+ optimal.totalSquaredXYLengths = totalSquaredXYLengths;
199
+ optimal.startingNode = startingNode;
200
+ }
201
+ }
202
+ const node = optimal.startingNode;
203
+ _shiftCircularArray(c1i.x, node);
204
+ _shiftCircularArray(c1i.y, node);
205
+ _shiftCircularArray(c1i.z, node);
206
+ _shiftCircularArray(c1i.I, node);
207
+ }
208
+ function _shiftCircularArray(arr, count) {
209
+ count -= arr.length * Math.floor(count / arr.length);
210
+ const slicedArray = arr.splice(0, count);
211
+ arr.push(...slicedArray);
212
+ return arr;
213
+ }
214
+ function _getSuperSampledContour(c, nodesPerSegment) {
215
+ const ci = {
216
+ x: [],
217
+ y: [],
218
+ z: [],
219
+ I: [],
220
+ };
221
+ for (let n = 0; n < c.x.length - 1; n++) {
222
+ ci.x.push(c.x[n]);
223
+ ci.y.push(c.y[n]);
224
+ ci.z.push(c.z[n]);
225
+ ci.I.push(true);
226
+ const xSpacing = (c.x[n + 1] - c.x[n]) / (nodesPerSegment[n] + 1);
227
+ const ySpacing = (c.y[n + 1] - c.y[n]) / (nodesPerSegment[n] + 1);
228
+ const zSpacing = (c.z[n + 1] - c.z[n]) / (nodesPerSegment[n] + 1);
229
+ for (let i = 0; i < nodesPerSegment[n] - 1; i++) {
230
+ ci.x.push(ci.x[ci.x.length - 1] + xSpacing);
231
+ ci.y.push(ci.y[ci.y.length - 1] + ySpacing);
232
+ ci.z.push(ci.z[ci.z.length - 1] + zSpacing);
233
+ ci.I.push(false);
234
+ }
235
+ }
236
+ return ci;
237
+ }
238
+ function _getNodesPerSegment(perimInterp, perimInd) {
239
+ const idx = [];
240
+ for (let i = 0; i < perimInterp.length; ++i) {
241
+ idx[i] = i;
242
+ }
243
+ idx.sort(function (a, b) {
244
+ return perimInterp[a] < perimInterp[b] ? -1 : 1;
245
+ });
246
+ const perimIndSorted = [];
247
+ for (let i = 0; i < perimInd.length; i++) {
248
+ perimIndSorted.push(perimInd[idx[i]]);
249
+ }
250
+ const indicesOfOriginNodes = perimIndSorted.reduce(function (arr, elementValue, i) {
251
+ if (elementValue) {
252
+ arr.push(i);
253
+ }
254
+ return arr;
255
+ }, []);
256
+ const nodesPerSegment = [];
257
+ for (let i = 0; i < indicesOfOriginNodes.length - 1; i++) {
258
+ nodesPerSegment.push(indicesOfOriginNodes[i + 1] - indicesOfOriginNodes[i]);
259
+ }
260
+ return nodesPerSegment;
261
+ }
262
+ function _getIndicatorArray(contour, numNodes) {
263
+ const perimInd = [];
264
+ for (let i = 0; i < numNodes - 2; i++) {
265
+ perimInd.push(false);
266
+ }
267
+ for (let i = 0; i < contour.x.length; i++) {
268
+ perimInd.push(true);
269
+ }
270
+ return perimInd;
271
+ }
272
+ function _getInterpolatedPerim(numNodes, cumPerimNorm) {
273
+ const diff = 1 / (numNodes - 1);
274
+ const linspace = [diff];
275
+ for (let i = 1; i < numNodes - 2; i++) {
276
+ linspace.push(linspace[linspace.length - 1] + diff);
277
+ }
278
+ return linspace.concat(cumPerimNorm);
279
+ }
280
+ function _normalisedCumulativePerimeter(cumPerim) {
281
+ const cumPerimNorm = [];
282
+ for (let i = 0; i < cumPerim.length; i++) {
283
+ cumPerimNorm.push(cumPerim[i] / cumPerim[cumPerim.length - 1]);
284
+ }
285
+ return cumPerimNorm;
286
+ }
287
+ function _getCumulativePerimeter(contour) {
288
+ const cumulativePerimeter = [0];
289
+ for (let i = 1; i < contour.x.length; i++) {
290
+ const lengthOfSegment = Math.sqrt((contour.x[i] - contour.x[i - 1]) ** 2 +
291
+ (contour.y[i] - contour.y[i - 1]) ** 2 +
292
+ (contour.z[i] - contour.z[i - 1]) ** 2);
293
+ cumulativePerimeter.push(cumulativePerimeter[i - 1] + lengthOfSegment);
294
+ }
295
+ return cumulativePerimeter;
296
+ }
297
+ function _generateClosedContour(points) {
298
+ const c = {
299
+ x: [],
300
+ y: [],
301
+ z: [],
302
+ };
303
+ for (let i = 0; i < points.length; i++) {
304
+ c.x[i] = points[i][0];
305
+ c.y[i] = points[i][1];
306
+ c.z[i] = points[i][2];
307
+ }
308
+ c.x.push(c.x[0]);
309
+ c.y.push(c.y[0]);
310
+ c.z.push(c.z[0]);
311
+ return c;
312
+ }
313
+ export default interpolate;
314
+ //# sourceMappingURL=interpolate.js.map