int main(const int argc, char* argv[]) { namespace js = anu_am::json; char* infile = argv[1]; if (argc < 2) { std::cerr << "Usage:" << argv[0] << " INPUT [OUTPUT]" << std::endl; return 1; } // Read the data for this process. NCFileInfo const info = readFileInfo(infile); Variable const var = findVolumeVariable(info); std::vector<size_t> const dims = readDimensions(info); CubicalComplex complex(dims.at(0), dims.at(1), dims.at(2)); Scalars::DataPtr scalarData = readVolumeData<Value>(infile); Scalars scalars(complex, scalarData); // Process the data. Mask const out = boundaries(complex, scalars); // Generate metadata std::string const parentID = guessDatasetID(infile, info.attributes()); std::string const thisID = derivedID(parentID, "segmented", "BBG"); std::string const outfile = argc > 2 ? argv[2] : (stripTimestamp(thisID) + ".nc"); js::Object const fullSpec = js::Object ("id" , thisID) ("process" , "Basin Boundaries via Gyulassi-Bremer-Pascucci Method") ("sourcefile" , __FILE__) ("revision" , js::Object("id", GIT_REVISION)("date", GIT_TIMESTAMP)) ("parent" , parentID) ("predecessors", js::Array(parentID)) ("parameters" , js::Object()); std::string const description = js::toString(fullSpec, 2); // Write the results to the output file writeVolumeData( out.data(), outfile, "segmented", dims.at(0), dims.at(1), dims.at(2), VolumeWriteOptions() .fileAttributes(inheritableAttributes(info.attributes())) .datasetID(thisID) .description(description) .computeHistogram(false)); }
int main(int argc, char* argv[]) { namespace js = anu_am::json; int c; float threshold = 0; int dimension = 3; while ((c = getopt (argc, argv, "d:t:")) != -1) { switch (c) { case 'd': dimension = atoi(optarg); break; 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. Mask const out = skeleton(complex, scalars, field, threshold, dimension); // Generate metadata to include with the output data std::string const parentID = guessDatasetID(fieldPath, info.attributes()); std::string const thisID = derivedID(parentID, "segmented", "SKL"); 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" , "Skeleton") ("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, "segmented", dims.at(0), dims.at(1), dims.at(2), VolumeWriteOptions() .fileAttributes(info.attributes()) .datasetID(thisID) .description(description)); }