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.
4.8 KiB
4.8 KiB
项目结构
.
│ CMakeLists.txt \\CMake构建配置文件
│ config.h.in
│ readme.md
├─data
│ ├─demo
│ │ └─ ...
│ └─Tinyroute_test
│ │ connector.csv \\连接器数据
│ │ result_ALL.txt \\当前数据与参数下应运行出的结果数据
│ ├─clip2
│ │ clips_with_dir.xml \\空间中卡箍点集数据
│ ├─OBJ
│ │ cangti_correct.obj \\输入模型
│ └─wirexml \\ 连接器间连接关系
│ 1START_END.xml
│ 2NEAR_END.xml
│ 3NEAR_START.xml
├─include
│ read_xml.h
│
├─lib \\所用运行库
│ │ tinyxml.lib
│ │ WireRouting_DLL.dll
│ │ WireRouting_DLL.lib
│ │
│ └─include \\库相关头文件
│ Astar.h
│ BasicChannel.h
│ BasicEdge.h
| ...
│
└─src \\编译目标源文件
xmlsql.cpp
运行环境配置
- CMake配置
- 确认Cmake已安装: Download CMake
- 添加cmake.exe至环境变量
- 确认编译器已安装,如VS2022、VS2019等环境
使用CMake构建项目
# 进入项目目录
cd <path_to_project>
# Standard CMake build
# 注意项目所用链接库均为 Debug x64 编译,构建务必使用同规格
cmake -S . -B build -T host=x64 -A x64
cmake --build build --config Debug --target ALL_BUILD -j 14
运行
# 进入可执行文件所在目录
cd <path_to_project>\build\Debug
# 运行
.\WireRouting.exe createTinyroute "..\\..\\data\\Tinyroute_test\\clip2" "..\\..\\data\\Tinyroute_test\\wirexml" "..\\..\\data\\Tinyroute_test\\connector.csv" "..\\..\\data\\Tinyroute_test\\OBJ" output
MacOS下运行 publish/bin/ 中的可执行文件
cd <path_to_project>/publish/bin
install_name_tool -add_rpath @executable_path/../lib/ ./WireRoutingProject
查看结果
在 <path_to_project>\build\Debug\output_ALL.txt 目录下查看输出文件
可与 <path_to_project>\data\Tinyroute_test\result_ALL.txt 比较结果
程序模块说明
参数输入
.\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);