@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
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import vtkCellArray from '@kitware/vtk.js/Common/Core/CellArray';
|
|
3
|
-
import { cache, getEnabledElementByIds, Enums, getWebWorkerManager, eventTarget, triggerEvent, utilities, VolumeViewport3D, } from '@cornerstonejs/core';
|
|
1
|
+
import { cache, getEnabledElementByIds, VolumeViewport3D, } from '@cornerstonejs/core';
|
|
4
2
|
import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
|
|
5
3
|
import Representations from '../../../enums/SegmentationRepresentations';
|
|
6
4
|
import { getToolGroup } from '../../../store/ToolGroupManager';
|
|
7
|
-
import { registerDisplayToolsWorker } from '../registerDisplayToolsWorker';
|
|
8
5
|
import removeSurfaceFromElement from './removeSurfaceFromElement';
|
|
9
6
|
import addOrUpdateSurfaceToElement from './addOrUpdateSurfaceToElement';
|
|
10
7
|
import { polySeg } from '../../../stateManagement/segmentation';
|
|
11
|
-
import { pointToString } from '../../../utilities';
|
|
12
|
-
import { WorkerTypes } from '../../../enums';
|
|
13
|
-
const workerManager = getWebWorkerManager();
|
|
14
|
-
const polyDataCache = new Map();
|
|
15
|
-
const currentViewportNormal = new Map();
|
|
16
|
-
const triggerWorkerProgress = (eventTarget, progress) => {
|
|
17
|
-
triggerEvent(eventTarget, Enums.Events.WEB_WORKER_PROGRESS, {
|
|
18
|
-
progress,
|
|
19
|
-
type: WorkerTypes.DISPLAY_TOOL_CLIP_SURFACE,
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
8
|
function removeSegmentationRepresentation(toolGroupId, segmentationRepresentationUID, renderImmediate = false) {
|
|
23
9
|
_removeSurfaceFromToolGroupViewports(toolGroupId, segmentationRepresentationUID);
|
|
24
10
|
SegmentationState.removeSegmentationRepresentation(toolGroupId, segmentationRepresentationUID);
|
|
@@ -30,12 +16,15 @@ function removeSegmentationRepresentation(toolGroupId, segmentationRepresentatio
|
|
|
30
16
|
});
|
|
31
17
|
}
|
|
32
18
|
}
|
|
33
|
-
async function render(viewport, representation
|
|
34
|
-
const { colorLUTIndex,
|
|
19
|
+
async function render(viewport, representation) {
|
|
20
|
+
const { colorLUTIndex, segmentationId, segmentationRepresentationUID } = representation;
|
|
35
21
|
const segmentation = SegmentationState.getSegmentation(segmentationId);
|
|
36
22
|
if (!segmentation) {
|
|
37
23
|
return;
|
|
38
24
|
}
|
|
25
|
+
if (!(viewport instanceof VolumeViewport3D)) {
|
|
26
|
+
throw new Error('Surface rendering is only supported in 3D viewports, if you need to visualize the surface cuts in 2D viewports, you can use the Contour representation, see polySeg converters');
|
|
27
|
+
}
|
|
39
28
|
let SurfaceData = segmentation.representationData[Representations.Surface];
|
|
40
29
|
if (!SurfaceData &&
|
|
41
30
|
polySeg.canComputeRequestedRepresentation(segmentationRepresentationUID)) {
|
|
@@ -54,13 +43,7 @@ async function render(viewport, representation, toolGroupConfig) {
|
|
|
54
43
|
const surfaces = [];
|
|
55
44
|
geometryIds.forEach((geometryId, segmentIndex) => {
|
|
56
45
|
const geometry = cache.getGeometry(geometryId);
|
|
57
|
-
if (!geometry) {
|
|
58
|
-
throw new Error(`No Surfaces found for geometryId ${geometryId}`);
|
|
59
|
-
}
|
|
60
|
-
if (geometry.type !== Enums.GeometryType.SURFACE) {
|
|
61
|
-
throw new Error(`Geometry type ${geometry.type} not supported for rendering.`);
|
|
62
|
-
}
|
|
63
|
-
if (!geometry.data) {
|
|
46
|
+
if (!geometry?.data) {
|
|
64
47
|
console.warn(`No Surfaces found for geometryId ${geometryId}. Skipping render.`);
|
|
65
48
|
return;
|
|
66
49
|
}
|
|
@@ -70,9 +53,6 @@ async function render(viewport, representation, toolGroupConfig) {
|
|
|
70
53
|
addOrUpdateSurfaceToElement(viewport.element, surface, segmentationRepresentationUID);
|
|
71
54
|
surfaces.push(surface);
|
|
72
55
|
});
|
|
73
|
-
if (!(viewport instanceof VolumeViewport3D)) {
|
|
74
|
-
generateAndCacheClippedSurfaces(surfaces, viewport, segmentationRepresentationUID);
|
|
75
|
-
}
|
|
76
56
|
viewport.render();
|
|
77
57
|
}
|
|
78
58
|
function _removeSurfaceFromToolGroupViewports(toolGroupId, segmentationRepresentationUID) {
|
|
@@ -87,120 +67,9 @@ function _removeSurfaceFromToolGroupViewports(toolGroupId, segmentationRepresent
|
|
|
87
67
|
removeSurfaceFromElement(enabledElement.viewport.element, segmentationRepresentationUID);
|
|
88
68
|
}
|
|
89
69
|
}
|
|
90
|
-
async function generateAndCacheClippedSurfaces(surfaces, viewport, segmentationRepresentationUID) {
|
|
91
|
-
registerDisplayToolsWorker();
|
|
92
|
-
const planesInfo = viewport.getSlicesClippingPlanes?.();
|
|
93
|
-
if (!planesInfo) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
const currentSliceIndex = viewport.getSliceIndex();
|
|
97
|
-
planesInfo.sort((a, b) => {
|
|
98
|
-
const diffA = Math.abs(a.sliceIndex - currentSliceIndex);
|
|
99
|
-
const diffB = Math.abs(b.sliceIndex - currentSliceIndex);
|
|
100
|
-
return diffA - diffB;
|
|
101
|
-
});
|
|
102
|
-
const pointsAndPolys = surfaces.map((surface) => {
|
|
103
|
-
const id = surface.id;
|
|
104
|
-
const points = surface.getPoints();
|
|
105
|
-
const polys = surface.getPolys();
|
|
106
|
-
return { id, points, polys };
|
|
107
|
-
});
|
|
108
|
-
const camera = viewport.getCamera();
|
|
109
|
-
function cameraModifiedCallback(evt) {
|
|
110
|
-
const { camera } = evt.detail;
|
|
111
|
-
const { viewPlaneNormal } = camera;
|
|
112
|
-
const surface1 = surfaces[0];
|
|
113
|
-
if (utilities.isEqual(viewPlaneNormal, currentViewportNormal.get(surface1.id))) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
currentViewportNormal.set(surface1.id, viewPlaneNormal);
|
|
117
|
-
workerManager.terminate('displayTools');
|
|
118
|
-
setTimeout(() => {
|
|
119
|
-
generateAndCacheClippedSurfaces(surfaces, viewport, segmentationRepresentationUID);
|
|
120
|
-
}, 0);
|
|
121
|
-
viewport.render();
|
|
122
|
-
}
|
|
123
|
-
viewport.element.removeEventListener(Enums.Events.CAMERA_MODIFIED, cameraModifiedCallback);
|
|
124
|
-
viewport.element.addEventListener(Enums.Events.CAMERA_MODIFIED, cameraModifiedCallback);
|
|
125
|
-
triggerWorkerProgress(eventTarget, 0);
|
|
126
|
-
await workerManager
|
|
127
|
-
.executeTask('displayTools', 'clipSurfaceWithPlanes', {
|
|
128
|
-
planesInfo,
|
|
129
|
-
pointsAndPolys,
|
|
130
|
-
}, {
|
|
131
|
-
callbacks: [
|
|
132
|
-
({ progress }) => {
|
|
133
|
-
triggerWorkerProgress(eventTarget, progress);
|
|
134
|
-
},
|
|
135
|
-
({ sliceIndex, polyDataResults }) => {
|
|
136
|
-
polyDataResults.forEach((polyDataResult, surfaceId) => {
|
|
137
|
-
const actorUID = `${segmentationRepresentationUID}_${surfaceId}`;
|
|
138
|
-
const cacheId = generateCacheId(viewport, camera.viewPlaneNormal, sliceIndex);
|
|
139
|
-
updatePolyDataCache(actorUID, cacheId, polyDataResult);
|
|
140
|
-
});
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
})
|
|
144
|
-
.catch((error) => {
|
|
145
|
-
console.error(error);
|
|
146
|
-
});
|
|
147
|
-
triggerWorkerProgress(eventTarget, 100);
|
|
148
|
-
}
|
|
149
|
-
export function getSurfaceActorUID(segmentationRepresentationUID, surfaceId) {
|
|
150
|
-
return `${segmentationRepresentationUID}_${surfaceId}`;
|
|
151
|
-
}
|
|
152
|
-
export function generateCacheId(viewport, viewPlaneNormal, sliceIndex) {
|
|
153
|
-
return `${viewport.id}-${pointToString(viewPlaneNormal)}-${sliceIndex}`;
|
|
154
|
-
}
|
|
155
|
-
export function getOrCreatePolyData(actorEntry, cacheId, vtkPlanes) {
|
|
156
|
-
let actorCache = polyDataCache.get(actorEntry.uid);
|
|
157
|
-
if (!actorCache) {
|
|
158
|
-
actorCache = new Map();
|
|
159
|
-
polyDataCache.set(actorEntry.uid, actorCache);
|
|
160
|
-
}
|
|
161
|
-
let polyData = actorCache.get(cacheId);
|
|
162
|
-
if (!polyData) {
|
|
163
|
-
const clippingFilter = actorEntry.clippingFilter;
|
|
164
|
-
clippingFilter.setClippingPlanes(vtkPlanes);
|
|
165
|
-
try {
|
|
166
|
-
clippingFilter.update();
|
|
167
|
-
polyData = clippingFilter.getOutputData();
|
|
168
|
-
actorCache.set(cacheId, polyData);
|
|
169
|
-
}
|
|
170
|
-
catch (e) {
|
|
171
|
-
console.error('Error clipping surface', e);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return polyData;
|
|
175
|
-
}
|
|
176
|
-
export function updatePolyDataCache(actorUID, cacheId, polyDataResult) {
|
|
177
|
-
const { points, lines } = polyDataResult;
|
|
178
|
-
const polyData = vtkPolyData.newInstance();
|
|
179
|
-
polyData.getPoints().setData(points, 3);
|
|
180
|
-
const linesArray = vtkCellArray.newInstance({
|
|
181
|
-
values: Int16Array.from(lines),
|
|
182
|
-
});
|
|
183
|
-
polyData.setLines(linesArray);
|
|
184
|
-
let actorCache = polyDataCache.get(actorUID);
|
|
185
|
-
if (!actorCache) {
|
|
186
|
-
actorCache = new Map();
|
|
187
|
-
polyDataCache.set(actorUID, actorCache);
|
|
188
|
-
}
|
|
189
|
-
actorCache.set(cacheId, polyData);
|
|
190
|
-
}
|
|
191
|
-
export function getSortedPlanesInfo(viewport) {
|
|
192
|
-
const planesInfo = viewport.getSlicesClippingPlanes?.();
|
|
193
|
-
const currentSliceIndex = viewport.getSliceIndex();
|
|
194
|
-
planesInfo.sort((a, b) => {
|
|
195
|
-
const diffA = Math.abs(a.sliceIndex - currentSliceIndex);
|
|
196
|
-
const diffB = Math.abs(b.sliceIndex - currentSliceIndex);
|
|
197
|
-
return diffA - diffB;
|
|
198
|
-
});
|
|
199
|
-
return planesInfo;
|
|
200
|
-
}
|
|
201
70
|
export default {
|
|
202
71
|
render,
|
|
203
72
|
removeSegmentationRepresentation,
|
|
204
73
|
};
|
|
205
|
-
export { render, removeSegmentationRepresentation
|
|
74
|
+
export { render, removeSegmentationRepresentation };
|
|
206
75
|
//# sourceMappingURL=surfaceDisplay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surfaceDisplay.js","sourceRoot":"","sources":["../../../../../src/tools/displayTools/Surface/surfaceDisplay.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"surfaceDisplay.js","sourceRoot":"","sources":["../../../../../src/tools/displayTools/Surface/surfaceDisplay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,sBAAsB,EAEtB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,iBAAiB,MAAM,yDAAyD,CAAC;AAC7F,OAAO,eAAe,MAAM,4CAA4C,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAG/D,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,2BAA2B,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAC;AAYhE,SAAS,gCAAgC,CACvC,WAAmB,EACnB,6BAAqC,EACrC,eAAe,GAAG,KAAK;IAEvB,oCAAoC,CAClC,WAAW,EACX,6BAA6B,CAC9B,CAAC;IACF,iBAAiB,CAAC,gCAAgC,CAChD,WAAW,EACX,6BAA6B,CAC9B,CAAC;IAEF,IAAI,eAAe,EAAE;QACnB,MAAM,aAAa,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,gBAAgB,EAAE,CAAC;QACnE,aAAa,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,iBAAiB,EAAE,EAAE,EAAE;YAC1D,MAAM,cAAc,GAAG,sBAAsB,CAC3C,UAAU,EACV,iBAAiB,CAClB,CAAC;YACF,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC;KACJ;AACH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OAAO;SACR;QAED,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAsB,CAAC;QAEhD,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;QACrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAiB,CAAC,CAAC;QAEpD,2BAA2B,CACzB,QAAQ,CAAC,OAAO,EAChB,OAAyB,EACzB,6BAA6B,CAC9B,CAAC;QAEF,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,EAAE,CAAC;AACpB,CAAC;AAED,SAAS,oCAAoC,CAC3C,WAAmB,EACnB,6BAAqC;IAErC,MAAM,SAAS,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;IAE5C,IAAI,SAAS,KAAK,SAAS,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,8BAA8B,WAAW,iBAAiB,CAAC,CAAC;KAC7E;IAED,MAAM,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;IAEpC,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;QACxC,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,YAAY,CAAC;QACvD,MAAM,cAAc,GAAG,sBAAsB,CAC3C,UAAU,EACV,iBAAiB,CAClB,CAAC;QACF,wBAAwB,CACtB,cAAc,CAAC,QAAQ,CAAC,OAAO,EAC/B,6BAA6B,CAC9B,CAAC;KACH;AACH,CAAC;AAED,eAAe;IACb,MAAM;IACN,gCAAgC;CACjC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,gCAAgC,EAAE,CAAC"}
|
|
@@ -5,12 +5,15 @@ export function addContourSegmentationAnnotation(annotation) {
|
|
|
5
5
|
}
|
|
6
6
|
const { segmentationId, segmentIndex } = annotation.data.segmentation;
|
|
7
7
|
const segmentation = getSegmentation(segmentationId);
|
|
8
|
+
if (!segmentation.representationData.CONTOUR) {
|
|
9
|
+
segmentation.representationData.CONTOUR = { annotationUIDsMap: new Map() };
|
|
10
|
+
}
|
|
8
11
|
const { annotationUIDsMap } = segmentation.representationData.CONTOUR;
|
|
9
12
|
let annotationsUIDsSet = annotationUIDsMap.get(segmentIndex);
|
|
10
13
|
if (!annotationsUIDsSet) {
|
|
11
14
|
annotationsUIDsSet = new Set();
|
|
12
15
|
annotationUIDsMap.set(segmentIndex, annotationsUIDsSet);
|
|
13
16
|
}
|
|
14
|
-
annotationsUIDsSet.add(annotation.annotationUID);
|
|
17
|
+
annotationUIDsMap.set(segmentIndex, annotationsUIDsSet.add(annotation.annotationUID));
|
|
15
18
|
}
|
|
16
19
|
//# sourceMappingURL=addContourSegmentationAnnotation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addContourSegmentationAnnotation.js","sourceRoot":"","sources":["../../../../src/utilities/contourSegmentation/addContourSegmentationAnnotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sDAAsD,CAAC;AAOvF,MAAM,UAAU,gCAAgC,CAC9C,UAAyC;IAEzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,EAAE;QACjC,MAAM,IAAI,KAAK,CACb,gFAAgF,CACjF,CAAC;KACH;IAED,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC;IACtE,MAAM,YAAY,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"addContourSegmentationAnnotation.js","sourceRoot":"","sources":["../../../../src/utilities/contourSegmentation/addContourSegmentationAnnotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sDAAsD,CAAC;AAOvF,MAAM,UAAU,gCAAgC,CAC9C,UAAyC;IAEzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,EAAE;QACjC,MAAM,IAAI,KAAK,CACb,gFAAgF,CACjF,CAAC;KACH;IAED,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC;IACtE,MAAM,YAAY,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;IAErD,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,OAAO,EAAE;QAC5C,YAAY,CAAC,kBAAkB,CAAC,OAAO,GAAG,EAAE,iBAAiB,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;KAC5E;IAED,MAAM,EAAE,iBAAiB,EAAE,GAAG,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC;IAEtE,IAAI,kBAAkB,GAAG,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAE7D,IAAI,CAAC,kBAAkB,EAAE;QACvB,kBAAkB,GAAG,IAAI,GAAG,EAAE,CAAC;QAC/B,iBAAiB,CAAC,GAAG,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC;KACzD;IAED,iBAAiB,CAAC,GAAG,CACnB,YAAY,EACZ,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,CACjD,CAAC;AACJ,CAAC"}
|
|
@@ -7,6 +7,9 @@ export function removeContourSegmentationAnnotation(annotation) {
|
|
|
7
7
|
const segmentation = state.getSegmentation(segmentationId);
|
|
8
8
|
const { annotationUIDsMap } = segmentation.representationData.CONTOUR;
|
|
9
9
|
const annotationsUIDsSet = annotationUIDsMap.get(segmentIndex);
|
|
10
|
+
if (!annotationsUIDsSet) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
10
13
|
annotationsUIDsSet.delete(annotation.annotationUID);
|
|
11
14
|
if (!annotationsUIDsSet.size) {
|
|
12
15
|
annotationUIDsMap.delete(segmentIndex);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeContourSegmentationAnnotation.js","sourceRoot":"","sources":["../../../../src/utilities/contourSegmentation/removeContourSegmentationAnnotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAS3D,MAAM,UAAU,mCAAmC,CACjD,UAAyC;IAEzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,EAAE;QACjC,MAAM,IAAI,KAAK,CACb,mFAAmF,CACpF,CAAC;KACH;IAED,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC;IACtE,MAAM,YAAY,GAAG,KAAK,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IAC3D,MAAM,EAAE,iBAAiB,EAAE,GAAG,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC;IACtE,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAE/D,kBAAkB,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAGpD,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE;QAC5B,iBAAiB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;KACxC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"removeContourSegmentationAnnotation.js","sourceRoot":"","sources":["../../../../src/utilities/contourSegmentation/removeContourSegmentationAnnotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAS3D,MAAM,UAAU,mCAAmC,CACjD,UAAyC;IAEzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,EAAE;QACjC,MAAM,IAAI,KAAK,CACb,mFAAmF,CACpF,CAAC;KACH;IAED,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC;IACtE,MAAM,YAAY,GAAG,KAAK,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IAC3D,MAAM,EAAE,iBAAiB,EAAE,GAAG,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC;IACtE,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAE/D,IAAI,CAAC,kBAAkB,EAAE;QACvB,OAAO;KACR;IAED,kBAAkB,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAGpD,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE;QAC5B,iBAAiB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;KACxC;AACH,CAAC"}
|
|
@@ -1,15 +1,41 @@
|
|
|
1
|
-
export default function getAABB(polyline) {
|
|
1
|
+
export default function getAABB(polyline, options) {
|
|
2
|
+
let polylineToUse = polyline;
|
|
3
|
+
const numDimensions = options?.numDimensions || 2;
|
|
4
|
+
const is3D = numDimensions === 3;
|
|
5
|
+
if (!Array.isArray(polyline[0])) {
|
|
6
|
+
const currentPolyline = polyline;
|
|
7
|
+
const totalPoints = currentPolyline.length / numDimensions;
|
|
8
|
+
polylineToUse = new Array(currentPolyline.length / numDimensions);
|
|
9
|
+
for (let i = 0, len = totalPoints; i < len; i++) {
|
|
10
|
+
polylineToUse[i] = [
|
|
11
|
+
currentPolyline[i * numDimensions],
|
|
12
|
+
currentPolyline[i * numDimensions + 1],
|
|
13
|
+
];
|
|
14
|
+
if (is3D) {
|
|
15
|
+
polylineToUse[i].push(currentPolyline[i * numDimensions + 2]);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
2
19
|
let minX = Infinity;
|
|
3
20
|
let minY = Infinity;
|
|
4
21
|
let maxX = -Infinity;
|
|
5
22
|
let maxY = -Infinity;
|
|
6
|
-
|
|
7
|
-
|
|
23
|
+
let minZ = Infinity;
|
|
24
|
+
let maxZ = -Infinity;
|
|
25
|
+
polylineToUse = polylineToUse;
|
|
26
|
+
for (let i = 0, len = polylineToUse.length; i < len; i++) {
|
|
27
|
+
const [x, y, z] = polylineToUse[i];
|
|
8
28
|
minX = minX < x ? minX : x;
|
|
9
29
|
minY = minY < y ? minY : y;
|
|
10
30
|
maxX = maxX > x ? maxX : x;
|
|
11
31
|
maxY = maxY > y ? maxY : y;
|
|
32
|
+
if (is3D) {
|
|
33
|
+
minZ = minZ < z ? minZ : z;
|
|
34
|
+
maxZ = maxZ > z ? maxZ : z;
|
|
35
|
+
}
|
|
12
36
|
}
|
|
13
|
-
return
|
|
37
|
+
return is3D
|
|
38
|
+
? { minX, maxX, minY, maxY, minZ, maxZ }
|
|
39
|
+
: { minX, maxX, minY, maxY };
|
|
14
40
|
}
|
|
15
41
|
//# sourceMappingURL=getAABB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAABB.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/getAABB.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getAABB.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/getAABB.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,UAAU,OAAO,CAC7B,QAAoD,EACpD,OAEC;IAID,IAAI,aAAa,GAAG,QAAQ,CAAC;IAC7B,MAAM,aAAa,GAAG,OAAO,EAAE,aAAa,IAAI,CAAC,CAAC;IAClD,MAAM,IAAI,GAAG,aAAa,KAAK,CAAC,CAAC;IAEjC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;QAC/B,MAAM,eAAe,GAAG,QAAoB,CAAC;QAI7C,MAAM,WAAW,GAAG,eAAe,CAAC,MAAM,GAAG,aAAa,CAAC;QAE3D,aAAa,GAAG,IAAI,KAAK,CAAC,eAAe,CAAC,MAAM,GAAG,aAAa,CAE9C,CAAC;QAEnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,WAAW,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YAC/C,aAAa,CAAC,CAAC,CAAC,GAAG;gBACjB,eAAe,CAAC,CAAC,GAAG,aAAa,CAAC;gBAClC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AI,CAAC,CAAC,CAAC,CAAC,CAAC;SAC5B;KACF;IAED,OAAO,IAAI;QACT,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;QACxC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -2,11 +2,13 @@ import filterAnnotationsWithinSlice from './filterAnnotationsWithinSlice';
|
|
|
2
2
|
import getWorldWidthAndHeightFromCorners from './getWorldWidthAndHeightFromCorners';
|
|
3
3
|
import filterAnnotationsForDisplay from './filterAnnotationsForDisplay';
|
|
4
4
|
import getPointInLineOfSightWithCriteria from './getPointInLineOfSightWithCriteria';
|
|
5
|
+
import { isPlaneIntersectingAABB } from './isPlaneIntersectingAABB';
|
|
5
6
|
export default {
|
|
6
7
|
filterAnnotationsWithinSlice,
|
|
7
8
|
getWorldWidthAndHeightFromCorners,
|
|
8
9
|
filterAnnotationsForDisplay,
|
|
9
10
|
getPointInLineOfSightWithCriteria,
|
|
11
|
+
isPlaneIntersectingAABB,
|
|
10
12
|
};
|
|
11
|
-
export { filterAnnotationsWithinSlice, getWorldWidthAndHeightFromCorners, filterAnnotationsForDisplay, getPointInLineOfSightWithCriteria, };
|
|
13
|
+
export { filterAnnotationsWithinSlice, getWorldWidthAndHeightFromCorners, filterAnnotationsForDisplay, getPointInLineOfSightWithCriteria, isPlaneIntersectingAABB, };
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/planar/index.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,MAAM,gCAAgC,CAAC;AAC1E,OAAO,iCAAiC,MAAM,qCAAqC,CAAC;AACpF,OAAO,2BAA2B,MAAM,+BAA+B,CAAC;AACxE,OAAO,iCAAiC,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/planar/index.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,MAAM,gCAAgC,CAAC;AAC1E,OAAO,iCAAiC,MAAM,qCAAqC,CAAC;AACpF,OAAO,2BAA2B,MAAM,+BAA+B,CAAC;AACxE,OAAO,iCAAiC,MAAM,qCAAqC,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,eAAe;IACb,4BAA4B;IAC5B,iCAAiC;IACjC,2BAA2B;IAC3B,iCAAiC;IACjC,uBAAuB;CACxB,CAAC;AAEF,OAAO,EACL,4BAA4B,EAC5B,iCAAiC,EACjC,2BAA2B,EAC3B,iCAAiC,EACjC,uBAAuB,GACxB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { vec3 } from 'gl-matrix';
|
|
2
|
+
export const isPlaneIntersectingAABB = (origin, normal, minX, minY, minZ, maxX, maxY, maxZ) => {
|
|
3
|
+
const vertices = [
|
|
4
|
+
vec3.fromValues(minX, minY, minZ),
|
|
5
|
+
vec3.fromValues(maxX, minY, minZ),
|
|
6
|
+
vec3.fromValues(minX, maxY, minZ),
|
|
7
|
+
vec3.fromValues(maxX, maxY, minZ),
|
|
8
|
+
vec3.fromValues(minX, minY, maxZ),
|
|
9
|
+
vec3.fromValues(maxX, minY, maxZ),
|
|
10
|
+
vec3.fromValues(minX, maxY, maxZ),
|
|
11
|
+
vec3.fromValues(maxX, maxY, maxZ),
|
|
12
|
+
];
|
|
13
|
+
const normalVec = vec3.fromValues(normal[0], normal[1], normal[2]);
|
|
14
|
+
const originVec = vec3.fromValues(origin[0], origin[1], origin[2]);
|
|
15
|
+
const planeDistance = -vec3.dot(normalVec, originVec);
|
|
16
|
+
let initialSign = null;
|
|
17
|
+
for (const vertex of vertices) {
|
|
18
|
+
const distance = vec3.dot(normalVec, vertex) + planeDistance;
|
|
19
|
+
if (initialSign === null) {
|
|
20
|
+
initialSign = Math.sign(distance);
|
|
21
|
+
}
|
|
22
|
+
else if (Math.sign(distance) !== initialSign) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=isPlaneIntersectingAABB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPlaneIntersectingAABB.js","sourceRoot":"","sources":["../../../../src/utilities/planar/isPlaneIntersectingAABB.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAejC,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,MAAM,EACN,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,EAAE;IACF,MAAM,QAAQ,GAAG;QACf,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;KAClC,CAAC;IAEF,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAGnE,MAAM,aAAa,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAGtD,IAAI,WAAW,GAAG,IAAI,CAAC;IACvB,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE;QAE7B,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,aAAa,CAAC;QAC7D,IAAI,WAAW,KAAK,IAAI,EAAE;YACxB,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACnC;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,WAAW,EAAE;YAC9C,OAAO,IAAI,CAAC;SACb;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -1,55 +1,103 @@
|
|
|
1
1
|
import { cache } from '@cornerstonejs/core';
|
|
2
|
-
import { SegmentationRepresentations } from '../../enums';
|
|
3
2
|
import { getSegmentation } from '../../stateManagement/segmentation/segmentationState';
|
|
4
3
|
import { isVolumeSegmentation } from '../../tools/segmentation/strategies/utils/stackVolumeCheck';
|
|
4
|
+
import { SegmentationRepresentations } from '../../enums';
|
|
5
|
+
const segmentIndicesCache = new Map();
|
|
6
|
+
export const setSegmentationDirty = (segmentationId) => {
|
|
7
|
+
const cached = segmentIndicesCache.get(segmentationId);
|
|
8
|
+
if (cached) {
|
|
9
|
+
cached.isDirty = true;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export const setSegmentationClean = (segmentationId) => {
|
|
13
|
+
const cached = segmentIndicesCache.get(segmentationId);
|
|
14
|
+
if (cached) {
|
|
15
|
+
cached.isDirty = false;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
function getCachedSegmentIndices(segmentationId) {
|
|
19
|
+
const cached = segmentIndicesCache.get(segmentationId);
|
|
20
|
+
if (cached && !cached.isDirty) {
|
|
21
|
+
return cached.indices;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
5
25
|
function getUniqueSegmentIndices(segmentationId) {
|
|
26
|
+
const cachedResult = getCachedSegmentIndices(segmentationId);
|
|
27
|
+
if (cachedResult) {
|
|
28
|
+
return cachedResult;
|
|
29
|
+
}
|
|
6
30
|
const segmentation = getSegmentation(segmentationId);
|
|
7
|
-
if (segmentation
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
if (!segmentation) {
|
|
32
|
+
throw new Error(`No segmentation found for segmentationId ${segmentationId}`);
|
|
33
|
+
}
|
|
34
|
+
let indices;
|
|
35
|
+
switch (segmentation.type) {
|
|
36
|
+
case SegmentationRepresentations.Labelmap:
|
|
37
|
+
indices = handleLabelmapSegmentation(segmentation, segmentationId);
|
|
38
|
+
break;
|
|
39
|
+
case SegmentationRepresentations.Contour:
|
|
40
|
+
indices = handleContourSegmentation(segmentation);
|
|
41
|
+
break;
|
|
42
|
+
case SegmentationRepresentations.Surface:
|
|
43
|
+
indices = handleSurfaceSegmentation(segmentation);
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
throw new Error(`Unsupported segmentation type: ${segmentation.type}`);
|
|
47
|
+
}
|
|
48
|
+
segmentIndicesCache.set(segmentationId, { indices, isDirty: false });
|
|
49
|
+
return indices;
|
|
50
|
+
}
|
|
51
|
+
function handleLabelmapSegmentation(segmentation, segmentationId) {
|
|
52
|
+
const labelmapData = segmentation.representationData[SegmentationRepresentations.Labelmap];
|
|
53
|
+
const keySet = new Set();
|
|
54
|
+
if (isVolumeSegmentation(labelmapData)) {
|
|
55
|
+
addVolumeSegmentIndices(keySet, segmentationId);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
addImageSegmentIndices(keySet, labelmapData.imageIdReferenceMap);
|
|
59
|
+
}
|
|
60
|
+
return Array.from(keySet)
|
|
61
|
+
.map(Number)
|
|
62
|
+
.sort((a, b) => a - b);
|
|
63
|
+
}
|
|
64
|
+
function addVolumeSegmentIndices(keySet, segmentationId) {
|
|
65
|
+
const volume = cache.getVolume(segmentationId);
|
|
66
|
+
const scalarData = volume.getScalarData();
|
|
67
|
+
scalarData.forEach((segmentIndex) => {
|
|
68
|
+
if (segmentIndex !== 0) {
|
|
69
|
+
keySet.add(segmentIndex);
|
|
42
70
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function addImageSegmentIndices(keySet, imageIdReferenceMap) {
|
|
74
|
+
imageIdReferenceMap.forEach((segmentationImageId) => {
|
|
75
|
+
const image = cache.getImage(segmentationImageId);
|
|
76
|
+
const scalarData = image.getPixelData();
|
|
77
|
+
scalarData.forEach((segmentIndex) => {
|
|
78
|
+
if (segmentIndex !== 0) {
|
|
79
|
+
keySet.add(segmentIndex);
|
|
80
|
+
}
|
|
46
81
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function handleContourSegmentation(segmentation) {
|
|
85
|
+
const { annotationUIDsMap, geometryIds } = segmentation.representationData.CONTOUR || {};
|
|
86
|
+
if (!geometryIds) {
|
|
87
|
+
throw new Error(`No geometryIds found for segmentationId ${segmentation.segmentationId}`);
|
|
52
88
|
}
|
|
89
|
+
const indices = new Set([...annotationUIDsMap.keys()]);
|
|
90
|
+
geometryIds.forEach((geometryId) => {
|
|
91
|
+
const geometry = cache.getGeometry(geometryId);
|
|
92
|
+
indices.add(geometry.data.getSegmentIndex());
|
|
93
|
+
});
|
|
94
|
+
return Array.from(indices).sort((a, b) => a - b);
|
|
95
|
+
}
|
|
96
|
+
function handleSurfaceSegmentation(segmentation) {
|
|
97
|
+
const geometryIds = segmentation.representationData.SURFACE?.geometryIds ?? [];
|
|
98
|
+
return Array.from(geometryIds.keys())
|
|
99
|
+
.map(Number)
|
|
100
|
+
.sort((a, b) => a - b);
|
|
53
101
|
}
|
|
54
102
|
export { getUniqueSegmentIndices };
|
|
55
103
|
//# sourceMappingURL=getUniqueSegmentIndices.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUniqueSegmentIndices.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/getUniqueSegmentIndices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"getUniqueSegmentIndices.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/getUniqueSegmentIndices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sDAAsD,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAC;AAClG,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAE1D,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAGhC,CAAC;AAMJ,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,cAAsB,EAAE,EAAE;IAC7D,MAAM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,CAAC,MAAM,CAAC;SACX,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3B,CAAC;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -3,9 +3,14 @@ import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
|
|
|
3
3
|
import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
|
|
4
4
|
import ICRPolySeg from '@icr/polyseg-wasm';
|
|
5
5
|
import { utilities } from '@cornerstonejs/core';
|
|
6
|
+
import vtkPlane from '@kitware/vtk.js/Common/DataModel/Plane';
|
|
7
|
+
import vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';
|
|
8
|
+
import vtkContourLoopExtraction from '@kitware/vtk.js/Filters/General/ContourLoopExtraction';
|
|
9
|
+
import vtkCutter from '@kitware/vtk.js/Filters/Core/Cutter';
|
|
6
10
|
import { getBoundingBoxAroundShapeWorld } from '../utilities/boundingBox';
|
|
7
11
|
import { pointInShapeCallback } from '../utilities';
|
|
8
|
-
import { isPointInsidePolyline3D } from '../utilities/math/polyline';
|
|
12
|
+
import { getAABB, isPointInsidePolyline3D } from '../utilities/math/polyline';
|
|
13
|
+
import { isPlaneIntersectingAABB } from '../utilities/planar';
|
|
9
14
|
const polySegConverters = {
|
|
10
15
|
polySeg: null,
|
|
11
16
|
polySegInitializing: false,
|
|
@@ -236,6 +241,74 @@ const polySegConverters = {
|
|
|
236
241
|
});
|
|
237
242
|
return segmentationVoxelManager.scalarData;
|
|
238
243
|
},
|
|
244
|
+
getSurfacesAABBs({ surfacesInfo }) {
|
|
245
|
+
const aabbs = new Map();
|
|
246
|
+
for (const { points, id } of surfacesInfo) {
|
|
247
|
+
const aabb = getAABB(points, { numDimensions: 3 });
|
|
248
|
+
aabbs.set(id, aabb);
|
|
249
|
+
}
|
|
250
|
+
return aabbs;
|
|
251
|
+
},
|
|
252
|
+
cutSurfacesIntoPlanes({ planesInfo, surfacesInfo, surfacesAABB = new Map() }, progressCallback, updateCacheCallback) {
|
|
253
|
+
const numberOfPlanes = planesInfo.length;
|
|
254
|
+
const cutter = vtkCutter.newInstance();
|
|
255
|
+
const plane1 = vtkPlane.newInstance();
|
|
256
|
+
cutter.setCutFunction(plane1);
|
|
257
|
+
const surfacePolyData = vtkPolyData.newInstance();
|
|
258
|
+
try {
|
|
259
|
+
for (const [index, planeInfo] of planesInfo.entries()) {
|
|
260
|
+
const { sliceIndex, planes } = planeInfo;
|
|
261
|
+
const polyDataResults = new Map();
|
|
262
|
+
for (const polyDataInfo of surfacesInfo) {
|
|
263
|
+
const { points, polys, id } = polyDataInfo;
|
|
264
|
+
const aabb3 = surfacesAABB.get(id) || getAABB(points, { numDimensions: 3 });
|
|
265
|
+
if (!surfacesAABB.has(id)) {
|
|
266
|
+
surfacesAABB.set(id, aabb3);
|
|
267
|
+
}
|
|
268
|
+
const { minX, minY, minZ, maxX, maxY, maxZ } = aabb3;
|
|
269
|
+
const { origin, normal } = planes[0];
|
|
270
|
+
if (!isPlaneIntersectingAABB(origin, normal, minX, minY, minZ, maxX, maxY, maxZ)) {
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
surfacePolyData.getPoints().setData(points, 3);
|
|
274
|
+
surfacePolyData.getPolys().setData(polys, 3);
|
|
275
|
+
surfacePolyData.modified();
|
|
276
|
+
cutter.setInputData(surfacePolyData);
|
|
277
|
+
plane1.setOrigin(origin);
|
|
278
|
+
plane1.setNormal(normal);
|
|
279
|
+
try {
|
|
280
|
+
cutter.update();
|
|
281
|
+
}
|
|
282
|
+
catch (e) {
|
|
283
|
+
console.warn('Error during clipping', e);
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
const polyData = cutter.getOutputData();
|
|
287
|
+
const cutterOutput = polyData;
|
|
288
|
+
cutterOutput.buildLinks();
|
|
289
|
+
const loopExtraction = vtkContourLoopExtraction.newInstance();
|
|
290
|
+
loopExtraction.setInputData(cutterOutput);
|
|
291
|
+
const loopOutput = loopExtraction.getOutputData();
|
|
292
|
+
if (polyData) {
|
|
293
|
+
polyDataResults.set(id, {
|
|
294
|
+
points: loopOutput.getPoints().getData(),
|
|
295
|
+
lines: loopOutput.getLines().getData(),
|
|
296
|
+
numberOfCells: loopOutput.getLines().getNumberOfCells(),
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
progressCallback({ progress: (index + 1) / numberOfPlanes });
|
|
301
|
+
updateCacheCallback({ sliceIndex, polyDataResults });
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
catch (e) {
|
|
305
|
+
console.warn('Error during processing', e);
|
|
306
|
+
}
|
|
307
|
+
finally {
|
|
308
|
+
surfacesInfo = null;
|
|
309
|
+
plane1.delete();
|
|
310
|
+
}
|
|
311
|
+
},
|
|
239
312
|
};
|
|
240
313
|
expose(polySegConverters);
|
|
241
314
|
//# sourceMappingURL=polySegConverters.js.map
|