Permalink
Browse files

--betti flag writes output file before exiting

  • Loading branch information...
mlwright84 committed Jul 27, 2017
1 parent 8e712c1 commit ce9b8e445a7fa2b93500f4b6a2589bb00a6bab2d
Showing with 21 additions and 6 deletions.
  1. +21 −2 console.cpp
  2. +0 −4 visualizationwindow.cpp
View
@@ -363,7 +363,7 @@ int main(int argc, char* argv[])
std::clog << "Wrote arrangement to " << params.outputFile << std::endl;
}
});
computation.template_points_ready.connect([&points_message, &binary, &betti_only, &verbosity](TemplatePointsMessage message) {
computation.template_points_ready.connect([&points_message, &binary, &betti_only, &verbosity, &params](TemplatePointsMessage message) {
points_message.reset(new TemplatePointsMessage(message));
if (binary) {
@@ -398,8 +398,27 @@ int main(int argc, char* argv[])
print_dims(message, std::cout);
std::cout << std::endl;
print_betti(message, std::cout);
std::cout.flush();
//if an output file has been specified, then save the Betti numbers in an arrangement file (with no barcode templates)
if (!params.outputFile.empty()) {
std::ofstream file(params.outputFile);
if (file.is_open()) {
std::vector<exact> emptyvec;
std::shared_ptr<Arrangement> temp_arrangement = std::make_shared<Arrangement>(emptyvec, emptyvec, verbosity);
std::shared_ptr<ArrangementMessage> temp_am = std::make_shared<ArrangementMessage>(*temp_arrangement);
if (verbosity > 0) {
debug() << "Writing file:" << params.outputFile;
}
write_boost_file(params, *points_message, *temp_am);
} else {
std::stringstream ss;
ss << "Error: Unable to write file:" << params.outputFile;
throw std::runtime_error(ss.str());
}
}
//TODO: this seems a little abrupt...
std::cout.flush();
exit(0);
}
});
View
@@ -286,12 +286,8 @@ void VisualizationWindow::update_persistence_diagram()
BarcodeTemplate dbc = arrangement->get_barcode_template(angle_precise, offset_precise);
barcode = dbc.rescale(angle_precise, offset_precise, template_points->template_points, grades);
qDebug() << "Unshifted barcode:";
barcode->print();
//shift the barcode so that "zero" is where the selected line crosses the bottom or left side of the viewing window
double ll_corner = rivet::numeric::project_to_line(angle_precise, offset_precise, grades.x[0], grades.y[0]); //lower-left corner of line selection window
qDebug() << "ll_corner: " << ll_corner;
barcode = barcode->shift(-1*ll_corner);
//TESTING

0 comments on commit ce9b8e4

Please sign in to comment.