Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | 428x 428x 428x 428x | import type { Types } from '@cornerstonejs/core'; import { Enums, eventTarget, triggerEvent, getWebWorkerManager, } from '@cornerstonejs/core'; import type { Types as ToolsTypes } from '@cornerstonejs/tools'; import * as cornerstoneTools from '@cornerstonejs/tools'; const { WorkerTypes } = cornerstoneTools.Enums; const { getAnnotation } = cornerstoneTools.annotation.state; const workerManager = getWebWorkerManager(); const triggerWorkerProgress = (eventTarget, progress, id) => { triggerEvent(eventTarget, Enums.Events.WEB_WORKER_PROGRESS, { progress, type: WorkerTypes.POLYSEG_CONTOUR_TO_SURFACE, id, }); }; /** * Converts a contour representation to a surface representation. * * @param contourRepresentationData - The contour segmentation data. * @param segmentIndex - The index of the segment to convert. * @returns A promise that resolves to the surface data. */ export async function convertContourToSurface( contourRepresentationData: ToolsTypes.ContourSegmentationData, segmentIndex: number ): Promise<Types.SurfaceData> { const { annotationUIDsMap } = contourRepresentationData; // loop over all annotations in the segment and flatten their polylines const polylines = []; const numPointsArray = []; const annotationUIDs = annotationUIDsMap.get(segmentIndex); if (!annotationUIDs) { return; } for (const annotationUID of annotationUIDs) { const annotation = getAnnotation(annotationUID); const { polyline } = ( annotation as ToolsTypes.ContourSegmentationAnnotation ).data.contour; numPointsArray.push(polyline.length); polyline.forEach((polyline) => polylines.push(...polyline)); } triggerWorkerProgress(eventTarget, 0, segmentIndex); const results = await workerManager.executeTask( 'polySeg', 'convertContourToSurface', { polylines, numPointsArray, }, { callbacks: [ (progress) => { triggerWorkerProgress(eventTarget, progress, segmentIndex); }, ], } ); triggerWorkerProgress(eventTarget, 100, segmentIndex); return results; } |