// GmtSurfaceGrid.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include #include #include #include "GmtSurfaceInterp.h" // Existing GMT processing code (no changes needed) // The functions: WriteDSAA, ConvertFaultFile, ExtractBounds, GmtSurfaceInterp should be reused as-is // Only main function will be adjusted to parse command line arguments void SetGmtEnvironment() { char exePath[MAX_PATH]; GetModuleFileNameA(NULL, exePath, MAX_PATH); std::string path(exePath); size_t pos = path.find_last_of("\\/"); std::string exeDir = path.substr(0, pos); std::string gmtSharePath = exeDir + "\\SplineInterpolation\\share"; _putenv_s("GMT6_SHAREDIR", gmtSharePath.c_str()); char oldPath[32767]; GetEnvironmentVariableA("PATH", oldPath, 32767); std::string newPath = exeDir + "\\SplineInterpolation\\bin;" + oldPath; _putenv_s("PATH", newPath.c_str()); //printf("GMT6_SHAREDIR=%s\n", gmtSharePath.c_str()); //printf("PATH=%s\n", newPath.c_str()); } int main(int argc, char* argv[]) { SetGmtEnvironment(); // 必须第一行执行 //const char* input_xyz = "C:/Users/13350/Desktop/test/input.xyz"; //const char* output_grid = "C:/Users/13350/Desktop/test/11.grd"; //const char* fault_file = ""; //const char* boundary_file = ""; //const char* ouput_file = "C:/Users/13350/Desktop/test/input.kev"; //double step = 5.0; //double tension = 0.0; if (argc < 6) { //printf("Usage: GmtSurfaceGrid.exe [step] [tension]\n"); return -1; } const char* input_xyz = argv[1]; const char* output_grid = argv[2]; const char* fault_file = (strcmp(argv[3], "NULL") == 0) ? "" : argv[3]; const char* boundary_file = (strcmp(argv[4], "NULL") == 0) ? "" : argv[4]; const char* ouput_file = argv[5]; double step = 5.0; double tension = 0.0; double contourStep = 5; int contourMarkStep = 5; double XMin = 0; double YMin = 0; double XMax = 0; double YMax = 0; if (argc >= 7) step = atof(argv[6]); if (argc >= 8) tension = atof(argv[7]); if (argc >= 9) contourStep = atof(argv[8]); if (argc >= 10) contourMarkStep = atoi(argv[9]); if (argc >= 11) XMin = atof(argv[10]); if (argc >= 12) YMin = atof(argv[11]); if (argc >= 13) XMax = atof(argv[12]); if (argc >= 14) YMax = atof(argv[13]); if (!GmtSurfaceInterp(input_xyz, output_grid, step, tension, fault_file, boundary_file, ouput_file, contourStep, contourMarkStep, XMin, YMin, XMax, YMax)) { printf("Interpolation failed.\n"); return -1; } return 0; } // 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单 // 调试程序: F5 或调试 >“开始调试”菜单 // 入门使用技巧: // 1. 使用解决方案资源管理器窗口添加/管理文件 // 2. 使用团队资源管理器窗口连接到源代码管理 // 3. 使用输出窗口查看生成输出和其他消息 // 4. 使用错误列表窗口查看错误 // 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目 // 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件