2026-05-25-00-07-30 优化自动匹配对比视图与采样设置

This commit is contained in:
2026-05-25 00:28:52 +08:00
parent 2fac0200fc
commit d1fa79aef9
8 changed files with 426 additions and 179 deletions

View File

@@ -1,4 +1,4 @@
import express from 'express';
import express, { type Request, type Response } from 'express';
import AdmZip from 'adm-zip';
import multer from 'multer';
import { createServer as createViteServer } from 'vite';
@@ -747,6 +747,23 @@ function writeState(state: AppState) {
fs.writeFileSync(statePath, JSON.stringify({ ...state, updatedAt: now() }, null, 2));
}
function sendJsonPayload(req: Request, res: Response, payload: unknown) {
const json = JSON.stringify(payload);
const acceptsGzip = String(req.headers['accept-encoding'] ?? '').includes('gzip');
res.setHeader('Content-Type', 'application/json; charset=utf-8');
res.setHeader('Vary', 'Accept-Encoding');
if (acceptsGzip && Buffer.byteLength(json) > 64 * 1024) {
const compressed = zlib.gzipSync(Buffer.from(json));
res.setHeader('Content-Encoding', 'gzip');
res.setHeader('Content-Length', String(compressed.length));
res.send(compressed);
return;
}
res.send(json);
}
interface DicomHuVolume {
width: number;
height: number;
@@ -1026,9 +1043,9 @@ function transformPointForExportPose(x: number, y: number, z: number, metrics: E
const defaultAutoMatchWeights: AutoMatchWeights = {
boneReward: 1,
missPenalty: 0.45,
movementPenalty: 0.08,
scalePenalty: 0.12,
missPenalty: 0.1,
movementPenalty: 0,
scalePenalty: 0,
};
const defaultAutoMatchAdjustable: AutoMatchParameterSelection = {
translateX: true,
@@ -3753,7 +3770,7 @@ async function startServer() {
}
try {
res.json(createStlPreview(getProjectModelFilePath(project, fileName), fileName, Number.isFinite(limit) ? limit : 5000));
sendJsonPayload(req, res, createStlPreview(getProjectModelFilePath(project, fileName), fileName, Number.isFinite(limit) ? limit : 5000));
} catch (error) {
res.status(422).json({ message: error instanceof Error ? error.message : 'STL 预览失败' });
}