14 #include <boost/program_options.hpp> 27 {
"text", {
".dat",
".shp",
".txt",
".shape"} },
28 {
"icedb", {
".hdf5",
".nc",
".h5",
".cdf",
".hdf"} }
36 int main(
int argc,
char** argv) {
41 namespace po = boost::program_options;
42 po::options_description desc(
"Allowed options");
44 (
"help,h",
"produce help message")
45 (
"from", po::value<string>(),
"The path where a shape is read from")
46 (
"to", po::value<string>(),
"The path where the shape is written to")
47 (
"db-path", po::value<string>()->default_value(
"shape"),
"The path within the database to write to")
48 (
"create",
"Create the output database if it does not exist")
49 (
"resolution", po::value<float>(),
"Lattice spacing for the shape, in um")
50 (
"truncate",
"Instead of opening existing output files in read-write mode, truncate them.")
53 po::store(po::command_line_parser(argc, argv).options(desc).run(), vm);
56 auto doHelp = [&](
const string& s)->
void 62 if (vm.count(
"help")) doHelp(
"");
63 if (!vm.count(
"from") || !vm.count(
"to")) doHelp(
"Need to specify to/from locations.");
65 using namespace icedb;
68 string sFromRaw = vm[
"from"].as<
string>();
69 string sToRaw = vm[
"to"].as<
string>();
70 sfs::path pFromRaw(sFromRaw);
71 sfs::path pToRaw(sToRaw);
72 string dbpath = vm[
"db-path"].as<
string>();
73 if (vm.count(
"resolution"))
resolution_um = vm[
"resolution"].as<float>();
76 auto iof = fs::IOopenFlags::READ_WRITE;
77 if (vm.count(
"create")) iof = fs::IOopenFlags::CREATE;
78 if (vm.count(
"truncate")) iof = fs::IOopenFlags::TRUNCATE;
79 if (!sfs::exists(pToRaw)) iof = fs::IOopenFlags::CREATE;
88 data.optional.particle_scattering_element_spacing =
resolution_um / 1.e6f;
92 basegrp = db->createGroupStructure(dbpath);
93 auto shp = data.toShape(data.required.particle_id,
basegrp->getHDF5Group());
96 catch (
const std::exception &e) {
97 std::cerr << e.what() << std::endl;
101 std::cerr <<
"Unknown exception caught." << std::endl;
float resolution_um
The resolution of each shape lattice, in micrometers.
const std::map< std::string, std::set< sfs::path > > file_formats
ShapeDataBasic readTextFile(const std::string &filename)
std::unique_ptr< Database > Database_ptr
icedb::Groups::Group::Group_ptr basegrp
Shapes get written to this location in the output database.
std::unique_ptr< Groups::Group > Group_ptr
int main(int argc, char **argv)
The main body of the program.
ShapeRequiredData required