Compare commits

..

2 Commits

Author SHA1 Message Date
mozzie
a0f4ca2f3a Merge branch 'main' of ssh://git.maxshader.com:10022/mozzie/cvpilot-tool 2024-09-19 10:59:22 +08:00
mozzie
cc783768db feat: memory leak 2024-09-19 10:59:20 +08:00
2 changed files with 14 additions and 11 deletions

View File

@ -7,7 +7,7 @@ export const initCornerstoneDICOMImageLoader = () => {
cornerstone.getConfiguration().rendering; cornerstone.getConfiguration().rendering;
console.log("dddd", cornerstone.getConfiguration().rendering); console.log("dddd", cornerstone.getConfiguration().rendering);
cornerstone.setUseSharedArrayBuffer(true); cornerstone.setUseSharedArrayBuffer(false);
cornerstone.setConfiguration({ cornerstone.setConfiguration({
detectGPUConfig: { detectGPUConfig: {
// benchmarksURL: "http://localhost:9000", // benchmarksURL: "http://localhost:9000",

View File

@ -13,6 +13,7 @@ import {
setVolumesForViewports, setVolumesForViewports,
volumeLoader, volumeLoader,
Enums as CoreEnums, Enums as CoreEnums,
cache,
} from "@cornerstonejs/core"; } from "@cornerstonejs/core";
import { import {
IStackViewport, IStackViewport,
@ -27,7 +28,6 @@ import {
viewportId1, viewportId1,
viewportId2, viewportId2,
viewportId3, viewportId3,
volumeId,
} from "./MprViewer/index.config"; } from "./MprViewer/index.config";
import setCtTransferFunctionForVolumeActor from "./MprViewer/CornerstoneDicomLoader/setCtTransferFunctionForVolumeActor"; import setCtTransferFunctionForVolumeActor from "./MprViewer/CornerstoneDicomLoader/setCtTransferFunctionForVolumeActor";
import { Slider } from "@/components/ui/slider"; import { Slider } from "@/components/ui/slider";
@ -68,7 +68,7 @@ export const Viewer = () => {
const StudyInstanceUID = queryParams.get("StudyInstanceUID"); const StudyInstanceUID = queryParams.get("StudyInstanceUID");
const [imageIds, setImageIds] = useState<string[]>(); const [imageIds, setImageIds] = useState<string[]>();
const renderingEngineRef = useRef<RenderingEngine>(); const renderingEngineRef = useRef<RenderingEngine>();
const ts = "-" + Date.now(); // 每次都是新的volumeId const volumeId = SeriesInstanceUID;
useEffect(() => { useEffect(() => {
cornerstoneTools.addTool(StackScrollMouseWheelTool); cornerstoneTools.addTool(StackScrollMouseWheelTool);
@ -90,13 +90,13 @@ export const Viewer = () => {
wadoRsRoot, wadoRsRoot,
}); });
// 这一步会对imageIds进行排序如果不排序imageIds会错误乱,stackViewport顺序会错误 // 这一步会对imageIds进行排序如果不排序imageIds会错误乱,stackViewport顺序会错误
const volume = await volumeLoader.createAndCacheVolume(volumeId + ts, { const volume = await volumeLoader.createAndCacheVolume(
SeriesInstanceUID,
{
imageIds, imageIds,
}); }
);
volume.load(); volume.load();
console.log("2222");
console.log(SeriesInstanceUID);
console.log(StudyInstanceUID);
const volumeViewportInput: PublicViewportInput[] = [ const volumeViewportInput: PublicViewportInput[] = [
{ {
@ -152,7 +152,7 @@ export const Viewer = () => {
renderingEngineRef.current, renderingEngineRef.current,
[ [
{ {
volumeId: volumeId + ts, volumeId: SeriesInstanceUID,
callback: ({ volumeActor }) => callback: ({ volumeActor }) =>
setCtTransferFunctionForVolumeActor({ setCtTransferFunctionForVolumeActor({
volumeActor, volumeActor,
@ -223,13 +223,16 @@ export const Viewer = () => {
ToolGroupManager.destroyToolGroup(toolGroupMprId); ToolGroupManager.destroyToolGroup(toolGroupMprId);
ToolGroupManager.destroyToolGroup(toolGroupStackId); ToolGroupManager.destroyToolGroup(toolGroupStackId);
cache.purgeCache();
console.log(cache.getVolume(volumeId!));
cornerstoneTools.removeTool(StackScrollMouseWheelTool); cornerstoneTools.removeTool(StackScrollMouseWheelTool);
1; 1;
cornerstoneTools.removeTool(CrosshairsTool); cornerstoneTools.removeTool(CrosshairsTool);
cornerstoneTools.removeTool(WindowLevelTool); cornerstoneTools.removeTool(WindowLevelTool);
cornerstoneTools.removeTool(ZoomTool); cornerstoneTools.removeTool(ZoomTool);
}; };
}, [SeriesInstanceUID, StudyInstanceUID]); }, [SeriesInstanceUID, StudyInstanceUID, volumeId]);
const onChangeIndex = (value: number[]) => { const onChangeIndex = (value: number[]) => {
setIndex(value[0]); setIndex(value[0]);