@cornerstonejs/tools 1.57.2 → 1.58.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/drawingSvg/drawPath.js +1 -1
- package/dist/cjs/drawingSvg/drawPath.js.map +1 -1
- package/dist/cjs/enums/WorkerTypes.d.ts +1 -1
- package/dist/cjs/enums/WorkerTypes.js +1 -1
- package/dist/cjs/enums/WorkerTypes.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.d.ts +17 -0
- package/dist/cjs/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.js +112 -0
- package/dist/cjs/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.js.map +1 -0
- package/dist/cjs/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.d.ts +3 -1
- package/dist/cjs/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.js +4 -1
- package/dist/cjs/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.d.ts +8 -0
- package/dist/cjs/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js +121 -0
- package/dist/cjs/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js.map +1 -0
- package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.d.ts +3 -0
- package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.js +73 -0
- package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.js.map +1 -0
- package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.d.ts +3 -0
- package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.js +25 -0
- package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.js.map +1 -0
- package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.d.ts +1 -0
- package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.js +41 -0
- package/dist/cjs/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.js.map +1 -0
- package/dist/cjs/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.js +2 -2
- package/dist/cjs/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/polySeg/Labelmap/convertSurfaceToLabelmap.js +1 -1
- package/dist/cjs/stateManagement/segmentation/polySeg/Labelmap/convertSurfaceToLabelmap.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/polySeg/Surface/convertContourToSurface.js +1 -1
- package/dist/cjs/stateManagement/segmentation/polySeg/Surface/convertContourToSurface.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.js +1 -1
- package/dist/cjs/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/polySeg/computeAndAddRepresentation.js +1 -1
- package/dist/cjs/stateManagement/segmentation/polySeg/computeAndAddRepresentation.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/triggerSegmentationEvents.js +2 -0
- package/dist/cjs/stateManagement/segmentation/triggerSegmentationEvents.js.map +1 -1
- package/dist/cjs/store/ToolGroupManager/getToolGroupForViewport.d.ts +1 -1
- package/dist/cjs/store/ToolGroupManager/getToolGroupForViewport.js +5 -0
- package/dist/cjs/store/ToolGroupManager/getToolGroupForViewport.js.map +1 -1
- package/dist/cjs/tools/base/BaseTool.js +3 -0
- package/dist/cjs/tools/base/BaseTool.js.map +1 -1
- package/dist/cjs/tools/base/ContourSegmentationBaseTool.js.map +1 -1
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.js +13 -5
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js +1 -1
- package/dist/cjs/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
- package/dist/cjs/tools/displayTools/SegmentationDisplayTool.d.ts +1 -0
- package/dist/cjs/tools/displayTools/SegmentationDisplayTool.js +17 -0
- package/dist/cjs/tools/displayTools/SegmentationDisplayTool.js.map +1 -1
- package/dist/cjs/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js +4 -47
- package/dist/cjs/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js.map +1 -1
- package/dist/cjs/tools/displayTools/Surface/surfaceDisplay.d.ts +3 -9
- package/dist/cjs/tools/displayTools/Surface/surfaceDisplay.js +7 -148
- package/dist/cjs/tools/displayTools/Surface/surfaceDisplay.js.map +1 -1
- package/dist/cjs/types/PolySeg.d.ts +1 -1
- package/dist/cjs/utilities/contourSegmentation/addContourSegmentationAnnotation.js +4 -1
- package/dist/cjs/utilities/contourSegmentation/addContourSegmentationAnnotation.js.map +1 -1
- package/dist/cjs/utilities/contourSegmentation/removeContourSegmentationAnnotation.js +3 -0
- package/dist/cjs/utilities/contourSegmentation/removeContourSegmentationAnnotation.js.map +1 -1
- package/dist/cjs/utilities/math/polyline/getAABB.d.ts +3 -1
- package/dist/cjs/utilities/math/polyline/getAABB.js +30 -4
- package/dist/cjs/utilities/math/polyline/getAABB.js.map +1 -1
- package/dist/cjs/utilities/planar/index.d.ts +3 -1
- package/dist/cjs/utilities/planar/index.js +4 -1
- package/dist/cjs/utilities/planar/index.js.map +1 -1
- package/dist/cjs/utilities/planar/isPlaneIntersectingAABB.d.ts +1 -0
- package/dist/cjs/utilities/planar/isPlaneIntersectingAABB.js +32 -0
- package/dist/cjs/utilities/planar/isPlaneIntersectingAABB.js.map +1 -0
- package/dist/cjs/utilities/segmentation/getUniqueSegmentIndices.d.ts +3 -1
- package/dist/cjs/utilities/segmentation/getUniqueSegmentIndices.js +97 -47
- package/dist/cjs/utilities/segmentation/getUniqueSegmentIndices.js.map +1 -1
- package/dist/cjs/workers/polySegConverters.js +73 -0
- package/dist/cjs/workers/polySegConverters.js.map +1 -1
- package/dist/esm/drawingSvg/drawPath.js +1 -1
- package/dist/esm/drawingSvg/drawPath.js.map +1 -1
- package/dist/esm/enums/WorkerTypes.js +1 -1
- package/dist/esm/enums/WorkerTypes.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.js +91 -0
- package/dist/esm/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.js.map +1 -0
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.js +4 -1
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js +105 -0
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js.map +1 -0
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.js +72 -0
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.js.map +1 -0
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.js +21 -0
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.js.map +1 -0
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.js +26 -0
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.js.map +1 -0
- package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.js +2 -2
- package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertSurfaceToLabelmap.js +1 -1
- package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertSurfaceToLabelmap.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.js +1 -1
- package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertContourToSurface.js +1 -1
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertContourToSurface.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.js +1 -1
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/polySeg/computeAndAddRepresentation.js +1 -1
- package/dist/esm/stateManagement/segmentation/polySeg/computeAndAddRepresentation.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.js +2 -0
- package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.js.map +1 -1
- package/dist/esm/store/ToolGroupManager/getToolGroupForViewport.js +4 -0
- package/dist/esm/store/ToolGroupManager/getToolGroupForViewport.js.map +1 -1
- package/dist/esm/tools/base/BaseTool.js +3 -0
- package/dist/esm/tools/base/BaseTool.js.map +1 -1
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js.map +1 -1
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js +13 -5
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +1 -1
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
- package/dist/esm/tools/displayTools/SegmentationDisplayTool.js +17 -0
- package/dist/esm/tools/displayTools/SegmentationDisplayTool.js.map +1 -1
- package/dist/esm/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js +3 -46
- package/dist/esm/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js.map +1 -1
- package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js +8 -139
- package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js.map +1 -1
- package/dist/esm/utilities/contourSegmentation/addContourSegmentationAnnotation.js +4 -1
- package/dist/esm/utilities/contourSegmentation/addContourSegmentationAnnotation.js.map +1 -1
- package/dist/esm/utilities/contourSegmentation/removeContourSegmentationAnnotation.js +3 -0
- package/dist/esm/utilities/contourSegmentation/removeContourSegmentationAnnotation.js.map +1 -1
- package/dist/esm/utilities/math/polyline/getAABB.js +30 -4
- package/dist/esm/utilities/math/polyline/getAABB.js.map +1 -1
- package/dist/esm/utilities/planar/index.js +3 -1
- package/dist/esm/utilities/planar/index.js.map +1 -1
- package/dist/esm/utilities/planar/isPlaneIntersectingAABB.js +28 -0
- package/dist/esm/utilities/planar/isPlaneIntersectingAABB.js.map +1 -0
- package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.js +92 -44
- package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.js.map +1 -1
- package/dist/esm/workers/polySegConverters.js +74 -1
- package/dist/esm/workers/polySegConverters.js.map +1 -1
- package/dist/types/drawingSvg/drawPath.d.ts.map +1 -1
- package/dist/types/enums/WorkerTypes.d.ts +1 -1
- package/dist/types/enums/WorkerTypes.d.ts.map +1 -1
- package/dist/types/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.d.ts +18 -0
- package/dist/types/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.d.ts.map +1 -0
- package/dist/types/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.d.ts +3 -1
- package/dist/types/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.d.ts.map +1 -1
- package/dist/types/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.d.ts +9 -0
- package/dist/types/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.d.ts.map +1 -0
- package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.d.ts +4 -0
- package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.d.ts.map +1 -0
- package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.d.ts +4 -0
- package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.d.ts.map +1 -0
- package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.d.ts +2 -0
- package/dist/types/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.d.ts.map +1 -0
- package/dist/types/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.d.ts.map +1 -1
- package/dist/types/stateManagement/segmentation/triggerSegmentationEvents.d.ts.map +1 -1
- package/dist/types/store/ToolGroupManager/getToolGroupForViewport.d.ts +1 -1
- package/dist/types/store/ToolGroupManager/getToolGroupForViewport.d.ts.map +1 -1
- package/dist/types/tools/base/BaseTool.d.ts.map +1 -1
- package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts.map +1 -1
- package/dist/types/tools/displayTools/Contour/contourDisplay.d.ts.map +1 -1
- package/dist/types/tools/displayTools/SegmentationDisplayTool.d.ts +1 -0
- package/dist/types/tools/displayTools/SegmentationDisplayTool.d.ts.map +1 -1
- package/dist/types/tools/displayTools/Surface/addOrUpdateSurfaceToElement.d.ts.map +1 -1
- package/dist/types/tools/displayTools/Surface/surfaceDisplay.d.ts +3 -9
- package/dist/types/tools/displayTools/Surface/surfaceDisplay.d.ts.map +1 -1
- package/dist/types/types/PolySeg.d.ts +1 -1
- package/dist/types/types/PolySeg.d.ts.map +1 -1
- package/dist/types/utilities/contourSegmentation/addContourSegmentationAnnotation.d.ts.map +1 -1
- package/dist/types/utilities/contourSegmentation/removeContourSegmentationAnnotation.d.ts.map +1 -1
- package/dist/types/utilities/math/polyline/getAABB.d.ts +3 -1
- package/dist/types/utilities/math/polyline/getAABB.d.ts.map +1 -1
- package/dist/types/utilities/planar/index.d.ts +3 -1
- package/dist/types/utilities/planar/index.d.ts.map +1 -1
- package/dist/types/utilities/planar/isPlaneIntersectingAABB.d.ts +2 -0
- package/dist/types/utilities/planar/isPlaneIntersectingAABB.d.ts.map +1 -0
- package/dist/types/utilities/segmentation/getUniqueSegmentIndices.d.ts +3 -1
- package/dist/types/utilities/segmentation/getUniqueSegmentIndices.d.ts.map +1 -1
- package/dist/umd/985.index.js +1 -1
- package/dist/umd/985.index.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +4 -4
- package/src/drawingSvg/drawPath.ts +3 -1
- package/src/enums/WorkerTypes.ts +1 -1
- package/src/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.ts +203 -0
- package/src/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.ts +9 -2
- package/src/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.ts +201 -0
- package/src/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.ts +103 -0
- package/src/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.ts +38 -0
- package/src/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.ts +58 -0
- package/src/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.ts +2 -2
- package/src/stateManagement/segmentation/polySeg/Labelmap/convertSurfaceToLabelmap.ts +1 -1
- package/src/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.ts +3 -8
- package/src/stateManagement/segmentation/polySeg/Surface/convertContourToSurface.ts +1 -1
- package/src/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.ts +1 -1
- package/src/stateManagement/segmentation/polySeg/computeAndAddRepresentation.ts +1 -1
- package/src/stateManagement/segmentation/triggerSegmentationEvents.ts +5 -0
- package/src/store/ToolGroupManager/getToolGroupForViewport.ts +8 -1
- package/src/tools/base/BaseTool.ts +7 -0
- package/src/tools/base/ContourSegmentationBaseTool.ts +5 -0
- package/src/tools/displayTools/Contour/contourDisplay.ts +29 -11
- package/src/tools/displayTools/Labelmap/labelmapDisplay.ts +1 -1
- package/src/tools/displayTools/SegmentationDisplayTool.ts +26 -0
- package/src/tools/displayTools/Surface/addOrUpdateSurfaceToElement.ts +3 -65
- package/src/tools/displayTools/Surface/surfaceDisplay.ts +12 -247
- package/src/types/PolySeg.ts +1 -1
- package/src/utilities/contourSegmentation/addContourSegmentationAnnotation.ts +9 -1
- package/src/utilities/contourSegmentation/removeContourSegmentationAnnotation.ts +4 -0
- package/src/utilities/math/polyline/getAABB.ts +58 -4
- package/src/utilities/planar/index.ts +3 -0
- package/src/utilities/planar/isPlaneIntersectingAABB.ts +56 -0
- package/src/utilities/segmentation/getUniqueSegmentIndices.ts +115 -49
- package/src/workers/polySegConverters.js +117 -1
- package/dist/cjs/tools/displayTools/registerDisplayToolsWorker.d.ts +0 -1
- package/dist/cjs/tools/displayTools/registerDisplayToolsWorker.js +0 -27
- package/dist/cjs/tools/displayTools/registerDisplayToolsWorker.js.map +0 -1
- package/dist/cjs/workers/clippingPlaneWorker.d.ts +0 -1
- package/dist/cjs/workers/clippingPlaneWorker.js +0 -63
- package/dist/cjs/workers/clippingPlaneWorker.js.map +0 -1
- package/dist/esm/tools/displayTools/registerDisplayToolsWorker.js +0 -23
- package/dist/esm/tools/displayTools/registerDisplayToolsWorker.js.map +0 -1
- package/dist/esm/workers/clippingPlaneWorker.js +0 -58
- package/dist/esm/workers/clippingPlaneWorker.js.map +0 -1
- package/dist/types/tools/displayTools/registerDisplayToolsWorker.d.ts +0 -2
- package/dist/types/tools/displayTools/registerDisplayToolsWorker.d.ts.map +0 -1
- package/dist/types/workers/clippingPlaneWorker.d.ts +0 -2
- package/dist/types/workers/clippingPlaneWorker.d.ts.map +0 -1
- package/dist/umd/444.index.js +0 -3
- package/dist/umd/444.index.js.LICENSE.txt +0 -5
- package/dist/umd/444.index.js.map +0 -1
- package/src/tools/displayTools/registerDisplayToolsWorker.ts +0 -34
- package/src/workers/clippingPlaneWorker.js +0 -87
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.58.1",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@cornerstonejs/core": "^1.
|
|
32
|
+
"@cornerstonejs/core": "^1.58.1",
|
|
33
33
|
"@icr/polyseg-wasm": "0.4.0",
|
|
34
34
|
"@types/offscreencanvas": "2019.7.3",
|
|
35
35
|
"comlink": "^4.4.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@icr/polyseg-wasm": "0.4.0",
|
|
44
|
-
"@kitware/vtk.js": "29.
|
|
44
|
+
"@kitware/vtk.js": "29.7.0",
|
|
45
45
|
"@types/d3-array": "^3.0.4",
|
|
46
46
|
"@types/d3-interpolate": "^3.0.1",
|
|
47
47
|
"d3-array": "^3.2.3",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"type": "individual",
|
|
60
60
|
"url": "https://ohif.org/donate"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "6125a8f89f37b975a49786ba2fd75f682f537402"
|
|
63
63
|
}
|
|
@@ -61,7 +61,9 @@ export default function drawPath(
|
|
|
61
61
|
const point = points[j];
|
|
62
62
|
const cmd = j ? 'L' : 'M';
|
|
63
63
|
|
|
64
|
-
pointsAttribute += `${cmd} ${point[0]}
|
|
64
|
+
pointsAttribute += `${cmd} ${point[0].toFixed(1)}, ${point[1].toFixed(
|
|
65
|
+
1
|
|
66
|
+
)} `;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
if (closePath) {
|
package/src/enums/WorkerTypes.ts
CHANGED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Types,
|
|
3
|
+
Enums,
|
|
4
|
+
getWebWorkerManager,
|
|
5
|
+
eventTarget,
|
|
6
|
+
triggerEvent,
|
|
7
|
+
} from '@cornerstonejs/core';
|
|
8
|
+
|
|
9
|
+
import { WorkerTypes } from '../../../enums';
|
|
10
|
+
import { pointToString } from '../../../utilities';
|
|
11
|
+
import { registerPolySegWorker } from '../polySeg/registerPolySegWorker';
|
|
12
|
+
const workerManager = getWebWorkerManager();
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Surfaces info for clipping
|
|
16
|
+
*/
|
|
17
|
+
export type SurfacesInfo = {
|
|
18
|
+
id: string;
|
|
19
|
+
points: number[];
|
|
20
|
+
polys: number[];
|
|
21
|
+
segmentIndex: number;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The result of the surface clipping
|
|
26
|
+
*/
|
|
27
|
+
export type SurfaceClipResult = {
|
|
28
|
+
points: number[];
|
|
29
|
+
lines: number[];
|
|
30
|
+
numberOfCells: number;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type PolyDataClipCacheType = Map<string, Map<string, SurfaceClipResult>>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* a cache from actorUID to cacheId to SurfaceClipResult
|
|
37
|
+
* Map<actorUID, Map<cacheId, SurfaceClipResult>>
|
|
38
|
+
* cacheId is slice specific (viewPlaneNormal, sliceIndex)
|
|
39
|
+
*/
|
|
40
|
+
const polyDataCache = new Map() as PolyDataClipCacheType;
|
|
41
|
+
const surfacesAABBCache = new Map();
|
|
42
|
+
|
|
43
|
+
const triggerWorkerProgress = (eventTarget, progress) => {
|
|
44
|
+
triggerEvent(eventTarget, Enums.Events.WEB_WORKER_PROGRESS, {
|
|
45
|
+
progress,
|
|
46
|
+
type: WorkerTypes.SURFACE_CLIPPING,
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Clips and caches surfaces for a specific viewport.
|
|
52
|
+
*
|
|
53
|
+
* @param surfacesInfo - An array of surfaces information.
|
|
54
|
+
* @param viewport - The volume viewport.
|
|
55
|
+
* @param segmentationRepresentationUID - The UID of the segmentation representation.
|
|
56
|
+
* @returns The cached polydata.
|
|
57
|
+
*/
|
|
58
|
+
export async function clipAndCacheSurfacesForViewport(
|
|
59
|
+
surfacesInfo: SurfacesInfo[],
|
|
60
|
+
viewport: Types.IVolumeViewport,
|
|
61
|
+
segmentationRepresentationUID: string
|
|
62
|
+
) {
|
|
63
|
+
registerPolySegWorker();
|
|
64
|
+
// All planes is an array of planes pairs for each slice, so we should loop over them and
|
|
65
|
+
// add the planes to the clipping filter and cache the results for that slice
|
|
66
|
+
|
|
67
|
+
// Fix these ts ignores
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
const planesInfo = viewport.getSlicesClippingPlanes?.();
|
|
70
|
+
|
|
71
|
+
if (!planesInfo) {
|
|
72
|
+
// this means it is probably the stack viewport not being ready
|
|
73
|
+
// in terms of planes which we should wait for the first render to
|
|
74
|
+
// get the planes
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// @ts-ignore
|
|
79
|
+
const currentSliceIndex = viewport.getSliceIndex();
|
|
80
|
+
|
|
81
|
+
// Reorder planesInfo based on proximity to currentSliceIndex
|
|
82
|
+
planesInfo.sort((a, b) => {
|
|
83
|
+
const diffA = Math.abs(a.sliceIndex - currentSliceIndex);
|
|
84
|
+
const diffB = Math.abs(b.sliceIndex - currentSliceIndex);
|
|
85
|
+
return diffA - diffB;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
triggerWorkerProgress(eventTarget, 0);
|
|
89
|
+
|
|
90
|
+
// check which surfaces don't have a cached AABB
|
|
91
|
+
// make a list of the surfaces that don't have a cached AABB
|
|
92
|
+
await updateSurfacesAABBCache(surfacesInfo);
|
|
93
|
+
|
|
94
|
+
const surfacesAABB = new Map();
|
|
95
|
+
surfacesInfo.forEach((surface) => {
|
|
96
|
+
surfacesAABB.set(surface.id, surfacesAABBCache.get(surface.id));
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const camera = viewport.getCamera();
|
|
100
|
+
|
|
101
|
+
await workerManager
|
|
102
|
+
.executeTask(
|
|
103
|
+
'polySeg',
|
|
104
|
+
'cutSurfacesIntoPlanes',
|
|
105
|
+
{
|
|
106
|
+
surfacesInfo,
|
|
107
|
+
planesInfo,
|
|
108
|
+
surfacesAABB,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
callbacks: [
|
|
112
|
+
// progress callback
|
|
113
|
+
({ progress }) => {
|
|
114
|
+
triggerWorkerProgress(eventTarget, progress);
|
|
115
|
+
},
|
|
116
|
+
// update cache callback
|
|
117
|
+
({ sliceIndex, polyDataResults }) => {
|
|
118
|
+
polyDataResults.forEach((polyDataResult, surfaceId) => {
|
|
119
|
+
const actorUID = `${segmentationRepresentationUID}_${surfaceId}`;
|
|
120
|
+
const cacheId = generateCacheId(
|
|
121
|
+
viewport,
|
|
122
|
+
camera.viewPlaneNormal,
|
|
123
|
+
sliceIndex
|
|
124
|
+
);
|
|
125
|
+
updatePolyDataCache(actorUID, cacheId, polyDataResult);
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
.catch((error) => {
|
|
132
|
+
console.error(error);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
triggerWorkerProgress(eventTarget, 1);
|
|
136
|
+
|
|
137
|
+
return polyDataCache;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Updates the surfaces AABB cache with the AABB information for the given surfaces.
|
|
142
|
+
* If the AABB information for a surface already exists in the cache, it will not be updated.
|
|
143
|
+
* @param surfacesInfo - An array of surfaces information.
|
|
144
|
+
* @returns A Promise that resolves when the surfaces AABB cache has been updated.
|
|
145
|
+
*/
|
|
146
|
+
async function updateSurfacesAABBCache(surfacesInfo: SurfacesInfo[]) {
|
|
147
|
+
const surfacesWithoutAABB = surfacesInfo.filter(
|
|
148
|
+
(surface) => !surfacesAABBCache.has(surface.id)
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
if (!surfacesWithoutAABB.length) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const surfacesAABB = await workerManager.executeTask(
|
|
156
|
+
'polySeg',
|
|
157
|
+
'getSurfacesAABBs',
|
|
158
|
+
{
|
|
159
|
+
surfacesInfo: surfacesWithoutAABB,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
callbacks: [
|
|
163
|
+
// progress callback
|
|
164
|
+
({ progress }) => {
|
|
165
|
+
triggerWorkerProgress(eventTarget, progress);
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
// update the surfacesAABBCache with the new surfacesAABB
|
|
172
|
+
surfacesAABB.forEach((aabb, id) => {
|
|
173
|
+
surfacesAABBCache.set(id, aabb);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function getSurfaceActorUID(
|
|
178
|
+
segmentationRepresentationUID: string,
|
|
179
|
+
surfaceId: string
|
|
180
|
+
) {
|
|
181
|
+
return `${segmentationRepresentationUID}_${surfaceId}`;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Helper function to generate a cache ID
|
|
185
|
+
export function generateCacheId(viewport, viewPlaneNormal, sliceIndex) {
|
|
186
|
+
return `${viewport.id}-${pointToString(viewPlaneNormal)}-${sliceIndex}`;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Helper function to update PolyData cache
|
|
190
|
+
export function updatePolyDataCache(
|
|
191
|
+
actorUID: string,
|
|
192
|
+
cacheId: string,
|
|
193
|
+
polyDataResult: SurfaceClipResult
|
|
194
|
+
) {
|
|
195
|
+
const { points, lines, numberOfCells } = polyDataResult;
|
|
196
|
+
|
|
197
|
+
let actorCache = polyDataCache.get(actorUID);
|
|
198
|
+
if (!actorCache) {
|
|
199
|
+
actorCache = new Map<string, SurfaceClipResult>();
|
|
200
|
+
polyDataCache.set(actorUID, actorCache);
|
|
201
|
+
}
|
|
202
|
+
actorCache.set(cacheId, { points, lines, numberOfCells });
|
|
203
|
+
}
|
package/src/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { SegmentationRepresentations } from '../../../../enums';
|
|
1
2
|
import { PolySegConversionOptions } from '../../../../types';
|
|
2
|
-
|
|
3
|
+
import { computeAndAddRepresentation } from '../computeAndAddRepresentation';
|
|
4
|
+
import { computeContourData } from './contourComputationStrategies';
|
|
3
5
|
/**
|
|
4
6
|
* Computes and adds the contour representation for a given segmentation.
|
|
5
7
|
*
|
|
@@ -13,5 +15,10 @@ export function computeAndAddContourRepresentation(
|
|
|
13
15
|
segmentationId: string,
|
|
14
16
|
options: PolySegConversionOptions = {}
|
|
15
17
|
) {
|
|
16
|
-
|
|
18
|
+
return computeAndAddRepresentation(
|
|
19
|
+
segmentationId,
|
|
20
|
+
SegmentationRepresentations.Contour,
|
|
21
|
+
() => computeContourData(segmentationId, options),
|
|
22
|
+
() => undefined
|
|
23
|
+
);
|
|
17
24
|
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { cache } from '@cornerstonejs/core';
|
|
2
|
+
import type { Types } from '@cornerstonejs/core';
|
|
3
|
+
import { getUniqueSegmentIndices } from '../../../../utilities/segmentation';
|
|
4
|
+
import {
|
|
5
|
+
getSegmentation,
|
|
6
|
+
setSegmentationRepresentationSpecificConfig,
|
|
7
|
+
} from '../../segmentationState';
|
|
8
|
+
import { PolySegConversionOptions } from '../../../../types';
|
|
9
|
+
import { computeSurfaceFromLabelmapSegmentation } from '../Surface/surfaceComputationStrategies';
|
|
10
|
+
import {
|
|
11
|
+
SurfaceClipResult,
|
|
12
|
+
clipAndCacheSurfacesForViewport,
|
|
13
|
+
} from '../../helpers/clipAndCacheSurfacesForViewport';
|
|
14
|
+
import { extractContourData } from './utils/extractContourData';
|
|
15
|
+
import { createAndAddContourSegmentationsFromClippedSurfaces } from './utils/createAndAddContourSegmentationsFromClippedSurfaces';
|
|
16
|
+
import { getToolGroupForViewport } from '../../../../store/ToolGroupManager';
|
|
17
|
+
|
|
18
|
+
// the map between segment index and the intersection points and lines
|
|
19
|
+
export type RawContourData = Map<number, SurfaceClipResult[]>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Computes contour data for a given segmentation.
|
|
23
|
+
* @param segmentationId - The ID of the segmentation.
|
|
24
|
+
* @param options - Optional parameters for the computation.
|
|
25
|
+
* @returns An object containing the annotation UIDs map.
|
|
26
|
+
* @throws Error if there is not enough data to convert to contour.
|
|
27
|
+
*/
|
|
28
|
+
export async function computeContourData(
|
|
29
|
+
segmentationId: string,
|
|
30
|
+
options: PolySegConversionOptions = {}
|
|
31
|
+
) {
|
|
32
|
+
const segmentIndices = options.segmentIndices?.length
|
|
33
|
+
? options.segmentIndices
|
|
34
|
+
: getUniqueSegmentIndices(segmentationId);
|
|
35
|
+
|
|
36
|
+
let rawContourData: RawContourData;
|
|
37
|
+
const segmentation = getSegmentation(segmentationId);
|
|
38
|
+
const representationData = segmentation.representationData;
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
if (representationData.SURFACE) {
|
|
42
|
+
rawContourData = await computeContourFromSurfaceSegmentation(
|
|
43
|
+
segmentationId,
|
|
44
|
+
{
|
|
45
|
+
segmentIndices,
|
|
46
|
+
...options,
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
} else if (representationData.LABELMAP) {
|
|
50
|
+
rawContourData = await computeContourFromLabelmapSegmentation(
|
|
51
|
+
segmentationId,
|
|
52
|
+
{
|
|
53
|
+
segmentIndices,
|
|
54
|
+
...options,
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error(error);
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!rawContourData) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
'Not enough data to convert to contour, currently only support converting volume labelmap to contour if available'
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const { viewport, segmentationRepresentationUID } = options;
|
|
70
|
+
|
|
71
|
+
// create the new annotations and add them to the segmentation state representation
|
|
72
|
+
// data for the contour representation
|
|
73
|
+
const annotationUIDsMap = createAndAddContourSegmentationsFromClippedSurfaces(
|
|
74
|
+
rawContourData,
|
|
75
|
+
viewport,
|
|
76
|
+
segmentationId
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// make the segmentation configuration fillAlpha 0 since
|
|
80
|
+
// we don't have proper hole support right now
|
|
81
|
+
// Todo: add hole support
|
|
82
|
+
const toolGroupId = getToolGroupForViewport(viewport.id)?.id;
|
|
83
|
+
|
|
84
|
+
setSegmentationRepresentationSpecificConfig(
|
|
85
|
+
toolGroupId,
|
|
86
|
+
segmentationRepresentationUID,
|
|
87
|
+
{
|
|
88
|
+
CONTOUR: {
|
|
89
|
+
fillAlpha: 0,
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
annotationUIDsMap,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Computes the contour from a labelmap segmentation.
|
|
101
|
+
* @param segmentationId - The ID of the segmentation.
|
|
102
|
+
* @param options - The options for the contour computation.
|
|
103
|
+
* @returns The raw contour data.
|
|
104
|
+
*/
|
|
105
|
+
async function computeContourFromLabelmapSegmentation(
|
|
106
|
+
segmentationId,
|
|
107
|
+
options: PolySegConversionOptions = {}
|
|
108
|
+
) {
|
|
109
|
+
if (!options.viewport) {
|
|
110
|
+
throw new Error('Viewport is required to compute contour from labelmap');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const results = await computeSurfaceFromLabelmapSegmentation(
|
|
114
|
+
segmentationId,
|
|
115
|
+
options
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
if (!results?.length) {
|
|
119
|
+
console.error('Failed to convert labelmap to surface or labelmap is empty');
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const { viewport, segmentationRepresentationUID } = options;
|
|
124
|
+
|
|
125
|
+
const pointsAndPolys = results.map((surface) => {
|
|
126
|
+
return {
|
|
127
|
+
id: surface.segmentIndex.toString(),
|
|
128
|
+
points: surface.data.points,
|
|
129
|
+
polys: surface.data.polys,
|
|
130
|
+
segmentIndex: surface.segmentIndex,
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const polyDataCache = await clipAndCacheSurfacesForViewport(
|
|
135
|
+
pointsAndPolys,
|
|
136
|
+
viewport as Types.IVolumeViewport,
|
|
137
|
+
segmentationRepresentationUID
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const rawResults = extractContourData(polyDataCache);
|
|
141
|
+
|
|
142
|
+
return rawResults;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Computes the contour from a surface segmentation.
|
|
147
|
+
* @param segmentationId - The ID of the segmentation.
|
|
148
|
+
* @param options - The options for the contour computation.
|
|
149
|
+
* @returns A promise that resolves to the raw contour data.
|
|
150
|
+
* @throws An error if the viewport is not provided.
|
|
151
|
+
*/
|
|
152
|
+
async function computeContourFromSurfaceSegmentation(
|
|
153
|
+
segmentationId,
|
|
154
|
+
options: PolySegConversionOptions = {}
|
|
155
|
+
): Promise<RawContourData> {
|
|
156
|
+
if (!options.viewport) {
|
|
157
|
+
throw new Error('Viewport is required to compute contour from surface');
|
|
158
|
+
}
|
|
159
|
+
const { viewport, segmentationRepresentationUID } = options;
|
|
160
|
+
|
|
161
|
+
const segmentIndices = options.segmentIndices?.length
|
|
162
|
+
? options.segmentIndices
|
|
163
|
+
: getUniqueSegmentIndices(segmentationId);
|
|
164
|
+
|
|
165
|
+
const segmentIndexToSurfaceId = new Map() as Map<number, string>;
|
|
166
|
+
const surfaceIdToSegmentIndex = new Map() as Map<string, number>;
|
|
167
|
+
|
|
168
|
+
const segmentation = getSegmentation(segmentationId);
|
|
169
|
+
const representationData = segmentation.representationData.SURFACE;
|
|
170
|
+
|
|
171
|
+
const surfacesInfo = [];
|
|
172
|
+
representationData.geometryIds.forEach((geometryId, segmentIndex) => {
|
|
173
|
+
if (segmentIndices.includes(segmentIndex)) {
|
|
174
|
+
segmentIndexToSurfaceId.set(segmentIndex, geometryId);
|
|
175
|
+
const surface = cache.getGeometry(geometryId)?.data as Types.ISurface;
|
|
176
|
+
if (surface) {
|
|
177
|
+
surfacesInfo.push({
|
|
178
|
+
id: geometryId,
|
|
179
|
+
points: surface.getPoints(),
|
|
180
|
+
polys: surface.getPolys(),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
segmentIndexToSurfaceId.forEach((surfaceId, segmentIndex) => {
|
|
187
|
+
surfaceIdToSegmentIndex.set(surfaceId, segmentIndex);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const polyDataCache = await clipAndCacheSurfacesForViewport(
|
|
191
|
+
surfacesInfo,
|
|
192
|
+
viewport as Types.IVolumeViewport,
|
|
193
|
+
segmentationRepresentationUID
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
const rawResults = extractContourData(polyDataCache, surfaceIdToSegmentIndex);
|
|
197
|
+
|
|
198
|
+
return rawResults;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export { computeContourFromLabelmapSegmentation };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { PlanarFreehandContourSegmentationTool } from '../../../../../tools';
|
|
2
|
+
import { addAnnotation } from '../../../../annotation/annotationState';
|
|
3
|
+
import { RawContourData } from '../contourComputationStrategies';
|
|
4
|
+
import { utilities, type Types } from '@cornerstonejs/core';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates and adds contour segmentations from a clipped surface.
|
|
8
|
+
*
|
|
9
|
+
* @param rawContourData - The raw contour data.
|
|
10
|
+
* @param viewport - The viewport.
|
|
11
|
+
* @param segmentationId - The segmentation ID.
|
|
12
|
+
*/
|
|
13
|
+
export function createAndAddContourSegmentationsFromClippedSurfaces(
|
|
14
|
+
rawContourData: RawContourData,
|
|
15
|
+
viewport: Types.IViewport,
|
|
16
|
+
segmentationId: string
|
|
17
|
+
) {
|
|
18
|
+
const annotationUIDsMap = new Map<number, Set<string>>();
|
|
19
|
+
|
|
20
|
+
for (const [segmentIndex, contoursData] of rawContourData) {
|
|
21
|
+
for (const contourData of contoursData) {
|
|
22
|
+
const { points } = contourData;
|
|
23
|
+
|
|
24
|
+
const { lineSegments, linesNumberOfPoints } =
|
|
25
|
+
_extractLineSegments(contourData);
|
|
26
|
+
|
|
27
|
+
// There may be a few lines as the surface might not be closed and could have holes in it.
|
|
28
|
+
// Currently, we simply render the generated contour as empty fill to indicate
|
|
29
|
+
// the presence of holes. However, filling the proper area with
|
|
30
|
+
// fillAlpha requires further work.
|
|
31
|
+
for (let i = 0; i < lineSegments.length; i++) {
|
|
32
|
+
const line = lineSegments[i];
|
|
33
|
+
const polyline = [];
|
|
34
|
+
|
|
35
|
+
for (let j = 0; j < linesNumberOfPoints[i]; j++) {
|
|
36
|
+
const pointIndex = line[j];
|
|
37
|
+
polyline.push([
|
|
38
|
+
points[3 * pointIndex],
|
|
39
|
+
points[3 * pointIndex + 1],
|
|
40
|
+
points[3 * pointIndex + 2],
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (polyline.length < 3) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const contourSegmentationAnnotation = {
|
|
49
|
+
annotationUID: utilities.uuidv4(),
|
|
50
|
+
data: {
|
|
51
|
+
contour: {
|
|
52
|
+
closed: true,
|
|
53
|
+
polyline,
|
|
54
|
+
},
|
|
55
|
+
segmentation: {
|
|
56
|
+
segmentationId,
|
|
57
|
+
segmentIndex,
|
|
58
|
+
},
|
|
59
|
+
handles: {},
|
|
60
|
+
},
|
|
61
|
+
handles: {},
|
|
62
|
+
highlighted: false,
|
|
63
|
+
autoGenerated: false,
|
|
64
|
+
invalidated: false,
|
|
65
|
+
isLocked: false,
|
|
66
|
+
isVisible: true,
|
|
67
|
+
metadata: {
|
|
68
|
+
toolName: PlanarFreehandContourSegmentationTool.toolName,
|
|
69
|
+
...viewport.getViewReference(),
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
addAnnotation(contourSegmentationAnnotation, viewport.element);
|
|
74
|
+
|
|
75
|
+
const currentSet = annotationUIDsMap.get(segmentIndex) || new Set();
|
|
76
|
+
currentSet.add(contourSegmentationAnnotation.annotationUID);
|
|
77
|
+
annotationUIDsMap.set(segmentIndex, currentSet);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return annotationUIDsMap;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const _extractLineSegments = (contourData) => {
|
|
86
|
+
const { numberOfCells, lines } = contourData;
|
|
87
|
+
|
|
88
|
+
const lineSegments = [];
|
|
89
|
+
const linesNumberOfPoints = [];
|
|
90
|
+
|
|
91
|
+
for (let i = 0; i < lines.length; ) {
|
|
92
|
+
const pointsInLine = lines[i];
|
|
93
|
+
linesNumberOfPoints.push(pointsInLine);
|
|
94
|
+
lineSegments.push(lines.slice(i + 1, i + pointsInLine + 1));
|
|
95
|
+
i += pointsInLine + 1;
|
|
96
|
+
|
|
97
|
+
if (lineSegments.length === numberOfCells) {
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return { lineSegments, linesNumberOfPoints };
|
|
103
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { PolyDataClipCacheType } from '../../../helpers/clipAndCacheSurfacesForViewport';
|
|
2
|
+
import { RawContourData } from '../contourComputationStrategies';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Extracts contour data from the given polyDataCache.
|
|
6
|
+
* @param polyDataCache - The polyData cache containing intersection information.
|
|
7
|
+
* @param segmentIndexMap - Optional map for mapping surface IDs to segment indices.
|
|
8
|
+
* @returns A map of segment indices to an array of contour results.
|
|
9
|
+
*/
|
|
10
|
+
export function extractContourData(
|
|
11
|
+
polyDataCache: PolyDataClipCacheType,
|
|
12
|
+
segmentIndexMap?: Map<string, number>
|
|
13
|
+
) {
|
|
14
|
+
const rawResults = new Map() as RawContourData;
|
|
15
|
+
|
|
16
|
+
for (const [cacheId, intersectionInfo] of polyDataCache) {
|
|
17
|
+
// Todo; fix this
|
|
18
|
+
const surfaceId = cacheId.split('_')[1];
|
|
19
|
+
|
|
20
|
+
for (const [_, result] of intersectionInfo) {
|
|
21
|
+
if (!result) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const segmentIndex = Number(surfaceId) || segmentIndexMap?.get(surfaceId);
|
|
25
|
+
|
|
26
|
+
if (!segmentIndex) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!rawResults.has(segmentIndex)) {
|
|
31
|
+
rawResults.set(segmentIndex, []);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
rawResults.get(segmentIndex).push(result);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return rawResults;
|
|
38
|
+
}
|
package/src/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { utilities, type Types, Enums } from '@cornerstonejs/core';
|
|
2
|
+
import { extractContourData } from './extractContourData';
|
|
3
|
+
import { clipAndCacheSurfacesForViewport } from '../../../helpers/clipAndCacheSurfacesForViewport';
|
|
4
|
+
import { createAndAddContourSegmentationsFromClippedSurfaces } from './createAndAddContourSegmentationsFromClippedSurfaces';
|
|
5
|
+
|
|
6
|
+
const currentViewportNormal = new Map();
|
|
7
|
+
|
|
8
|
+
export function updateContoursOnCameraModified(
|
|
9
|
+
surfacesInfo,
|
|
10
|
+
viewport,
|
|
11
|
+
segmentationRepresentationUID
|
|
12
|
+
) {
|
|
13
|
+
async function cameraModifiedCallback(
|
|
14
|
+
evt: Types.EventTypes.CameraModifiedEvent
|
|
15
|
+
) {
|
|
16
|
+
const { camera } = evt.detail;
|
|
17
|
+
const { viewPlaneNormal } = camera;
|
|
18
|
+
|
|
19
|
+
// Note: I think choosing one of the surfaces to see
|
|
20
|
+
// if the viewPlaneNormal is the same for all surfaces is ok enough
|
|
21
|
+
// to decide if we should recompute the clipping planes
|
|
22
|
+
const surface1 = surfacesInfo[0];
|
|
23
|
+
|
|
24
|
+
const currentNormal = currentViewportNormal.get(surface1.id);
|
|
25
|
+
if (utilities.isEqual(viewPlaneNormal, currentNormal)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
currentViewportNormal.set(surface1.id, viewPlaneNormal);
|
|
29
|
+
|
|
30
|
+
const polyDataCache = await clipAndCacheSurfacesForViewport(
|
|
31
|
+
surfacesInfo,
|
|
32
|
+
viewport as Types.IVolumeViewport,
|
|
33
|
+
segmentationRepresentationUID
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const results = extractContourData(polyDataCache);
|
|
37
|
+
|
|
38
|
+
createAndAddContourSegmentationsFromClippedSurfaces(
|
|
39
|
+
results,
|
|
40
|
+
viewport,
|
|
41
|
+
segmentationRepresentationUID
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
viewport.render();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const camera = viewport.getCamera();
|
|
48
|
+
currentViewportNormal.set(surfacesInfo[0].id, camera.viewPlaneNormal);
|
|
49
|
+
|
|
50
|
+
// Remove the existing event listener
|
|
51
|
+
viewport.element.removeEventListener(
|
|
52
|
+
Enums.Events.CAMERA_MODIFIED,
|
|
53
|
+
cameraModifiedCallback
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// Add the event listener
|
|
57
|
+
viewport.element.addEventListener(Enums.Events.CAMERA_MODIFIED);
|
|
58
|
+
}
|
|
@@ -91,7 +91,7 @@ export async function convertContourToVolumeLabelmap(
|
|
|
91
91
|
}
|
|
92
92
|
);
|
|
93
93
|
|
|
94
|
-
triggerWorkerProgress(eventTarget,
|
|
94
|
+
triggerWorkerProgress(eventTarget, 1);
|
|
95
95
|
|
|
96
96
|
segmentationVolume.imageData
|
|
97
97
|
.getPointData()
|
|
@@ -227,7 +227,7 @@ export async function convertContourToStackLabelmap(
|
|
|
227
227
|
}
|
|
228
228
|
);
|
|
229
229
|
|
|
230
|
-
triggerWorkerProgress(eventTarget,
|
|
230
|
+
triggerWorkerProgress(eventTarget, 1);
|
|
231
231
|
|
|
232
232
|
const imageIdReferenceMap = new Map();
|
|
233
233
|
newSegmentationsScalarData.forEach(({ scalarData }, referencedImageId) => {
|