@cornerstonejs/tools 1.33.0 → 1.35.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 (338) hide show
  1. package/dist/cjs/eventDispatchers/mouseEventHandlers/mouseDown.js +4 -4
  2. package/dist/cjs/eventDispatchers/mouseEventHandlers/mouseDown.js.map +1 -1
  3. package/dist/cjs/eventDispatchers/shared/getToolsWithActionsForMouseEvent.js +3 -2
  4. package/dist/cjs/eventDispatchers/shared/getToolsWithActionsForMouseEvent.js.map +1 -1
  5. package/dist/cjs/index.d.ts +2 -2
  6. package/dist/cjs/index.js +3 -2
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/cjs/store/SynchronizerManager/Synchronizer.d.ts +1 -0
  9. package/dist/cjs/store/SynchronizerManager/Synchronizer.js +17 -1
  10. package/dist/cjs/store/SynchronizerManager/Synchronizer.js.map +1 -1
  11. package/dist/cjs/synchronizers/callbacks/areViewportsCoplanar .d.ts +1 -1
  12. package/dist/cjs/synchronizers/callbacks/areViewportsCoplanar .js.map +1 -1
  13. package/dist/cjs/synchronizers/callbacks/{stackImageSyncCallback.d.ts → imageSliceSyncCallback.d.ts} +1 -1
  14. package/dist/cjs/synchronizers/callbacks/{stackImageSyncCallback.js → imageSliceSyncCallback.js} +8 -4
  15. package/dist/cjs/synchronizers/callbacks/{stackImageSyncCallback.js.map → imageSliceSyncCallback.js.map} +1 -1
  16. package/dist/cjs/synchronizers/index.d.ts +3 -2
  17. package/dist/cjs/synchronizers/index.js +5 -3
  18. package/dist/cjs/synchronizers/index.js.map +1 -1
  19. package/dist/cjs/synchronizers/synchronizers/{createStackImageSynchronizer.d.ts → createImageSliceSynchronizer.d.ts} +1 -1
  20. package/dist/cjs/synchronizers/synchronizers/createImageSliceSynchronizer.js +17 -0
  21. package/dist/cjs/synchronizers/synchronizers/createImageSliceSynchronizer.js.map +1 -0
  22. package/dist/cjs/synchronizers/synchronizers/index.d.ts +3 -2
  23. package/dist/cjs/synchronizers/synchronizers/index.js +5 -3
  24. package/dist/cjs/synchronizers/synchronizers/index.js.map +1 -1
  25. package/dist/cjs/tools/AdvancedMagnifyTool.d.ts +4 -0
  26. package/dist/cjs/tools/AdvancedMagnifyTool.js +8 -3
  27. package/dist/cjs/tools/AdvancedMagnifyTool.js.map +1 -1
  28. package/dist/cjs/tools/annotation/SplineROITool.d.ts +59 -0
  29. package/dist/cjs/tools/annotation/SplineROITool.js +709 -0
  30. package/dist/cjs/tools/annotation/SplineROITool.js.map +1 -0
  31. package/dist/cjs/tools/annotation/splines/BSpline.d.ts +5 -0
  32. package/dist/cjs/tools/annotation/splines/BSpline.js +14 -0
  33. package/dist/cjs/tools/annotation/splines/BSpline.js.map +1 -0
  34. package/dist/cjs/tools/annotation/splines/CardinalSpline.d.ts +12 -0
  35. package/dist/cjs/tools/annotation/splines/CardinalSpline.js +38 -0
  36. package/dist/cjs/tools/annotation/splines/CardinalSpline.js.map +1 -0
  37. package/dist/cjs/tools/annotation/splines/CatmullRomSpline.d.ts +5 -0
  38. package/dist/cjs/tools/annotation/splines/CatmullRomSpline.js +12 -0
  39. package/dist/cjs/tools/annotation/splines/CatmullRomSpline.js.map +1 -0
  40. package/dist/cjs/tools/annotation/splines/CubicSpline.d.ts +13 -0
  41. package/dist/cjs/tools/annotation/splines/CubicSpline.js +192 -0
  42. package/dist/cjs/tools/annotation/splines/CubicSpline.js.map +1 -0
  43. package/dist/cjs/tools/annotation/splines/LinearSpline.d.ts +5 -0
  44. package/dist/cjs/tools/annotation/splines/LinearSpline.js +12 -0
  45. package/dist/cjs/tools/annotation/splines/LinearSpline.js.map +1 -0
  46. package/dist/cjs/tools/annotation/splines/QuadraticBezier.d.ts +6 -0
  47. package/dist/cjs/tools/annotation/splines/QuadraticBezier.js +20 -0
  48. package/dist/cjs/tools/annotation/splines/QuadraticBezier.js.map +1 -0
  49. package/dist/cjs/tools/annotation/splines/QuadraticSpline.d.ts +9 -0
  50. package/dist/cjs/tools/annotation/splines/QuadraticSpline.js +18 -0
  51. package/dist/cjs/tools/annotation/splines/QuadraticSpline.js.map +1 -0
  52. package/dist/cjs/tools/annotation/splines/Spline.d.ts +49 -0
  53. package/dist/cjs/tools/annotation/splines/Spline.js +420 -0
  54. package/dist/cjs/tools/annotation/splines/Spline.js.map +1 -0
  55. package/dist/cjs/tools/index.d.ts +2 -1
  56. package/dist/cjs/tools/index.js +3 -1
  57. package/dist/cjs/tools/index.js.map +1 -1
  58. package/dist/cjs/types/CardinalSplineProps.d.ts +5 -0
  59. package/dist/cjs/types/CardinalSplineProps.js +3 -0
  60. package/dist/cjs/types/CardinalSplineProps.js.map +1 -0
  61. package/dist/cjs/types/ClosestControlPoint.d.ts +4 -0
  62. package/dist/cjs/types/ClosestControlPoint.js +3 -0
  63. package/dist/cjs/types/ClosestControlPoint.js.map +1 -0
  64. package/dist/cjs/types/ClosestPoint.d.ts +5 -0
  65. package/dist/cjs/types/ClosestPoint.js +3 -0
  66. package/dist/cjs/types/ClosestPoint.js.map +1 -0
  67. package/dist/cjs/types/ClosestSplinePoint.d.ts +4 -0
  68. package/dist/cjs/types/ClosestSplinePoint.js +3 -0
  69. package/dist/cjs/types/ClosestSplinePoint.js.map +1 -0
  70. package/dist/cjs/types/ControlPointInfo.d.ts +5 -0
  71. package/dist/cjs/types/ControlPointInfo.js +3 -0
  72. package/dist/cjs/types/ControlPointInfo.js.map +1 -0
  73. package/dist/cjs/types/ISpline.d.ts +29 -0
  74. package/dist/cjs/types/ISpline.js +3 -0
  75. package/dist/cjs/types/ISpline.js.map +1 -0
  76. package/dist/cjs/types/SplineCurveSegment.d.ts +14 -0
  77. package/dist/cjs/types/SplineCurveSegment.js +3 -0
  78. package/dist/cjs/types/SplineCurveSegment.js.map +1 -0
  79. package/dist/cjs/types/SplineLineSegment.d.ts +10 -0
  80. package/dist/cjs/types/SplineLineSegment.js +3 -0
  81. package/dist/cjs/types/SplineLineSegment.js.map +1 -0
  82. package/dist/cjs/types/SplineProps.d.ts +4 -0
  83. package/dist/cjs/types/SplineProps.js +3 -0
  84. package/dist/cjs/types/SplineProps.js.map +1 -0
  85. package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +34 -0
  86. package/dist/cjs/types/index.d.ts +10 -1
  87. package/dist/cjs/utilities/index.d.ts +2 -3
  88. package/dist/cjs/utilities/index.js +5 -5
  89. package/dist/cjs/utilities/index.js.map +1 -1
  90. package/dist/cjs/utilities/math/aabb/distanceToPoint.d.ts +2 -0
  91. package/dist/cjs/utilities/math/aabb/distanceToPoint.js +11 -0
  92. package/dist/cjs/utilities/math/aabb/distanceToPoint.js.map +1 -0
  93. package/dist/cjs/utilities/math/aabb/distanceToPointSquared.d.ts +2 -0
  94. package/dist/cjs/utilities/math/aabb/distanceToPointSquared.js +24 -0
  95. package/dist/cjs/utilities/math/aabb/distanceToPointSquared.js.map +1 -0
  96. package/dist/cjs/utilities/math/aabb/index.d.ts +2 -0
  97. package/dist/cjs/utilities/math/aabb/index.js +11 -0
  98. package/dist/cjs/utilities/math/aabb/index.js.map +1 -0
  99. package/dist/cjs/utilities/math/index.d.ts +6 -5
  100. package/dist/cjs/utilities/math/index.js +11 -9
  101. package/dist/cjs/utilities/math/index.js.map +1 -1
  102. package/dist/cjs/utilities/math/line/distanceToPointSquared.js +5 -21
  103. package/dist/cjs/utilities/math/line/distanceToPointSquared.js.map +1 -1
  104. package/dist/cjs/utilities/math/line/distanceToPointSquaredInfo.d.ts +5 -0
  105. package/dist/cjs/utilities/math/line/distanceToPointSquaredInfo.js +56 -0
  106. package/dist/cjs/utilities/math/line/distanceToPointSquaredInfo.js.map +1 -0
  107. package/dist/cjs/utilities/math/line/index.d.ts +2 -1
  108. package/dist/cjs/utilities/math/line/index.js +3 -1
  109. package/dist/cjs/utilities/math/line/index.js.map +1 -1
  110. package/dist/cjs/utilities/math/point/distanceToPoint.js +5 -6
  111. package/dist/cjs/utilities/math/point/distanceToPoint.js.map +1 -1
  112. package/dist/cjs/utilities/math/point/distanceToPointSquared.d.ts +4 -0
  113. package/dist/cjs/utilities/math/point/distanceToPointSquared.js +12 -0
  114. package/dist/cjs/utilities/math/point/distanceToPointSquared.js.map +1 -0
  115. package/dist/cjs/utilities/math/point/index.d.ts +3 -2
  116. package/dist/cjs/utilities/math/point/index.js +7 -3
  117. package/dist/cjs/utilities/math/point/index.js.map +1 -1
  118. package/dist/cjs/utilities/math/point/mirror.d.ts +2 -0
  119. package/dist/cjs/utilities/math/point/mirror.js +11 -0
  120. package/dist/cjs/utilities/math/point/mirror.js.map +1 -0
  121. package/dist/esm/eventDispatchers/mouseEventHandlers/mouseDown.js +4 -4
  122. package/dist/esm/eventDispatchers/mouseEventHandlers/mouseDown.js.map +1 -1
  123. package/dist/esm/eventDispatchers/shared/getToolsWithActionsForMouseEvent.js +2 -1
  124. package/dist/esm/eventDispatchers/shared/getToolsWithActionsForMouseEvent.js.map +1 -1
  125. package/dist/esm/index.js +2 -2
  126. package/dist/esm/index.js.map +1 -1
  127. package/dist/esm/store/SynchronizerManager/Synchronizer.js +17 -1
  128. package/dist/esm/store/SynchronizerManager/Synchronizer.js.map +1 -1
  129. package/dist/esm/synchronizers/callbacks/areViewportsCoplanar .js.map +1 -1
  130. package/dist/esm/synchronizers/callbacks/{stackImageSyncCallback.js → imageSliceSyncCallback.js} +8 -4
  131. package/dist/esm/synchronizers/callbacks/imageSliceSyncCallback.js.map +1 -0
  132. package/dist/esm/synchronizers/index.js +3 -2
  133. package/dist/esm/synchronizers/index.js.map +1 -1
  134. package/dist/esm/synchronizers/synchronizers/createImageSliceSynchronizer.js +11 -0
  135. package/dist/esm/synchronizers/synchronizers/createImageSliceSynchronizer.js.map +1 -0
  136. package/dist/esm/synchronizers/synchronizers/index.js +3 -2
  137. package/dist/esm/synchronizers/synchronizers/index.js.map +1 -1
  138. package/dist/esm/tools/AdvancedMagnifyTool.js +8 -3
  139. package/dist/esm/tools/AdvancedMagnifyTool.js.map +1 -1
  140. package/dist/esm/tools/annotation/SplineROITool.js +703 -0
  141. package/dist/esm/tools/annotation/SplineROITool.js.map +1 -0
  142. package/dist/esm/tools/annotation/splines/BSpline.js +10 -0
  143. package/dist/esm/tools/annotation/splines/BSpline.js.map +1 -0
  144. package/dist/esm/tools/annotation/splines/CardinalSpline.js +33 -0
  145. package/dist/esm/tools/annotation/splines/CardinalSpline.js.map +1 -0
  146. package/dist/esm/tools/annotation/splines/CatmullRomSpline.js +8 -0
  147. package/dist/esm/tools/annotation/splines/CatmullRomSpline.js.map +1 -0
  148. package/dist/esm/tools/annotation/splines/CubicSpline.js +165 -0
  149. package/dist/esm/tools/annotation/splines/CubicSpline.js.map +1 -0
  150. package/dist/esm/tools/annotation/splines/LinearSpline.js +8 -0
  151. package/dist/esm/tools/annotation/splines/LinearSpline.js.map +1 -0
  152. package/dist/esm/tools/annotation/splines/QuadraticBezier.js +16 -0
  153. package/dist/esm/tools/annotation/splines/QuadraticBezier.js.map +1 -0
  154. package/dist/esm/tools/annotation/splines/QuadraticSpline.js +14 -0
  155. package/dist/esm/tools/annotation/splines/QuadraticSpline.js.map +1 -0
  156. package/dist/esm/tools/annotation/splines/Spline.js +392 -0
  157. package/dist/esm/tools/annotation/splines/Spline.js.map +1 -0
  158. package/dist/esm/tools/index.js +2 -1
  159. package/dist/esm/tools/index.js.map +1 -1
  160. package/dist/esm/types/CardinalSplineProps.js +2 -0
  161. package/dist/esm/types/CardinalSplineProps.js.map +1 -0
  162. package/dist/esm/types/ClosestControlPoint.js +2 -0
  163. package/dist/esm/types/ClosestControlPoint.js.map +1 -0
  164. package/dist/esm/types/ClosestPoint.js +2 -0
  165. package/dist/esm/types/ClosestPoint.js.map +1 -0
  166. package/dist/esm/types/ClosestSplinePoint.js +2 -0
  167. package/dist/esm/types/ClosestSplinePoint.js.map +1 -0
  168. package/dist/esm/types/ControlPointInfo.js +2 -0
  169. package/dist/esm/types/ControlPointInfo.js.map +1 -0
  170. package/dist/esm/types/ISpline.js +2 -0
  171. package/dist/esm/types/ISpline.js.map +1 -0
  172. package/dist/esm/types/SplineCurveSegment.js +2 -0
  173. package/dist/esm/types/SplineCurveSegment.js.map +1 -0
  174. package/dist/esm/types/SplineLineSegment.js +2 -0
  175. package/dist/esm/types/SplineLineSegment.js.map +1 -0
  176. package/dist/esm/types/SplineProps.js +2 -0
  177. package/dist/esm/types/SplineProps.js.map +1 -0
  178. package/dist/esm/utilities/index.js +2 -3
  179. package/dist/esm/utilities/index.js.map +1 -1
  180. package/dist/esm/utilities/math/aabb/distanceToPoint.js +5 -0
  181. package/dist/esm/utilities/math/aabb/distanceToPoint.js.map +1 -0
  182. package/dist/esm/utilities/math/aabb/distanceToPointSquared.js +21 -0
  183. package/dist/esm/utilities/math/aabb/distanceToPointSquared.js.map +1 -0
  184. package/dist/esm/utilities/math/aabb/index.js +3 -0
  185. package/dist/esm/utilities/math/aabb/index.js.map +1 -0
  186. package/dist/esm/utilities/math/index.js +6 -5
  187. package/dist/esm/utilities/math/index.js.map +1 -1
  188. package/dist/esm/utilities/math/line/distanceToPointSquared.js +2 -21
  189. package/dist/esm/utilities/math/line/distanceToPointSquared.js.map +1 -1
  190. package/dist/esm/utilities/math/line/distanceToPointSquaredInfo.js +30 -0
  191. package/dist/esm/utilities/math/line/distanceToPointSquaredInfo.js.map +1 -0
  192. package/dist/esm/utilities/math/line/index.js +2 -1
  193. package/dist/esm/utilities/math/line/index.js.map +1 -1
  194. package/dist/esm/utilities/math/point/distanceToPoint.js +2 -6
  195. package/dist/esm/utilities/math/point/distanceToPoint.js.map +1 -1
  196. package/dist/esm/utilities/math/point/distanceToPointSquared.js +9 -0
  197. package/dist/esm/utilities/math/point/distanceToPointSquared.js.map +1 -0
  198. package/dist/esm/utilities/math/point/index.js +3 -2
  199. package/dist/esm/utilities/math/point/index.js.map +1 -1
  200. package/dist/esm/utilities/math/point/mirror.js +8 -0
  201. package/dist/esm/utilities/math/point/mirror.js.map +1 -0
  202. package/dist/types/eventDispatchers/mouseEventHandlers/mouseDown.d.ts.map +1 -1
  203. package/dist/types/eventDispatchers/shared/getToolsWithActionsForMouseEvent.d.ts.map +1 -1
  204. package/dist/types/index.d.ts +2 -2
  205. package/dist/types/index.d.ts.map +1 -1
  206. package/dist/types/store/SynchronizerManager/Synchronizer.d.ts +1 -0
  207. package/dist/types/store/SynchronizerManager/Synchronizer.d.ts.map +1 -1
  208. package/dist/types/synchronizers/callbacks/areViewportsCoplanar .d.ts +1 -1
  209. package/dist/types/synchronizers/callbacks/areViewportsCoplanar .d.ts.map +1 -1
  210. package/dist/types/synchronizers/callbacks/{stackImageSyncCallback.d.ts → imageSliceSyncCallback.d.ts} +2 -2
  211. package/dist/types/synchronizers/callbacks/imageSliceSyncCallback.d.ts.map +1 -0
  212. package/dist/types/synchronizers/index.d.ts +3 -2
  213. package/dist/types/synchronizers/index.d.ts.map +1 -1
  214. package/dist/types/synchronizers/synchronizers/createImageSliceSynchronizer.d.ts +3 -0
  215. package/dist/types/synchronizers/synchronizers/createImageSliceSynchronizer.d.ts.map +1 -0
  216. package/dist/types/synchronizers/synchronizers/index.d.ts +3 -2
  217. package/dist/types/synchronizers/synchronizers/index.d.ts.map +1 -1
  218. package/dist/types/tools/AdvancedMagnifyTool.d.ts +4 -0
  219. package/dist/types/tools/AdvancedMagnifyTool.d.ts.map +1 -1
  220. package/dist/types/tools/annotation/SplineROITool.d.ts +60 -0
  221. package/dist/types/tools/annotation/SplineROITool.d.ts.map +1 -0
  222. package/dist/types/tools/annotation/splines/BSpline.d.ts +6 -0
  223. package/dist/types/tools/annotation/splines/BSpline.d.ts.map +1 -0
  224. package/dist/types/tools/annotation/splines/CardinalSpline.d.ts +13 -0
  225. package/dist/types/tools/annotation/splines/CardinalSpline.d.ts.map +1 -0
  226. package/dist/types/tools/annotation/splines/CatmullRomSpline.d.ts +6 -0
  227. package/dist/types/tools/annotation/splines/CatmullRomSpline.d.ts.map +1 -0
  228. package/dist/types/tools/annotation/splines/CubicSpline.d.ts +14 -0
  229. package/dist/types/tools/annotation/splines/CubicSpline.d.ts.map +1 -0
  230. package/dist/types/tools/annotation/splines/LinearSpline.d.ts +6 -0
  231. package/dist/types/tools/annotation/splines/LinearSpline.d.ts.map +1 -0
  232. package/dist/types/tools/annotation/splines/QuadraticBezier.d.ts +7 -0
  233. package/dist/types/tools/annotation/splines/QuadraticBezier.d.ts.map +1 -0
  234. package/dist/types/tools/annotation/splines/QuadraticSpline.d.ts +10 -0
  235. package/dist/types/tools/annotation/splines/QuadraticSpline.d.ts.map +1 -0
  236. package/dist/types/tools/annotation/splines/Spline.d.ts +50 -0
  237. package/dist/types/tools/annotation/splines/Spline.d.ts.map +1 -0
  238. package/dist/types/tools/index.d.ts +2 -1
  239. package/dist/types/tools/index.d.ts.map +1 -1
  240. package/dist/types/types/CardinalSplineProps.d.ts +6 -0
  241. package/dist/types/types/CardinalSplineProps.d.ts.map +1 -0
  242. package/dist/types/types/ClosestControlPoint.d.ts +5 -0
  243. package/dist/types/types/ClosestControlPoint.d.ts.map +1 -0
  244. package/dist/types/types/ClosestPoint.d.ts +6 -0
  245. package/dist/types/types/ClosestPoint.d.ts.map +1 -0
  246. package/dist/types/types/ClosestSplinePoint.d.ts +5 -0
  247. package/dist/types/types/ClosestSplinePoint.d.ts.map +1 -0
  248. package/dist/types/types/ControlPointInfo.d.ts +6 -0
  249. package/dist/types/types/ControlPointInfo.d.ts.map +1 -0
  250. package/dist/types/types/ISpline.d.ts +30 -0
  251. package/dist/types/types/ISpline.d.ts.map +1 -0
  252. package/dist/types/types/SplineCurveSegment.d.ts +15 -0
  253. package/dist/types/types/SplineCurveSegment.d.ts.map +1 -0
  254. package/dist/types/types/SplineLineSegment.d.ts +11 -0
  255. package/dist/types/types/SplineLineSegment.d.ts.map +1 -0
  256. package/dist/types/types/SplineProps.d.ts +5 -0
  257. package/dist/types/types/SplineProps.d.ts.map +1 -0
  258. package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +34 -0
  259. package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
  260. package/dist/types/types/index.d.ts +10 -1
  261. package/dist/types/types/index.d.ts.map +1 -1
  262. package/dist/types/utilities/index.d.ts +2 -3
  263. package/dist/types/utilities/index.d.ts.map +1 -1
  264. package/dist/types/utilities/math/aabb/distanceToPoint.d.ts +3 -0
  265. package/dist/types/utilities/math/aabb/distanceToPoint.d.ts.map +1 -0
  266. package/dist/types/utilities/math/aabb/distanceToPointSquared.d.ts +3 -0
  267. package/dist/types/utilities/math/aabb/distanceToPointSquared.d.ts.map +1 -0
  268. package/dist/types/utilities/math/aabb/index.d.ts +3 -0
  269. package/dist/types/utilities/math/aabb/index.d.ts.map +1 -0
  270. package/dist/types/utilities/math/index.d.ts +6 -5
  271. package/dist/types/utilities/math/index.d.ts.map +1 -1
  272. package/dist/types/utilities/math/line/distanceToPointSquared.d.ts.map +1 -1
  273. package/dist/types/utilities/math/line/distanceToPointSquaredInfo.d.ts +6 -0
  274. package/dist/types/utilities/math/line/distanceToPointSquaredInfo.d.ts.map +1 -0
  275. package/dist/types/utilities/math/line/index.d.ts +2 -1
  276. package/dist/types/utilities/math/line/index.d.ts.map +1 -1
  277. package/dist/types/utilities/math/point/distanceToPoint.d.ts.map +1 -1
  278. package/dist/types/utilities/math/point/distanceToPointSquared.d.ts +5 -0
  279. package/dist/types/utilities/math/point/distanceToPointSquared.d.ts.map +1 -0
  280. package/dist/types/utilities/math/point/index.d.ts +3 -2
  281. package/dist/types/utilities/math/point/index.d.ts.map +1 -1
  282. package/dist/types/utilities/math/point/mirror.d.ts +3 -0
  283. package/dist/types/utilities/math/point/mirror.d.ts.map +1 -0
  284. package/dist/umd/index.js +2 -1
  285. package/dist/umd/index.js.LICENSE.txt +6 -0
  286. package/dist/umd/index.js.map +1 -1
  287. package/package.json +3 -3
  288. package/src/eventDispatchers/mouseEventHandlers/mouseDown.ts +8 -6
  289. package/src/eventDispatchers/shared/getToolsWithActionsForMouseEvent.ts +3 -2
  290. package/src/index.ts +2 -0
  291. package/src/store/SynchronizerManager/Synchronizer.ts +28 -3
  292. package/src/synchronizers/callbacks/areViewportsCoplanar .ts +2 -2
  293. package/src/synchronizers/callbacks/{stackImageSyncCallback.ts → imageSliceSyncCallback.ts} +16 -8
  294. package/src/synchronizers/index.ts +5 -1
  295. package/src/synchronizers/synchronizers/{createStackImageSynchronizer.ts → createImageSliceSynchronizer.ts} +8 -5
  296. package/src/synchronizers/synchronizers/index.ts +4 -1
  297. package/src/tools/AdvancedMagnifyTool.ts +8 -3
  298. package/src/tools/annotation/SplineROITool.ts +1151 -0
  299. package/src/tools/annotation/splines/BSpline.ts +22 -0
  300. package/src/tools/annotation/splines/CardinalSpline.ts +45 -0
  301. package/src/tools/annotation/splines/CatmullRomSpline.ts +19 -0
  302. package/src/tools/annotation/splines/CubicSpline.ts +288 -0
  303. package/src/tools/annotation/splines/LinearSpline.ts +20 -0
  304. package/src/tools/annotation/splines/QuadraticBezier.ts +20 -0
  305. package/src/tools/annotation/splines/QuadraticSpline.ts +25 -0
  306. package/src/tools/annotation/splines/Spline.ts +729 -0
  307. package/src/tools/index.ts +2 -0
  308. package/src/types/CardinalSplineProps.ts +11 -0
  309. package/src/types/ClosestControlPoint.ts +6 -0
  310. package/src/types/ClosestPoint.ts +8 -0
  311. package/src/types/ClosestSplinePoint.ts +6 -0
  312. package/src/types/ControlPointInfo.ts +8 -0
  313. package/src/types/ISpline.ts +164 -0
  314. package/src/types/SplineCurveSegment.ts +28 -0
  315. package/src/types/SplineLineSegment.ts +20 -0
  316. package/src/types/SplineProps.ts +15 -0
  317. package/src/types/ToolSpecificAnnotationTypes.ts +35 -0
  318. package/src/types/index.ts +21 -0
  319. package/src/utilities/index.ts +6 -2
  320. package/src/utilities/math/aabb/distanceToPoint.ts +20 -0
  321. package/src/utilities/math/aabb/distanceToPointSquared.ts +47 -0
  322. package/src/utilities/math/aabb/index.ts +2 -0
  323. package/src/utilities/math/index.ts +10 -8
  324. package/src/utilities/math/line/distanceToPointSquared.ts +3 -29
  325. package/src/utilities/math/line/distanceToPointSquaredInfo.ts +54 -0
  326. package/src/utilities/math/line/index.ts +7 -1
  327. package/src/utilities/math/point/distanceToPoint.ts +2 -10
  328. package/src/utilities/math/point/distanceToPointSquared.ts +21 -0
  329. package/src/utilities/math/point/index.ts +3 -3
  330. package/src/utilities/math/point/mirror.ts +21 -0
  331. package/dist/cjs/synchronizers/synchronizers/createStackImageSynchronizer.js +0 -15
  332. package/dist/cjs/synchronizers/synchronizers/createStackImageSynchronizer.js.map +0 -1
  333. package/dist/esm/synchronizers/callbacks/stackImageSyncCallback.js.map +0 -1
  334. package/dist/esm/synchronizers/synchronizers/createStackImageSynchronizer.js +0 -9
  335. package/dist/esm/synchronizers/synchronizers/createStackImageSynchronizer.js.map +0 -1
  336. package/dist/types/synchronizers/callbacks/stackImageSyncCallback.d.ts.map +0 -1
  337. package/dist/types/synchronizers/synchronizers/createStackImageSynchronizer.d.ts +0 -3
  338. package/dist/types/synchronizers/synchronizers/createStackImageSynchronizer.d.ts.map +0 -1
