@cornerstonejs/tools 1.48.2 → 1.49.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 (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 +51 -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "1.48.2",
3
+ "version": "1.49.1",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "main": "src/index.ts",
6
6
  "types": "dist/types/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
30
30
  },
31
31
  "dependencies": {
32
- "@cornerstonejs/core": "^1.48.2",
32
+ "@cornerstonejs/core": "^1.49.1",
33
33
  "comlink": "^4.4.1",
34
34
  "lodash.clonedeep": "4.5.0",
35
35
  "lodash.get": "^4.4.2"
@@ -53,5 +53,5 @@
53
53
  "type": "individual",
54
54
  "url": "https://ohif.org/donate"
55
55
  },
56
- "gitHead": "7573fab26ab98bd17c71c1318a777db3d0783bff"
56
+ "gitHead": "68c692e507ef36cdb64f77aa344d79bd04685cc9"
57
57
  }
@@ -11,12 +11,15 @@
11
11
  * The annotation has been selected by the user;
12
12
  * Locked:
13
13
  * The annotation has been locked;
14
+ * AutoGenerated:
15
+ * The annotation has been auto generated;
14
16
  */
15
17
  enum AnnotationStyleStates {
16
18
  Default = '',
17
19
  Highlighted = 'Highlighted',
18
20
  Selected = 'Selected',
19
21
  Locked = 'Locked',
22
+ AutoGenerated = 'AutoGenerated',
20
23
  }
21
24
 
22
25
  export default AnnotationStyleStates;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * ChangeTypes defines the types of changes occurring on annotation and
