#include "dispHelp.h" #include "FractalTopo.h" void disp_help(char* proname) { string exName = proname; string exUsage = proname; exUsage += " [-p/] [-r////[/|]] [-t///] [-g//////[/rho]] [h] > output-file"; dispHelp dh; dh.changeLayerOut(0,10); dh.addHeadInfo(exName,"1.4.1","fractal topography generater.","Yi Zhang (zhangyi.cugwuhan@gmail.com)"); dh.addUsage(exUsage); dh.addOption("Roughness and maximal changing range of the output topography data. The defaults are 1.2/600","-p"); dh.addOption("Calculation range, the program can output topography data under a rectangular grid or at random positions. The defaults are 0/1000/0/1000/10/10","-r"); dh.addOption("Altitudes at four corner's positions. The defaults are 0/0/0/0","-t"); dh.addOption("filter parameters","-g"); dh.addOptionSec("cx/cy : center coordinates of the filter"); dh.addOptionSec("sigma : radius of the shorter axis of the 0.5 filter amplitude"); dh.addOptionSec("ang : angle between the shorter axis of the filter and the x-axis"); dh.addOptionSec("Lx/Ly : length factor the long and short axises of the filter. usually we take Lx = 1 to ensure the radius of 0.5 filter amplitude equals \ the distance given by sigma in the direction of the shorter axis of the filter. a bigger L value indicates faster changing rate in the corresponding \ direction. For instance 1/0.5 yields an oval which flattening equals 2.0"); dh.addOptionSec("magnify : filter amplitude at the center"); dh.addOptionSec("rho : changing rate of the arctan function"); dh.addOption("choose weight function type, input 'pow' for power function (default) and 'atan' for arctan function","-f"); dh.addOption("print this information","-h"); dh.addExample("fractopo > regular.xyz"); dh.addExample("fractopo > -r0/1000/0/1000/5000 > random.xyz"); dh.addExample("fractopo > -g500/500/100/45/1/0.6/1 > regular_gauss.xyz"); dh.addExample("fractopo > -r0/1000/0/1000/5000 -g500/500/100/45/1/0.6/1 > random_gauss.xyz"); dh.show(); } int main(int argc, char* argv[]) { double Para[2] = {1.2,600}; double Range[6] = {0,1000,0,1000,10,10}; double Topo[4] = {0,0,0,0}; double Gauss[8] = {1e+30,1e+30,1e+30,1e+30,1e+30,1e+30,1e+30,1e+30}; char flType[1024] = "pow"; FracTopo FT; opterr = 0; int curr; /*循环拾取参数 最后一个参数为-1 需要变量的参数后跟一个冒号 可有可无参数跟两个冒号*/ while((curr = getopt(argc,argv,"hf:p:r:t:g:")) != -1) { /*匹配命令*/ switch (curr) { case 'h': //显示帮助信息 disp_help(argv[0]); return 0; case 'f': if (1!=sscanf(optarg,"%s",flType)) //格式化读入参数 { cout< "< "< "<Range[1]) { cout< "<Range[3]) { cout< "< "<Range[1]||(Range[0]+2*Range[4])>Range[1]) { cout< "<Range[3]||(Range[2]+2*Range[5])>Range[3]) { cout< "< "< "<