This commit is contained in:
2026-03-07 01:40:37 +08:00
parent 57a67309bd
commit 4ce0662df1
2 changed files with 39 additions and 22 deletions
+28 -16
View File
@@ -468,14 +468,16 @@ async def process_file_core(
try:
mesh_result = mesh_generator.generate_mesh_from_shape(shape)
tri_mesh = mesh_result.get("trimesh_mesh")
pointcloud = mesh_result.get("pointcloud") or {}
if tri_mesh is not None:
# 顶点和面转为 JSON 可序列化
vertices = tri_mesh.vertices.tolist()
faces = tri_mesh.faces.tolist()
# mesh_generator 返回: vertices, faces, points, normals, point_count, vertex_count, face_count
vertices = mesh_result.get("vertices", [])
faces = mesh_result.get("faces", [])
points = mesh_result.get("points", [])
normals = mesh_result.get("normals", [])
point_count = mesh_result.get("point_count", 0)
vertex_count = mesh_result.get("vertex_count", 0)
face_count = mesh_result.get("face_count", 0)
if vertices and faces:
# 使用已计算的几何边界框,避免重复计算
bbox = geometry_data.get("bounding_box", {})
@@ -484,15 +486,19 @@ async def process_file_core(
"file_name": Path(file_path).name,
"generated_at": datetime.now().isoformat(),
"quality": "medium",
"vertex_count": len(vertices),
"face_count": len(faces),
"point_count": pointcloud.get("count"),
"vertex_count": vertex_count,
"face_count": face_count,
"point_count": point_count,
},
"mesh": {
"vertices": vertices,
"faces": faces,
},
"pointcloud": pointcloud,
"pointcloud": {
"points": points,
"normals": normals,
"count": point_count
},
"bounding_box": bbox,
}
@@ -504,9 +510,9 @@ async def process_file_core(
)
# 将简要网格摘要写入内存任务,便于前端展示汇总信息
tasks[task_id]["mesh_summary"] = {
"vertex_count": len(vertices),
"face_count": len(faces),
"point_count": pointcloud.get("count"),
"vertex_count": vertex_count,
"face_count": face_count,
"point_count": point_count,
"quality": "medium",
}
except Exception as mesh_err:
@@ -653,8 +659,14 @@ async def process_file_core(
db_session, task_id, "processing", 85, "生成可视化报告"
)
# 获取点云数据
pointcloud_data = mesh_result.get("pointcloud", {}) if mesh_result else {}
# 获取点云数据 - mesh_result 直接返回 points 和 normals
pointcloud_data = None
if mesh_result:
pointcloud_data = {
"points": mesh_result.get("points", []),
"normals": mesh_result.get("normals", []),
"point_count": mesh_result.get("point_count", 0)
}
html_file_path = html_generator.generate_and_save_visualization(
geometry_data,