Files
OnebotCatalog/occt-service/README.md

42 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# OCCT 转换服务
把 STEP 文件转成 glTF/GLB供网页 3D 轻量化预览用。**只做转换,不做参数化建模**(升级 2 已决策不做)。
## 依赖
- Python 3.x
- `OCP`OpenCASCADE Python 绑定,本机已验证可用)
## 启动
```
start-service.bat
```
或命令行:`python occt_service.py`(端口默认 8090可用环境变量 `OCCT_PORT` 改)。
## 接口
| 接口 | 方法 | 说明 |
|---|---|---|
| `/health` | GET | 存活探测 → `{"ok":true,"port":8090}` |
| `/convert` | POST | 请求体 = STEP 文件二进制query `deflection=0.5`(弦偏差,越大越轻)→ 返回 GLB 二进制 |
## 调用示例
```bash
curl -X POST --data-binary @model.step "http://localhost:8090/convert?deflection=0.5" -o model.glb
```
## 设计说明
- 零新依赖HTTP 用标准库 `http.server`,几何用 OCP。
- 单线程OCP 非线程安全,避免并发崩溃。
- 临时文件用完即删,不落盘。
- deflection 默认 0.5mm(屏幕预览够用,体积小);要更精细可调小到 0.1,要更小可调大到 2.0。
## 与主项目的关系
- 这是升级 1网页 3D 轻量化)的转换后端,独立进程、独立端口,不依赖 NX。
- 生产部署时可放服务器(服务器无需装 NXOCP 是纯 Python 库)。