#include <openzgy/api.h>
#include <iostream>
#include <stdexcept>
#include <stdlib.h>
void copy(const std::string& srcname, const std::string& dstname)
{
const std::array<std::int64_t,3> size = r->
size();
const std::array<std::int64_t,3> brick = r->
bricksize();
const std::array<std::int64_t,3> bs{brick[0], brick[1], size[2]};
const std::int64_t total = ((size[0] + bs[0] - 1) / bs[0]) *
((size[1] + bs[1] - 1) / bs[1]);
std::int64_t done{0};
std::unique_ptr<float> buf(new float[bs[0]*bs[1]*bs[2]]);
std::array<std::int64_t,3> pos;
for (pos[0] = 0; pos[0] < size[0]; pos[0] += bs[0]) {
for (pos[1] = 0; pos[1] < size[1]; pos[1] += bs[1]) {
for (pos[2] = 0; pos[2] < size[2]; pos[2] += bs[2]) {
r->
read(pos, bs, buf.get(), 0);
w->
write(pos, bs, buf.get());
p1(++done, total);
}
}
}
w->
finalize(std::vector<DecimationType>(), p2);
}
int main(int argc, const char **argv)
{
if (argc != 3) {
std::cerr << "Usage: " << argv[0] << " infile outfile" << std::endl;
exit(1);
}
try {
copy(argv[1], argv[2]);
}
catch (const std::exception& ex) {
std::cerr << argv[0] << ": " << ex.what() << std::endl;
exit(1);
}
}