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;
for (let c = 0; c < ContourSequence.length; c++) {
const ContourSequenceArray = _toArray(ContourSequence);
for (let c = 0; c < ContourSequenceArray.length; c++) {
const {
ContourImageSequence,
ContourData,
NumberOfContourPoints,
ContourGeometricType,
} = ContourSequence[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;
} = ContourSequenceArray[c];
const sopInstanceUID = ContourImageSequence.ReferencedSOPInstanceUID;
const imageId = _getImageId(imageIdSopInstanceUidPairs, sopInstanceUID);
@ -102,26 +96,38 @@ export default async function loadRTStruct(
const imagePlane = cornerstone.metaData.get('imagePlaneModule', imageId);
const points = [];
let measurementData;
for (let p = 0; p < NumberOfContourPoints * 3; p += 3) {
points.push({
x: ContourData[p],
y: ContourData[p + 1],
z: ContourData[p + 2],
});
switch (ContourGeometricType) {
case 'CLOSED_PLANAR':
case 'OPEN_PLANAR':
case 'POINT':
isSupported = true;
for (let p = 0; p < NumberOfContourPoints * 3; p += 3) {
points.push({
x: ContourData[p],
y: ContourData[p + 1],
z: ContourData[p + 2],
});
}
transformPointsToImagePlane(points, imagePlane);
measurementData = {
handles: {
points,
},
type: ContourGeometricType,
structureSetSeriesInstanceUid: rtStructDataset.SeriesInstanceUID,
ROINumber: ReferencedROINumber,
};
imageIdSpecificToolData.push(measurementData);
break;
default:
continue;
}
transformPointsToImagePlane(points, imagePlane);
const measurementData = {
handles: {
points,
},
structureSetSeriesInstanceUid: rtStructDataset.SeriesInstanceUID,
ROINumber: ReferencedROINumber,
};
imageIdSpecificToolData.push(measurementData);
}
_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
const draw = importInternal('drawing/draw');
const drawCircle = importInternal('drawing/drawCircle');
const drawJoinedLines = importInternal('drawing/drawJoinedLines');
const getNewContext = importInternal('drawing/getNewContext');
const BaseTool = importInternal('base/BaseTool');
@ -72,22 +73,52 @@ export default class RTStructDisplayTool extends BaseTool {
const colorArray = ROIContourData.colorArray;
const color = `rgba(${colorArray[0]},${colorArray[1]},${
colorArray[2]
},${opacity})`;
},${opacity})`;
lineWidth;
draw(context, context => {
drawJoinedLines(
context,
eventData.element,
points[points.length - 1],
points,
{
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 => {
drawJoinedLines(
context,
element,
points[points.length - 1],
points,
options
);
});
}
_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);
});
}
}