75 lines
1.6 KiB
C++
75 lines
1.6 KiB
C++
/*
|
||
tetgen2gmsh: 读取tetgen文件(.node\.ele\.face\.edge)转换为.msh文件(tetgen竟然不支持输出.msh)
|
||
添加需要的属性值到.pos文件
|
||
*/
|
||
|
||
#include "tetgen2gmsh.h"
|
||
|
||
void disp_help()
|
||
{
|
||
cout<<"tetgen2gmsh 0.0.1 - convert tetgen files(.node& .edge& .face& .ele) to gmsh(.msh) file"<<endl<<endl
|
||
<<"usage: tetgen2msh input_file [-o<output-file>]"<<endl
|
||
<<" -o specify output file's name, the input name will be used if -o is absent"<<endl
|
||
<<" the extensions of input and output files will be added atuomaticly"<<endl<<endl
|
||
<<"example: tetgen2gmsh in -otest"<<endl;
|
||
}
|
||
|
||
int typeget(char *str, const char* str2,string &str3)//提出头端的子句
|
||
{
|
||
char* strp = strstr(str, str2); // 从字符串str中查找str2,
|
||
if (strp == NULL)
|
||
{
|
||
return 0; // 如果没有找到,返回
|
||
}
|
||
string temp = str;
|
||
str3=temp.substr(strlen(str2));//提出除str2外的子句
|
||
return 1;
|
||
}
|
||
|
||
//tetgen2gmsh p1;
|
||
//p1.call_back();
|
||
|
||
int main(int argc, char* argv[])
|
||
{
|
||
string innname="";
|
||
string outname="";
|
||
string temp;
|
||
if (argc==1)
|
||
{
|
||
disp_help();
|
||
}
|
||
else if (argc==2)
|
||
{
|
||
innname=outname=argv[1];
|
||
tetgen2gmsh p1;
|
||
p1.call_back(innname,outname);
|
||
}
|
||
else
|
||
{
|
||
innname=argv[1];
|
||
for (int i = 2; i < argc; i++)
|
||
{
|
||
if (typeget(argv[i],OUTPUT,temp))
|
||
{
|
||
if (temp=="")
|
||
{
|
||
cout<<"no output picked, program stopped..."<<endl;
|
||
return 0;
|
||
}
|
||
else outname = temp;
|
||
}
|
||
}
|
||
|
||
if (outname=="")
|
||
{
|
||
cout<<"no output picked, program stopped..."<<endl;
|
||
return 0;
|
||
}
|
||
else
|
||
{
|
||
tetgen2gmsh p1;
|
||
p1.call_back(innname,outname);
|
||
}
|
||
}
|
||
return 0;
|
||
} |