fix/RTStructInlineBinaryContourData (#5611)
* -check for ContourData still in InlineBinary format and perform conversion
This commit is contained in:
parent
42168442b9
commit
b2c469d087
@ -69,6 +69,40 @@ async function checkAndLoadContourData({
|
||||
promisesMap.has(referencedROINumber)
|
||||
? promisesMap.get(referencedROINumber).push(bulkDataPromise)
|
||||
: promisesMap.set(referencedROINumber, [bulkDataPromise]);
|
||||
} else if (contourData && contourData.InlineBinary) {
|
||||
// Contour data is still in binary format, conversion needed
|
||||
const base64String = contourData.InlineBinary;
|
||||
const decodedText = atob(base64String);
|
||||
|
||||
const rawValues = decodedText.split('\\');
|
||||
|
||||
const result = [];
|
||||
|
||||
// Ensure strictly that we have a full set of 3 coordinates
|
||||
if (rawValues.length % 3 !== 0) {
|
||||
return Promise.reject('ContourData raw values not divisible by 3');
|
||||
}
|
||||
|
||||
for (let i = 0; i < rawValues.length; i += 3) {
|
||||
if (i + 2 < rawValues.length) {
|
||||
const x = parseFloat(rawValues[i]);
|
||||
const y = parseFloat(rawValues[i + 1]);
|
||||
const z = parseFloat(rawValues[i + 2]);
|
||||
|
||||
// Only push if all three are valid numbers (filters out trailing empty splits)
|
||||
if (!isNaN(x) && !isNaN(y) && !isNaN(z)) {
|
||||
result.push(x);
|
||||
result.push(y);
|
||||
result.push(z);
|
||||
} else {
|
||||
return Promise.reject('Error parsing contourData from InlineBinary format');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
promisesMap.has(referencedROINumber)
|
||||
? promisesMap.get(referencedROINumber).push(result)
|
||||
: promisesMap.set(referencedROINumber, [result]);
|
||||
} else {
|
||||
return Promise.reject(`Invalid ContourData: ${contourData}`);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user