@cornerstonejs/tools 1.50.2 → 1.51.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 (489) hide show
  1. package/dist/cjs/eventListeners/annotations/annotationCompletedListener.d.ts +2 -0
  2. package/dist/cjs/eventListeners/annotations/annotationCompletedListener.js +35 -0
  3. package/dist/cjs/eventListeners/annotations/annotationCompletedListener.js.map +1 -0
  4. package/dist/cjs/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.d.ts +2 -0
  5. package/dist/cjs/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js +174 -0
  6. package/dist/cjs/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js.map +1 -0
  7. package/dist/cjs/eventListeners/annotations/contourSegmentation/index.d.ts +1 -0
  8. package/dist/cjs/eventListeners/annotations/contourSegmentation/index.js +9 -0
  9. package/dist/cjs/eventListeners/annotations/contourSegmentation/index.js.map +1 -0
  10. package/dist/cjs/eventListeners/annotations/index.d.ts +2 -1
  11. package/dist/cjs/eventListeners/annotations/index.js +3 -1
  12. package/dist/cjs/eventListeners/annotations/index.js.map +1 -1
  13. package/dist/cjs/eventListeners/index.d.ts +2 -2
  14. package/dist/cjs/eventListeners/index.js +2 -1
  15. package/dist/cjs/eventListeners/index.js.map +1 -1
  16. package/dist/cjs/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.d.ts +3 -0
  17. package/dist/cjs/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js +89 -0
  18. package/dist/cjs/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js.map +1 -0
  19. package/dist/cjs/eventListeners/segmentation/segmentationDataModifiedEventListener.js +5 -53
  20. package/dist/cjs/eventListeners/segmentation/segmentationDataModifiedEventListener.js.map +1 -1
  21. package/dist/cjs/init.js +2 -0
  22. package/dist/cjs/init.js.map +1 -1
  23. package/dist/cjs/stateManagement/annotation/helpers/state.d.ts +3 -1
  24. package/dist/cjs/stateManagement/annotation/helpers/state.js +21 -1
  25. package/dist/cjs/stateManagement/annotation/helpers/state.js.map +1 -1
  26. package/dist/cjs/store/ToolGroupManager/ToolGroup.d.ts +1 -0
  27. package/dist/cjs/store/ToolGroupManager/ToolGroup.js +3 -0
  28. package/dist/cjs/store/ToolGroupManager/ToolGroup.js.map +1 -1
  29. package/dist/cjs/store/addTool.d.ts +1 -0
  30. package/dist/cjs/store/addTool.js +6 -1
  31. package/dist/cjs/store/addTool.js.map +1 -1
  32. package/dist/cjs/store/index.d.ts +2 -2
  33. package/dist/cjs/store/index.js +2 -1
  34. package/dist/cjs/store/index.js.map +1 -1
  35. package/dist/cjs/store/removeEnabledElement.js +1 -2
  36. package/dist/cjs/store/removeEnabledElement.js.map +1 -1
  37. package/dist/cjs/tools/AdvancedMagnifyTool.js +3 -10
  38. package/dist/cjs/tools/AdvancedMagnifyTool.js.map +1 -1
  39. package/dist/cjs/tools/annotation/AngleTool.js +5 -18
  40. package/dist/cjs/tools/annotation/AngleTool.js.map +1 -1
  41. package/dist/cjs/tools/annotation/ArrowAnnotateTool.js +9 -28
  42. package/dist/cjs/tools/annotation/ArrowAnnotateTool.js.map +1 -1
  43. package/dist/cjs/tools/annotation/BidirectionalTool.js +7 -22
  44. package/dist/cjs/tools/annotation/BidirectionalTool.js.map +1 -1
  45. package/dist/cjs/tools/annotation/CircleROITool.js +7 -22
  46. package/dist/cjs/tools/annotation/CircleROITool.js.map +1 -1
  47. package/dist/cjs/tools/annotation/CobbAngleTool.js +5 -18
  48. package/dist/cjs/tools/annotation/CobbAngleTool.js.map +1 -1
  49. package/dist/cjs/tools/annotation/EllipticalROITool.js +7 -22
  50. package/dist/cjs/tools/annotation/EllipticalROITool.js.map +1 -1
  51. package/dist/cjs/tools/annotation/KeyImageTool.js +5 -12
  52. package/dist/cjs/tools/annotation/KeyImageTool.js.map +1 -1
  53. package/dist/cjs/tools/annotation/LengthTool.js +5 -18
  54. package/dist/cjs/tools/annotation/LengthTool.js.map +1 -1
  55. package/dist/cjs/tools/annotation/LivewireContourTool.d.ts +4 -1
  56. package/dist/cjs/tools/annotation/LivewireContourTool.js +30 -22
  57. package/dist/cjs/tools/annotation/LivewireContourTool.js.map +1 -1
  58. package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts +2 -1
  59. package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.js +11 -0
  60. package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.js.map +1 -1
  61. package/dist/cjs/tools/annotation/PlanarFreehandROITool.d.ts +2 -10
  62. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +6 -22
  63. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  64. package/dist/cjs/tools/annotation/ProbeTool.js +8 -23
  65. package/dist/cjs/tools/annotation/ProbeTool.js.map +1 -1
  66. package/dist/cjs/tools/annotation/RectangleROITool.js +8 -22
  67. package/dist/cjs/tools/annotation/RectangleROITool.js.map +1 -1
  68. package/dist/cjs/tools/annotation/SplineROITool.d.ts +8 -9
  69. package/dist/cjs/tools/annotation/SplineROITool.js +27 -10
  70. package/dist/cjs/tools/annotation/SplineROITool.js.map +1 -1
  71. package/dist/cjs/tools/annotation/UltrasoundDirectionalTool.js +5 -18
  72. package/dist/cjs/tools/annotation/UltrasoundDirectionalTool.js.map +1 -1
  73. package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +7 -6
  74. package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
  75. package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js +8 -5
  76. package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
  77. package/dist/cjs/tools/annotation/planarFreehandROITool/editLoopCommon.js +8 -8
  78. package/dist/cjs/tools/annotation/planarFreehandROITool/editLoopCommon.js.map +1 -1
  79. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js +6 -5
  80. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
  81. package/dist/cjs/tools/base/ContourBaseTool.d.ts +2 -8
  82. package/dist/cjs/tools/base/ContourBaseTool.js.map +1 -1
  83. package/dist/cjs/tools/base/ContourSegmentationBaseTool.d.ts +3 -2
  84. package/dist/cjs/tools/base/ContourSegmentationBaseTool.js +13 -1
  85. package/dist/cjs/tools/base/ContourSegmentationBaseTool.js.map +1 -1
  86. package/dist/cjs/tools/segmentation/RectangleROIStartEndThresholdTool.js +3 -9
  87. package/dist/cjs/tools/segmentation/RectangleROIStartEndThresholdTool.js.map +1 -1
  88. package/dist/cjs/tools/segmentation/RectangleROIThresholdTool.js +3 -9
  89. package/dist/cjs/tools/segmentation/RectangleROIThresholdTool.js.map +1 -1
  90. package/dist/cjs/types/AnnotationRenderContext.d.ts +11 -0
  91. package/dist/cjs/types/AnnotationRenderContext.js +3 -0
  92. package/dist/cjs/types/AnnotationRenderContext.js.map +1 -0
  93. package/dist/cjs/types/IToolGroup.d.ts +2 -1
  94. package/dist/cjs/types/index.d.ts +2 -1
  95. package/dist/cjs/utilities/contourSegmentation/areSameSegment.d.ts +2 -0
  96. package/dist/cjs/utilities/contourSegmentation/areSameSegment.js +12 -0
  97. package/dist/cjs/utilities/contourSegmentation/areSameSegment.js.map +1 -0
  98. package/dist/cjs/utilities/contourSegmentation/index.d.ts +2 -0
  99. package/dist/cjs/utilities/contourSegmentation/index.js +11 -0
  100. package/dist/cjs/utilities/contourSegmentation/index.js.map +1 -0
  101. package/dist/cjs/utilities/contourSegmentation/isContourSegmentationAnnotation.d.ts +3 -0
  102. package/dist/cjs/utilities/contourSegmentation/isContourSegmentationAnnotation.js +8 -0
  103. package/dist/cjs/utilities/contourSegmentation/isContourSegmentationAnnotation.js.map +1 -0
  104. package/dist/cjs/utilities/contours/areCoplanarContours.d.ts +2 -0
  105. package/dist/cjs/utilities/contours/areCoplanarContours.js +19 -0
  106. package/dist/cjs/utilities/contours/areCoplanarContours.js.map +1 -0
  107. package/dist/cjs/utilities/contours/index.d.ts +2 -1
  108. package/dist/cjs/utilities/contours/index.js +3 -1
  109. package/dist/cjs/utilities/contours/index.js.map +1 -1
  110. package/dist/cjs/utilities/contours/reverseIfAntiClockwise.js +3 -22
  111. package/dist/cjs/utilities/contours/reverseIfAntiClockwise.js.map +1 -1
  112. package/dist/cjs/utilities/math/aabb/index.d.ts +1 -0
  113. package/dist/cjs/utilities/math/aabb/index.js +3 -1
  114. package/dist/cjs/utilities/math/aabb/index.js.map +1 -1
  115. package/dist/cjs/utilities/math/aabb/intersectAABB.d.ts +2 -0
  116. package/dist/cjs/utilities/math/aabb/intersectAABB.js +10 -0
  117. package/dist/cjs/utilities/math/aabb/intersectAABB.js.map +1 -0
  118. package/dist/cjs/utilities/math/point/distanceToPointSquared.js +4 -1
  119. package/dist/cjs/utilities/math/point/distanceToPointSquared.js.map +1 -1
  120. package/dist/cjs/utilities/math/polyline/areLineSegmentsIntersecting.d.ts +2 -0
  121. package/dist/cjs/utilities/math/polyline/areLineSegmentsIntersecting.js +59 -0
  122. package/dist/cjs/utilities/math/polyline/areLineSegmentsIntersecting.js.map +1 -0
  123. package/dist/cjs/utilities/math/polyline/combinePolyline.d.ts +4 -0
  124. package/dist/cjs/utilities/math/polyline/combinePolyline.js +213 -0
  125. package/dist/cjs/utilities/math/polyline/combinePolyline.js.map +1 -0
  126. package/dist/cjs/utilities/math/polyline/containsPoint.d.ts +2 -0
  127. package/dist/cjs/utilities/math/polyline/containsPoint.js +36 -0
  128. package/dist/cjs/utilities/math/polyline/containsPoint.js.map +1 -0
  129. package/dist/cjs/utilities/math/polyline/getAABB.d.ts +2 -0
  130. package/dist/cjs/utilities/math/polyline/getAABB.js +18 -0
  131. package/dist/cjs/utilities/math/polyline/getAABB.js.map +1 -0
  132. package/dist/cjs/utilities/math/polyline/getArea.d.ts +2 -0
  133. package/dist/cjs/utilities/math/polyline/{calculateAreaOfPoints.js → getArea.js} +3 -3
  134. package/dist/cjs/utilities/math/polyline/getArea.js.map +1 -0
  135. package/dist/cjs/utilities/math/polyline/getClosestLineSegmentIntersection.d.ts +5 -0
  136. package/dist/cjs/utilities/math/polyline/getClosestLineSegmentIntersection.js +51 -0
  137. package/dist/cjs/utilities/math/polyline/getClosestLineSegmentIntersection.js.map +1 -0
  138. package/dist/cjs/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.d.ts +2 -0
  139. package/dist/cjs/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.js +28 -0
  140. package/dist/cjs/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.js.map +1 -0
  141. package/dist/cjs/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.d.ts +2 -0
  142. package/dist/cjs/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.js +20 -0
  143. package/dist/cjs/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.js.map +1 -0
  144. package/dist/cjs/utilities/math/polyline/getLineSegmentIntersectionsIndexes.d.ts +2 -0
  145. package/dist/cjs/utilities/math/polyline/getLineSegmentIntersectionsIndexes.js +22 -0
  146. package/dist/cjs/utilities/math/polyline/getLineSegmentIntersectionsIndexes.js.map +1 -0
  147. package/dist/cjs/utilities/math/polyline/getLineSegmentsIntersection.d.ts +2 -0
  148. package/dist/cjs/utilities/math/polyline/getLineSegmentsIntersection.js +21 -0
  149. package/dist/cjs/utilities/math/polyline/getLineSegmentsIntersection.js.map +1 -0
  150. package/dist/cjs/utilities/math/polyline/getNormal2.d.ts +2 -0
  151. package/dist/cjs/utilities/math/polyline/getNormal2.js +12 -0
  152. package/dist/cjs/utilities/math/polyline/getNormal2.js.map +1 -0
  153. package/dist/cjs/utilities/math/polyline/getNormal3.d.ts +2 -0
  154. package/dist/cjs/utilities/math/polyline/getNormal3.js +29 -0
  155. package/dist/cjs/utilities/math/polyline/getNormal3.js.map +1 -0
  156. package/dist/cjs/utilities/math/polyline/getSignedArea.d.ts +2 -0
  157. package/dist/cjs/utilities/math/polyline/getSignedArea.js +20 -0
  158. package/dist/cjs/utilities/math/polyline/getSignedArea.js.map +1 -0
  159. package/dist/cjs/utilities/math/polyline/index.d.ts +14 -3
  160. package/dist/cjs/utilities/math/polyline/index.js +28 -6
  161. package/dist/cjs/utilities/math/polyline/index.js.map +1 -1
  162. package/dist/cjs/utilities/math/polyline/intersectPolyline.d.ts +2 -0
  163. package/dist/cjs/utilities/math/polyline/intersectPolyline.js +20 -0
  164. package/dist/cjs/utilities/math/polyline/intersectPolyline.js.map +1 -0
  165. package/dist/cjs/utilities/math/polyline/isClosed.d.ts +2 -0
  166. package/dist/cjs/utilities/math/polyline/isClosed.js +39 -0
  167. package/dist/cjs/utilities/math/polyline/isClosed.js.map +1 -0
  168. package/dist/esm/eventListeners/annotations/annotationCompletedListener.js +9 -0
  169. package/dist/esm/eventListeners/annotations/annotationCompletedListener.js.map +1 -0
  170. package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js +153 -0
  171. package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js.map +1 -0
  172. package/dist/esm/eventListeners/annotations/contourSegmentation/index.js +2 -0
  173. package/dist/esm/eventListeners/annotations/contourSegmentation/index.js.map +1 -0
  174. package/dist/esm/eventListeners/annotations/index.js +2 -1
  175. package/dist/esm/eventListeners/annotations/index.js.map +1 -1
  176. package/dist/esm/eventListeners/index.js +2 -2
  177. package/dist/esm/eventListeners/index.js.map +1 -1
  178. package/dist/esm/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js +61 -0
  179. package/dist/esm/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js.map +1 -0
  180. package/dist/esm/eventListeners/segmentation/segmentationDataModifiedEventListener.js +5 -53
  181. package/dist/esm/eventListeners/segmentation/segmentationDataModifiedEventListener.js.map +1 -1
  182. package/dist/esm/init.js +3 -1
  183. package/dist/esm/init.js.map +1 -1
  184. package/dist/esm/stateManagement/annotation/helpers/state.js +19 -1
  185. package/dist/esm/stateManagement/annotation/helpers/state.js.map +1 -1
  186. package/dist/esm/store/ToolGroupManager/ToolGroup.js +3 -0
  187. package/dist/esm/store/ToolGroupManager/ToolGroup.js.map +1 -1
  188. package/dist/esm/store/addTool.js +4 -0
  189. package/dist/esm/store/addTool.js.map +1 -1
  190. package/dist/esm/store/index.js +2 -2
  191. package/dist/esm/store/index.js.map +1 -1
  192. package/dist/esm/store/removeEnabledElement.js +1 -2
  193. package/dist/esm/store/removeEnabledElement.js.map +1 -1
  194. package/dist/esm/tools/AdvancedMagnifyTool.js +4 -11
  195. package/dist/esm/tools/AdvancedMagnifyTool.js.map +1 -1
  196. package/dist/esm/tools/annotation/AngleTool.js +6 -19
  197. package/dist/esm/tools/annotation/AngleTool.js.map +1 -1
  198. package/dist/esm/tools/annotation/ArrowAnnotateTool.js +10 -29
  199. package/dist/esm/tools/annotation/ArrowAnnotateTool.js.map +1 -1
  200. package/dist/esm/tools/annotation/BidirectionalTool.js +8 -23
  201. package/dist/esm/tools/annotation/BidirectionalTool.js.map +1 -1
  202. package/dist/esm/tools/annotation/CircleROITool.js +8 -23
  203. package/dist/esm/tools/annotation/CircleROITool.js.map +1 -1
  204. package/dist/esm/tools/annotation/CobbAngleTool.js +6 -19
  205. package/dist/esm/tools/annotation/CobbAngleTool.js.map +1 -1
  206. package/dist/esm/tools/annotation/EllipticalROITool.js +8 -23
  207. package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
  208. package/dist/esm/tools/annotation/KeyImageTool.js +6 -13
  209. package/dist/esm/tools/annotation/KeyImageTool.js.map +1 -1
  210. package/dist/esm/tools/annotation/LengthTool.js +6 -19
  211. package/dist/esm/tools/annotation/LengthTool.js.map +1 -1
  212. package/dist/esm/tools/annotation/LivewireContourTool.js +31 -23
  213. package/dist/esm/tools/annotation/LivewireContourTool.js.map +1 -1
  214. package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js +11 -0
  215. package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js.map +1 -1
  216. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +7 -23
  217. package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
  218. package/dist/esm/tools/annotation/ProbeTool.js +9 -24
  219. package/dist/esm/tools/annotation/ProbeTool.js.map +1 -1
  220. package/dist/esm/tools/annotation/RectangleROITool.js +9 -23
  221. package/dist/esm/tools/annotation/RectangleROITool.js.map +1 -1
  222. package/dist/esm/tools/annotation/SplineROITool.js +26 -9
  223. package/dist/esm/tools/annotation/SplineROITool.js.map +1 -1
  224. package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js +6 -19
  225. package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js.map +1 -1
  226. package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +7 -6
  227. package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
  228. package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js +8 -5
  229. package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
  230. package/dist/esm/tools/annotation/planarFreehandROITool/editLoopCommon.js +8 -8
  231. package/dist/esm/tools/annotation/planarFreehandROITool/editLoopCommon.js.map +1 -1
  232. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js +6 -5
  233. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
  234. package/dist/esm/tools/base/ContourBaseTool.js.map +1 -1
  235. package/dist/esm/tools/base/ContourSegmentationBaseTool.js +13 -1
  236. package/dist/esm/tools/base/ContourSegmentationBaseTool.js.map +1 -1
  237. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +4 -10
  238. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js.map +1 -1
  239. package/dist/esm/tools/segmentation/RectangleROIThresholdTool.js +4 -10
  240. package/dist/esm/tools/segmentation/RectangleROIThresholdTool.js.map +1 -1
  241. package/dist/esm/types/AnnotationRenderContext.js +2 -0
  242. package/dist/esm/types/AnnotationRenderContext.js.map +1 -0
  243. package/dist/esm/utilities/contourSegmentation/areSameSegment.js +9 -0
  244. package/dist/esm/utilities/contourSegmentation/areSameSegment.js.map +1 -0
  245. package/dist/esm/utilities/contourSegmentation/index.js +3 -0
  246. package/dist/esm/utilities/contourSegmentation/index.js.map +1 -0
  247. package/dist/esm/utilities/contourSegmentation/isContourSegmentationAnnotation.js +4 -0
  248. package/dist/esm/utilities/contourSegmentation/isContourSegmentationAnnotation.js.map +1 -0
  249. package/dist/esm/utilities/contours/areCoplanarContours.js +16 -0
  250. package/dist/esm/utilities/contours/areCoplanarContours.js.map +1 -0
  251. package/dist/esm/utilities/contours/index.js +2 -1
  252. package/dist/esm/utilities/contours/index.js.map +1 -1
  253. package/dist/esm/utilities/contours/reverseIfAntiClockwise.js +3 -22
  254. package/dist/esm/utilities/contours/reverseIfAntiClockwise.js.map +1 -1
  255. package/dist/esm/utilities/math/aabb/index.js +1 -0
  256. package/dist/esm/utilities/math/aabb/index.js.map +1 -1
  257. package/dist/esm/utilities/math/aabb/intersectAABB.js +7 -0
  258. package/dist/esm/utilities/math/aabb/intersectAABB.js.map +1 -0
  259. package/dist/esm/utilities/math/point/distanceToPointSquared.js +4 -1
  260. package/dist/esm/utilities/math/point/distanceToPointSquared.js.map +1 -1
  261. package/dist/esm/utilities/math/polyline/areLineSegmentsIntersecting.js +56 -0
  262. package/dist/esm/utilities/math/polyline/areLineSegmentsIntersecting.js.map +1 -0
  263. package/dist/esm/utilities/math/polyline/combinePolyline.js +187 -0
  264. package/dist/esm/utilities/math/polyline/combinePolyline.js.map +1 -0
  265. package/dist/esm/utilities/math/polyline/containsPoint.js +30 -0
  266. package/dist/esm/utilities/math/polyline/containsPoint.js.map +1 -0
  267. package/dist/esm/utilities/math/polyline/getAABB.js +15 -0
  268. package/dist/esm/utilities/math/polyline/getAABB.js.map +1 -0
  269. package/dist/esm/utilities/math/polyline/{calculateAreaOfPoints.js → getArea.js} +2 -2
  270. package/dist/esm/utilities/math/polyline/getArea.js.map +1 -0
  271. package/dist/esm/utilities/math/polyline/getClosestLineSegmentIntersection.js +45 -0
  272. package/dist/esm/utilities/math/polyline/getClosestLineSegmentIntersection.js.map +1 -0
  273. package/dist/esm/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.js +22 -0
  274. package/dist/esm/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.js.map +1 -0
  275. package/dist/esm/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.js +14 -0
  276. package/dist/esm/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.js.map +1 -0
  277. package/dist/esm/utilities/math/polyline/getLineSegmentIntersectionsIndexes.js +16 -0
  278. package/dist/esm/utilities/math/polyline/getLineSegmentIntersectionsIndexes.js.map +1 -0
  279. package/dist/esm/utilities/math/polyline/getLineSegmentsIntersection.js +18 -0
  280. package/dist/esm/utilities/math/polyline/getLineSegmentsIntersection.js.map +1 -0
  281. package/dist/esm/utilities/math/polyline/getNormal2.js +6 -0
  282. package/dist/esm/utilities/math/polyline/getNormal2.js.map +1 -0
  283. package/dist/esm/utilities/math/polyline/getNormal3.js +26 -0
  284. package/dist/esm/utilities/math/polyline/getNormal3.js.map +1 -0
  285. package/dist/esm/utilities/math/polyline/getSignedArea.js +17 -0
  286. package/dist/esm/utilities/math/polyline/getSignedArea.js.map +1 -0
  287. package/dist/esm/utilities/math/polyline/index.js +14 -3
  288. package/dist/esm/utilities/math/polyline/index.js.map +1 -1
  289. package/dist/esm/utilities/math/polyline/intersectPolyline.js +14 -0
  290. package/dist/esm/utilities/math/polyline/intersectPolyline.js.map +1 -0
  291. package/dist/esm/utilities/math/polyline/isClosed.js +13 -0
  292. package/dist/esm/utilities/math/polyline/isClosed.js.map +1 -0
  293. package/dist/types/eventListeners/annotations/annotationCompletedListener.d.ts +3 -0
  294. package/dist/types/eventListeners/annotations/annotationCompletedListener.d.ts.map +1 -0
  295. package/dist/types/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.d.ts +3 -0
  296. package/dist/types/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.d.ts.map +1 -0
  297. package/dist/types/eventListeners/annotations/contourSegmentation/index.d.ts +2 -0
  298. package/dist/types/eventListeners/annotations/contourSegmentation/index.d.ts.map +1 -0
  299. package/dist/types/eventListeners/annotations/index.d.ts +2 -1
  300. package/dist/types/eventListeners/annotations/index.d.ts.map +1 -1
  301. package/dist/types/eventListeners/index.d.ts +2 -2
  302. package/dist/types/eventListeners/index.d.ts.map +1 -1
  303. package/dist/types/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.d.ts +4 -0
  304. package/dist/types/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.d.ts.map +1 -0
  305. package/dist/types/eventListeners/segmentation/segmentationDataModifiedEventListener.d.ts.map +1 -1
  306. package/dist/types/init.d.ts.map +1 -1
  307. package/dist/types/stateManagement/annotation/helpers/state.d.ts +3 -1
  308. package/dist/types/stateManagement/annotation/helpers/state.d.ts.map +1 -1
  309. package/dist/types/store/ToolGroupManager/ToolGroup.d.ts +1 -0
  310. package/dist/types/store/ToolGroupManager/ToolGroup.d.ts.map +1 -1
  311. package/dist/types/store/addTool.d.ts +1 -0
  312. package/dist/types/store/addTool.d.ts.map +1 -1
  313. package/dist/types/store/index.d.ts +2 -2
  314. package/dist/types/store/index.d.ts.map +1 -1
  315. package/dist/types/store/removeEnabledElement.d.ts.map +1 -1
  316. package/dist/types/tools/AdvancedMagnifyTool.d.ts.map +1 -1
  317. package/dist/types/tools/annotation/AngleTool.d.ts.map +1 -1
  318. package/dist/types/tools/annotation/ArrowAnnotateTool.d.ts.map +1 -1
  319. package/dist/types/tools/annotation/BidirectionalTool.d.ts.map +1 -1
  320. package/dist/types/tools/annotation/CircleROITool.d.ts.map +1 -1
  321. package/dist/types/tools/annotation/CobbAngleTool.d.ts.map +1 -1
  322. package/dist/types/tools/annotation/EllipticalROITool.d.ts.map +1 -1
  323. package/dist/types/tools/annotation/KeyImageTool.d.ts.map +1 -1
  324. package/dist/types/tools/annotation/LengthTool.d.ts.map +1 -1
  325. package/dist/types/tools/annotation/LivewireContourTool.d.ts +4 -1
  326. package/dist/types/tools/annotation/LivewireContourTool.d.ts.map +1 -1
  327. package/dist/types/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts +2 -1
  328. package/dist/types/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts.map +1 -1
  329. package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts +2 -10
  330. package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts.map +1 -1
  331. package/dist/types/tools/annotation/ProbeTool.d.ts.map +1 -1
  332. package/dist/types/tools/annotation/RectangleROITool.d.ts.map +1 -1
  333. package/dist/types/tools/annotation/SplineROITool.d.ts +8 -9
  334. package/dist/types/tools/annotation/SplineROITool.d.ts.map +1 -1
  335. package/dist/types/tools/annotation/UltrasoundDirectionalTool.d.ts.map +1 -1
  336. package/dist/types/tools/annotation/planarFreehandROITool/closedContourEditLoop.d.ts.map +1 -1
  337. package/dist/types/tools/annotation/planarFreehandROITool/drawLoop.d.ts.map +1 -1
  338. package/dist/types/tools/annotation/planarFreehandROITool/editLoopCommon.d.ts.map +1 -1
  339. package/dist/types/tools/annotation/planarFreehandROITool/openContourEditLoop.d.ts.map +1 -1
  340. package/dist/types/tools/base/ContourBaseTool.d.ts +2 -8
  341. package/dist/types/tools/base/ContourBaseTool.d.ts.map +1 -1
  342. package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts +3 -2
  343. package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts.map +1 -1
  344. package/dist/types/tools/segmentation/RectangleROIStartEndThresholdTool.d.ts.map +1 -1
  345. package/dist/types/tools/segmentation/RectangleROIThresholdTool.d.ts.map +1 -1
  346. package/dist/types/types/AnnotationRenderContext.d.ts +12 -0
  347. package/dist/types/types/AnnotationRenderContext.d.ts.map +1 -0
  348. package/dist/types/types/IToolGroup.d.ts +2 -1
  349. package/dist/types/types/IToolGroup.d.ts.map +1 -1
  350. package/dist/types/types/index.d.ts +2 -1
  351. package/dist/types/types/index.d.ts.map +1 -1
  352. package/dist/types/utilities/contourSegmentation/areSameSegment.d.ts +3 -0
  353. package/dist/types/utilities/contourSegmentation/areSameSegment.d.ts.map +1 -0
  354. package/dist/types/utilities/contourSegmentation/index.d.ts +3 -0
  355. package/dist/types/utilities/contourSegmentation/index.d.ts.map +1 -0
  356. package/dist/types/utilities/contourSegmentation/isContourSegmentationAnnotation.d.ts +4 -0
  357. package/dist/types/utilities/contourSegmentation/isContourSegmentationAnnotation.d.ts.map +1 -0
  358. package/dist/types/utilities/contours/areCoplanarContours.d.ts +3 -0
  359. package/dist/types/utilities/contours/areCoplanarContours.d.ts.map +1 -0
  360. package/dist/types/utilities/contours/index.d.ts +2 -1
  361. package/dist/types/utilities/contours/index.d.ts.map +1 -1
  362. package/dist/types/utilities/contours/reverseIfAntiClockwise.d.ts.map +1 -1
  363. package/dist/types/utilities/math/aabb/index.d.ts +1 -0
  364. package/dist/types/utilities/math/aabb/index.d.ts.map +1 -1
  365. package/dist/types/utilities/math/aabb/intersectAABB.d.ts +3 -0
  366. package/dist/types/utilities/math/aabb/intersectAABB.d.ts.map +1 -0
  367. package/dist/types/utilities/math/point/distanceToPointSquared.d.ts.map +1 -1
  368. package/dist/types/utilities/math/polyline/areLineSegmentsIntersecting.d.ts +3 -0
  369. package/dist/types/utilities/math/polyline/areLineSegmentsIntersecting.d.ts.map +1 -0
  370. package/dist/types/utilities/math/polyline/combinePolyline.d.ts +5 -0
  371. package/dist/types/utilities/math/polyline/combinePolyline.d.ts.map +1 -0
  372. package/dist/types/utilities/math/polyline/containsPoint.d.ts +3 -0
  373. package/dist/types/utilities/math/polyline/containsPoint.d.ts.map +1 -0
  374. package/dist/types/utilities/math/polyline/getAABB.d.ts +3 -0
  375. package/dist/types/utilities/math/polyline/getAABB.d.ts.map +1 -0
  376. package/dist/types/utilities/math/polyline/getArea.d.ts +3 -0
  377. package/dist/types/utilities/math/polyline/getArea.d.ts.map +1 -0
  378. package/dist/types/utilities/math/polyline/getClosestLineSegmentIntersection.d.ts +6 -0
  379. package/dist/types/utilities/math/polyline/getClosestLineSegmentIntersection.d.ts.map +1 -0
  380. package/dist/types/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.d.ts +3 -0
  381. package/dist/types/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.d.ts.map +1 -0
  382. package/dist/types/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.d.ts +3 -0
  383. package/dist/types/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.d.ts.map +1 -0
  384. package/dist/types/utilities/math/polyline/getLineSegmentIntersectionsIndexes.d.ts +3 -0
  385. package/dist/types/utilities/math/polyline/getLineSegmentIntersectionsIndexes.d.ts.map +1 -0
  386. package/dist/types/utilities/math/polyline/getLineSegmentsIntersection.d.ts +3 -0
  387. package/dist/types/utilities/math/polyline/getLineSegmentsIntersection.d.ts.map +1 -0
  388. package/dist/types/utilities/math/polyline/getNormal2.d.ts +3 -0
  389. package/dist/types/utilities/math/polyline/getNormal2.d.ts.map +1 -0
  390. package/dist/types/utilities/math/polyline/getNormal3.d.ts +3 -0
  391. package/dist/types/utilities/math/polyline/getNormal3.d.ts.map +1 -0
  392. package/dist/types/utilities/math/polyline/getSignedArea.d.ts +3 -0
  393. package/dist/types/utilities/math/polyline/getSignedArea.d.ts.map +1 -0
  394. package/dist/types/utilities/math/polyline/index.d.ts +14 -3
  395. package/dist/types/utilities/math/polyline/index.d.ts.map +1 -1
  396. package/dist/types/utilities/math/polyline/intersectPolyline.d.ts +3 -0
  397. package/dist/types/utilities/math/polyline/intersectPolyline.d.ts.map +1 -0
  398. package/dist/types/utilities/math/polyline/isClosed.d.ts +3 -0
  399. package/dist/types/utilities/math/polyline/isClosed.d.ts.map +1 -0
  400. package/dist/umd/index.js +1 -2
  401. package/dist/umd/index.js.map +1 -1
  402. package/package.json +3 -3
  403. package/src/eventListeners/annotations/annotationCompletedListener.ts +13 -0
  404. package/src/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.ts +273 -0
  405. package/src/eventListeners/annotations/contourSegmentation/index.ts +1 -0
  406. package/src/eventListeners/annotations/index.ts +6 -1
  407. package/src/eventListeners/index.ts +2 -0
  408. package/src/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.ts +117 -0
  409. package/src/eventListeners/segmentation/segmentationDataModifiedEventListener.ts +5 -99
  410. package/src/init.ts +12 -1
  411. package/src/stateManagement/annotation/helpers/state.ts +42 -2
  412. package/src/store/ToolGroupManager/ToolGroup.ts +10 -0
  413. package/src/store/addTool.ts +11 -0
  414. package/src/store/index.ts +2 -1
  415. package/src/store/removeEnabledElement.ts +2 -1
  416. package/src/tools/AdvancedMagnifyTool.ts +4 -21
  417. package/src/tools/annotation/AngleTool.ts +8 -32
  418. package/src/tools/annotation/ArrowAnnotateTool.ts +12 -45
  419. package/src/tools/annotation/BidirectionalTool.ts +11 -39
  420. package/src/tools/annotation/CircleROITool.ts +10 -34
  421. package/src/tools/annotation/CobbAngleTool.ts +9 -32
  422. package/src/tools/annotation/EllipticalROITool.ts +10 -34
  423. package/src/tools/annotation/KeyImageTool.ts +9 -23
  424. package/src/tools/annotation/LengthTool.ts +9 -33
  425. package/src/tools/annotation/LivewireContourTool.ts +58 -33
  426. package/src/tools/annotation/PlanarFreehandContourSegmentationTool.ts +22 -1
  427. package/src/tools/annotation/PlanarFreehandROITool.ts +10 -53
  428. package/src/tools/annotation/ProbeTool.ts +11 -36
  429. package/src/tools/annotation/RectangleROITool.ts +11 -33
  430. package/src/tools/annotation/SplineROITool.ts +53 -24
  431. package/src/tools/annotation/UltrasoundDirectionalTool.ts +8 -29
  432. package/src/tools/annotation/planarFreehandROITool/closedContourEditLoop.ts +9 -11
  433. package/src/tools/annotation/planarFreehandROITool/drawLoop.ts +8 -5
  434. package/src/tools/annotation/planarFreehandROITool/editLoopCommon.ts +9 -8
  435. package/src/tools/annotation/planarFreehandROITool/openContourEditLoop.ts +7 -6
  436. package/src/tools/base/ContourBaseTool.ts +5 -8
  437. package/src/tools/base/ContourSegmentationBaseTool.ts +29 -6
  438. package/src/tools/segmentation/RectangleROIStartEndThresholdTool.ts +3 -13
  439. package/src/tools/segmentation/RectangleROIThresholdTool.ts +3 -14
  440. package/src/types/AnnotationRenderContext.ts +13 -0
  441. package/src/types/IToolGroup.ts +3 -1
  442. package/src/types/index.ts +3 -0
  443. package/src/utilities/contourSegmentation/areSameSegment.ts +24 -0
  444. package/src/utilities/contourSegmentation/index.ts +2 -0
  445. package/src/utilities/contourSegmentation/isContourSegmentationAnnotation.ts +8 -0
  446. package/src/utilities/contours/areCoplanarContours.ts +39 -0
  447. package/src/utilities/contours/index.ts +2 -0
  448. package/src/utilities/contours/reverseIfAntiClockwise.ts +6 -25
  449. package/src/utilities/math/aabb/index.ts +1 -0
  450. package/src/utilities/math/aabb/intersectAABB.ts +19 -0
  451. package/src/utilities/math/point/distanceToPointSquared.ts +6 -1
  452. package/src/utilities/math/polyline/areLineSegmentsIntersecting.ts +118 -0
  453. package/src/utilities/math/polyline/combinePolyline.ts +350 -0
  454. package/src/utilities/math/polyline/containsPoint.ts +63 -0
  455. package/src/utilities/math/polyline/getAABB.ts +20 -0
  456. package/src/utilities/math/polyline/{calculateAreaOfPoints.ts → getArea.ts} +1 -1
  457. package/src/utilities/math/polyline/getClosestLineSegmentIntersection.ts +72 -0
  458. package/src/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.ts +42 -0
  459. package/src/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.ts +30 -0
  460. package/src/utilities/math/polyline/getLineSegmentIntersectionsIndexes.ts +35 -0
  461. package/src/utilities/math/polyline/getLineSegmentsIntersection.ts +47 -0
  462. package/src/utilities/math/polyline/getNormal2.ts +17 -0
  463. package/src/utilities/math/polyline/getNormal3.ts +53 -0
  464. package/src/utilities/math/polyline/getSignedArea.ts +47 -0
  465. package/src/utilities/math/polyline/index.ts +27 -8
  466. package/src/utilities/math/polyline/intersectPolyline.ts +34 -0
  467. package/src/utilities/math/polyline/isClosed.ts +26 -0
  468. package/dist/cjs/utilities/math/polyline/calculateAreaOfPoints.d.ts +0 -2
  469. package/dist/cjs/utilities/math/polyline/calculateAreaOfPoints.js.map +0 -1
  470. package/dist/cjs/utilities/math/polyline/getIntersectionWithPolyline.d.ts +0 -9
  471. package/dist/cjs/utilities/math/polyline/getIntersectionWithPolyline.js +0 -160
  472. package/dist/cjs/utilities/math/polyline/getIntersectionWithPolyline.js.map +0 -1
  473. package/dist/cjs/utilities/math/polyline/pointInPolyline.d.ts +0 -2
  474. package/dist/cjs/utilities/math/polyline/pointInPolyline.js +0 -15
  475. package/dist/cjs/utilities/math/polyline/pointInPolyline.js.map +0 -1
  476. package/dist/esm/utilities/math/polyline/calculateAreaOfPoints.js.map +0 -1
  477. package/dist/esm/utilities/math/polyline/getIntersectionWithPolyline.js +0 -154
  478. package/dist/esm/utilities/math/polyline/getIntersectionWithPolyline.js.map +0 -1
  479. package/dist/esm/utilities/math/polyline/pointInPolyline.js +0 -12
  480. package/dist/esm/utilities/math/polyline/pointInPolyline.js.map +0 -1
  481. package/dist/types/utilities/math/polyline/calculateAreaOfPoints.d.ts +0 -3
  482. package/dist/types/utilities/math/polyline/calculateAreaOfPoints.d.ts.map +0 -1
  483. package/dist/types/utilities/math/polyline/getIntersectionWithPolyline.d.ts +0 -10
  484. package/dist/types/utilities/math/polyline/getIntersectionWithPolyline.d.ts.map +0 -1
  485. package/dist/types/utilities/math/polyline/pointInPolyline.d.ts +0 -3
  486. package/dist/types/utilities/math/polyline/pointInPolyline.d.ts.map +0 -1
  487. package/dist/umd/index.js.LICENSE.txt +0 -6
  488. package/src/utilities/math/polyline/getIntersectionWithPolyline.ts +0 -275
  489. package/src/utilities/math/polyline/pointInPolyline.ts +0 -19
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const gl_matrix_1 = require("gl-matrix");
7
+ const areLineSegmentsIntersecting_1 = __importDefault(require("./areLineSegmentsIntersecting"));
8
+ function getClosestLineSegmentIntersection(points, p1, q1, closed = true) {
9
+ let initialQ2Index;
10
+ let p2Index;
11
+ if (closed) {
12
+ p2Index = points.length - 1;
13
+ initialQ2Index = 0;
14
+ }
15
+ else {
16
+ p2Index = 0;
17
+ initialQ2Index = 1;
18
+ }
19
+ const intersections = [];
20
+ for (let q2Index = initialQ2Index; q2Index < points.length; q2Index++) {
21
+ const p2 = points[p2Index];
22
+ const q2 = points[q2Index];
23
+ if ((0, areLineSegmentsIntersecting_1.default)(p1, q1, p2, q2)) {
24
+ intersections.push([p2Index, q2Index]);
25
+ }
26
+ p2Index = q2Index;
27
+ }
28
+ if (intersections.length === 0) {
29
+ return;
30
+ }
31
+ const distances = [];
32
+ intersections.forEach((intersection) => {
33
+ const intersectionPoints = [
34
+ points[intersection[0]],
35
+ points[intersection[1]],
36
+ ];
37
+ const midpoint = [
38
+ (intersectionPoints[0][0] + intersectionPoints[1][0]) / 2,
39
+ (intersectionPoints[0][1] + intersectionPoints[1][1]) / 2,
40
+ ];
41
+ distances.push(gl_matrix_1.vec2.distance(midpoint, p1));
42
+ });
43
+ const minDistance = Math.min(...distances);
44
+ const indexOfMinDistance = distances.indexOf(minDistance);
45
+ return {
46
+ segment: intersections[indexOfMinDistance],
47
+ distance: minDistance,
48
+ };
49
+ }
50
+ exports.default = getClosestLineSegmentIntersection;
51
+ //# sourceMappingURL=getClosestLineSegmentIntersection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getClosestLineSegmentIntersection.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/getClosestLineSegmentIntersection.ts"],"names":[],"mappings":";;;;;AAAA,yCAAiC;AAEjC,gGAAwE;AAWxE,SAAwB,iCAAiC,CACvD,MAAsB,EACtB,EAAgB,EAChB,EAA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C,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;SAC1D,CAAC;QAEF,SAAS,CAAC,IAAI,CAAC,gBAAI,CAAC,QAAQ,CAAO,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC;IAC3C,MAAM,kBAAkB,GAAG,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAE1D,OAAO;QACL,OAAO,EAAE,aAAa,CAAC,kBAAkB,CAAC;QAC1C,QAAQ,EAAE,WAAW;KACtB,CAAC;AACJ,CAAC;AA1DD,oDA0DC"}
@@ -0,0 +1,2 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ export default function getFirstLineSegmentIntersectionIndexes(points: Types.Point2[], p1: Types.Point2, q1: Types.Point2, closed?: boolean): Types.Point2 | undefined;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const areLineSegmentsIntersecting_1 = __importDefault(require("./areLineSegmentsIntersecting"));
7
+ function getFirstLineSegmentIntersectionIndexes(points, p1, q1, closed = true) {
8
+ let initialI;
9
+ let j;
10
+ if (closed) {
11
+ j = points.length - 1;
12
+ initialI = 0;
13
+ }
14
+ else {
15
+ j = 0;
16
+ initialI = 1;
17
+ }
18
+ for (let i = initialI; i < points.length; i++) {
19
+ const p2 = points[j];
20
+ const q2 = points[i];
21
+ if ((0, areLineSegmentsIntersecting_1.default)(p1, q1, p2, q2)) {
22
+ return [j, i];
23
+ }
24
+ j = i;
25
+ }
26
+ }
27
+ exports.default = getFirstLineSegmentIntersectionIndexes;
28
+ //# sourceMappingURL=getFirstLineSegmentIntersectionIndexes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFirstLineSegmentIntersectionIndexes.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.ts"],"names":[],"mappings":";;;;;AACA,gGAAwE;AAaxE,SAAwB,sCAAsC,CAC5D,MAAsB,EACtB,EAAgB,EAChB,EAAgB,EAChB,MAAM,GAAG,IAAI;IAEb,IAAI,QAAQ,CAAC;IACb,IAAI,CAAC,CAAC;IAEN,IAAI,MAAM,EAAE;QACV,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACtB,QAAQ,GAAG,CAAC,CAAC;KACd;SAAM;QACL,CAAC,GAAG,CAAC,CAAC;QACN,QAAQ,GAAG,CAAC,CAAC;KACd;IAED,KAAK,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC7C,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QAErB,IAAI,IAAA,qCAA2B,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE;YAC/C,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACf;QAED,CAAC,GAAG,CAAC,CAAC;KACP;AACH,CAAC;AA3BD,yDA2BC"}
@@ -0,0 +1,2 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ export default function getLineSegmentIntersectionsCoordinates(points: Types.Point2[], p1: Types.Point2, q1: Types.Point2, closed?: boolean): Types.Point2[];
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const getLineSegmentIntersectionsIndexes_1 = __importDefault(require("./getLineSegmentIntersectionsIndexes"));
7
+ const getLineSegmentsIntersection_1 = __importDefault(require("./getLineSegmentsIntersection"));
8
+ function getLineSegmentIntersectionsCoordinates(points, p1, q1, closed = true) {
9
+ const result = [];
10
+ const polylineIndexes = (0, getLineSegmentIntersectionsIndexes_1.default)(points, p1, q1, closed);
11
+ for (let i = 0; i < polylineIndexes.length; i++) {
12
+ const p2 = points[polylineIndexes[i][0]];
13
+ const q2 = points[polylineIndexes[i][1]];
14
+ const intersection = (0, getLineSegmentsIntersection_1.default)(p1, q1, p2, q2);
15
+ result.push(intersection);
16
+ }
17
+ return result;
18
+ }
19
+ exports.default = getLineSegmentIntersectionsCoordinates;
20
+ //# sourceMappingURL=getLineSegmentIntersectionsCoordinates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLineSegmentIntersectionsCoordinates.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.ts"],"names":[],"mappings":";;;;;AACA,8GAAsF;AACtF,gGAAwE;AAKxE,SAAwB,sCAAsC,CAC5D,MAAsB,EACtB,EAAgB,EAChB,EAAgB,EAChB,MAAM,GAAG,IAAI;IAEb,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,MAAM,eAAe,GAAG,IAAA,4CAAkC,EACxD,MAAM,EACN,EAAE,EACF,EAAE,EACF,MAAM,CACP,CAAC;IAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/C,MAAM,EAAE,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,MAAM,EAAE,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,MAAM,YAAY,GAAG,IAAA,qCAA2B,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QACjE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;KAC3B;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAtBD,yDAsBC"}
@@ -0,0 +1,2 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ export default function getLineSegmentIntersectionsIndexes(polyline: Types.Point2[], p1: Types.Point2, q1: Types.Point2, closed?: boolean): Types.Point2[];
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const areLineSegmentsIntersecting_1 = __importDefault(require("./areLineSegmentsIntersecting"));
7
+ function getLineSegmentIntersectionsIndexes(polyline, p1, q1, closed = true) {
8
+ const intersections = [];
9
+ const numPoints = polyline.length;
10
+ const maxI = numPoints - (closed ? 1 : 2);
11
+ for (let i = 0; i <= maxI; i++) {
12
+ const p2 = polyline[i];
13
+ const j = i === numPoints - 1 ? 0 : i + 1;
14
+ const q2 = polyline[j];
15
+ if ((0, areLineSegmentsIntersecting_1.default)(p1, q1, p2, q2)) {
16
+ intersections.push([i, j]);
17
+ }
18
+ }
19
+ return intersections;
20
+ }
21
+ exports.default = getLineSegmentIntersectionsIndexes;
22
+ //# sourceMappingURL=getLineSegmentIntersectionsIndexes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLineSegmentIntersectionsIndexes.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/getLineSegmentIntersectionsIndexes.ts"],"names":[],"mappings":";;;;;AACA,gGAAwE;AAWxE,SAAwB,kCAAkC,CACxD,QAAwB,EACxB,EAAgB,EAChB,EAAgB,EAChB,MAAM,GAAG,IAAI;IAEb,MAAM,aAAa,GAAmB,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC;IAClC,MAAM,IAAI,GAAG,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,EAAE;QAC9B,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEvB,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEvB,IAAI,IAAA,qCAA2B,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE;YAC/C,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAC5B;KACF;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAtBD,qDAsBC"}
@@ -0,0 +1,2 @@
1
+ import { Types } from '@cornerstonejs/core';
2
+ export default function getLineSegmentsIntersection(p1: Types.Point2, q1: Types.Point2, p2: Types.Point2, q2: Types.Point2): Types.Point2;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function getLineSegmentsIntersection(p1, q1, p2, q2) {
4
+ const diffQ1P1 = [q1[0] - p1[0], q1[1] - p1[1]];
5
+ const diffQ2P2 = [q2[0] - p2[0], q2[1] - p2[1]];
6
+ const denominator = diffQ2P2[1] * diffQ1P1[0] - diffQ2P2[0] * diffQ1P1[1];
7
+ if (denominator == 0) {
8
+ return;
9
+ }
10
+ let a = p1[1] - p2[1];
11
+ let b = p1[0] - p2[0];
12
+ const numerator1 = diffQ2P2[0] * a - diffQ2P2[1] * b;
13
+ const numerator2 = diffQ1P1[0] * a - diffQ1P1[1] * b;
14
+ a = numerator1 / denominator;
15
+ b = numerator2 / denominator;
16
+ const resultX = p1[0] + a * diffQ1P1[0];
17
+ const resultY = p1[1] + a * diffQ1P1[1];
18
+ return [resultX, resultY];
19
+ }
20
+ exports.default = getLineSegmentsIntersection;
21
+ //# sourceMappingURL=getLineSegmentsIntersection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLineSegmentsIntersection.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/getLineSegmentsIntersection.ts"],"names":[],"mappings":";;AAqBA,SAAwB,2BAA2B,CACjD,EAAgB,EAChB,EAAgB,EAChB,EAAgB,EAChB,EAAgB;IAEhB,MAAM,QAAQ,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE1E,IAAI,WAAW,IAAI,CAAC,EAAE;QACpB,OAAO;KACR;IAED,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACrD,CAAC,GAAG,UAAU,GAAG,WAAW,CAAC;IAC7B,CAAC,GAAG,UAAU,GAAG,WAAW,CAAC;IAE7B,MAAM,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAExC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC;AAzBD,8CAyBC"}
@@ -0,0 +1,2 @@
1
+ import { Types } from '@cornerstonejs/core';
2
+ export default function getNormal2(polyline: Types.Point2[]): Types.Point3;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const getSignedArea_1 = __importDefault(require("./getSignedArea"));
7
+ function getNormal2(polyline) {
8
+ const area = (0, getSignedArea_1.default)(polyline);
9
+ return [0, 0, area / Math.abs(area)];
10
+ }
11
+ exports.default = getNormal2;
12
+ //# sourceMappingURL=getNormal2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNormal2.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/getNormal2.ts"],"names":[],"mappings":";;;;;AACA,oEAA4C;AAS5C,SAAwB,UAAU,CAAC,QAAwB;IACzD,MAAM,IAAI,GAAG,IAAA,uBAAa,EAAC,QAAQ,CAAC,CAAC;IAIrC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAiB,CAAC;AACvD,CAAC;AAND,6BAMC"}
@@ -0,0 +1,2 @@
1
+ import { Types } from '@cornerstonejs/core';
2
+ export default function getNormal3(polyline: Types.Point3[]): Types.Point3;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const gl_matrix_1 = require("gl-matrix");
4
+ function _getAreaVector(polyline) {
5
+ const vecArea = gl_matrix_1.vec3.create();
6
+ const refPoint = polyline[0];
7
+ for (let i = 0, len = polyline.length; i < len; i++) {
8
+ const p1 = polyline[i];
9
+ const p2Index = i === len - 1 ? 0 : i + 1;
10
+ const p2 = polyline[p2Index];
11
+ const aX = p1[0] - refPoint[0];
12
+ const aY = p1[1] - refPoint[1];
13
+ const aZ = p1[2] - refPoint[2];
14
+ const bX = p2[0] - refPoint[0];
15
+ const bY = p2[1] - refPoint[1];
16
+ const bZ = p2[2] - refPoint[2];
17
+ vecArea[0] += aY * bZ - aZ * bY;
18
+ vecArea[1] += aZ * bX - aX * bZ;
19
+ vecArea[2] += aX * bY - aY * bX;
20
+ }
21
+ gl_matrix_1.vec3.scale(vecArea, vecArea, 0.5);
22
+ return vecArea;
23
+ }
24
+ function getNormal3(polyline) {
25
+ const vecArea = _getAreaVector(polyline);
26
+ return gl_matrix_1.vec3.normalize(vecArea, vecArea);
27
+ }
28
+ exports.default = getNormal3;
29
+ //# sourceMappingURL=getNormal3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNormal3.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/getNormal3.ts"],"names":[],"mappings":";;AAAA,yCAAiC;AAGjC,SAAS,cAAc,CAAC,QAAwB;IAC9C,MAAM,OAAO,GAAG,gBAAI,CAAC,MAAM,EAAE,CAAC;IAG9B,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAU7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QACnD,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEvB,MAAM,OAAO,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,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use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function getSignedArea(polyline) {
4
+ const refPoint = polyline[0];
5
+ let area = 0;
6
+ for (let i = 0, len = polyline.length; i < len; i++) {
7
+ const p1 = polyline[i];
8
+ const p2Index = i === len - 1 ? 0 : i + 1;
9
+ const p2 = polyline[p2Index];
10
+ const aX = p1[0] - refPoint[0];
11
+ const aY = p1[1] - refPoint[1];
12
+ const bX = p2[0] - refPoint[0];
13
+ const bY = p2[1] - refPoint[1];
14
+ area += aX * bY - aY * bX;
15
+ }
16
+ area *= 0.5;
17
+ return area;
18
+ }
19
+ exports.default = getSignedArea;
20
+ //# sourceMappingURL=getSignedArea.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSignedArea.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/getSignedArea.ts"],"names":[],"mappings":";;AAcA,SAAwB,aAAa,CAAC,QAAwB;IAE5D,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC7B,IAAI,IAAI,GAAG,CAAC,CAAC;IAUb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QACnD,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEvB,MAAM,OAAO,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC7B,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAI/B,IAAI,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;KAC3B;IAGD,IAAI,IAAI,GAAG,CAAC;IAEZ,OAAO,IAAI,CAAC;AACd,CAAC;AAhCD,gCAgCC"}
@@ -1,7 +1,18 @@
1
- import { getFirstIntersectionWithPolyline, getClosestIntersectionWithPolyline } from './getIntersectionWithPolyline';
1
+ import isClosed from './isClosed';
2
+ import containsPoint from './containsPoint';
3
+ import getAABB from './getAABB';
4
+ import getArea from './getArea';
5
+ import getSignedArea from './getSignedArea';
6
+ import getNormal3 from './getNormal3';
7
+ import getNormal2 from './getNormal2';
8
+ import { mergePolylines, subtractPolylines } from './combinePolyline';
9
+ import intersectPolyline from './intersectPolyline';
10
+ import getFirstLineSegmentIntersectionIndexes from './getFirstLineSegmentIntersectionIndexes';
11
+ import getLineSegmentIntersectionsIndexes from './getLineSegmentIntersectionsIndexes';
12
+ import getLineSegmentIntersectionsCoordinates from './getLineSegmentIntersectionsCoordinates';
13
+ import getClosestLineSegmentIntersection from './getClosestLineSegmentIntersection';
2
14
  import getSubPixelSpacingAndXYDirections from './getSubPixelSpacingAndXYDirections';
