83 lines
3.2 KiB
C++
83 lines
3.2 KiB
C++
/********************************************************
|
|
* ██████╗ ██████╗████████╗██╗
|
|
* ██╔════╝ ██╔════╝╚══██╔══╝██║
|
|
* ██║ ███╗██║ ██║ ██║
|
|
* ██║ ██║██║ ██║ ██║
|
|
* ╚██████╔╝╚██████╗ ██║ ███████╗
|
|
* ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
|
|
* Geophysical Computational Tools & Library (GCTL)
|
|
*
|
|
* Copyright (c) 2022 Yi Zhang (yizhang-geo@zju.edu.cn)
|
|
*
|
|
* GCTL is distributed under a dual licensing scheme. You can redistribute
|
|
* it and/or modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation, either version 2
|
|
* of the License, or (at your option) any later version. You should have
|
|
* received a copy of the GNU Lesser General Public License along with this
|
|
* program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* If the terms and conditions of the LGPL v.2. would prevent you from using
|
|
* the GCTL, please consider the option to obtain a commercial license for a
|
|
* fee. These licenses are offered by the GCTL's original author. As a rule,
|
|
* licenses are provided "as-is", unlimited in time for a one time fee. Please
|
|
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
|
|
* to include some description of your company and the realm of its activities.
|
|
* Also add information on how to contact you by electronic and paper mail.
|
|
******************************************************/
|
|
|
|
#include "gctl/core.h"
|
|
#include "gctl/io.h"
|
|
|
|
int main(int argc, char const *argv[])
|
|
{
|
|
// prepare data
|
|
gctl::_2d_vector input_topo;
|
|
gctl::text_descriptor desc;
|
|
gctl::read_text2vector2d("data/topo.txt", input_topo, desc);
|
|
|
|
gctl::matrix<double> test_d(101, 101, 0.0);
|
|
for (int i = 0; i < 101; i++)
|
|
{
|
|
for (int j = 0; j < 101; j++)
|
|
{
|
|
test_d[i][j] = input_topo[i*101+j][2];
|
|
}
|
|
}
|
|
|
|
// save grid
|
|
gctl::save_surfer6_grid("data/out/sample_grid_surfer6", test_d, 0, 1000, 0, 1000, NAN, NAN, gctl::Surfer6Binary);
|
|
|
|
// read grid
|
|
gctl::matrix<double> in_data;
|
|
int xnum, ynum;
|
|
double xmin, xmax, ymin, ymax, zmin, zmax;
|
|
gctl::read_surfer6_grid("data/sample_grid_surfer6", in_data, xnum, ynum, xmin, xmax, ymin, ymax, zmin, zmax, gctl::Surfer6Binary);
|
|
|
|
// show info
|
|
std::cout << xmin << " " << xmax << std::endl;
|
|
std::cout << ymin << " " << ymax << std::endl;
|
|
std::cout << zmin << " " << zmax << std::endl;
|
|
for (int j = 0; j < in_data.col_size(); j++)
|
|
{
|
|
std::cout << in_data[in_data.row_size()-1][j] << " ";
|
|
}
|
|
std::cout << std::endl;
|
|
|
|
// save surfer7 grid
|
|
gctl::save_surfer7_grid("data/sample_grid_surfer7", test_d, 100, 120, 10, 8);
|
|
|
|
// read surfer7 grid
|
|
double dx, dy, null_val;
|
|
gctl::read_surfer7_grid("data/sample_grid_surfer7", in_data, xmin, ymin, dx, dy, zmin, zmax, null_val);
|
|
|
|
// show info
|
|
std::cout << xmin << " " << ymin << std::endl;
|
|
std::cout << dx << " " << dy << std::endl;
|
|
std::cout << zmin << " " << zmax << std::endl;
|
|
for (int j = 0; j < in_data.col_size(); j++)
|
|
{
|
|
std::cout << in_data[in_data.row_size()-1][j] << " ";
|
|
}
|
|
std::cout << std::endl;
|
|
return 0;
|
|
} |