|
|
@ -1,4 +1,4 @@ |
|
|
|
// xmlsql.cpp : �������̨Ӧ�ó������ڵ㡣
|
|
|
|
// xmlsql.cpp : 定义控制台应用程序的入口点。
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "stdafx.h" |
|
|
@ -76,7 +76,7 @@ struct Readexcel{ |
|
|
|
} |
|
|
|
}rexcel; |
|
|
|
|
|
|
|
//��ȡ������
|
|
|
|
//读取卡箍点
|
|
|
|
void read_points(string filename,Astar * pastar){ |
|
|
|
//cout<<"read "<<filename<<endl;
|
|
|
|
vector<string>sl=rexcel.read(filename); |
|
|
@ -87,7 +87,7 @@ void read_points(string filename,Astar * pastar){ |
|
|
|
{ |
|
|
|
string s1=sl[i+1],s2=sl[i+2],s0=sl[i]; |
|
|
|
//cout<<s0<<" "<<s1<<endl;//test
|
|
|
|
istringstream sin(s1),sin2(s2); //�������ַ���line���뵽�ַ�����istringstream��
|
|
|
|
istringstream sin(s1),sin2(s2); //将整行字符串line读入到字符串流istringstream中
|
|
|
|
|
|
|
|
P p1,p2; |
|
|
|
sin>>p1.x>>p1.y>>p1.z; |
|
|
@ -107,17 +107,17 @@ void read_points(string filename,Astar * pastar){ |
|
|
|
} |
|
|
|
|
|
|
|
unsigned int extractAndConvert(const string& str) { |
|
|
|
size_t pos = str.find("/"); // ���� "//" ���
|
|
|
|
size_t pos = str.find("/"); // 查找 "//" 的位置
|
|
|
|
if (pos == std::string::npos) { |
|
|
|
throw invalid_argument("No '/' found in the string."); |
|
|
|
} |
|
|
|
string numberStr = str.substr(0, pos); // ��ȡ "//" ֮ǰ�IJ���
|
|
|
|
string numberStr = str.substr(0, pos); // 截取 "//" 之前的部分
|
|
|
|
char* endptr; |
|
|
|
long number = strtol(numberStr.c_str(), &endptr, 10); // ʹ�� strtol ���ַ���ת��Ϊ long�������ת���Ƿ�ɹ�
|
|
|
|
long number = strtol(numberStr.c_str(), &endptr, 10); // 使用 strtol 将字符串转换为 long,并检查转换是否成功
|
|
|
|
if (endptr == numberStr.c_str() || *endptr != '\0' || number < 0 || static_cast<unsigned int>(number) != number) { |
|
|
|
throw invalid_argument("Invalid input string for conversion to unsigned int."); |
|
|
|
} // ���ת���Ƿ�ɹ����Լ�ֵ�Ƿ��� unsigned int �ķ�Χ��
|
|
|
|
return static_cast<unsigned int>(number); // ת��Ϊ unsigned int ������
|
|
|
|
} // 检查转换是否成功,以及值是否在 unsigned int 的范围内
|
|
|
|
return static_cast<unsigned int>(number); // 转换为 unsigned int 并返回
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -129,26 +129,26 @@ bool read_OBJ(const string& filename,vector<Vec3f>& vertices,vector<Vec3u>& indi |
|
|
|
} |
|
|
|
string line; |
|
|
|
while (getline(file, line)) { |
|
|
|
// ���Կ��к�ע����
|
|
|
|
// 忽略空行和注释行
|
|
|
|
if (line.empty() || line.at(0) == '#') { |
|
|
|
continue; |
|
|
|
} |
|
|
|
//std::cout<<line<<std::endl;
|
|
|
|
istringstream iss(line); |
|
|
|
string token; |
|
|
|
if (iss >> token && token == "v") {// ��������
|
|
|
|
if (iss >> token && token == "v") {// 解析顶点
|
|
|
|
float x, y, z; |
|
|
|
iss >> x >> y >> z; |
|
|
|
//std::cout<<"v:"<<x<<" "<<y<<" "<<z<<std::endl;
|
|
|
|
//std::cout<<"vertices_length"<<vertices.size()<<std::endl;
|
|
|
|
vertices.push_back(Vec3f(x,y,z)); |
|
|
|
} |
|
|
|
else if (token == "f") {// �����棨����ֻ��ȡ����������
|
|
|
|
else if (token == "f") {// 解析面(这里只提取顶点索引)
|
|
|
|
//std::cout<<"enter_f"<<std::endl;
|
|
|
|
string v1_s,v2_s,v3_s; |
|
|
|
unsigned int v1, v2, v3; // ͨ��һ�������������㶨��
|
|
|
|
unsigned int v1, v2, v3; // 通常一个面由三个顶点定义
|
|
|
|
if (!(iss >> v1_s >> v2_s >> v3_s)) { |
|
|
|
// ��������������������������
|
|
|
|
// 处理非三角形面或其他错误情况
|
|
|
|
continue; |
|
|
|
} |
|
|
|
try { |
|
|
@ -171,7 +171,7 @@ bool read_OBJ(const string& filename,vector<Vec3f>& vertices,vector<Vec3u>& indi |
|
|
|
indices.push_back(Vec3u(v1,v2,v3)); |
|
|
|
} |
|
|
|
//else std::cout<<token<<std::endl;
|
|
|
|
// �����������͵��У��編�ߡ���������ȣ�
|
|
|
|
// 忽略其他类型的行(如法线、纹理坐标等)
|
|
|
|
} |
|
|
|
file.close(); |
|
|
|
return true; |
|
|
@ -225,29 +225,29 @@ void produceXML(const char * xml,const char * connectorFile,string resultfile){ |
|
|
|
} |
|
|
|
|
|
|
|
void getAllFiles(string path, vector<string>& files) { |
|
|
|
//����
|
|
|
|
//文件句柄
|
|
|
|
long long hFile = 0; |
|
|
|
//�ļ���Ϣ
|
|
|
|
//文件信息
|
|
|
|
struct _finddata_t fileinfo; |
|
|
|
string p; |
|
|
|
if ((hFile = _findfirst(p.assign(path).append("\\*").c_str(), &fileinfo)) != -1) { |
|
|
|
do { |
|
|
|
if ((fileinfo.attrib & _A_SUBDIR)) { //�Ƚ��ļ������Ƿ����ļ���
|
|
|
|
if ((fileinfo.attrib & _A_SUBDIR)) { //比较文件类型是否是文件夹
|
|
|
|
if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0) { |
|
|
|
files.push_back(p.assign(path).append("\\").append(fileinfo.name)); |
|
|
|
//�ݹ�����
|
|
|
|
//递归搜索
|
|
|
|
getAllFiles(p.assign(path).append("\\").append(fileinfo.name), files); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
files.push_back(p.assign(path).append("\\").append(fileinfo.name)); |
|
|
|
} |
|
|
|
} while (_findnext(hFile, &fileinfo) == 0); //Ѱ����һ�����ɹ�����0������-1
|
|
|
|
} while (_findnext(hFile, &fileinfo) == 0); //寻找下一个,成功返回0,否则-1
|
|
|
|
_findclose(hFile); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//��ʼ�������ṹ��
|
|
|
|
//初始化各个结构体
|
|
|
|
inline void init(){ |
|
|
|
kdtree.build(); |
|
|
|
cout<<"kdtree build Finish"<<endl; |
|
|
@ -282,9 +282,9 @@ int _tmain(int argc, char * argv[]) |
|
|
|
string mode; |
|
|
|
// cin>>mode;
|
|
|
|
mode = argv[1]; |
|
|
|
|
|
|
|
|
|
|
|
if(mode=="generateCATIA"){ |
|
|
|
//��ģʽΪ����ģʽ��ʹ����������ͨ��ģ��
|
|
|
|
//该模式为基本模式,使用它来生成通道模型
|
|
|
|
string clipDoc,xmlDoc,connectorFile,stlFileName,outputFileName; |
|
|
|
cin>>clipDoc>>xmlDoc>>connectorFile>>stlFileName>>outputFileName; |
|
|
|
vector<string> clipFileNames; |
|
|
@ -324,7 +324,7 @@ int _tmain(int argc, char * argv[]) |
|
|
|
cout<<"ALL FINISH"<<endl; |
|
|
|
} |
|
|
|
else if(mode=="createChannel"){ |
|
|
|
//��ģʽ���ڸ��ݿ������λ�����ɽ���ͨ��
|
|
|
|
//该模式用于根据卡箍相对位置生成近似通道
|
|
|
|
string clipDoc,stlFileName,outputFileName; |
|
|
|
cin>>clipDoc>>stlFileName>>outputFileName; |
|
|
|
cout<<"mode = createChannel"<<endl; |
|
|
@ -348,7 +348,7 @@ int _tmain(int argc, char * argv[]) |
|
|
|
} |
|
|
|
//----------------------mark----------------------
|
|
|
|
else if(mode=="createTinyroute"){ |
|
|
|
//��ģʽΪ��С�ռ�ģʽ��ʹ������������С�ռ��·��
|
|
|
|
//该模式为狭小空间模式,使用它来生成狭小空间的路径
|
|
|
|
string clipDoc,xmlDoc,connectorFile,OBJDoc,outputFileName; |
|
|
|
// cin>>clipDoc>>xmlDoc>>connectorFile>>OBJDoc>>outputFileName;
|
|
|
|
clipDoc = argv[2]; |
|
|
|