@cornerstonejs/tools 1.40.3 → 1.42.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 (211) hide show
  1. package/dist/cjs/drawingSvg/drawHandle.d.ts +4 -0
  2. package/dist/cjs/drawingSvg/drawHandle.js +66 -0
  3. package/dist/cjs/drawingSvg/drawHandle.js.map +1 -0
  4. package/dist/cjs/drawingSvg/drawHandles.js +4 -60
  5. package/dist/cjs/drawingSvg/drawHandles.js.map +1 -1
  6. package/dist/cjs/drawingSvg/index.d.ts +2 -1
  7. package/dist/cjs/drawingSvg/index.js +3 -1
  8. package/dist/cjs/drawingSvg/index.js.map +1 -1
  9. package/dist/cjs/eventDispatchers/keyboardEventHandlers/keyDown.js +2 -1
  10. package/dist/cjs/eventDispatchers/keyboardEventHandlers/keyDown.js.map +1 -1
  11. package/dist/cjs/index.d.ts +2 -2
  12. package/dist/cjs/index.js +3 -2
  13. package/dist/cjs/index.js.map +1 -1
  14. package/dist/cjs/stateManagement/annotation/annotationState.js +3 -0
  15. package/dist/cjs/stateManagement/annotation/annotationState.js.map +1 -1
  16. package/dist/cjs/tools/annotation/AngleTool.js.map +1 -1
  17. package/dist/cjs/tools/annotation/BidirectionalTool.js +7 -6
  18. package/dist/cjs/tools/annotation/BidirectionalTool.js.map +1 -1
  19. package/dist/cjs/tools/annotation/LengthTool.js +4 -3
  20. package/dist/cjs/tools/annotation/LengthTool.js.map +1 -1
  21. package/dist/cjs/tools/annotation/ProbeTool.js +24 -3
  22. package/dist/cjs/tools/annotation/ProbeTool.js.map +1 -1
  23. package/dist/cjs/tools/annotation/UltrasoundDirectionalTool.d.ts +36 -0
  24. package/dist/cjs/tools/annotation/UltrasoundDirectionalTool.js +483 -0
  25. package/dist/cjs/tools/annotation/UltrasoundDirectionalTool.js.map +1 -0
  26. package/dist/cjs/tools/index.d.ts +2 -1
  27. package/dist/cjs/tools/index.js +3 -1
  28. package/dist/cjs/tools/index.js.map +1 -1
  29. package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +28 -0
  30. package/dist/cjs/types/index.d.ts +2 -1
  31. package/dist/cjs/utilities/contours/AnnotationToPointData.d.ts +11 -0
  32. package/dist/cjs/utilities/contours/AnnotationToPointData.js +44 -0
  33. package/dist/cjs/utilities/contours/AnnotationToPointData.js.map +1 -0
  34. package/dist/cjs/utilities/contours/RectangleROIStartEndThreshold.d.ts +6 -0
  35. package/dist/cjs/utilities/contours/RectangleROIStartEndThreshold.js +43 -0
  36. package/dist/cjs/utilities/contours/RectangleROIStartEndThreshold.js.map +1 -0
  37. package/dist/cjs/utilities/contours/contourFinder.d.ts +7 -0
  38. package/dist/cjs/utilities/contours/contourFinder.js +68 -0
  39. package/dist/cjs/utilities/contours/contourFinder.js.map +1 -0
  40. package/dist/cjs/utilities/contours/detectContourHoles.d.ts +5 -0
  41. package/dist/cjs/utilities/contours/detectContourHoles.js +78 -0
  42. package/dist/cjs/utilities/contours/detectContourHoles.js.map +1 -0
  43. package/dist/cjs/utilities/contours/generateContourSetsFromLabelmap.d.ts +4 -0
  44. package/dist/cjs/utilities/contours/generateContourSetsFromLabelmap.js +124 -0
  45. package/dist/cjs/utilities/contours/generateContourSetsFromLabelmap.js.map +1 -0
  46. package/dist/cjs/utilities/contours/index.d.ts +6 -0
  47. package/dist/cjs/utilities/contours/index.js +17 -0
  48. package/dist/cjs/utilities/contours/index.js.map +1 -0
  49. package/dist/cjs/utilities/contours/mergePoints.d.ts +8 -0
  50. package/dist/cjs/utilities/contours/mergePoints.js +77 -0
  51. package/dist/cjs/utilities/contours/mergePoints.js.map +1 -0
  52. package/dist/cjs/utilities/getCalibratedUnits.d.ts +16 -2
  53. package/dist/cjs/utilities/getCalibratedUnits.js +127 -5
  54. package/dist/cjs/utilities/getCalibratedUnits.js.map +1 -1
  55. package/dist/cjs/utilities/index.d.ts +2 -1
  56. package/dist/cjs/utilities/index.js +3 -1
  57. package/dist/cjs/utilities/index.js.map +1 -1
  58. package/dist/cjs/utilities/segmentation/contourAndFindLargestBidirectional.d.ts +1 -0
  59. package/dist/cjs/utilities/segmentation/contourAndFindLargestBidirectional.js +31 -0
  60. package/dist/cjs/utilities/segmentation/contourAndFindLargestBidirectional.js.map +1 -0
  61. package/dist/cjs/utilities/segmentation/createBidirectionalToolData.d.ts +14 -0
  62. package/dist/cjs/utilities/segmentation/createBidirectionalToolData.js +43 -0
  63. package/dist/cjs/utilities/segmentation/createBidirectionalToolData.js.map +1 -0
  64. package/dist/cjs/utilities/segmentation/findLargestBidirectional.d.ts +1 -0
  65. package/dist/cjs/utilities/segmentation/findLargestBidirectional.js +94 -0
  66. package/dist/cjs/utilities/segmentation/findLargestBidirectional.js.map +1 -0
  67. package/dist/cjs/utilities/segmentation/index.d.ts +4 -1
  68. package/dist/cjs/utilities/segmentation/index.js +7 -1
  69. package/dist/cjs/utilities/segmentation/index.js.map +1 -1
  70. package/dist/cjs/utilities/segmentation/isLineInSegment.d.ts +9 -0
  71. package/dist/cjs/utilities/segmentation/isLineInSegment.js +55 -0
  72. package/dist/cjs/utilities/segmentation/isLineInSegment.js.map +1 -0
  73. package/dist/cjs/utilities/segmentation/segmentContourAction.d.ts +17 -0
  74. package/dist/cjs/utilities/segmentation/segmentContourAction.js +122 -0
  75. package/dist/cjs/utilities/segmentation/segmentContourAction.js.map +1 -0
  76. package/dist/esm/drawingSvg/drawHandle.js +61 -0
  77. package/dist/esm/drawingSvg/drawHandle.js.map +1 -0
  78. package/dist/esm/drawingSvg/drawHandles.js +4 -60
  79. package/dist/esm/drawingSvg/drawHandles.js.map +1 -1
  80. package/dist/esm/drawingSvg/index.js +2 -1
  81. package/dist/esm/drawingSvg/index.js.map +1 -1
  82. package/dist/esm/eventDispatchers/keyboardEventHandlers/keyDown.js +2 -1
  83. package/dist/esm/eventDispatchers/keyboardEventHandlers/keyDown.js.map +1 -1
  84. package/dist/esm/index.js +2 -2
  85. package/dist/esm/index.js.map +1 -1
  86. package/dist/esm/stateManagement/annotation/annotationState.js +3 -0
  87. package/dist/esm/stateManagement/annotation/annotationState.js.map +1 -1
  88. package/dist/esm/tools/annotation/AngleTool.js.map +1 -1
  89. package/dist/esm/tools/annotation/BidirectionalTool.js +7 -6
  90. package/dist/esm/tools/annotation/BidirectionalTool.js.map +1 -1
  91. package/dist/esm/tools/annotation/LengthTool.js +5 -4
  92. package/dist/esm/tools/annotation/LengthTool.js.map +1 -1
  93. package/dist/esm/tools/annotation/ProbeTool.js +24 -3
  94. package/dist/esm/tools/annotation/ProbeTool.js.map +1 -1
  95. package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js +478 -0
  96. package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js.map +1 -0
  97. package/dist/esm/tools/index.js +2 -1
  98. package/dist/esm/tools/index.js.map +1 -1
  99. package/dist/esm/utilities/contours/AnnotationToPointData.js +39 -0
  100. package/dist/esm/utilities/contours/AnnotationToPointData.js.map +1 -0
  101. package/dist/esm/utilities/contours/RectangleROIStartEndThreshold.js +41 -0
  102. package/dist/esm/utilities/contours/RectangleROIStartEndThreshold.js.map +1 -0
  103. package/dist/esm/utilities/contours/contourFinder.js +63 -0
  104. package/dist/esm/utilities/contours/contourFinder.js.map +1 -0
  105. package/dist/esm/utilities/contours/detectContourHoles.js +74 -0
  106. package/dist/esm/utilities/contours/detectContourHoles.js.map +1 -0
  107. package/dist/esm/utilities/contours/generateContourSetsFromLabelmap.js +117 -0
  108. package/dist/esm/utilities/contours/generateContourSetsFromLabelmap.js.map +1 -0
  109. package/dist/esm/utilities/contours/index.js +7 -0
  110. package/dist/esm/utilities/contours/index.js.map +1 -0
  111. package/dist/esm/utilities/contours/mergePoints.js +73 -0
  112. package/dist/esm/utilities/contours/mergePoints.js.map +1 -0
  113. package/dist/esm/utilities/getCalibratedUnits.js +125 -6
  114. package/dist/esm/utilities/getCalibratedUnits.js.map +1 -1
  115. package/dist/esm/utilities/index.js +2 -1
  116. package/dist/esm/utilities/index.js.map +1 -1
  117. package/dist/esm/utilities/segmentation/contourAndFindLargestBidirectional.js +25 -0
  118. package/dist/esm/utilities/segmentation/contourAndFindLargestBidirectional.js.map +1 -0
  119. package/dist/esm/utilities/segmentation/createBidirectionalToolData.js +40 -0
  120. package/dist/esm/utilities/segmentation/createBidirectionalToolData.js.map +1 -0
  121. package/dist/esm/utilities/segmentation/findLargestBidirectional.js +96 -0
  122. package/dist/esm/utilities/segmentation/findLargestBidirectional.js.map +1 -0
  123. package/dist/esm/utilities/segmentation/index.js +4 -1
  124. package/dist/esm/utilities/segmentation/index.js.map +1 -1
  125. package/dist/esm/utilities/segmentation/isLineInSegment.js +50 -0
  126. package/dist/esm/utilities/segmentation/isLineInSegment.js.map +1 -0
  127. package/dist/esm/utilities/segmentation/segmentContourAction.js +98 -0
  128. package/dist/esm/utilities/segmentation/segmentContourAction.js.map +1 -0
  129. package/dist/types/drawingSvg/drawHandle.d.ts +5 -0
  130. package/dist/types/drawingSvg/drawHandle.d.ts.map +1 -0
  131. package/dist/types/drawingSvg/drawHandles.d.ts.map +1 -1
  132. package/dist/types/drawingSvg/index.d.ts +2 -1
  133. package/dist/types/drawingSvg/index.d.ts.map +1 -1
  134. package/dist/types/eventDispatchers/keyboardEventHandlers/keyDown.d.ts.map +1 -1
  135. package/dist/types/index.d.ts +2 -2
  136. package/dist/types/index.d.ts.map +1 -1
  137. package/dist/types/stateManagement/annotation/annotationState.d.ts.map +1 -1
  138. package/dist/types/tools/annotation/AngleTool.d.ts.map +1 -1
  139. package/dist/types/tools/annotation/BidirectionalTool.d.ts.map +1 -1
  140. package/dist/types/tools/annotation/LengthTool.d.ts.map +1 -1
  141. package/dist/types/tools/annotation/ProbeTool.d.ts.map +1 -1
  142. package/dist/types/tools/annotation/UltrasoundDirectionalTool.d.ts +37 -0
  143. package/dist/types/tools/annotation/UltrasoundDirectionalTool.d.ts.map +1 -0
  144. package/dist/types/tools/index.d.ts +2 -1
  145. package/dist/types/tools/index.d.ts.map +1 -1
  146. package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +28 -0
  147. package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
  148. package/dist/types/types/index.d.ts +2 -1
  149. package/dist/types/types/index.d.ts.map +1 -1
  150. package/dist/types/utilities/contours/AnnotationToPointData.d.ts +12 -0
  151. package/dist/types/utilities/contours/AnnotationToPointData.d.ts.map +1 -0
  152. package/dist/types/utilities/contours/RectangleROIStartEndThreshold.d.ts +7 -0
  153. package/dist/types/utilities/contours/RectangleROIStartEndThreshold.d.ts.map +1 -0
  154. package/dist/types/utilities/contours/contourFinder.d.ts +8 -0
  155. package/dist/types/utilities/contours/contourFinder.d.ts.map +1 -0
  156. package/dist/types/utilities/contours/detectContourHoles.d.ts +6 -0
  157. package/dist/types/utilities/contours/detectContourHoles.d.ts.map +1 -0
  158. package/dist/types/utilities/contours/generateContourSetsFromLabelmap.d.ts +5 -0
  159. package/dist/types/utilities/contours/generateContourSetsFromLabelmap.d.ts.map +1 -0
  160. package/dist/types/utilities/contours/index.d.ts +7 -0
  161. package/dist/types/utilities/contours/index.d.ts.map +1 -0
  162. package/dist/types/utilities/contours/mergePoints.d.ts +9 -0
  163. package/dist/types/utilities/contours/mergePoints.d.ts.map +1 -0
  164. package/dist/types/utilities/getCalibratedUnits.d.ts +16 -2
  165. package/dist/types/utilities/getCalibratedUnits.d.ts.map +1 -1
  166. package/dist/types/utilities/index.d.ts +2 -1
  167. package/dist/types/utilities/index.d.ts.map +1 -1
  168. package/dist/types/utilities/segmentation/contourAndFindLargestBidirectional.d.ts +2 -0
  169. package/dist/types/utilities/segmentation/contourAndFindLargestBidirectional.d.ts.map +1 -0
  170. package/dist/types/utilities/segmentation/createBidirectionalToolData.d.ts +15 -0
  171. package/dist/types/utilities/segmentation/createBidirectionalToolData.d.ts.map +1 -0
  172. package/dist/types/utilities/segmentation/findLargestBidirectional.d.ts +2 -0
  173. package/dist/types/utilities/segmentation/findLargestBidirectional.d.ts.map +1 -0
  174. package/dist/types/utilities/segmentation/index.d.ts +4 -1
  175. package/dist/types/utilities/segmentation/index.d.ts.map +1 -1
  176. package/dist/types/utilities/segmentation/isLineInSegment.d.ts +10 -0
  177. package/dist/types/utilities/segmentation/isLineInSegment.d.ts.map +1 -0
  178. package/dist/types/utilities/segmentation/segmentContourAction.d.ts +18 -0
  179. package/dist/types/utilities/segmentation/segmentContourAction.d.ts.map +1 -0
  180. package/dist/umd/index.js +1 -1
  181. package/dist/umd/index.js.map +1 -1
  182. package/package.json +3 -3
  183. package/src/drawingSvg/drawHandle.ts +88 -0
  184. package/src/drawingSvg/drawHandles.ts +9 -75
  185. package/src/drawingSvg/index.ts +2 -0
  186. package/src/eventDispatchers/keyboardEventHandlers/keyDown.ts +7 -1
  187. package/src/index.ts +2 -0
  188. package/src/stateManagement/annotation/annotationState.ts +3 -0
  189. package/src/tools/annotation/AngleTool.ts +0 -1
  190. package/src/tools/annotation/BidirectionalTool.ts +9 -5
  191. package/src/tools/annotation/LengthTool.ts +6 -8
  192. package/src/tools/annotation/ProbeTool.ts +31 -7
  193. package/src/tools/annotation/UltrasoundDirectionalTool.ts +916 -0
  194. package/src/tools/index.ts +2 -0
  195. package/src/types/ToolSpecificAnnotationTypes.ts +29 -0
  196. package/src/types/index.ts +2 -0
  197. package/src/utilities/contours/AnnotationToPointData.ts +61 -0
  198. package/src/utilities/contours/RectangleROIStartEndThreshold.ts +60 -0
  199. package/src/utilities/contours/contourFinder.ts +78 -0
  200. package/src/utilities/contours/detectContourHoles.ts +147 -0
  201. package/src/utilities/contours/generateContourSetsFromLabelmap.ts +160 -0
  202. package/src/utilities/contours/index.ts +14 -0
  203. package/src/utilities/contours/mergePoints.ts +108 -0
  204. package/src/utilities/getCalibratedUnits.ts +203 -7
  205. package/src/utilities/index.ts +2 -0
  206. package/src/utilities/segmentation/contourAndFindLargestBidirectional.ts +46 -0
  207. package/src/utilities/segmentation/createBidirectionalToolData.ts +68 -0
  208. package/src/utilities/segmentation/findLargestBidirectional.ts +159 -0
  209. package/src/utilities/segmentation/index.ts +6 -0
  210. package/src/utilities/segmentation/isLineInSegment.ts +84 -0
  211. package/src/utilities/segmentation/segmentContourAction.ts +169 -0
