gctl_toolkits/archive/tetgen2gmsh/main.cpp
2024-09-10 20:25:18 +08:00

75 lines
1.6 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
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;
}