Add capability to download STP files directly from HTTP/HTTPS URLs in both CLI and HTTP server modes. Changes: - Add http_downloader module for downloading files from URLs - Extend GlobalConfig to track downloaded files - Update CLI parameter processing to detect and handle URLs - Enhance HTTP server to accept URL parameter alongside file upload - Implement automatic cleanup of downloaded temporary files - Add comprehensive usage documentation (USAGE.md) Usage examples: CLI: STP2GLB.exe --stp https://example.com/model.stp --glb output.glb API: curl -X POST http://localhost:8080/convert -F "url=https://example.com/model.stp" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
181 lines
4.0 KiB
Markdown
181 lines
4.0 KiB
Markdown
# STP2GLB 使用说明
|
||
|
||
STP2GLB 支持两种运行模式:**CLI命令行模式** 和 **HTTP服务器模式**
|
||
|
||
---
|
||
|
||
## CLI 命令行模式
|
||
|
||
### 基本用法
|
||
|
||
#### 1. 本地文件转换
|
||
```bash
|
||
STP2GLB.exe --stp input.stp --glb output.glb
|
||
```
|
||
|
||
#### 2. HTTP URL转换(新功能)
|
||
```bash
|
||
STP2GLB.exe --stp https://example.com/model.stp --glb output.glb
|
||
```
|
||
|
||
### 主要参数
|
||
|
||
| 参数 | 说明 | 默认值 | 范围 |
|
||
|------|------|--------|------|
|
||
| `--stp` | STP文件路径或HTTP/HTTPS URL(必填) | - | 本地路径或URL |
|
||
| `--glb` | 输出GLB文件路径(必填) | - | 本地路径 |
|
||
| `--lin-defl` | 线性偏差 | 0.5 | 0.0-1.0 |
|
||
| `--ang-defl` | 角度偏差 | 0.8 | 0.0-1.0 |
|
||
| `--rel-defl` | 相对偏差模式 | false | - |
|
||
| `--debug` | 调试模式(更详细的错误信息) | false | - |
|
||
| `--solid-only` | 仅转换实体 | false | - |
|
||
| `--max-geometry-num` | 最大几何体数量(0=无限制) | 0 | ≥0 |
|
||
| `--tessellation-timeout` | 网格化超时时间(秒) | 30 | >0 |
|
||
|
||
### 使用示例
|
||
|
||
```bash
|
||
# 本地文件转换,调整精度
|
||
STP2GLB.exe --stp model.stp --glb output.glb --lin-defl 0.1 --ang-defl 0.5
|
||
|
||
# 从URL下载并转换
|
||
STP2GLB.exe --stp http://example.com/files/part.step --glb result.glb
|
||
|
||
# 调试模式转换
|
||
STP2GLB.exe --stp model.stp --glb output.glb --debug
|
||
|
||
# 限制几何体数量
|
||
STP2GLB.exe --stp large.stp --glb output.glb --max-geometry-num 100
|
||
```
|
||
|
||
---
|
||
|
||
## HTTP 服务器模式
|
||
|
||
### 启动服务器
|
||
|
||
```bash
|
||
STP2GLB.exe --server --port 8080 --host 0.0.0.0
|
||
```
|
||
|
||
### 服务器参数
|
||
|
||
| 参数 | 说明 | 默认值 |
|
||
|------|------|--------|
|
||
| `--server` | 启动服务器模式 | - |
|
||
| `--port` | 服务器端口 | 8080 |
|
||
| `--host` | 监听地址 | 0.0.0.0 |
|
||
| `--max-file-size` | 最大文件大小(MB) | 500 |
|
||
|
||
### API 端点
|
||
|
||
#### 1. 健康检查
|
||
```bash
|
||
GET /health
|
||
```
|
||
|
||
**响应示例:**
|
||
```json
|
||
{
|
||
"status": "ok",
|
||
"service": "STP2GLB"
|
||
}
|
||
```
|
||
|
||
#### 2. 文件转换
|
||
```bash
|
||
POST /convert
|
||
```
|
||
|
||
**支持两种输入方式:**
|
||
|
||
##### 方式一:文件上传
|
||
```bash
|
||
curl -X POST http://localhost:8080/convert \
|
||
-F "file=@model.stp" \
|
||
-F "linearDeflection=0.1" \
|
||
-F "angularDeflection=0.5"
|
||
```
|
||
|
||
##### 方式二:HTTP URL(新功能)
|
||
```bash
|
||
curl -X POST http://localhost:8080/convert \
|
||
-F "url=https://example.com/model.stp" \
|
||
-F "linearDeflection=0.1"
|
||
```
|
||
|
||
### 转换参数
|
||
|
||
| 参数名 | 说明 | 默认值 |
|
||
|--------|------|--------|
|
||
| `file` | STP文件(multipart上传) | - |
|
||
| `url` | STP文件HTTP/HTTPS URL | - |
|
||
| `linearDeflection` | 线性偏差 | 0.5 |
|
||
| `angularDeflection` | 角度偏差 | 0.8 |
|
||
| `relativeDeflection` | 相对偏差(true/false) | false |
|
||
| `debug` | 调试模式(true/false) | false |
|
||
| `solidOnly` | 仅实体(true/false) | false |
|
||
| `maxGeometryNum` | 最大几何体数量 | 0 |
|
||
|
||
**注意:** `file` 和 `url` 二选一,`url` 优先级更高
|
||
|
||
### 响应示例
|
||
|
||
**成功响应:**
|
||
```json
|
||
{
|
||
"success": true,
|
||
"output_file": "1234567890_5678.glb",
|
||
"output_path": "./output/1234567890_5678.glb",
|
||
"conversion_time": 2.35
|
||
}
|
||
```
|
||
|
||
**错误响应:**
|
||
```json
|
||
{
|
||
"success": false,
|
||
"error": "Failed to download from URL: HTTP error: 404 Not Found"
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## 注意事项
|
||
|
||
1. **URL下载**:
|
||
- 仅支持HTTP和HTTPS协议
|
||
- URL必须直接指向.stp或.step文件
|
||
- 下载的临时文件会在转换完成后自动清理
|
||
|
||
2. **文件大小限制**:
|
||
- HTTP服务器模式默认限制500MB
|
||
- 可通过 `--max-file-size` 参数调整
|
||
|
||
3. **超时设置**:
|
||
- 默认网格化超时30秒
|
||
- 大型复杂模型建议增加超时时间
|
||
|
||
4. **调试模式**:
|
||
- 提供详细的STEP实体转换失败信息
|
||
- 会显著降低转换速度
|
||
|
||
---
|
||
|
||
## 快速测试
|
||
|
||
```bash
|
||
# CLI模式测试
|
||
STP2GLB.exe --stp https://example.com/test.stp --glb test.glb
|
||
|
||
# 服务器模式测试
|
||
STP2GLB.exe --server --port 8080
|
||
|
||
# 测试健康检查
|
||
curl http://localhost:8080/health
|
||
|
||
# 测试URL转换
|
||
curl -X POST http://localhost:8080/convert \
|
||
-F "url=https://example.com/model.stp"
|
||
```
|