Files
cse5543_homework/lab3/test_grid2DIO.cpp
2026-03-31 10:26:51 -04:00

54 lines
1.2 KiB
C++

// Test read and write functions in grid2DIO.py.
// Mainly for an example of reading and writing a GRID2D_POINTS3D array
#include <iostream>
#include <string>
#include "grid2DPoints3D.h"
#include "grid2DIO.h"
// ********************* Functions ************************************
void UsageMsg(const std::string& command_name) {
std::cerr << "Usage: " << command_name << " {infile} {outfile}\n";
}
// ********************* Main *****************************************
int main(int argc, char* argv[]) {
using namespace std;
if (argc != 3) {
UsageMsg(argv[0]);
return 0;
}
GRID2D_POINTS3D grid2D;
try {
cout << "Reading " << argv[1] << "." << endl;
OpenReadGrid2DPoints3D(argv[1], grid2D);
}
catch (const exception&) {
cerr << "Exiting...\n";
return -1;
}
try {
cout << "Copying to file " << argv[2] << ".";
vector<string> comment_list;
string s = string("Copy of ") + argv[1] + ".";
comment_list.push_back(s);
OpenWriteGrid2DPoints3D(argv[2], grid2D, comment_list);
}
catch (const exception&) {
cerr << "Exiting...\n";
return -1;
}
return 0;
}