3
+ * segmentation data.
4
+ */
5
+ enum ChangeTypes {
6
+ /**
7
+ * Interaction events are done when the user is actively interacting with
8
+ * an annotation, and probably means the event shouldn't be handled/used.
9
+ */
10
+ Interaction = 'Interaction',
11
+ /**
12
+ * HandlesUpdated occurs when the handle data is added or removed, or moved around
13
+ */
14
+ HandlesUpdated = 'HandlesUpdated',
15
+ /**
16
+ * StatsUpdated occurs when the stats are updated/calculated. This can be used
17
+ * to ignore stats calculations changes occurring on initial load, while still
18
+ * rendering other updates.
19
+ */
20
+ StatsUpdated = 'StatsUpdated',
21
+ /**
22
+ * InitialSetup occurs when an annotation has been created initially and
23
+ * has the first render/data calculation being applied.
24
+ */
25
+ InitialSetup = 'InitialSetup',
26
+ /**
27
+ * Completed occurs only for the annotation completed event, just to identify it
28
+ */
29
+ Completed = 'Completed',
30
+ }
31
+
32
+ export default ChangeTypes;
@@ -96,6 +96,22 @@ enum Events {
96
96
  */
97
97
  ANNOTATION_RENDERED = 'CORNERSTONE_TOOLS_ANNOTATION_RENDERED',
98
98
 
99
+ /**
100
+ * Triggers on the eventTarget when an annotation interpolation process completed.
101
+ * Make use of {@link EventTypes.AnnotationInterpolationCompletedEventType | Annotation Interpolation process Completed Event Type}
102
+ * for typing your event listeners for this annotation interpolation complete event, and see what
103
+ * event detail is included in {@link EventTypes.AnnotationInterpolationCompletedEventDetail | Annotation interpolation process Event Detail}.
104
+ */
105
+ ANNOTATION_INTERPOLATION_PROCESS_COMPLETED = 'CORNERSTONE_TOOLS_ANNOTATION_INTERPOLATION_PROCESS_COMPLETED',
106
+
107
+ /**
108
+ * Triggers on the eventTarget when interpolated annotations are removed.
109
+ * Make use of {@link EventTypes.AnnotationInterpolationRemovedEventType | Annotation Interpolation Removed Event Type}
110
+ * for typing your event listeners for this interpolated annotation removed event, and see what
111
+ * event detail is included in {@link EventTypes.AnnotationInterpolationRemovedEventDetail | Annotation interpolation removed Event Detail}.
112
+ */
113
+ INTERPOLATED_ANNOTATIONS_REMOVED = 'CORNERSTONE_TOOLS_INTERPOLATED_ANNOTATIONS_REMOVED',
114
+
99
115
  ///////////////////////////////////////
100
116
  // Segmentations Events
101
117
  ///////////////////////////////////////
@@ -5,6 +5,7 @@ import Events from './Events';
5
5
  import SegmentationRepresentations from './SegmentationRepresentations';
6
6
  import { Swipe } from './Touch';
7
7
  import StrategyCallbacks from './StrategyCallbacks';
8
+ import ChangeTypes from './ChangeTypes';
8
9
 
9
10
  export {
10
11
  MouseBindings,
@@ -15,4 +16,5 @@ export {
15
16
  SegmentationRepresentations,
16
17
  Swipe,
17
18
  StrategyCallbacks,
19
+ ChangeTypes,
18
20
  };
@@ -0,0 +1,42 @@
1
+ import { eventTarget } from '@cornerstonejs/core';
2
+ import Events from '../enums/Events';
3
+ import InterpolationManager from '../utilities/segmentation/InterpolationManager/InterpolationManager';
4
+
5
+ /**
6
+ * The enable and disable add/remove the event listeners that dispatch the
7
+ * required events to the interpolation manager.
8
+ */
9
+ const enable = function () {
10
+ eventTarget.addEventListener(
11
+ Events.ANNOTATION_COMPLETED,
12
+ InterpolationManager.handleAnnotationCompleted as EventListener
13
+ );
14
+ eventTarget.addEventListener(
15
+ Events.ANNOTATION_MODIFIED,
16
+ InterpolationManager.handleAnnotationUpdate as EventListener
17
+ );
18
+ eventTarget.addEventListener(
19
+ Events.ANNOTATION_REMOVED,
20
+ InterpolationManager.handleAnnotationDelete as EventListener
21
+ );
22
+ };
23
+
24
+ const disable = function () {
25
+ eventTarget.removeEventListener(
26
+ Events.ANNOTATION_COMPLETED,
27
+ InterpolationManager.handleAnnotationCompleted as EventListener
28
+ );
29
+ eventTarget.removeEventListener(
30
+ Events.ANNOTATION_MODIFIED,
31
+ InterpolationManager.handleAnnotationUpdate as EventListener
32
+ );
33
+ eventTarget.removeEventListener(
34
+ Events.ANNOTATION_REMOVED,
35
+ InterpolationManager.handleAnnotationDelete as EventListener
36
+ );
37
+ };
38
+
39
+ export default {
40
+ enable,
41
+ disable,
42
+ };
@@ -4,6 +4,7 @@ import keyboardToolEventDispatcher from './keyboardToolEventDispatcher';
4
4
  import cameraModifiedEventDispatcher from './cameraModifiedEventDispatcher';
5
5
  import imageSpacingCalibratedEventDispatcher from './imageSpacingCalibratedEventDispatcher';
6
6
  import touchToolEventDispatcher from './touchToolEventDispatcher';
7
+ import annotationInterpolationEventDispatcher from './annotationInterpolationEventDispatcher';
7
8
 
8
9
  export {
9
10
  imageRenderedEventDispatcher,
@@ -12,4 +13,5 @@ export {
12
13
  cameraModifiedEventDispatcher,
13
14
  imageSpacingCalibratedEventDispatcher,
14
15
  touchToolEventDispatcher,
16
+ annotationInterpolationEventDispatcher,
15
17
  };
package/src/init.ts CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  segmentationModifiedListener,
13
13
  annotationModifiedListener,
14
14
  } from './eventListeners';
15
+ import { annotationInterpolationEventDispatcher } from './eventDispatchers';
15
16
 
16
17
  import * as ToolGroupManager from './store/ToolGroupManager';
17
18
 
@@ -74,6 +75,7 @@ function _addCornerstoneEventListeners(): void {
74
75
 
75
76
  eventTarget.addEventListener(elementEnabledEvent, addEnabledElement);
76
77
  eventTarget.addEventListener(elementDisabledEvent, removeEnabledElement);
78
+ annotationInterpolationEventDispatcher.enable();
77
79
  }
78
80
 
79
81
  /**
@@ -87,6 +89,7 @@ function _removeCornerstoneEventListeners(): void {
87
89
 
88
90
  eventTarget.removeEventListener(elementEnabledEvent, addEnabledElement);
89
91
  eventTarget.removeEventListener(elementDisabledEvent, removeEnabledElement);
92
+ annotationInterpolationEventDispatcher.disable();
90
93
  }
91
94
 
92
95
  /**
@@ -5,9 +5,19 @@ import { AnnotationStyleStates } from '../../../enums';
5
5
 
6
6
  /**
7
7
  * Given a Annotation object, return the annotationStyle State that it
8
- * should be in based on its data
8
+ * should be in based on its data.
9
+ * The ordering of states is:
10
+ * * Highlighted
11
+ * * Selected
12
+ * * Locked
13
+ * * Autogenerated
14
+ * * Default
15
+ * So the first one that applies will be returned.
16
+ * For the autogenerated state, it depends on the autoGenerated flag on the
17
+ * annotation, so once that is gone/false, the annotation will go to default.
18
+ *
9
19
  * @param annotation - The annotation that we want to style.
10
- * @returns The state of the annotation whether it is Default, Highlighted, Locked, or Selected.
20
+ * @returns The state of the annotation whether it is Default, Highlighted, Locked, Selected, or AutoGenerated.
11
21
  */
12
22
  function getState(annotation?: Annotation): AnnotationStyleStates {
13
23
  if (annotation) {
@@ -22,6 +32,10 @@ function getState(annotation?: Annotation): AnnotationStyleStates {
22
32
  if (isAnnotationLocked(annotation)) {
23
33
  return AnnotationStyleStates.Locked;
24
34
  }
35
+
36
+ if (annotation.data && annotation.autoGenerated) {
37
+ return AnnotationStyleStates.AutoGenerated;
38
+ }
25
39
  }
26
40
 
27
41
  return AnnotationStyleStates.Default;
@@ -11,9 +11,9 @@ import type { Types } from '@cornerstonejs/core';
11
11
  import { removeAnnotation } from '../../stateManagement/annotation/annotationState';
12
12
  import { drawHandles as drawHandlesSvg } from '../../drawingSvg';
13
13
  import { state } from '../../store';
14
- import { Events } from '../../enums';
14
+ import { Events, ChangeTypes } from '../../enums';
15
15
  import { resetElementCursor } from '../../cursors/elementCursor';
16
- import {
16
+ import type {
17
17
  Annotation,
18
18
  EventTypes,
19
19
  ToolHandle,
@@ -89,12 +89,6 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
89
89
 
90
90
  this.isDrawing = true;
91
91
 
92
- const defaultActor = viewport.getDefaultActor();
93
-
94
- // if (!defaultActor || !csUtils.isImageActor(defaultActor)) {
95
- // throw new Error('Default actor must be an image actor');
96
- // }
97
-
98
92
  const viewportImageData = viewport.getImageData();
99
93
  const { imageData: vtkImageData } = viewportImageData;
100
94
  let worldToSlice: (point: Types.Point3) => Types.Point2;
@@ -337,6 +331,7 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
337
331
  const eventType = Events.ANNOTATION_COMPLETED;
338
332
  const eventDetail: AnnotationCompletedEventDetail = {
339
333
  annotation,
334
+ changeType: ChangeTypes.Completed,
340
335
  };
341
336
 
342
337
  triggerEvent(eventTarget, eventType, eventDetail);
@@ -10,6 +10,12 @@ class PlanarFreehandContourSegmentationTool extends PlanarFreehandROITool {
10
10
  {
11
11
  configuration: {
12
12
  calculateStats: false,
13
+ /**
14
+ * Allow open contours false means to not allow a final/complete
15
+ * annotation to be done as an open contour. This does not mean
16
+ * that the contour won't be open during creation.
17
+ */
18
+ allowOpenContours: false,
13
19
  },
14
20
  },
15
21
  toolProps
@@ -30,7 +30,7 @@ import {
30
30
  AnnotationCompletedEventDetail,
31
31
  AnnotationModifiedEventDetail,
32
32
  } from '../../types/EventTypes';
33
- import {
33
+ import type {
34
34
  EventTypes,
35
35
  ToolHandle,
36
36
  Annotation,
@@ -68,23 +68,23 @@ const PARALLEL_THRESHOLD = 1 - EPSILON;
68
68
  * or similar methods.
69
69
  *
70
70
  * PlanarFreehandROITool annotation can be smoothed on drawing completion. This is a configured based approach.
71
- * The interpolation process uses b-spline algorithm and consider 4 configurations properties:
72
- * - interpolation.interpolateOnAdd: to tell whether it should be interpolated or not (for editing it is considered the property interpolateOnEdit) (default: false)
73
- * - interpolation.interpolateOnEdit: to tell whether it should be interpolated or not when editing (default: false)
74
- * - interpolation.knotsRatioPercentageOnAdd: percentage of points from Segment that are likely to be considered knots during interpolation (for editing it is considered the property knotsRatioPercentageOnEdit) ( default: 40)
75
- * - interpolation.knotsRatioPercentageOnEdit: same as knotsRatioPercentageOnAdd but applicable only when editing the tool (default: 40)
71
+ * The smoothing process uses b-spline algorithm and consider 4 configurations properties:
72
+ * - smoothing.smoothOnAdd: to tell whether it should be smoothed or not (for editing it is considered the property smoothOnEdit) (default: false)
73
+ * - smoothing.smoothOnEdit: to tell whether it should be smoothed or not when editing (default: false)
74
+ * - smoothing.knotsRatioPercentageOnAdd: percentage of points from Segment that are likely to be considered knots during smoothing (for editing it is considered the property knotsRatioPercentageOnEdit) ( default: 40)
75
+ * - smoothing.knotsRatioPercentageOnEdit: same as knotsRatioPercentageOnAdd but applicable only when editing the tool (default: 40)
76
76
  *
77
- * So, with that said the interpolation might occur when:
78
- * - drawing is done (i.e mouse is released) and interpolation.interpolateOnAdd is true. Interpolation algorithm uses knotsRatioPercentageOnAdd
79
- * - edit drawing is done (i.e mouse is released) and interpolation.interpolateOnEdit is true. Interpolation algorithm uses knotsRatioPercentageOnEdit and its only applied to changed segment
80
- * Interpolation does not occur when:
81
- * - interpolation.interpolateOnAdd is false and drawing is completed
82
- * - interpolation.interpolateOnEdit is false and edit is completed
77
+ * So, with that said the smoothing might occur when:
78
+ * - drawing is done (i.e mouse is released) and smoothing.smoothOnAdd is true. smoothing algorithm uses knotsRatioPercentageOnAdd
79
+ * - edit drawing is done (i.e mouse is released) and smoothing.smoothOnEdit is true. smoothing algorithm uses knotsRatioPercentageOnEdit and its only applied to changed segment
80
+ * smoothing does not occur when:
81
+ * - smoothing.smoothOnAdd is false and drawing is completed
82
+ * - smoothing.smoothOnEdit is false and edit is completed
83
83
  * - drawing still happening (editing or not)
84
84
  *
85
- * The result of interpolation will be a smoother set of segments.
86
- * Changing tool configuration (see below) you can fine-tune the interpolation process by changing knotsRatioPercentageOnAdd and knotsRatioPercentageOnEdit value, which smaller values produces a more agressive interpolation.
87
- * A smaller value of knotsRatioPercentageOnAdd/knotsRatioPercentageOnEdit produces a more agressive interpolation.
85
+ * The result of smoothing will be removal of some of the outliers
86
+ * Changing tool configuration (see below) you can fine-tune the smoothing process by changing knotsRatioPercentageOnAdd and knotsRatioPercentageOnEdit value, which smaller values produces a more agressive smoothing.
87
+ * A smaller value of knotsRatioPercentageOnAdd/knotsRatioPercentageOnEdit produces a more agressive smoothing.
88
88
  *
89
89
  * ```js
90
90
  * cornerstoneTools.addTool(PlanarFreehandROITool)
@@ -103,14 +103,14 @@ const PARALLEL_THRESHOLD = 1 - EPSILON;
103
103
  * ],
104
104
  * })
105
105
  *
106
- * // set interpolation agressiveness while adding new annotation (ps: this does not change if interpolation is ON or OFF)
106
+ * // set smoothing agressiveness while adding new annotation (ps: this does not change if smoothing is ON or OFF)
107
107
  * toolGroup.setToolConfiguration(PlanarFreehandROITool.toolName, {
108
- * interpolation: { knotsRatioPercentageOnAdd: 30 },
108
+ * smoothing: { knotsRatioPercentageOnAdd: 30 },
109
109
  * });
110
110
  *
111
- * // set interpolation to be ON while editing only
111
+ * // set smoothing to be ON while editing only
112
112
  * toolGroup.setToolConfiguration(PlanarFreehandROITool.toolName, {
113
- * interpolation: { interpolateOnAdd: false, interpolateOnEdit: true },
113
+ * smoothing: { smoothOnAdd: false, smoothOnEdit: true },
114
114
  * });
115
115
  * ```
116
116
  *
@@ -129,7 +129,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
129
129
  isEditingClosed = false;
130
130
  isEditingOpen = false;
131
131
 
132
- private activateDraw: (
132
+ protected activateDraw: (
133
133
  evt: EventTypes.InteractionEventType,
134
134
  annotation: PlanarFreehandROIAnnotation,
135
135
  viewportIdsToRender: string[]
@@ -195,19 +195,41 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
195
195
  // The proximity at which we fallback to the simplest grabbing logic for
196
196
  // determining what index of the contour to start editing.
197
197
  checkCanvasEditFallbackProximity: 6,
198
+ // For closed contours, make them clockwise
199
+ // This can be useful if contours are compared between slices, eg for
200
+ // interpolation, and does not cause problems otherwise so defaulting to true.
201
+ makeClockWise: true,
198
202
  // The relative distance that points should be dropped along the polyline
199
203
  // in units of the image pixel spacing. A value of 1 means that nodes must
200
204
  // be placed no closed than the image spacing apart. A value of 4 means that 4
201
205
  // nodes should be placed within the space of one image pixel size. A higher
202
- // value gives more finese to the tool/smoother lines, but the value cannot
206
+ // value gives more finesse to the tool/smoother lines, but the value cannot
203
207
  // be infinite as the lines become very computationally expensive to draw.
204
208
  subPixelResolution: 4,
205
- interpolation: {
206
- interpolateOnAdd: false,
207
- interpolateOnEdit: false, // used for edit only
209
+ /**
210
+ * Smoothing is used to remove jagged irregularities in the polyline,
211
+ * as opposed to interpolation, which is used to create new polylines
212
+ * between existing polylines.
213
+ */
214
+ smoothing: {
215
+ smoothOnAdd: false,
216
+ smoothOnEdit: false, // used for edit only
208
217
  knotsRatioPercentageOnAdd: 40,
209
218
  knotsRatioPercentageOnEdit: 40,
210
219
  },
220
+ /**
221
+ * Interpolation is the creation of new segmentations in between the
222
+ * existing segmentations/indices. Note that this does not apply to
223
+ * ROI values, since those annotations are individual annotations, not
224
+ * connected in any way to each other, whereas segmentations are intended
225
+ * to be connected 2d + 1 dimension (time or space or other) volumes.
226
+ */
227
+ interpolation: {
228
+ enabled: false,
229
+ // Callback to update the annotation or perform other action when the
230
+ // interpolation is complete.
231
+ onInterpolationComplete: null,
232
+ },
211
233
  calculateStats: false,
212
234
  getTextLines: defaultGetTextLines,
213
235
  statsCalculator: BasicStatsCalculator,
@@ -916,7 +938,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
916
938
  function defaultGetTextLines(data, targetId): string[] {
917
939
  const cachedVolumeStats = data.cachedStats[targetId];
918
940
  const { area, mean, stdDev, max, isEmptyArea, areaUnit, modalityUnit } =
919
- cachedVolumeStats;
941
+ cachedVolumeStats || {};
920
942
 
921
943
  const textLines: string[] = [];
922
944
 
@@ -13,7 +13,12 @@ import {
13
13
  drawLinkedTextBox as drawLinkedTextBoxSvg,
14
14
  } from '../../drawingSvg';
15
15
  import { state } from '../../store';
16
- import { Events, MouseBindings, KeyboardBindings } from '../../enums';
16
+ import {
17
+ Events,
18
+ MouseBindings,
19
+ KeyboardBindings,
20
+ ChangeTypes,
21
+ } from '../../enums';
17
22
  import { resetElementCursor } from '../../cursors/elementCursor';
18
23
  import {
19
24
  Annotation,
@@ -36,16 +41,14 @@ import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters'
36
41
  import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
37
42
 
38
43
  import { SplineROIAnnotation } from '../../types/ToolSpecificAnnotationTypes';
39
- import {
40
- AnnotationCompletedEventDetail,
41
- AnnotationModifiedEventDetail,
42
- } from '../../types/EventTypes';
44
+ import { AnnotationModifiedEventDetail } from '../../types/EventTypes';
43
45
  import { ISpline } from '../../types/ISpline';
44
46
  import { CardinalSpline } from './splines/CardinalSpline';
45
47
  import { LinearSpline } from './splines/LinearSpline';
46
48
  import { CatmullRomSpline } from './splines/CatmullRomSpline';
47
49
  import { BSpline } from './splines/BSpline';
48
50
  import ContourSegmentationBaseTool from '../base/ContourSegmentationBaseTool';
51
+ import reverseIfAntiClockwise from '../../utilities/contours/reverseIfAntiClockwise';
49
52
 
50
53
  const SPLINE_MIN_POINTS = 3;
51
54
  const SPLINE_CLICK_CLOSE_CURVE_DIST = 10;
@@ -90,6 +93,7 @@ class SplineROITool extends ContourSegmentationBaseTool {
90
93
  } | null;
91
94
  isDrawing: boolean;
92
95
  isHandleOutsideImage = false;
96
+ fireChangeOnUpdate: ChangeTypes = null;
93
97
 
94
98
  constructor(
95
99
  toolProps: PublicToolProps = {},
@@ -295,6 +299,7 @@ class SplineROITool extends ContourSegmentationBaseTool {
295
299
 
296
300
  const { annotation, viewportIdsToRender, newAnnotation } = this.editData;
297
301
  const { data } = annotation;
302
+ annotation.autoGenerated = false;
298
303
 
299
304
  data.handles.activeHandleIndex = null;
300
305
 
@@ -322,17 +327,11 @@ class SplineROITool extends ContourSegmentationBaseTool {
322
327
  removeAnnotation(annotation.annotationUID);
323
328
  }
324
329
 
330
+ this.fireChangeOnUpdate ||= newAnnotation
331
+ ? ChangeTypes.Completed
332
+ : ChangeTypes.HandlesUpdated;
325
333
  triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
326
334
 
327
- if (newAnnotation) {
328
- const eventType = Events.ANNOTATION_COMPLETED;
329
- const eventDetail: AnnotationCompletedEventDetail = {
330
- annotation,
331
- };
332
-
333
- triggerEvent(eventTarget, eventType, eventDetail);
334
- }
335
-
336
335
  this.editData = null;
337
336
  this.isDrawing = false;
338
337
  };
@@ -515,15 +514,20 @@ class SplineROITool extends ContourSegmentationBaseTool {
515
514
  */
516
515
  triggerAnnotationModified = (
517
516
  annotation: SplineROIAnnotation,
518
- enabledElement: Types.IEnabledElement
517
+ enabledElement: Types.IEnabledElement,
518
+ changeType = ChangeTypes.StatsUpdated
519
519
  ): void => {
520
520
  const { viewportId, renderingEngineId } = enabledElement;
521
- const eventType = Events.ANNOTATION_MODIFIED;
521
+ const eventType =
522
+ changeType === ChangeTypes.Completed
523
+ ? Events.ANNOTATION_COMPLETED
524
+ : Events.ANNOTATION_MODIFIED;
522
525
 
523
526
  const eventDetail: AnnotationModifiedEventDetail = {
524
527
  annotation,
525
528
  viewportId,
526
529
  renderingEngineId,
530
+ changeType,
527
531
  };
528
532
 
529
533
  triggerEvent(eventTarget, eventType, eventDetail);
@@ -625,12 +629,12 @@ class SplineROITool extends ContourSegmentationBaseTool {
625
629
  const splineType = annotation.data.spline.type;
626
630
  const splineConfig = this._getSplineConfig(splineType);
627
631
  const spline = this._updateSplineInstance(element, annotation);
628
- const splinePolylineCanvas = spline.getPolylinePoints();
629
- const splinePolylineWorld = [];
630
-
631
- for (let i = 0, len = splinePolylineCanvas.length; i < len; i++) {
632
- splinePolylineWorld.push(viewport.canvasToWorld(splinePolylineCanvas[i]));
633
- }
632
+ const splinePolylineCanvas = reverseIfAntiClockwise(
633
+ spline.getPolylinePoints()
634
+ );
635
+ const splinePolylineWorld = splinePolylineCanvas.map((point2) =>
636
+ viewport.canvasToWorld(point2)
637
+ );
634
638
 
635
639
  data.contour.polyline = splinePolylineWorld;
636
640
 
@@ -730,29 +734,73 @@ class SplineROITool extends ContourSegmentationBaseTool {
730
734
  annotationStyle.textbox
731
735
  );
732
736
 
737
+ if (this.fireChangeOnUpdate) {
738
+ this.triggerAnnotationModified(
739
+ annotation,
740
+ enabledElement,
741
+ this.fireChangeOnUpdate
742
+ );
743
+ this.fireChangeOnUpdate = null;
744
+ }
745
+
733
746
  annotation.invalidated = false;
734
747
  return true;
735
748
  }
736
749
 
750
+ /**
751
+ * Creates new interpolated handles for the spline control given the
752
+ * polyline data. This allows creating the spline from polyline data
753
+ * directly.
754
+ */
755
+ protected createInterpolatedSplineControl(annotation) {
756
+ if (annotation.data.handles.points?.length) {
757
+ // The interpolation itself created the handles
758
+ return;
759
+ }
760
+ const { polyline } = annotation.data.contour;
761
+ if (!polyline || !polyline.length) {
762
+ return;
763
+ }
764
+ annotation.data.handles.points = [];
765
+ const { points } = annotation.data.handles;
766
+ const increment = Math.max(10, Math.floor(polyline.length / 20));
767
+ for (let i = 0; i < polyline.length - increment; i += increment) {
768
+ points.push(polyline[i]);
769
+ }
770
+ points.push(polyline[polyline.length - 1]);
771
+ }
772
+
737
773
  protected createAnnotation(evt: EventTypes.InteractionEventType): Annotation {
738
774
  const contourAnnotation = super.createAnnotation(evt);
739
775
  const { world: worldPos } = evt.detail.currentPoints;
740
776
  const { type: splineType } = this.configuration.spline;
741
777
  const splineConfig = this._getSplineConfig(splineType);
742
778
  const spline = new splineConfig.Class();
779
+ const createSpline = () => ({
780
+ type: splineConfig.type,
781
+ instance: spline,
782
+ resolution: splineConfig.resolution,
783
+ });
784
+
785
+ // Add an action to create a new spline data on creating an interpolated
786
+ // instance.
787
+ let postInterpolateAction;
788
+ if (this.configuration.interpolation?.enabled) {
789
+ postInterpolateAction = (annotation) => {
790
+ annotation.data.spline ||= createSpline();
791
+ this.createInterpolatedSplineControl(annotation);
792
+ };
793
+ }
743
794
 
744
795
  return <SplineROIAnnotation>utilities.deepMerge(contourAnnotation, {
745
796
  data: {
746
797
  handles: {
747
798
  points: [[...worldPos]],
748
799
  },
749
- spline: {
750
- type: splineConfig.type,
751
- instance: spline,
752
- resolution: splineConfig.resolution,
753
- },
800
+ spline: createSpline(),
754
801
  cachedStats: {},
755
802
  },
803
+ postInterpolateAction,
756
804
  });
757
805
  }
758
806
 
@@ -1023,7 +1071,11 @@ class SplineROITool extends ContourSegmentationBaseTool {
1023
1071
  };
1024
1072
  }
1025
1073
 
1026
- this.triggerAnnotationModified(annotation, enabledElement);
1074
+ this.triggerAnnotationModified(
1075
+ annotation,
1076
+ enabledElement,
1077
+ ChangeTypes.StatsUpdated
1078
+ );
1027
1079
 
1028
1080
  return cachedStats;
1029
1081
  };
@@ -12,8 +12,8 @@ import { vec3, vec2 } from 'gl-matrix';
12
12
  import { PlanarFreehandROIAnnotation } from '../../../types/ToolSpecificAnnotationTypes';
13
13
  import {
14
14
  getInterpolatedPoints,
15
- shouldInterpolate,
16
- } from '../../../utilities/planarFreehandROITool/interpolatePoints';
15
+ shouldSmooth,
16
+ } from '../../../utilities/planarFreehandROITool/smoothPoints';
17
17
  import triggerAnnotationRenderForViewportIds from '../../../utilities/triggerAnnotationRenderForViewportIds';
18
18
 
19
19
  const {
@@ -36,6 +36,10 @@ function activateClosedContourEdit(
36
36
  const { currentPoints, element } = eventDetail;
37
37
  const canvasPos = currentPoints.canvas;
38
38
  const enabledElement = getEnabledElement(element);
39
+ if (!enabledElement) {
40
+ // Occurs on shutdown
41
+ return;
42
+ }
39
43
  const { viewport } = enabledElement;
40
44
 
41
45
  const prevCanvasPoints = annotation.data.contour.polyline.map(
@@ -227,6 +231,10 @@ function finishEditAndStartNewEdit(evt: EventTypes.InteractionEventType): void {
227
231
 
228
232
  annotation.data.contour.polyline = worldPoints;
229
233
  annotation.data.contour.closed = true;
234
+ // If any manual update, triggered on an annotation, then it will be treated as non-autogenerated.
235
+ if (annotation.autoGenerated) {
236
+ annotation.autoGenerated = false;
237
+ }
230
238
 
231
239
  this.triggerAnnotationModified(annotation, enabledElement);
232
240
 
@@ -432,7 +440,7 @@ function completeClosedContourEdit(element: HTMLDivElement) {
432
440
  const { fusedCanvasPoints, prevCanvasPoints } = this.editData;
433
441
 
434
442
  if (fusedCanvasPoints) {
435
- const updatedPoints = shouldInterpolate(this.configuration)
443
+ const updatedPoints = shouldSmooth(this.configuration, annotation)
436
444
  ? getInterpolatedPoints(
437
445
  this.configuration,
438
446
  fusedCanvasPoints,
@@ -447,6 +455,10 @@ function completeClosedContourEdit(element: HTMLDivElement) {
447
455
  annotation.data.contour.closed = true;
448
456
 
449
457
  annotation.invalidated = true;
458
+ // If any manual update, triggered on an annotation, then it will be treated as non-autogenerated.
459
+ if (annotation.autoGenerated) {
460
+ annotation.autoGenerated = false;
461
+ }
450
462
 
451
463
  this.triggerAnnotationModified(annotation, enabledElement);
452
464
  }