2026-05-20-03-19-25 完善分割结果保存与STL导出

This commit is contained in:
2026-05-20 03:33:21 +08:00
parent b9c0f17313
commit 25f34d1eef
10 changed files with 667 additions and 78 deletions

View File

@@ -1,7 +1,7 @@
import { DicomFusionVolume, DicomInfo, DicomPreview, ModelPose, ModuleStyle, OverviewSummary, Project, SavedModelPose, SessionState, UserRecord } from '../types';
import { DicomFusionVolume, DicomInfo, DicomPreview, ModelPose, ModuleStyle, OverviewSummary, Project, SavedModelPose, SegmentationExportScope, SessionState, UserRecord } from '../types';
export type ProjectExportTarget = 'dicom' | 'segmentation' | 'pose';
export type SegmentationExportScope = 'all' | 'visible';
export type ProjectExportTarget = 'dicom' | 'segmentation' | 'pose' | 'stl';
export type { SegmentationExportScope } from '../types';
async function request<T>(path: string, options: RequestInit = {}): Promise<T> {
const response = await fetch(path, {
@@ -63,6 +63,19 @@ export const api = {
method: 'PATCH',
body: JSON.stringify({ modelPoses }),
}),
saveProjectSegmentationResult: (
projectId: string,
payload: {
name?: string;
pose: ModelPose;
segmentationScope: SegmentationExportScope;
moduleStyles: Record<string, ModuleStyle>;
},
) =>
request<Project>(`/api/projects/${projectId}/segmentation-results`, {
method: 'POST',
body: JSON.stringify(payload),
}),
getDicomPreview: (projectId: string, slice: number, plane: DicomPreview['plane'] = 'axial', mode: DicomPreview['mode'] = 'default') =>
request<DicomPreview>(`/api/projects/${projectId}/dicom-preview?slice=${slice}&plane=${plane}&mode=${mode}`),
getDicomFusionVolume: (projectId: string, start: number, end: number, mode: DicomPreview['mode'] = 'soft') =>
@@ -99,7 +112,7 @@ export async function downloadMask(projectId: string, format: 'nii' | 'nii.gz' =
export async function downloadProjectExport(projectId: string, target: ProjectExportTarget, format: 'nii' | 'nii.gz' = 'nii.gz', options: { pose?: ModelPose; segmentationScope?: SegmentationExportScope } = {}) {
const params = new URLSearchParams({ target, format });
if (target !== 'dicom') {
if (target === 'segmentation' || target === 'pose') {
appendPose(params, options.pose);
}
if (target === 'segmentation') {