int main(int argc, char* argv[]) { namespace js = anu_am::json; int c; float threshold = 0; while ((c = getopt (argc, argv, "t:")) != -1) { switch (c) { case 't': threshold = atof(optarg); break; default: usage(argv[0]); return 1; } } if (argc - optind < 2) { usage(argv[0]); return 1; } char* scalarPath = argv[optind]; char* fieldPath = argv[optind + 1]; // Read the data for this process. NCFileInfo const info = readFileInfo(fieldPath); Variable const var = findVolumeVariable(info); std::vector<size_t> dims = readDimensions(info); CubicalComplex complex(dims.at(0), dims.at(1), dims.at(2)); Vertices vertices(dims.at(0), dims.at(1), dims.at(2)); assert(dims == readDimensions(scalarPath)); Scalars::DataPtr scalarData = readVolumeData<Value>(scalarPath); Scalars scalars(complex, scalarData); Field::DataPtr fieldData = readVolumeData<FieldItem>(fieldPath); Field field = Field(dims.at(0), dims.at(1), dims.at(2), fieldData); // Process the data. Labels const out = pores(complex, scalars, field, threshold); // Generate metadata to include with the output data std::string const parentID = guessDatasetID(fieldPath, info.attributes()); std::string const thisID = derivedID(parentID, "labels", "POR"); std::string const outfile = (argc - optind > 2) ? argv[optind+2] : (stripTimestamp(thisID) + ".nc"); js::Array const predecessors = js::Array (parentID) (guessDatasetID(scalarPath, readFileInfo(scalarPath).attributes())); js::Object const parameters = js::Object("threshold" , threshold); js::Object const fullSpec = js::Object ("id" , thisID) ("process" , "Pores") ("sourcefile" , __FILE__) ("revision" , js::Object("id", GIT_REVISION)("date", GIT_TIMESTAMP)) ("parent" , parentID) ("predecessors", predecessors) ("parameters" , parameters); std::string const description = js::toString(fullSpec, 2); // Write the resulting gradient vector field to the output file writeVolumeData( out.data(), outfile, "labels", dims.at(0), dims.at(1), dims.at(2), VolumeWriteOptions() .fileAttributes(info.attributes()) .datasetID(thisID) .description(description)); }