add lab3
This commit is contained in:
53
lab3/test_grid2DIO.cpp
Normal file
53
lab3/test_grid2DIO.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
// 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;
|
||||
}
|
||||
Reference in New Issue
Block a user