3
15
  import pointsAreWithinCloseContourProximity from './pointsAreWithinCloseContourProximity';
4
16
  import addCanvasPointsToArray from './addCanvasPointsToArray';
5
17
  import pointCanProjectOnLine from './pointCanProjectOnLine';
6
- import calculateAreaOfPoints from './calculateAreaOfPoints';
7
- export { getFirstIntersectionWithPolyline, getClosestIntersectionWithPolyline, getSubPixelSpacingAndXYDirections, pointsAreWithinCloseContourProximity, addCanvasPointsToArray, pointCanProjectOnLine, calculateAreaOfPoints, };
18
+ export { isClosed, containsPoint, getAABB, getArea, getSignedArea, getNormal3, getNormal2, intersectPolyline, getFirstLineSegmentIntersectionIndexes, getLineSegmentIntersectionsIndexes, getLineSegmentIntersectionsCoordinates, getClosestLineSegmentIntersection, getSubPixelSpacingAndXYDirections, pointsAreWithinCloseContourProximity, addCanvasPointsToArray, pointCanProjectOnLine, mergePolylines, subtractPolylines, };
@@ -3,10 +3,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.calculateAreaOfPoints = exports.pointCanProjectOnLine = exports.addCanvasPointsToArray = exports.pointsAreWithinCloseContourProximity = exports.getSubPixelSpacingAndXYDirections = exports.getClosestIntersectionWithPolyline = exports.getFirstIntersectionWithPolyline = void 0;
7
- const getIntersectionWithPolyline_1 = require("./getIntersectionWithPolyline");
8
- Object.defineProperty(exports, "getFirstIntersectionWithPolyline", { enumerable: true, get: function () { return getIntersectionWithPolyline_1.getFirstIntersectionWithPolyline; } });
9
- Object.defineProperty(exports, "getClosestIntersectionWithPolyline", { enumerable: true, get: function () { return getIntersectionWithPolyline_1.getClosestIntersectionWithPolyline; } });
6
+ exports.subtractPolylines = exports.mergePolylines = exports.pointCanProjectOnLine = exports.addCanvasPointsToArray = exports.pointsAreWithinCloseContourProximity = exports.getSubPixelSpacingAndXYDirections = exports.getClosestLineSegmentIntersection = exports.getLineSegmentIntersectionsCoordinates = exports.getLineSegmentIntersectionsIndexes = exports.getFirstLineSegmentIntersectionIndexes = exports.intersectPolyline = exports.getNormal2 = exports.getNormal3 = exports.getSignedArea = exports.getArea = exports.getAABB = exports.containsPoint = exports.isClosed = void 0;
7
+ const isClosed_1 = __importDefault(require("./isClosed"));
8
+ exports.isClosed = isClosed_1.default;
9
+ const containsPoint_1 = __importDefault(require("./containsPoint"));
10
+ exports.containsPoint = containsPoint_1.default;
11
+ const getAABB_1 = __importDefault(require("./getAABB"));
12
+ exports.getAABB = getAABB_1.default;
13
+ const getArea_1 = __importDefault(require("./getArea"));
14
+ exports.getArea = getArea_1.default;
15
+ const getSignedArea_1 = __importDefault(require("./getSignedArea"));
16
+ exports.getSignedArea = getSignedArea_1.default;
17
+ const getNormal3_1 = __importDefault(require("./getNormal3"));
18
+ exports.getNormal3 = getNormal3_1.default;
19
+ const getNormal2_1 = __importDefault(require("./getNormal2"));
20
+ exports.getNormal2 = getNormal2_1.default;
21
+ const combinePolyline_1 = require("./combinePolyline");
22
+ Object.defineProperty(exports, "mergePolylines", { enumerable: true, get: function () { return combinePolyline_1.mergePolylines; } });
23
+ Object.defineProperty(exports, "subtractPolylines", { enumerable: true, get: function () { return combinePolyline_1.subtractPolylines; } });
24
+ const intersectPolyline_1 = __importDefault(require("./intersectPolyline"));
25
+ exports.intersectPolyline = intersectPolyline_1.default;
26
+ const getFirstLineSegmentIntersectionIndexes_1 = __importDefault(require("./getFirstLineSegmentIntersectionIndexes"));
27
+ exports.getFirstLineSegmentIntersectionIndexes = getFirstLineSegmentIntersectionIndexes_1.default;
28
+ const getLineSegmentIntersectionsIndexes_1 = __importDefault(require("./getLineSegmentIntersectionsIndexes"));
29
+ exports.getLineSegmentIntersectionsIndexes = getLineSegmentIntersectionsIndexes_1.default;
30
+ const getLineSegmentIntersectionsCoordinates_1 = __importDefault(require("./getLineSegmentIntersectionsCoordinates"));
31
+ exports.getLineSegmentIntersectionsCoordinates = getLineSegmentIntersectionsCoordinates_1.default;
32
+ const getClosestLineSegmentIntersection_1 = __importDefault(require("./getClosestLineSegmentIntersection"));
33
+ exports.getClosestLineSegmentIntersection = getClosestLineSegmentIntersection_1.default;
10
34
  const getSubPixelSpacingAndXYDirections_1 = __importDefault(require("./getSubPixelSpacingAndXYDirections"));