@@ -0,0 +1,44 @@
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 RectangleROIStartEndThreshold_1 = __importDefault(require("./RectangleROIStartEndThreshold"));
7
+ function validateAnnotation(annotation) {
8
+ if (!(annotation === null || annotation === void 0 ? void 0 : annotation.data)) {
9
+ throw new Error('Tool data is empty');
10
+ }
11
+ if (!annotation.metadata || annotation.metadata.referenceImageId) {
12
+ throw new Error('Tool data is not associated with any imageId');
13
+ }
14
+ }
15
+ class AnnotationToPointData {
16
+ constructor() {
17
+ }
18
+ static convert(annotation, index, metadataProvider) {
19
+ validateAnnotation(annotation);
20
+ const { toolName } = annotation.metadata;
21
+ const toolClass = AnnotationToPointData.TOOL_NAMES[toolName];
22
+ if (!toolClass) {
23
+ throw new Error(`Unknown tool type: ${toolName}, cannot convert to RTSSReport`);
24
+ }
25
+ const ContourSequence = toolClass.getContourSequence(annotation, metadataProvider);
26
+ const color = [
27
+ Math.floor(Math.random() * 255),
28
+ Math.floor(Math.random() * 255),
29
+ Math.floor(Math.random() * 255),
30
+ ];
31
+ return {
32
+ ReferencedROINumber: index + 1,
33
+ ROIDisplayColor: color,
34
+ ContourSequence,
35
+ };
36
+ }
37
+ static register(toolClass) {
38
+ AnnotationToPointData.TOOL_NAMES[toolClass.toolName] = toolClass;
39
+ }
40
+ }
41
+ AnnotationToPointData.TOOL_NAMES = {};
42
+ AnnotationToPointData.register(RectangleROIStartEndThreshold_1.default);
43
+ exports.default = AnnotationToPointData;
44
+ //# sourceMappingURL=AnnotationToPointData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnnotationToPointData.js","sourceRoot":"","sources":["../../../../src/utilities/contours/AnnotationToPointData.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,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;IACnE,CAAC;;AA1CM,gCAAU,GAAwB,EAAE,CAAC;AA6C9C,qBAAqB,CAAC,QAAQ,CAAC,uCAA6B,CAAC,CAAC;AAE9D,kBAAe,qBAAqB,CAAC"}
@@ -0,0 +1,6 @@
1
+ declare class RectangleROIStartEndThreshold {
2
+ static toolName: string;
3
+ constructor();
4
+ static getContourSequence(toolData: any, metadataProvider: any): any;
5
+ }
6
+ export default RectangleROIStartEndThreshold;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class RectangleROIStartEndThreshold {
4
+ constructor() {
5
+ }
6
+ static getContourSequence(toolData, metadataProvider) {
7
+ const { data } = toolData;
8
+ const { projectionPoints, projectionPointsImageIds } = data.cachedStats;
9
+ return projectionPoints.map((point, index) => {
10
+ const ContourData = getPointData(point);
11
+ const ContourImageSequence = getContourImageSequence(projectionPointsImageIds[index], metadataProvider);
12
+ return {
13
+ NumberOfContourPoints: ContourData.length / 3,
14
+ ContourImageSequence,
15
+ ContourGeometricType: 'CLOSED_PLANAR',
16
+ ContourData,
17
+ };
18
+ });
19
+ }
20
+ }
21
+ RectangleROIStartEndThreshold.toolName = 'RectangleROIStartEndThreshold';
22
+ function getPointData(points) {
23
+ const orderedPoints = [
24
+ ...points[0],
25
+ ...points[1],
26
+ ...points[3],
27
+ ...points[2],
28
+ ];
29
+ const pointsArray = orderedPoints.flat();
30
+ const pointsArrayWithPrecision = pointsArray.map((point) => {
31
+ return point.toFixed(2);
32
+ });
33
+ return pointsArrayWithPrecision;
34
+ }
35
+ function getContourImageSequence(imageId, metadataProvider) {
36
+ const sopCommon = metadataProvider.get('sopCommonModule', imageId);
37
+ return {
38
+ ReferencedSOPClassUID: sopCommon.sopClassUID,
39
+ ReferencedSOPInstanceUID: sopCommon.sopInstanceUID,
40
+ };
41
+ }
42
+ exports.default = RectangleROIStartEndThreshold;
43
+ //# sourceMappingURL=RectangleROIStartEndThreshold.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RectangleROIStartEndThreshold.js","sourceRoot":"","sources":["../../../../src/utilities/contours/RectangleROIStartEndThreshold.ts"],"names":[],"mappings":";;AACA,MAAM,6BAA6B;IAGjC;IAEA,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,gBAAgB;QAClD,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;QAC1B,MAAM,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC;QAExE,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YAC3C,MAAM,WAAW,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;YACxC,MAAM,oBAAoB,GAAG,uBAAuB,CAClD,wBAAwB,CAAC,KAAK,CAAC,EAC/B,gBAAgB,CACjB,CAAC;YAEF,OAAO;gBACL,qBAAqB,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC;gBAC7C,oBAAoB;gBACpB,oBAAoB,EAAE,eAAe;gBACrC,WAAW;aACZ,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,6BAA6B,CAAC,QAAQ,GAAG,+BAA+B,CAAC;AAEzE,SAAS,YAAY,CAAC,MAAM;IAI1B,MAAM,aAAa,GAAG;QACpB,GAAG,MAAM,CAAC,CAAC,CAAC;QACZ,GAAG,MAAM,CAAC,CAAC,CAAC;QACZ,GAAG,MAAM,CAAC,CAAC,CAAC;QACZ,GAAG,MAAM,CAAC,CAAC,CAAC;KACb,CAAC;IACF,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC;IAGzC,MAAM,wBAAwB,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACzD,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,OAAO,wBAAwB,CAAC;AAClC,CAAC;AAED,SAAS,uBAAuB,CAAC,OAAO,EAAE,gBAAgB;IACxD,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAEnE,OAAO;QACL,qBAAqB,EAAE,SAAS,CAAC,WAAW;QAC5C,wBAAwB,EAAE,SAAS,CAAC,cAAc;KACnD,CAAC;AACJ,CAAC;AACD,kBAAe,6BAA6B,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare function findContours(lines: any): any;
2
+ export declare function findContoursFromReducedSet(lines: any): any;
3
+ declare const _default: {
4
+ findContours: typeof findContours;
5
+ findContoursFromReducedSet: typeof findContoursFromReducedSet;
6
+ };
7
+ export default _default;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findContoursFromReducedSet = exports.findContours = void 0;
4
+ function findNextLink(line, lines, contourPoints) {
5
+ let index = -1;
6
+ lines.forEach((cell, i) => {
7
+ if (index >= 0) {
8
+ return;
9
+ }
10
+ if (cell.a == line.b) {
11
+ index = i;
12
+ }
13
+ });
14
+ if (index >= 0) {
15
+ const nextLine = lines[index];
16
+ lines.splice(index, 1);
17
+ contourPoints.push(nextLine.b);
18
+ if (contourPoints[0] == nextLine.b) {
19
+ return {
20
+ remainingLines: lines,
21
+ contourPoints,
22
+ type: 'CLOSED_PLANAR',
23
+ };
24
+ }
25
+ return findNextLink(nextLine, lines, contourPoints);
26
+ }
27
+ return {
28
+ remainingLines: lines,
29
+ contourPoints,
30
+ type: 'OPEN_PLANAR',
31
+ };
32
+ }
33
+ function findContours(lines) {
34
+ if (lines.length == 0) {
35
+ return [];
36
+ }
37
+ const contourPoints = [];
38
+ const firstCell = lines.shift();
39
+ contourPoints.push(firstCell.a);
40
+ contourPoints.push(firstCell.b);
41
+ const result = findNextLink(firstCell, lines, contourPoints);
42
+ if (result.remainingLines.length == 0) {
43
+ return [
44
+ {
45
+ type: result.type,
46
+ contourPoints: result.contourPoints,
47
+ },
48
+ ];
49
+ }
50
+ else {
51
+ const extraContours = findContours(result.remainingLines);
52
+ extraContours.push({
53
+ type: result.type,
54
+ contourPoints: result.contourPoints,
55
+ });
56
+ return extraContours;
57
+ }
58
+ }
59
+ exports.findContours = findContours;
60
+ function findContoursFromReducedSet(lines) {
61
+ return findContours(lines);
62
+ }
63
+ exports.findContoursFromReducedSet = findContoursFromReducedSet;
64
+ exports.default = {
65
+ findContours,
66
+ findContoursFromReducedSet,
67
+ };
68
+ //# sourceMappingURL=contourFinder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contourFinder.js","sourceRoot":"","sources":["../../../../src/utilities/contours/contourFinder.ts"],"names":[],"mappings":";;;AAAA,SAAS,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa;IAC9C,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;IACf,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;QACxB,IAAI,KAAK,IAAI,CAAC,EAAE;YACd,OAAO;SACR;QAED,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE;YACpB,KAAK,GAAG,CAAC,CAAC;SACX;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,KAAK,IAAI,CAAC,EAAE;QACd,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9B,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAEvB,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAE/B,IAAI,aAAa,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,EAAE;YAClC,OAAO;gBACL,cAAc,EAAE,KAAK;gBACrB,aAAa;gBACb,IAAI,EAAE,eAAe;aAEtB,CAAC;SACH;QAED,OAAO,YAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;KACrD;IAED,OAAO;QACL,cAAc,EAAE,KAAK;QACrB,aAAa;QACb,IAAI,EAAE,aAAa;KACpB,CAAC;AACJ,CAAC;AAMD,SAAgB,YAAY,CAAC,KAAK;IAChC,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;QACrB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,aAAa,GAAG,EAAE,CAAC;IAEzB,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAChC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAChC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,MAAM,GAAG,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;IAE7D,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,IAAI,CAAC,EAAE;QACrC,OAAO;YACL;gBACE,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,aAAa,EAAE,MAAM,CAAC,aAAa;aACpC;SACF,CAAC;KACH;SAAM;QACL,MAAM,aAAa,GAAG,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAC1D,aAAa,CAAC,IAAI,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,aAAa,EAAE,MAAM,CAAC,aAAa;SACpC,CAAC,CAAC;QACH,OAAO,aAAa,CAAC;KACtB;AACH,CAAC;AA3BD,oCA2BC;AAED,SAAgB,0BAA0B,CAAC,KAAK;IAC9C,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAFD,gEAEC;AAED,kBAAe;IACb,YAAY;IACZ,0BAA0B;CAC3B,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare function processContourHoles(contours: any, points: any, useXOR?: boolean): any;
2
+ declare const _default: {
3
+ processContourHoles: typeof processContourHoles;
4
+ };
5
+ export default _default;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processContourHoles = void 0;
4
+ const getIsPointInsidePolygon = (point, vertices) => {
5
+ const x = point[0];
6
+ const y = point[1];
7
+ let inside = false;
8
+ for (let i = 0, j = vertices.length - 1; i < vertices.length; j = i++) {
9
+ const xi = vertices[i][0], yi = vertices[i][1];
10
+ const xj = vertices[j][0], yj = vertices[j][1];
11
+ const intersect = yi > y != yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi;
12
+ if (intersect) {
13
+ inside = !inside;
14
+ }
15
+ }
16
+ return inside;
17
+ };
18
+ function checkEnclosed(outerContour, innerContour, points) {
19
+ const vertices = [];
20
+ outerContour.contourPoints.forEach((point) => {
21
+ vertices.push([points[point][0], points[point][1]]);
22
+ });
23
+ let pointsNotEnclosed = 0;
24
+ innerContour.contourPoints.forEach((point) => {
25
+ const result = getIsPointInsidePolygon([points[point][0], points[point][1]], vertices);
26
+ if (!result) {
27
+ pointsNotEnclosed++;
28
+ }
29
+ });
30
+ return pointsNotEnclosed === 0;
31
+ }
32
+ function processContourHoles(contours, points, useXOR = true) {
33
+ const retContours = contours.filter((contour) => contour.type !== 'CLOSED_PLANAR');
34
+ const closedContours = contours.filter((contour) => contour.type === 'CLOSED_PLANAR');
35
+ const contourWithHoles = [];
36
+ let contourWithoutHoles = [];
37
+ closedContours.forEach((contour, index) => {
38
+ const holes = [];
39
+ closedContours.forEach((hContour, hIndex) => {
40
+ if (index != hIndex) {
41
+ if (checkEnclosed(contour, hContour, points)) {
42
+ holes.push(hIndex);
43
+ }
44
+ }
45
+ });
46
+ if (holes.length > 0) {
47
+ contourWithHoles.push({
48
+ contour,
49
+ holes,
50
+ });
51
+ }
52
+ else {
53
+ contourWithoutHoles.push(index);
54
+ }
55
+ });
56
+ if (useXOR) {
57
+ contourWithHoles.forEach((contourHoleSet) => {
58
+ contourHoleSet.contour.type = 'CLOSEDPLANAR_XOR';
59
+ retContours.push(contourHoleSet.contour);
60
+ contourHoleSet.holes.forEach((holeIndex) => {
61
+ closedContours[holeIndex].type = 'CLOSEDPLANAR_XOR';
62
+ retContours.push(closedContours[holeIndex]);
63
+ contourWithoutHoles = contourWithoutHoles.filter((contourIndex) => {
64
+ return contourIndex !== holeIndex;
65
+ });
66
+ });
67
+ });
68
+ contourWithoutHoles.forEach((contourIndex) => {
69
+ retContours.push(closedContours[contourIndex]);
70
+ });
71
+ }
72
+ else {
73
+ }
74
+ return retContours;
75
+ }
76
+ exports.processContourHoles = processContourHoles;
77
+ exports.default = { processContourHoles };
78
+ //# sourceMappingURL=detectContourHoles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detectContourHoles.js","sourceRoot":"","sources":["../../../../src/utilities/contours/detectContourHoles.ts"],"names":[],"mappings":";;;AAmBA,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;IAClD,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnB,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE;QACrE,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACvB,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACtB,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACvB,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtB,MAAM,SAAS,GACb,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,C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AAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAGH,mBAAmB,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;YAC3C,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;KACJ;SAAM;KAEN;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAvED,kDAuEC;AAED,kBAAe,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ declare function generateContourSetsFromLabelmap({ segmentations }: {
2
+ segmentations: any;
3
+ }): any[];
4
+ export { generateContourSetsFromLabelmap };
@@ -0,0 +1,124 @@
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
+ exports.generateContourSetsFromLabelmap = void 0;
7
+ const core_1 = require("@cornerstonejs/core");
8
+ const ImageMarchingSquares_1 = __importDefault(require("@kitware/vtk.js/Filters/General/ImageMarchingSquares"));
9
+ const DataArray_1 = __importDefault(require("@kitware/vtk.js/Common/Core/DataArray"));
10
+ const ImageData_1 = __importDefault(require("@kitware/vtk.js/Common/DataModel/ImageData"));
11
+ const mergePoints_1 = require("./mergePoints");
12
+ const contourFinder_1 = require("./contourFinder");
13
+ const SegmentationRepresentations_1 = __importDefault(require("../../enums/SegmentationRepresentations"));
14
+ const { Labelmap } = SegmentationRepresentations_1.default;
15
+ function generateContourSetsFromLabelmap({ segmentations }) {
16
+ var _a;
17
+ const { representationData, segments = [0, 1] } = segmentations;
18
+ const { volumeId: segVolumeId } = representationData[Labelmap];
19
+ const vol = core_1.cache.getVolume(segVolumeId);
20
+ if (!vol) {
21
+ console.warn(`No volume found for ${segVolumeId}`);
22
+ return;
23
+ }
24
+ const numSlices = vol.dimensions[2];
25
+ const imageVol = core_1.cache.getVolume(vol.referencedVolumeId);
26
+ if (!imageVol) {
27
+ console.warn(`No volume found for ${vol.referencedVolumeId}`);
28
+ return;
29
+ }
30
+ const segData = vol.imageData.getPointData().getScalars().getData();
31
+ const pixelsPerSlice = vol.dimensions[0] * vol.dimensions[1];
32
+ for (let z = 0; z < numSlices; z++) {
33
+ for (let y = 0; y < vol.dimensions[1]; y++) {
34
+ const index = y * vol.dimensions[0] + z * pixelsPerSlice;
35
+ segData[index] = 0;
36
+ segData[index + vol.dimensions[0] - 1] = 0;
37
+ }
38
+ }
39
+ const ContourSets = [];
40
+ const { FrameOfReferenceUID } = imageVol.metadata;
41
+ const numSegments = segments.length;
42
+ for (let segIndex = 0; segIndex < numSegments; segIndex++) {
43
+ const segment = segments[segIndex];
44
+ if (!segment) {
45
+ continue;
46
+ }
47
+ const sliceContours = [];
48
+ const scalars = DataArray_1.default.newInstance({
49
+ name: 'Scalars',
50
+ numberOfComponents: 1,
51
+ size: pixelsPerSlice * numSlices,
52
+ dataType: 'Uint8Array',
53
+ });
54
+ const { containedSegmentIndices } = segment;
55
+ for (let sliceIndex = 0; sliceIndex < numSlices; sliceIndex++) {
56
+ if (isSliceEmptyForSegment(sliceIndex, segData, pixelsPerSlice, segIndex)) {
57
+ continue;
58
+ }
59
+ const frameStart = sliceIndex * pixelsPerSlice;
60
+ try {
61
+ for (let i = 0; i < pixelsPerSlice; i++) {
62
+ const value = segData[i + frameStart];
63
+ if (value === segIndex || (containedSegmentIndices === null || containedSegmentIndices === void 0 ? void 0 : containedSegmentIndices.has(value))) {
64
+ scalars.setValue(i + frameStart, 1);
65
+ }
66
+ else {
67
+ scalars.setValue(i, 0);
68
+ }
69
+ }
70
+ const mSquares = ImageMarchingSquares_1.default.newInstance({
71
+ slice: sliceIndex,
72
+ });
73
+ const imageDataCopy = ImageData_1.default.newInstance();
74
+ imageDataCopy.shallowCopy(vol.imageData);
75
+ imageDataCopy.getPointData().setScalars(scalars);
76
+ mSquares.setInputData(imageDataCopy);
77
+ const cValues = [1];
78
+ mSquares.setContourValues(cValues);
79
+ mSquares.setMergePoints(false);
80
+ const msOutput = mSquares.getOutputData();
81
+ const reducedSet = (0, mergePoints_1.removeDuplicatePoints)(msOutput);
82
+ if ((_a = reducedSet.points) === null || _a === void 0 ? void 0 : _a.length) {
83
+ const contours = (0, contourFinder_1.findContoursFromReducedSet)(reducedSet.lines);
84
+ sliceContours.push({
85
+ referencedImageId: imageVol.imageIds[sliceIndex],
86
+ contours,
87
+ polyData: reducedSet,
88
+ FrameNumber: sliceIndex + 1,
89
+ sliceIndex,
90
+ FrameOfReferenceUID,
91
+ });
92
+ }
93
+ }
94
+ catch (e) {
95
+ console.warn(sliceIndex);
96
+ console.warn(e);
97
+ }
98
+ }
99
+ const metadata = {
100
+ referencedImageId: imageVol.imageIds[0],
101
+ FrameOfReferenceUID,
102
+ };
103
+ const ContourSet = {
104
+ label: segment.label,
105
+ color: segment.color,
106
+ metadata,
107
+ sliceContours,
108
+ };
109
+ ContourSets.push(ContourSet);
110
+ }
111
+ return ContourSets;
112
+ }
113
+ exports.generateContourSetsFromLabelmap = generateContourSetsFromLabelmap;
114
+ function isSliceEmptyForSegment(sliceIndex, segData, pixelsPerSlice, segIndex) {
115
+ const startIdx = sliceIndex * pixelsPerSlice;
116
+ const endIdx = startIdx + pixelsPerSlice;
117
+ for (let i = startIdx; i < endIdx; i++) {
118
+ if (segData[i] === segIndex) {
119
+ return false;
120
+ }
121
+ }
122
+ return true;
123
+ }
124
+ //# sourceMappingURL=generateContourSetsFromLabelmap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateContourSetsFromLabelmap.js","sourceRoot":"","sources":["../../../../src/utilities/contours/generateContourSetsFromLabelmap.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAgE;AAChE,gHAA2F;AAC3F,sFAAiE;AACjE,2FAAsE;AAEtE,+CAAsD;AACtD,mDAA6D;AAC7D,0GAAkF;AAElF,MAAM,EAAE,QAAQ,EAAE,GAAG,qCAA2B,CAAC;AAEj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zB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACjB;SACF;QAED,MAAM,QAAQ,GAAG;YACf,iBAAiB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;YACvC,mBAAmB;SACpB,CAAC;QAEF,MAAM,UAAU,GAAG;YACjB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,QAAQ;YACR,aAAa;SACd,CAAC;QAEF,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KAC9B;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAeQ,0EAA+B;AAbxC,SAAS,sBAAsB,CAAC,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ;IAC3E,MAAM,QAAQ,GAAG,UAAU,GAAG,cAAc,CAAC;IAC7C,MAAM,MAAM,GAAG,QAAQ,GAAG,cAAc,CAAC;IAEzC,KAAK,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;YAC3B,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,6 @@
1
+ import contourFinder from './contourFinder';
2
+ import mergePoints from './mergePoints';
3
+ import detectContourHoles from './detectContourHoles';
4
+ import { generateContourSetsFromLabelmap } from './generateContourSetsFromLabelmap';
5
+ import AnnotationToPointData from './AnnotationToPointData';
6
+ export { contourFinder, mergePoints, detectContourHoles, generateContourSetsFromLabelmap, AnnotationToPointData, };
@@ -0,0 +1,17 @@
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
+ exports.AnnotationToPointData = exports.generateContourSetsFromLabelmap = exports.detectContourHoles = exports.mergePoints = exports.contourFinder = void 0;
7
+ const contourFinder_1 = __importDefault(require("./contourFinder"));
8
+ exports.contourFinder = contourFinder_1.default;
9
+ const mergePoints_1 = __importDefault(require("./mergePoints"));
10
+ exports.mergePoints = mergePoints_1.default;
11
+ const detectContourHoles_1 = __importDefault(require("./detectContourHoles"));
12
+ exports.detectContourHoles = detectContourHoles_1.default;
13
+ const generateContourSetsFromLabelmap_1 = require("./generateContourSetsFromLabelmap");
14
+ Object.defineProperty(exports, "generateContourSetsFromLabelmap", { enumerable: true, get: function () { return generateContourSetsFromLabelmap_1.generateContourSetsFromLabelmap; } });
15
+ const AnnotationToPointData_1 = __importDefault(require("./AnnotationToPointData"));
16
+ exports.AnnotationToPointData = AnnotationToPointData_1.default;
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/contours/index.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA4C;AAQ1C,wBARK,uBAAa,CAQL;AAPf,gEAAwC;AAQtC,sBARK,qBAAW,CAQL;AAPb,8EAAsD;AAQpD,6BARK,4BAAkB,CAQL;AAPpB,uFAAoF;AAQlF,gHARO,iEAA+B,OAQP;AANjC,oFAA4D;AAO1D,gCAPK,+BAAqB,CAOL"}
@@ -0,0 +1,8 @@
1
+ export declare function removeDuplicatePoints(polyData: any, bypass?: boolean): {
2
+ points: any[];
3
+ lines: any[];
4
+ };
5
+ declare const _default: {
6
+ removeDuplicatePoints: typeof removeDuplicatePoints;
7
+ };
8
+ export default _default;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeDuplicatePoints = void 0;
4
+ function ptInArray(array, pt) {
5
+ let index = -1;
6
+ for (let i = 0; i < array.length; i++) {
7
+ if (isSamePoint(pt, array[i])) {
8
+ index = i;
9
+ }
10
+ }
11
+ return index;
12
+ }
13
+ function isSamePoint(ptA, ptB) {
14
+ if (ptA[0] == ptB[0] && ptA[1] == ptB[1] && ptA[2] == ptB[2]) {
15
+ return true;
16
+ }
17
+ else {
18
+ return false;
19
+ }
20
+ }
21
+ function replacePointIndexReferences(linesArray, oldIndex, newIndex) {
22
+ for (let i = 0; i < linesArray.length; i++) {
23
+ const line = linesArray[i];
24
+ if (line.a == oldIndex) {
25
+ line.a = newIndex;
26
+ }
27
+ else if (line.b == oldIndex) {
28
+ line.b = newIndex;
29
+ }
30
+ }
31
+ }
32
+ function removeDuplicatePoints(polyData, bypass = false) {
33
+ const points = polyData.getPoints();
34
+ const lines = polyData.getLines();
35
+ const pointsArray = [];
36
+ for (let i = 0; i < points.getNumberOfPoints(); i++) {
37
+ const pt = points.getPoint(i).slice();
38
+ pointsArray.push(pt);
39
+ }
40
+ const linesArray = [];
41
+ for (let i = 0; i < lines.getNumberOfCells(); i++) {
42
+ const cell = lines.getCell(i * 3).slice();
43
+ const a = cell[0];
44
+ const b = cell[1];
45
+ const line = {
46
+ a,
47
+ b,
48
+ };
49
+ linesArray.push(line);
50
+ }
51
+ if (bypass) {
52
+ return { points: pointsArray, lines: linesArray };
53
+ }
54
+ const newPoints = [];
55
+ for (let i = 0; i < pointsArray.length; i++) {
56
+ const pt = pointsArray[i];
57
+ let index = ptInArray(newPoints, pt);
58
+ if (index >= 0) {
59
+ replacePointIndexReferences(linesArray, i, index);
60
+ }
61
+ else {
62
+ index = newPoints.length;
63
+ newPoints.push(pt);
64
+ replacePointIndexReferences(linesArray, i, index);
65
+ }
66
+ }
67
+ const newLines = [];
68
+ linesArray.forEach((line) => {
69
+ if (line.a != line.b) {
70
+ newLines.push(line);
71
+ }
72
+ });
73
+ return { points: newPoints, lines: newLines };
74
+ }
75
+ exports.removeDuplicatePoints = removeDuplicatePoints;
76
+ exports.default = { removeDuplicatePoints };
77
+ //# sourceMappingURL=mergePoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergePoints.js","sourceRoot":"","sources":["../../../../src/utilities/contours/mergePoints.ts"],"names":[],"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S,CAAC,MAAM,CAAC;YACzB,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACnB,2BAA2B,CAAC,UAAU,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;SACnD;KACF;IAGD,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC1B,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE;YACpB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACrB;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAChD,CAAC;AAnDD,sDAmDC;AAED,kBAAe,EAAE,qBAAqB,EAAE,CAAC"}
@@ -1,6 +1,20 @@
1
1
  declare const getCalibratedLengthUnits: (handles: any, image: any) => string;
2
2
  declare const getCalibratedAreaUnits: (handles: any, image: any) => string;
3
- declare const getCalibratedScale: (image: any) => any;
3
+ declare const getCalibratedScale: (image: any, handles?: any[]) => any;
4
+ declare const getCalibratedLengthUnitsAndScale: (image: any, handles: any) => {
5
+ units: string;
6
+ areaUnits: string;
7
+ scale: number;
8
+ };
9
+ declare const getCalibratedProbeUnitsAndValue: (image: any, handles: any) => {
10
+ units: string[];
11
+ values: any[];
12
+ calibrationType?: undefined;
13
+ } | {
14
+ units: string[];
15
+ values: any[];
16
+ calibrationType: string;
17
+ };
4
18
  declare const getCalibratedAspect: (image: any) => any;
5
19
  export default getCalibratedLengthUnits;
6
- export { getCalibratedAreaUnits, getCalibratedLengthUnits, getCalibratedScale, getCalibratedAspect, };
20
+ export { getCalibratedAreaUnits, getCalibratedLengthUnits, getCalibratedLengthUnitsAndScale, getCalibratedScale, getCalibratedAspect, getCalibratedProbeUnitsAndValue, };