|
|
@ -67,7 +67,7 @@ struct Readexcel |
|
|
|
|
|
|
|
// cout<<(cell->FirstChildElement()->GetText())<<endl;
|
|
|
|
|
|
|
|
s[i] = cell->FirstChildElement()->GetText(); |
|
|
|
s[i] = cell->FirstChildElement()->GetText(); |
|
|
|
i++; |
|
|
|
} |
|
|
|
slist.push_back(s[0]); |
|
|
@ -201,7 +201,8 @@ void produceXML(const char *xml, const char *connectorFile, string resultfile) |
|
|
|
ofs.open("result.txt", ios::out); |
|
|
|
string endfilename = "end" + resultfile; |
|
|
|
// oendpoint.open(endfilename.c_str(),ios::out);
|
|
|
|
|
|
|
|
|
|
|
|
// 读取线缆起始点数据
|
|
|
|
readxml(xml, connectorFile); |
|
|
|
|
|
|
|
cout << "wire_pairs num: " << wire_pairs.size() << endl; |
|
|
@ -218,11 +219,14 @@ void produceXML(const char *xml, const char *connectorFile, string resultfile) |
|
|
|
|
|
|
|
if (inbox(bd.start) && inbox(bd.goal)) |
|
|
|
{ |
|
|
|
|
|
|
|
// 路径规划
|
|
|
|
cout << "yes" << endl; |
|
|
|
Path path = astar.search_pair(bd); |
|
|
|
Path path = astar.search_pair(bd); // 多线缆下只能搜索出第一次的路径
|
|
|
|
|
|
|
|
// 打印路径
|
|
|
|
for (int j = 0; j < path.points.size(); j++) |
|
|
|
{ |
|
|
|
cout << path.wirelist[0] << endl; |
|
|
|
P pp = path.points[j]; |
|
|
|
ofs << pp.x << " " << pp.y << " " << pp.z << endl; |
|
|
|
cout << setprecision(10) << "(" << pp.x << "," << pp.y << "," << pp.z << ")"; |
|
|
@ -280,34 +284,34 @@ inline void init() |
|
|
|
|
|
|
|
clipSet.computeCenter(); |
|
|
|
cout << "compute center Finish Y:" << Ycenter << " Z:" << Zcenter << endl; |
|
|
|
clipSet.buildChannel(); |
|
|
|
basicChannel.createChannel(); |
|
|
|
clipSet.buildChannel(); //?
|
|
|
|
basicChannel.createChannel(); //?
|
|
|
|
cout << "basicChannel build Finish" << endl; |
|
|
|
basicChannel.createBranchPoint(); |
|
|
|
basicChannel.createBranchPoint(); //?
|
|
|
|
cout << "branchPoint create Finish" << endl; |
|
|
|
for (int i = 1; i <= branchPointSet.branchPointNum; i++) |
|
|
|
{ |
|
|
|
astar.add_branchPoint(branchPointSet.b[i]); |
|
|
|
} |
|
|
|
astar.init(); |
|
|
|
astar.init(); //pnum+2
|
|
|
|
cout << "astar init Finish clipNum:" << astar.pnum - 2 << " Toatal Point Num:" << astar.tnum << endl; |
|
|
|
basicEdge.buildEdgeBetweenClipAndBranchPoint(); |
|
|
|
basicEdge.buildEdgeBetweenClipAndBranchPoint(); //?
|
|
|
|
cout << "edge build Finish" << endl; |
|
|
|
cout << "INIT Finish" << endl; |
|
|
|
} |
|
|
|
|
|
|
|
int _tmain(int argc, char *argv[]) |
|
|
|
{ |
|
|
|
|
|
|
|
// test();
|
|
|
|
// return 0;
|
|
|
|
cout << "Start" << endl; |
|
|
|
Astar *pastar = &astar; |
|
|
|
|
|
|
|
cout << "Start" << endl; |
|
|
|
string mode; |
|
|
|
// cin>>mode;
|
|
|
|
mode = argv[1]; |
|
|
|
|
|
|
|
Astar *pastar = &astar; |
|
|
|
|
|
|
|
if (mode == "generateCATIA") |
|
|
|
{ |
|
|
|
// 该模式为基本模式,使用它来生成通道模型
|
|
|
@ -374,9 +378,9 @@ int _tmain(int argc, char *argv[]) |
|
|
|
cout << "ALL FINISH" << endl; |
|
|
|
} |
|
|
|
//----------------------mark----------------------
|
|
|
|
// 该模式为狭小空间模式,使用它来生成狭小空间的路径
|
|
|
|
else if (mode == "createTinyroute") |
|
|
|
{ |
|
|
|
// 该模式为狭小空间模式,使用它来生成狭小空间的路径
|
|
|
|
string clipDoc, xmlDoc, connectorFile, OBJDoc, outputFileName; |
|
|
|
// cin>>clipDoc>>xmlDoc>>connectorFile>>OBJDoc>>outputFileName;
|
|
|
|
clipDoc = argv[2]; |
|
|
@ -385,9 +389,11 @@ int _tmain(int argc, char *argv[]) |
|
|
|
OBJDoc = argv[5]; |
|
|
|
outputFileName = argv[6]; |
|
|
|
|
|
|
|
// 读取obj文件列表
|
|
|
|
vector<string> OBJFilenames; |
|
|
|
getAllFiles(OBJDoc, OBJFilenames); |
|
|
|
cout << "OBJfilename.size()" << OBJFilenames.size() << endl; |
|
|
|
cout << "OBJfilename.size():" << OBJFilenames.size() << endl; |
|
|
|
// 测试模型输入与bvh相交算法
|
|
|
|
for (int i = 0; i < OBJFilenames.size(); i++) |
|
|
|
{ |
|
|
|
if (read_OBJ(OBJFilenames[i], vertices, indices)) |
|
|
@ -399,10 +405,13 @@ int _tmain(int argc, char *argv[]) |
|
|
|
cout << "indices_length:" << indices.size() << endl; |
|
|
|
// Line segment
|
|
|
|
intersection_model = 1; |
|
|
|
// 测试线段长度、方向
|
|
|
|
LineSegment lineSegment(Vec3f(3.46, 0.87, 1.57), Vec3f(1.7, 2.04, 1.46)); // VS2008
|
|
|
|
// 构建BVH树
|
|
|
|
static BVH_intersection bvh(mesh); |
|
|
|
// 判断线段是否与模型相交
|
|
|
|
bool hit = bvh.intersectWithLineSegment(lineSegment); |
|
|
|
cout << "Line segment intersects with Mesh:" << hit << endl; |
|
|
|
cout << "Test line segment (3.46, 0.87, 1.57)->(1.7, 2.04, 1.46) intersects with Mesh:" << hit << endl; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@ -410,26 +419,28 @@ int _tmain(int argc, char *argv[]) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 读取卡箍点
|
|
|
|
vector<string> clipFileNames; |
|
|
|
getAllFiles(clipDoc, clipFileNames); |
|
|
|
for (int i = 0; i < clipFileNames.size(); i++) |
|
|
|
read_points(clipFileNames[i].c_str(), pastar); |
|
|
|
|
|
|
|
cout << "read points finish" << endl; |
|
|
|
|
|
|
|
// bvh.read_stl(stlFileName.c_str());
|
|
|
|
|
|
|
|
time_t r1, r2; |
|
|
|
|
|
|
|
time(&r1); |
|
|
|
|
|
|
|
//?通道初始化
|
|
|
|
init(); |
|
|
|
|
|
|
|
//读取路径起始点
|
|
|
|
vector<string> filenames; |
|
|
|
getAllFiles(xmlDoc, filenames); |
|
|
|
|
|
|
|
cout << "filename.size()" << filenames.size() << endl; |
|
|
|
for (int i = 0; i < filenames.size(); i++) |
|
|
|
{ |
|
|
|
cout << "i:" << i << " " << filenames[i] << endl; |
|
|
|
// if(i!=0)break;
|
|
|
|
string wirebh; |
|
|
|
stringstream ss; |
|
|
|
ss << i; |
|
|
@ -438,10 +449,12 @@ int _tmain(int argc, char *argv[]) |
|
|
|
cout << filename << endl; |
|
|
|
cout << endl; |
|
|
|
string resultname = outputFileName + wirebh + ".txt"; |
|
|
|
|
|
|
|
//路径规划
|
|
|
|
produceXML(filename.c_str(), connectorFile.c_str(), resultname); |
|
|
|
} |
|
|
|
// string resultname = outputFileName + "ALL.txt";
|
|
|
|
string resultname = outputFileName + filenames[0][19] + "toEx100.txt"; |
|
|
|
string resultname = outputFileName + filenames[0].substr(filenames[0].find_last_of("/\\") + 1) + "_ALL.txt"; |
|
|
|
|
|
|
|
basicChannel.printBundle(resultname); |
|
|
|
|
|
|
|