feat: 🎸 Add support for POINT and OPEN_PLANAR for RT

* feat: 🎸 Add support for POINT and OPEN_PLANAR for RT
This commit is contained in:
James Petts 2020-08-10 13:16:19 +01:00 committed by GitHub
parent 756b005fe1
commit 0e87ab37c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 82 additions and 41 deletions

View File

@ -76,21 +76,15 @@ export default async function loadRTStruct(
const isSupported = false; const isSupported = false;
for (let c = 0; c < ContourSequence.length; c++) { const ContourSequenceArray = _toArray(ContourSequence);
for (let c = 0; c < ContourSequenceArray.length; c++) {
const { const {
ContourImageSequence, ContourImageSequence,
ContourData, ContourData,
NumberOfContourPoints, NumberOfContourPoints,
ContourGeometricType, ContourGeometricType,
} = ContourSequence[c]; } = ContourSequenceArray[c];
if (ContourGeometricType !== 'CLOSED_PLANAR') {
// TODO: Do we want to visualise types other than closed planar?
// We could easily do open planar and point.
continue;
}
isSupported = true;
const sopInstanceUID = ContourImageSequence.ReferencedSOPInstanceUID; const sopInstanceUID = ContourImageSequence.ReferencedSOPInstanceUID;
const imageId = _getImageId(imageIdSopInstanceUidPairs, sopInstanceUID); const imageId = _getImageId(imageIdSopInstanceUidPairs, sopInstanceUID);
@ -102,6 +96,13 @@ export default async function loadRTStruct(
const imagePlane = cornerstone.metaData.get('imagePlaneModule', imageId); const imagePlane = cornerstone.metaData.get('imagePlaneModule', imageId);
const points = []; const points = [];
let measurementData;
switch (ContourGeometricType) {
case 'CLOSED_PLANAR':
case 'OPEN_PLANAR':
case 'POINT':
isSupported = true;
for (let p = 0; p < NumberOfContourPoints * 3; p += 3) { for (let p = 0; p < NumberOfContourPoints * 3; p += 3) {
points.push({ points.push({
@ -113,15 +114,20 @@ export default async function loadRTStruct(
transformPointsToImagePlane(points, imagePlane); transformPointsToImagePlane(points, imagePlane);
const measurementData = { measurementData = {
handles: { handles: {
points, points,
}, },
type: ContourGeometricType,
structureSetSeriesInstanceUid: rtStructDataset.SeriesInstanceUID, structureSetSeriesInstanceUid: rtStructDataset.SeriesInstanceUID,
ROINumber: ReferencedROINumber, ROINumber: ReferencedROINumber,
}; };
imageIdSpecificToolData.push(measurementData); imageIdSpecificToolData.push(measurementData);
break;
default:
continue;
}
} }
_setROIContourMetadata( _setROIContourMetadata(
@ -314,3 +320,7 @@ function _getImageIdSopInstanceUidPairsForDisplaySet(
}; };
}); });
} }
function _toArray(objOrArray) {
return Array.isArray(objOrArray) ? objOrArray : [objOrArray];
}

View File

@ -4,6 +4,7 @@ import TOOL_NAMES from '../utils/toolNames';
// Cornerstone 3rd party dev kit imports // Cornerstone 3rd party dev kit imports
const draw = importInternal('drawing/draw'); const draw = importInternal('drawing/draw');
const drawCircle = importInternal('drawing/drawCircle');
const drawJoinedLines = importInternal('drawing/drawJoinedLines'); const drawJoinedLines = importInternal('drawing/drawJoinedLines');
const getNewContext = importInternal('drawing/getNewContext'); const getNewContext = importInternal('drawing/getNewContext');
const BaseTool = importInternal('base/BaseTool'); const BaseTool = importInternal('base/BaseTool');
@ -74,20 +75,50 @@ export default class RTStructDisplayTool extends BaseTool {
colorArray[2] colorArray[2]
},${opacity})`; },${opacity})`;
lineWidth; switch (data.type) {
case 'CLOSED_PLANAR':
this._renderClosedPlanar(context, eventData.element, points, {
color,
lineWidth,
});
break;
case 'POINT':
this._renderPoint(context, eventData.element, points, {
color,
lineWidth,
});
break;
case 'OPEN_PLANAR':
this._renderOpenPlanar(context, eventData.element, points, {
color,
lineWidth,
});
break;
}
}
}
_renderClosedPlanar(context, element, points, options) {
draw(context, context => { draw(context, context => {
drawJoinedLines( drawJoinedLines(
context, context,
eventData.element, element,
points[points.length - 1], points[points.length - 1],
points, points,
{ options
color,
lineWidth,
}
); );
}); });
} }
_renderPoint(context, element, points, options) {
draw(context, context => {
drawCircle(context, element, points[0], 3, options);
});
}
_renderOpenPlanar(context, element, points, options) {
draw(context, context => {
drawJoinedLines(context, element, points[0], points, options);
});
} }
} }