Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(streaming-image-volume): add caching for image load object #567

Merged
merged 1 commit into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -896,9 +896,11 @@ export default class BaseStreamingImageVolume extends ImageVolume {
);

// 3. Caching the image
cache.putImageLoadObject(imageId, imageLoadObject).catch((err) => {
console.error(err);
});
if (!cache.getImageLoadObject(imageId)) {
cache.putImageLoadObject(imageId, imageLoadObject).catch((err) => {
console.error(err);
});
}

// 4. If we know we won't be able to add another Image to the cache
// without breaching the limit, stop here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,14 @@ function _convertVolumeToStackViewport(
const { uid: volumeId } = actorEntry;
const volume = cache.getVolume(volumeId) as StreamingImageVolume;

const imageIds = volume.imageIds;

// if this is the first time decaching do it
if (!cache.getImageLoadObject(imageIds[0])) {
volume.decache();
}
volume.decache();

const stack = volume.imageIds;
const stack = volume.imageIds.reverse();

// Set the stack on the viewport
const currentIndex = Math.floor(stack.length / 2);
stackViewport.setStack(stack, currentIndex);
// const currentIndex = Math.floor(stack.length / 2);
stackViewport.setStack(stack, 0);

// Render the image
viewport.render();
Expand Down Expand Up @@ -82,7 +78,7 @@ async function _convertStackToVolumeViewport(
type: ViewportType.ORTHOGRAPHIC,
element,
defaultOptions: {
orientation: Enums.OrientationAxis.AXIAL,
orientation: Enums.OrientationAxis.SAGITTAL,
background: <Types.Point3>[0.2, 0.4, 0.2],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ async function run() {
const stack = imageIds;

// Set the stack on the viewport
const currentIndex = Math.floor(stack.length / 2);
viewport.setStack(stack, currentIndex);
viewport.setStack(stack, 0);

// Render the image
viewport.render();
Expand Down