You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.8 KiB
80 lines
2.8 KiB
9 months ago
|
## 程序模块说明
|
||
|
|
||
|
### 参数输入
|
||
|
|
||
|
```
|
||
|
.\WireRouting.exe-------------------------------------程序入口
|
||
|
createTinyroute-----------------------------------<mode> 路径规划模式,默认使用createTinyroute
|
||
|
"..\\..\\data\\Tinyroute_test\\clip2"-------------<clipDoc> 卡箍点数据所在路径
|
||
|
"..\\..\\data\\Tinyroute_test\\wirexml"------------<xmlDoc> 连接器连接关系数据所在路径
|
||
|
"..\\..\\data\\Tinyroute_test\\connector.csv"------<connectorFile> 连接器坐标数据文件路径
|
||
|
"..\\..\\data\\Tinyroute_test\\OBJ"----------------<OBJDoc> 模型所在路径
|
||
|
output---------------------------------------------<outputFileName> 输出文件名
|
||
|
```
|
||
|
|
||
|
### 主程序模块
|
||
|
|
||
|
- 选择生成模式:检查模式是否为 "createTinyroute"狭小空间模式
|
||
|
```
|
||
|
else if (mode == "createTinyroute")
|
||
|
|
||
|
- 从命令行参数中获取4个输入文件的路径(clipDoc, xmlDoc, connectorFile, OBJDoc)和一个输出文件的名称(outputFileName)
|
||
|
```
|
||
|
string clipDoc, xmlDoc, connectorFile, OBJDoc, outputFileName;
|
||
|
```
|
||
|
|
||
|
- 读取.obj文件列表:查找`OBJDoc` 路径下所有文件,返回向量列表给`OBJFilenames`
|
||
|
```
|
||
|
getAllFiles(OBJDoc, OBJFilenames);
|
||
|
```
|
||
|
|
||
|
- 测试obj模型输入与bvh相交算法:
|
||
|
|
||
|
- 对于OBJFilenames中的每一个.obj文件`OBJFilenames[i]`,尝试读取并解析该文件,将三角面片的顶点和索引信息存储在`vertices, indices` 以及`mesh`中
|
||
|
```
|
||
|
read_OBJ(OBJFilenames[i], vertices, indices)
|
||
|
mesh.indices = indices; mesh.vertices = vertices;
|
||
|
```
|
||
|
|
||
|
- 创建一条用于测试碰撞检测的线段
|
||
|
```
|
||
|
LineSegment lineSegment(Vec3f(3.46, 0.87, 1.57), Vec3f(1.7, 2.04, 1.46));
|
||
|
```
|
||
|
|
||
|
- 输入三角网格`mesh`创建BVH(Bounding Volume Hierarchy)树来检查该线段是否与模型相交
|
||
|
```
|
||
|
static BVH_intersection bvh(mesh);
|
||
|
bool hit = bvh.intersectWithLineSegment(lineSegment);
|
||
|
```
|
||
|
|
||
|
- 读取卡箍点信息:
|
||
|
|
||
|
- 搜索`clipDoc`路径下的所有文件,并将文件名存储在`clipFileNames`向量列表中
|
||
|
```
|
||
|
getAllFiles(clipDoc, clipFileNames);
|
||
|
```
|
||
|
|
||
|
- 然后读取每个文件中的卡箍点坐标与法向,并将这些点存储在`pastar`中
|
||
|
```
|
||
|
read_points(clipFileNames[i].c_str(), pastar);
|
||
|
```
|
||
|
|
||
|
- 初始化结构体:`kdtree, clipSet, basicChannel, astar, basicEdge`
|
||
|
```
|
||
|
init();
|
||
|
```
|
||
|
|
||
|
- 读取连接关系:搜索`xmlDoc`路径下的所有文件,并将文件名存储在`filenames`向量中
|
||
|
```
|
||
|
getAllFiles(xmlDoc, filenames);
|
||
|
```
|
||
|
|
||
|
- 调用`produceXML`函数进行路径规划,并将结果存储在结果文件`resultname`中
|
||
|
```
|
||
|
produceXML(filename, connectorFile.c_str(), resultname);
|
||
|
```
|
||
|
|
||
|
- 打印信息并以规范数据结构保存结果
|
||
|
```
|
||
|
basicChannel.printBundle(resultname);
|
||
|
```
|