11
35
  exports.getSubPixelSpacingAndXYDirections = getSubPixelSpacingAndXYDirections_1.default;
12
36
  const pointsAreWithinCloseContourProximity_1 = __importDefault(require("./pointsAreWithinCloseContourProximity"));
@@ -15,6 +39,4 @@ const addCanvasPointsToArray_1 = __importDefault(require("./addCanvasPointsToArr
15
39
  exports.addCanvasPointsToArray = addCanvasPointsToArray_1.default;
16
40
  const pointCanProjectOnLine_1 = __importDefault(require("./pointCanProjectOnLine"));
17
41
  exports.pointCanProjectOnLine = pointCanProjectOnLine_1.default;
18
- const calculateAreaOfPoints_1 = __importDefault(require("./calculateAreaOfPoints"));
19
- exports.calculateAreaOfPoints = calculateAreaOfPoints_1.default;
20
42
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/index.ts"],"names":[],"mappings":";;;;;;AAAA,+EAGuC;AAQrC,iHAVA,8DAAgC,OAUA;AAChC,mHAVA,gEAAkC,OAUA;AARpC,4GAAoF;AASlF,4CATK,2CAAiC,CASL;AARnC,kHAA0F;AASxF,+CATK,8CAAoC,CASL;AARtC,sFAA8D;AAS5D,iCATK,gCAAsB,CASL;AARxB,oFAA4D;AAS1D,gCATK,+BAAqB,CASL;AARvB,oFAA4D;AAS1D,gCATK,+BAAqB,CASL"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/index.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAkC;AAmBhC,mBAnBK,kBAAQ,CAmBL;AAlBV,oEAA4C;AAmB1C,wBAnBK,uBAAa,CAmBL;AAlBf,wDAAgC;AAmB9B,kBAnBK,iBAAO,CAmBL;AAlBT,wDAAgC;AAmB9B,kBAnBK,iBAAO,CAmBL;AAlBT,oEAA4C;AAmB1C,wBAnBK,uBAAa,CAmBL;AAlBf,8DAAsC;AAmBpC,qBAnBK,oBAAU,CAmBL;AAlBZ,8DAAsC;AAmBpC,qBAnBK,oBAAU,CAmBL;AAlBZ,uDAAsE;AA4BpE,+FA5BO,gCAAc,OA4BP;AACd,kGA7BuB,mCAAiB,OA6BvB;AA5BnB,4EAAoD;AAkBlD,4BAlBK,2BAAiB,CAkBL;AAjBnB,sHAA8F;AAkB5F,iDAlBK,gDAAsC,CAkBL;AAjBxC,8GAAsF;AAkBpF,6CAlBK,4CAAkC,CAkBL;AAjBpC,sHAA8F;AAkB5F,iDAlBK,gDAAsC,CAkBL;AAjBxC,4GAAoF;AAkBlF,4CAlBK,2CAAiC,CAkBL;AAjBnC,4GAAoF;AAkBlF,4CAlBK,2CAAiC,CAkBL;AAjBnC,kHAA0F;AAkBxF,+CAlBK,8CAAoC,CAkBL;AAjBtC,sFAA8D;AAkB5D,iCAlBK,gCAAsB,CAkBL;AAjBxB,oFAA4D;AAkB1D,gCAlBK,+BAAqB,CAkBL"}
@@ -0,0 +1,2 @@
1
+ import { Types } from '@cornerstonejs/core';
2
+ export default function intersectPolyline(sourcePolyline: Types.Point2[], targetPolyline: Types.Point2[]): boolean;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const getFirstLineSegmentIntersectionIndexes_1 = __importDefault(require("./getFirstLineSegmentIntersectionIndexes"));
7
+ function intersectPolyline(sourcePolyline, targetPolyline) {
8
+ for (let i = 0, sourceLen = sourcePolyline.length; i < sourceLen; i++) {
9
+ const sourceP1 = sourcePolyline[i];
10
+ const sourceP2Index = i === sourceLen - 1 ? 0 : i + 1;
11
+ const sourceP2 = sourcePolyline[sourceP2Index];
12
+ const intersectionPointIndexes = (0, getFirstLineSegmentIntersectionIndexes_1.default)(targetPolyline, sourceP1, sourceP2);
13
+ if ((intersectionPointIndexes === null || intersectionPointIndexes === void 0 ? void 0 : intersectionPointIndexes.length) === 2) {
14
+ return true;
15
+ }
16
+ }
17
+ return false;
18
+ }
19
+ exports.default = intersectPolyline;
20
+ //# sourceMappingURL=intersectPolyline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intersectPolyline.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/intersectPolyline.ts"],"names":[],"mappings":";;;;;AACA,sHAA8F;AAQ9F,SAAwB,iBAAiB,CACvC,cAA8B,EAC9B,cAA8B;IAK9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE;QACrE,MAAM,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,aAAa,GAAG,CAAC,KAAK,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACtD,MAAM,QAAQ,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;QAE/C,MAAM,wBAAwB,GAAG,IAAA,gDAAsC,EACrE,cAAc,EACd,QAAQ,EACR,QAAQ,CACT,CAAC;QAEF,IAAI,CAAA,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CAAE,MAAM,MAAK,CAAC,EAAE;YAC1C,OAAO,IAAI,CAAC;SACb;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAxBD,oCAwBC"}
@@ -0,0 +1,2 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ export default function isClosed(polyline: Types.Point2[]): boolean;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const gl_matrix_1 = require("gl-matrix");
27
+ const math = __importStar(require(".."));
28
+ function isClosed(polyline) {
29
+ if (polyline.length < 3) {
30
+ return false;
31
+ }
32
+ const numPolylinePoints = polyline.length;
33
+ const firstPoint = polyline[0];
34
+ const lastPoint = polyline[numPolylinePoints - 1];
35
+ const distFirstToLastPoints = math.point.distanceToPointSquared(firstPoint, lastPoint);
36
+ return gl_matrix_1.glMatrix.equals(0, distFirstToLastPoints);
37
+ }
38
+ exports.default = isClosed;
39
+ //# sourceMappingURL=isClosed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isClosed.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/isClosed.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAqC;AAErC,yCAA2B;AAQ3B,SAAwB,QAAQ,CAAC,QAAwB;IACvD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,OAAO,KAAK,CAAC;KACd;IAED,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC;IAE1C,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,SAAS,GAAG,QAAQ,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAC;IAClD,MAAM,qBAAqB,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAC7D,UAAU,EACV,SAAS,CACV,CAAC;IAEF,OAAO,oBAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;AACnD,CAAC;AAfD,2BAeC"}
@@ -0,0 +1,9 @@
1
+ import * as contourSegUtils from '../../utilities/contourSegmentation';
2
+ import { contourSegmentationCompleted } from './contourSegmentation';
3
+ export default function annotationCompletedListener(evt) {
4
+ const annotation = evt.detail.annotation;
5
+ if (contourSegUtils.isContourSegmentationAnnotation(annotation)) {
6
+ contourSegmentationCompleted(evt);
7
+ }
8
+ }
9
+ //# sourceMappingURL=annotationCompletedListener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotationCompletedListener.js","sourceRoot":"","sources":["../../../../src/eventListeners/annotations/annotationCompletedListener.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,MAAM,CAAC,OAAO,UAAU,2BAA2B,CACjD,GAAiC;IAEjC,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC;IAEzC,IAAI,eAAe,CAAC,+BAA+B,CAAC,UAAU,CAAC,EAAE;QAC/D,4BAA4B,CAAC,GAAG,CAAC,CAAC;KACnC;AACH,CAAC"}
@@ -0,0 +1,153 @@
1
+ import { getEnabledElement, utilities as csUtils, } from '@cornerstonejs/core';
2
+ import { getViewportForAnnotation, math, triggerAnnotationRenderForViewportIds, } from '../../../utilities';
3
+ import { getViewportIdsWithToolToRender } from '../../../utilities/viewportFilters';
4
+ import { getAnnotations, addAnnotation, removeAnnotation, } from '../../../stateManagement/annotation/annotationState';
5
+ import * as contourUtils from '../../../utilities/contours';
6
+ import * as contourSegUtils from '../../../utilities/contourSegmentation';
7
+ import { ToolGroupManager, hasTool as cstHasTool } from '../../../store';
8
+ import { PlanarFreehandContourSegmentationTool } from '../../../tools';
9
+ const DEFAULT_CONTOUR_SEG_TOOLNAME = 'PlanarFreehandContourSegmentationTool';
10
+ export default function contourSegmentationCompletedListener(evt) {
11
+ const sourceAnnotation = evt.detail
12
+ .annotation;
13
+ if (!contourSegUtils.isContourSegmentationAnnotation(sourceAnnotation)) {
14
+ return;
15
+ }
16
+ const viewport = getViewportForAnnotation(sourceAnnotation);
17
+ const contourSegmentationAnnotations = getValidContourSegmentationAnnotations(sourceAnnotation);
18
+ if (!contourSegmentationAnnotations.length) {
19
+ return;
20
+ }
21
+ const sourcePolyline = convertContourPolylineToCanvasSpace(sourceAnnotation.data.contour.polyline, viewport);
22
+ const targetAnnotationInfo = findIntersectingContour(viewport, sourcePolyline, contourSegmentationAnnotations);
23
+ if (!targetAnnotationInfo) {
24
+ return;
25
+ }
26
+ if (!isFreehandContourSegToolRegistered(viewport)) {
27
+ return;
28
+ }
29
+ const { targetAnnotation, targetPolyline } = targetAnnotationInfo;
30
+ processContours(viewport, sourceAnnotation, sourcePolyline, targetAnnotation, targetPolyline);
31
+ }
32
+ function isFreehandContourSegToolRegistered(viewport) {
33
+ const { toolName } = PlanarFreehandContourSegmentationTool;
34
+ if (!cstHasTool(PlanarFreehandContourSegmentationTool)) {
35
+ console.warn(`${toolName} is not registered in cornerstone`);
36
+ return false;
37
+ }
38
+ const toolGroup = ToolGroupManager.getToolGroupForViewport(viewport.id, viewport.renderingEngineId);
39
+ if (!toolGroup.hasTool(toolName)) {
40
+ console.warn(`Tool ${toolName} not added to ${toolGroup.id} toolGroup`);
41
+ return false;
42
+ }
43
+ if (!toolGroup.getToolOptions(toolName)) {
44
+ console.warn(`Tool ${toolName} must be in active/passive state`);
45
+ return false;
46
+ }
47
+ return true;
48
+ }
49
+ function convertContourPolylineToCanvasSpace(polyline, viewport) {
50
+ const numPoints = polyline.length;
51
+ const projectedPolyline = new Array(numPoints);
52
+ for (let i = 0; i < numPoints; i++) {
53
+ projectedPolyline[i] = viewport.worldToCanvas(polyline[i]);
54
+ }
55
+ return projectedPolyline;
56
+ }
57
+ function convertPolylineToWorldSpace(polyline, viewport) {
58
+ const numPoints = polyline.length;
59
+ const projectedPolyline = new Array(numPoints);
60
+ for (let i = 0; i < numPoints; i++) {
61
+ projectedPolyline[i] = viewport.canvasToWorld(polyline[i]);
62
+ }
63
+ return projectedPolyline;
64
+ }
65
+ function getValidContourSegmentationAnnotations(sourceAnnotation) {
66
+ const { annotationUID: sourceAnnotationUID } = sourceAnnotation;
67
+ const { FrameOfReferenceUID } = sourceAnnotation.metadata;
68
+ const toolName = undefined;
69
+ const annotationsGroups = getAnnotations(toolName, FrameOfReferenceUID);
70
+ const toolNames = Object.keys(annotationsGroups);
71
+ return toolNames.reduce((validAnnotations, toolName) => {
72
+ const toolAnnotations = annotationsGroups[toolName].filter((targetAnnotation) => targetAnnotation.annotationUID &&
73
+ targetAnnotation.annotationUID !== sourceAnnotationUID &&
74
+ contourSegUtils.isContourSegmentationAnnotation(targetAnnotation) &&
75
+ contourSegUtils.areSameSegment(targetAnnotation, sourceAnnotation) &&
76
+ contourUtils.areCoplanarContours(targetAnnotation, sourceAnnotation));
77
+ return validAnnotations.concat(toolAnnotations);
78
+ }, []);
79
+ }
80
+ function findIntersectingContour(viewport, sourcePolyline, contourSegmentationAnnotations) {
81
+ const sourceAABB = math.polyline.getAABB(sourcePolyline);
82
+ for (let i = 0; i < contourSegmentationAnnotations.length; i++) {
83
+ const targetAnnotation = contourSegmentationAnnotations[i];
84
+ const targetPolyline = convertContourPolylineToCanvasSpace(targetAnnotation.data.contour.polyline, viewport);
85
+ const targetAABB = math.polyline.getAABB(targetPolyline);
86
+ const polylinesIntersect = math.aabb.intersectAABB(sourceAABB, targetAABB) &&
87
+ math.polyline.intersectPolyline(sourcePolyline, targetPolyline);
88
+ if (polylinesIntersect) {
89
+ return { targetAnnotation, targetPolyline };
90
+ }
91
+ }
92
+ }
93
+ function processContours(viewport, sourceAnnotation, sourcePolyline, targetAnnotation, targetPolyline) {
94
+ const sourceStartPoint = sourcePolyline[0];
95
+ const mergePolylines = math.polyline.containsPoint(targetPolyline, sourceStartPoint);
96
+ const newPolylines = [];
97
+ if (mergePolylines) {
98
+ const mergedPolyline = math.polyline.mergePolylines(targetPolyline, sourcePolyline);
99
+ newPolylines.push(mergedPolyline);
100
+ }
101
+ else {
102
+ const subtractedPolylines = math.polyline.subtractPolylines(targetPolyline, sourcePolyline);
103
+ subtractedPolylines.forEach((newPolyline) => newPolylines.push(newPolyline));
104
+ }
105
+ removeAnnotation(sourceAnnotation.annotationUID);
106
+ removeAnnotation(targetAnnotation.annotationUID);
107
+ const { element } = viewport;
108
+ const enabledElement = getEnabledElement(element);
109
+ const { renderingEngine } = enabledElement;
110
+ const { metadata, data } = targetAnnotation;
111
+ const { handles, segmentation } = data;
112
+ const { textBox } = handles;
113
+ for (let i = 0; i < newPolylines.length; i++) {
114
+ const polyline = convertPolylineToWorldSpace(newPolylines[i], viewport);
115
+ const startPoint = polyline[0];
116
+ const endPoint = polyline[polyline.length - 1];
117
+ const newAnnotation = {
118
+ metadata: {
119
+ ...metadata,
120
+ toolName: DEFAULT_CONTOUR_SEG_TOOLNAME,
121
+ },
122
+ data: {
123
+ cachedStats: {},
124
+ handles: {
125
+ points: [startPoint, endPoint],
126
+ textBox: textBox ? { ...textBox } : undefined,
127
+ },
128
+ contour: {
129
+ polyline,
130
+ closed: true,
131
+ },
132
+ segmentation: {
133
+ ...segmentation,
134
+ },
135
+ },
136
+ annotationUID: csUtils.uuidv4(),
137
+ highlighted: true,
138
+ invalidated: true,
139
+ isLocked: false,
140
+ isVisible: undefined,
141
+ };
142
+ addAnnotation(newAnnotation, element);
143
+ const updatedTtoolNames = new Set([
144
+ DEFAULT_CONTOUR_SEG_TOOLNAME,
145
+ targetAnnotation.metadata.toolName,
146
+ ]);
147
+ for (const toolName of updatedTtoolNames.values()) {
148
+ const viewportIdsToRender = getViewportIdsWithToolToRender(element, toolName);
149
+ triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
150
+ }
151
+ }
152
+ }
153
+ //# sourceMappingURL=contourSegmentationCompleted.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contourSegmentationCompleted.js","sourceRoot":"","sources":["../../../../../src/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.ts"],"names":[],"mappings":"AAAA,OAAO,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