@@ -0,0 +1,22 @@
1
+ import { mat4 } from 'gl-matrix';
2
+ import { CubicSpline } from './CubicSpline';
3
+
4
+ // prettier-ignore
5
+ const TRANSFORM_MATRIX = mat4.multiplyScalar(
6
+ mat4.create(),
7
+ mat4.fromValues(
8
+ 1, 4, 1, 0,
9
+ -3, 0, 3, 0,
10
+ 3, -6, 3, 0,
11
+ -1, 3, -3, 1,
12
+ ),
13
+ 1 / 6
14
+ ) as number[];
15
+
16
+ class BSpline extends CubicSpline {
17
+ protected getTransformMatrix(): number[] {
18
+ return TRANSFORM_MATRIX;
19
+ }
20
+ }
21
+
22
+ export { BSpline as default, BSpline };
@@ -0,0 +1,45 @@
1
+ import { CubicSpline } from './CubicSpline';
2
+ import { CardinalSplineProps } from '../../../types';
3
+
4
+ class CardinalSpline extends CubicSpline {
5
+ private _scale: number;
6
+ private _fixedScale: boolean;
7
+
8
+ constructor(props?: CardinalSplineProps) {
9
+ super(props);
10
+ this._scale = props?.scale ?? 0.5;
11
+ this._fixedScale = props?.fixedScale ?? false;
12
+ }
13
+
14
+ public get scale() {
15
+ return this._scale;
16
+ }
17
+
18
+ public set scale(scale: number) {
19
+ if (this._fixedScale || this._scale === scale) {
20
+ return;
21
+ }
22
+
23
+ this._scale = scale;
24
+ this.invalidated = true;
25
+ }
26
+
27
+ public get fixedScale() {
28
+ return this._fixedScale;
29
+ }
30
+
31
+ protected getTransformMatrix(): number[] {
32
+ const { scale: s } = this;
33
+ const s2 = 2 * s;
34
+
35
+ // prettier-ignore
36
+ return [
37
+ 0, 1, 0, 0,
38
+ -s, 0, s, 0,
39
+ s2, s - 3, 3 - s2, -s,
40
+ -s, 2 - s, s - 2, s
41
+ ];
42
+ }
43
+ }
44
+
45
+ export { CardinalSpline as default, CardinalSpline };
@@ -0,0 +1,19 @@
1
+ import { CardinalSpline } from './CardinalSpline';
2
+
3
+ // Catmull-Rom spline matrix is a Cardinal spline with scale equal to 1/2. Then
4
+ // it can inherit from CubicSpline using the matrix below or inherit from
5
+ // CardinalSpline using a fixed scale equal to 0.5.
6
+ //
7
+ // Transformation Matrix:
8
+ // 0, 2, 0, 0,
9
+ // -1, 0, 1, 0,
10
+ // 2, -5, 4, -1,
11
+ // -1, 3, -3, 1
12
+
13
+ class CatmullRomSpline extends CardinalSpline {
14
+ constructor() {
15
+ super({ scale: 0.5, fixedScale: true });
16
+ }
17
+ }
18
+
19
+ export { CatmullRomSpline as default, CatmullRomSpline };
@@ -0,0 +1,288 @@
1
+ import { vec4, mat4 } from 'gl-matrix';
2
+ import { Types } from '@cornerstonejs/core';
3
+ import { Spline } from './Spline';
4
+ import * as math from '../../../utilities/math';
5
+ import type { SplineCurveSegment, SplineLineSegment } from '../../../types';
6
+
7
+ // The `u` in Parameter Space used when spliting a curve segment into line segments must
8
+ // be greater than or equal to `curveSegmentIndex` and smaller than `curveSegmentIndex + 1`.
9
+ // In this case we are using `curveSegmentIndex + 1 - MAX_U_ERROR`
10
+ const MAX_U_ERROR = 1e-8;
11
+
12
+ /**
13
+ * Base class for all cubic splines
14
+ */
15
+ abstract class CubicSpline extends Spline {
16
+ protected getPreviewCurveSegments(
17
+ controlPointPreview: Types.Point2,
18
+ closeSpline: boolean
19
+ ): SplineCurveSegment[] {
20
+ const previewNumCurveSegments = this._getNumCurveSegments() + 1;
21
+ const startCurveSegIndex = Math.max(0, previewNumCurveSegments - 2);
22
+ const endCurveSegIndex = closeSpline
23
+ ? previewNumCurveSegments
24
+ : previewNumCurveSegments - 1;
25
+ const transformMatrix = this.getTransformMatrix();
26
+ const controlPoints = [...this.controlPoints];
27
+ const curveSegments: SplineCurveSegment[] = [];
28
+
29
+ if (!closeSpline) {
30
+ controlPoints.push(controlPointPreview);
31
+ }
32
+
33
+ for (let i = startCurveSegIndex; i <= endCurveSegIndex; i++) {
34
+ const curveSegment = this._getCurveSegment(
35
+ i,
36
+ transformMatrix,
37
+ controlPoints,
38
+ closeSpline
39
+ );
40
+
41
+ curveSegments.push(curveSegment);
42
+ }
43
+
44
+ return curveSegments;
45
+ }
46
+
47
+ protected getSplineCurves(): SplineCurveSegment[] {
48
+ const numCurveSegments = this._getNumCurveSegments();
49
+ const curveSegments: SplineCurveSegment[] = new Array(numCurveSegments);
50
+
51
+ if (numCurveSegments <= 0) {
52
+ return [];
53
+ }
54
+
55
+ const transformMatrix = this.getTransformMatrix();
56
+ let previousCurveSegmentsLength = 0;
57
+
58
+ for (let i = 0; i < numCurveSegments; i++) {
59
+ const curveSegment = this._getCurveSegment(i, transformMatrix);
60
+
61
+ curveSegment.previousCurveSegmentsLength = previousCurveSegmentsLength;
62
+ curveSegments[i] = curveSegment;
63
+
64
+ previousCurveSegmentsLength += curveSegment.length;
65
+ }
66
+
67
+ return curveSegments;
68
+ }
69
+
70
+ private _getNumCurveSegments(
71
+ controlPoints: Types.Point2[] = this.controlPoints,
72
+ closed: boolean = this.closed
73
+ ): number {
74
+ return closed
75
+ ? controlPoints.length
76
+ : Math.max(0, controlPoints.length - 1);
77
+ }
78
+
79
+ /**
80
+ * Get a point on a spline curve given `u` value
81
+ *
82
+ * @param u - `u` value in Parameter Space that must be between 0 and N where N is the number of
83
+ * curve segments for opened splines or any negative/positive number for closed splines
84
+ * @returns - Point (x, y) on the spline. It may return `undefined` when `u` is smaller than 0
85
+ * or greater than N for opened splines
86
+ */
87
+ private _getPoint(
88
+ u: number,
89
+ transformMatrix: number[],
90
+ controlPoints: Types.Point2[] = this.controlPoints,
91
+ closed: boolean = this.closed
92
+ ): Types.Point2 {
93
+ const numCurveSegments = this._getNumCurveSegments(controlPoints, closed);
94
+ const uInt = Math.floor(u);
95
+ let curveSegmentIndex = uInt % numCurveSegments;
96
+
97
+ // `t` must be between 0 and 1
98
+ const t = u - uInt;
99
+
100
+ const curveSegmentIndexOutOfBounds =
101
+ curveSegmentIndex < 0 || curveSegmentIndex >= numCurveSegments;
102
+
103
+ if (curveSegmentIndexOutOfBounds) {
104
+ if (this.closed) {
105
+ // Wraps around when the index is negative or greater than or equal to `numSegments`
106
+ curveSegmentIndex =
107
+ (numCurveSegments + curveSegmentIndex) % numCurveSegments;
108
+ } else {
109
+ // Point is not on the spline curve
110
+ return;
111
+ }
112
+ }
113
+
114
+ const { p0, p1, p2, p3 } = this._getCurveSegmentPoints(
115
+ curveSegmentIndex,
116
+ controlPoints,
117
+ closed
118
+ );
119
+
120
+ // Formula to find any point on a cubic spline curve given a `t` value
121
+ //
122
+ // P(t) = [1 t t2 t3] | m00 m01 m02 m03 | | P0 |
123
+ // | m10 m11 m12 m13 | | P1 |
124
+ // | m20 m21 m22 m23 | | P2 |
125
+ // | m30 m31 m32 m33 | | P3 |
126
+
127
+ const tt = t * t;
128
+ const ttt = tt * t;
129
+ const tValues = vec4.fromValues(1, t, tt, ttt);
130
+
131
+ // Influential field values which tell us how much P0, P1, P2 and P3 influence
132
+ // each point of the curve
133
+ const qValues = vec4.transformMat4(
134
+ vec4.create(),
135
+ tValues,
136
+ transformMatrix as mat4
137
+ );
138
+
139
+ return [
140
+ vec4.dot(qValues, vec4.fromValues(p0[0], p1[0], p2[0], p3[0])),
141
+ vec4.dot(qValues, vec4.fromValues(p0[1], p1[1], p2[1], p3[1])),
142
+ ] as Types.Point2;
143
+ }
144
+
145
+ private _getCurveSegmentPoints(
146
+ curveSegmentIndex: number,
147
+ controlPoints: Types.Point2[] = this.controlPoints,
148
+ closed: boolean = this.closed
149
+ ) {
150
+ const numCurveSegments = this._getNumCurveSegments(controlPoints, closed);
151
+ const p1Index = curveSegmentIndex;
152
+ const p0Index = p1Index - 1;
153
+ const p2Index = closed ? (p1Index + 1) % numCurveSegments : p1Index + 1;
154
+ const p3Index = p2Index + 1;
155
+ const p1 = controlPoints[p1Index];
156
+ const p2 = controlPoints[p2Index];
157
+ let p0;
158
+ let p3;
159
+
160
+ // P0 shall be negative when P1/P2 are the start/end points of the first curve segment
161
+ if (p0Index >= 0) {
162
+ p0 = controlPoints[p0Index];
163
+ } else {
164
+ p0 = closed
165
+ ? controlPoints[controlPoints.length - 1]
166
+ : math.point.mirror(p2, p1);
167
+ }
168
+
169
+ // P3 shall be negative when P1/P2 are the start/end points of the last curve segment
170
+ if (p3Index < controlPoints.length) {
171
+ p3 = controlPoints[p3Index];
172
+ } else {
173
+ p3 = closed ? controlPoints[0] : math.point.mirror(p1, p2);
174
+ }
175
+
176
+ return { p0, p1, p2, p3 };
177
+ }
178
+
179
+ private _getLineSegments(
180
+ curveSegmentIndex: number,
181
+ transformMatrix: number[],
182
+ controlPoints: Types.Point2[] = this.controlPoints,
183
+ closed: boolean = this.closed
184
+ ): SplineLineSegment[] {
185
+ const numCurveSegments = this._getNumCurveSegments(controlPoints, closed);
186
+ const numLineSegments = this.resolution + 1;
187
+ const inc = 1 / numLineSegments;
188
+ const minU = curveSegmentIndex;
189
+ let maxU = minU + 1;
190
+
191
+ // 'u' must be greater than or equal to 0 and smaller than N where N is the number of segments
192
+ // otherwise it does not find the spline segment when it is not a closed curve because it is
193
+ // 0-based indexed. In this case `u` needs to get very close to the end point but never touch it
194
+ if (!closed && curveSegmentIndex === numCurveSegments - 1) {
195
+ maxU -= MAX_U_ERROR;
196
+ }
197
+
198
+ const lineSegments: SplineLineSegment[] = [];
199
+ let startPoint: Types.Point2;
200
+ let endPoint: Types.Point2;
201
+ let previousLineSegmentsLength = 0;
202
+
203
+ for (let i = 0, u = minU; i <= numLineSegments; i++, u += inc) {
204
+ // `u` may be greater than maxU in the last FOR loop due to number precision issue
205
+ u = u > maxU ? maxU : u;
206
+
207
+ const point = this._getPoint(u, transformMatrix, controlPoints, closed);
208
+
209
+ if (!i) {
210
+ startPoint = point;
211
+ continue;
212
+ }
213
+
214
+ endPoint = point;
215
+
216
+ const dx = endPoint[0] - startPoint[0];
217
+ const dy = endPoint[1] - startPoint[1];
218
+ const length = Math.sqrt(dx ** 2 + dy ** 2);
219
+ const aabb: Types.AABB2 = {
220
+ minX: startPoint[0] <= endPoint[0] ? startPoint[0] : endPoint[0],
221
+ maxX: startPoint[0] >= endPoint[0] ? startPoint[0] : endPoint[0],
222
+ minY: startPoint[1] <= endPoint[1] ? startPoint[1] : endPoint[1],
223
+ maxY: startPoint[1] >= endPoint[1] ? startPoint[1] : endPoint[1],
224
+ };
225
+
226
+ lineSegments.push({
227
+ points: {
228
+ start: startPoint,
229
+ end: endPoint,
230
+ },
231
+ aabb,
232
+ length,
233
+ previousLineSegmentsLength,
234
+ });
235
+
236
+ startPoint = endPoint;
237
+ previousLineSegmentsLength += length;
238
+ }
239
+
240
+ return lineSegments;
241
+ }
242
+
243
+ private _getCurveSegment(
244
+ curveSegmentIndex: number,
245
+ transformMatrix: number[] = this.getTransformMatrix(),
246
+ controlPoints: Types.Point2[] = this.controlPoints,
247
+ closed: boolean = this.closed
248
+ ): SplineCurveSegment {
249
+ // Cubic spline curves are mainly controlled by P1 and P2 points but
250
+ // they are also influenced by previous (P0) and next (P3) poins. For
251
+ // Cardinal, Linear and Catmull-Rom splines P1 and P2 are also known as
252
+ // knots because they are the connection between two curve segments.
253
+ const { p0, p1, p2, p3 } = this._getCurveSegmentPoints(
254
+ curveSegmentIndex,
255
+ controlPoints,
256
+ closed
257
+ );
258
+ const lineSegments = this._getLineSegments(
259
+ curveSegmentIndex,
260
+ transformMatrix,
261
+ controlPoints,
262
+ closed
263
+ );
264
+ let curveSegmentLength = 0;
265
+ let minX = Infinity;
266
+ let minY = Infinity;
267
+ let maxX = -Infinity;
268
+ let maxY = -Infinity;
269
+
270
+ lineSegments.forEach(({ aabb: lineSegAABB, length: lineSegLength }) => {
271
+ minX = Math.min(minX, lineSegAABB.minX);
272
+ minY = Math.min(minY, lineSegAABB.minY);
273
+ maxX = Math.max(maxX, lineSegAABB.maxX);
274
+ maxY = Math.max(maxY, lineSegAABB.maxY);
275
+ curveSegmentLength += lineSegLength;
276
+ });
277
+
278
+ return {
279
+ controlPoints: { p0, p1, p2, p3 },
280
+ aabb: { minX, minY, maxX, maxY },
281
+ length: curveSegmentLength,
282
+ previousCurveSegmentsLength: 0,
283
+ lineSegments,
284
+ };
285
+ }
286
+ }
287
+
288
+ export { CubicSpline as default, CubicSpline };
@@ -0,0 +1,20 @@
1
+ import { CardinalSpline } from './CardinalSpline';
2
+
3
+ // TODO: LinearSpline should inherit from Spline
4
+
5
+ /**
6
+ * Linear spline matrix is the same one from Cardinal spline with scale equal
7
+ * to 0. Then it can inherit from Spline using the matrix below or inherit from
8
+ * CardinalSpline fixing the scale to 0
9
+ *
10
+ * Transformation Matrix:
11
+ * 1, 0,
12
+ * -1, -1,
13
+ */
14
+ class LinearSpline extends CardinalSpline {
15
+ constructor() {
16
+ super({ scale: 0, fixedScale: true });
17
+ }
18
+ }
19
+
20
+ export { LinearSpline as default, LinearSpline };
@@ -0,0 +1,20 @@
1
+ import { QuadraticSpline } from './QuadraticSpline';
2
+
3
+ // prettier-ignore
4
+ const TRANSFORM_MATRIX = [
5
+ 1, 0, 0,
6
+ -2, 2, 0,
7
+ 1, -2, 1,
8
+ ];
9
+
10
+ class QuadraticBezier extends QuadraticSpline {
11
+ public hasTangentPoints() {
12
+ return true;
13
+ }
14
+
15
+ protected getTransformMatrix(): number[] {
16
+ return TRANSFORM_MATRIX;
17
+ }
18
+ }
19
+
20
+ export { QuadraticBezier as default, QuadraticBezier };
@@ -0,0 +1,25 @@
1
+ import { Types } from '@cornerstonejs/core';
2
+ import { Spline } from './Spline';
3
+ import type { SplineLineSegment, SplineCurveSegment } from '../../../types/';
4
+
5
+ abstract class QuadraticSpline extends Spline {
6
+ // TODO: QuadraticSpline :: getSplineCurves
7
+ protected getSplineCurves(): SplineCurveSegment[] {
8
+ return [];
9
+ }
10
+
11
+ // TODO: QuadraticSpline :: getLineSegments
12
+ protected getLineSegments(): SplineLineSegment[] {
13
+ return [];
14
+ }
15
+
16
+ // TODO: QuadraticSpline :: getPreviewCurveSegments
17
+ public getPreviewCurveSegments(
18
+ controlPointPreview: Types.Point2,
19
+ closeSpline: boolean
20
+ ): SplineCurveSegment[] {
21
+ return [];
22
+ }
23
+ }
24
+
25
+ export { QuadraticSpline as default, QuadraticSpline };