2020-05-15 12:48:00 +02:00
|
|
|
import cornerstone from 'cornerstone-core';
|
|
|
|
|
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
|
|
|
|
|
import dicomParser from 'dicom-parser';
|
|
|
|
|
|
2021-06-23 20:41:27 +02:00
|
|
|
let initialized = false;
|
2020-05-15 12:48:00 +02:00
|
|
|
|
2021-06-23 20:41:27 +02:00
|
|
|
function initWebWorkers() {
|
|
|
|
|
const config = {
|
|
|
|
|
maxWebWorkers: Math.max(navigator.hardwareConcurrency - 1, 1),
|
|
|
|
|
startWebWorkersOnDemand: true,
|
|
|
|
|
taskConfiguration: {
|
|
|
|
|
decodeTask: {
|
|
|
|
|
initializeCodecsOnStartup: false,
|
|
|
|
|
usePDFJS: false,
|
|
|
|
|
strict: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
2020-05-15 12:48:00 +02:00
|
|
|
|
2021-06-23 20:41:27 +02:00
|
|
|
if (!initialized) {
|
|
|
|
|
cornerstoneWADOImageLoader.webWorkerManager.initialize(config);
|
|
|
|
|
initialized = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-15 12:48:00 +02:00
|
|
|
|
2021-06-23 20:41:27 +02:00
|
|
|
export default function initWADOImageLoader(UserAuthenticationService) {
|
|
|
|
|
cornerstoneWADOImageLoader.external.cornerstone = cornerstone;
|
|
|
|
|
cornerstoneWADOImageLoader.external.dicomParser = dicomParser;
|
|
|
|
|
|
|
|
|
|
cornerstoneWADOImageLoader.configure({
|
|
|
|
|
beforeSend: function(xhr) {
|
|
|
|
|
const headers = UserAuthenticationService.getAuthorizationHeader();
|
|
|
|
|
|
|
|
|
|
if (headers && headers.Authorization) {
|
|
|
|
|
xhr.setRequestHeader('Authorization', headers.Authorization);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
initWebWorkers();
|
|
|
|
|
}
|