Skip to content

Commit

Permalink
--betti flag writes output file before exiting
Browse files Browse the repository at this point in the history
  • Loading branch information
mlwright84 committed Jul 27, 2017
1 parent 8e712c1 commit ce9b8e4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
23 changes: 21 additions & 2 deletions console.cpp
Expand Up @@ -363,7 +363,7 @@ int main(int argc, char* argv[])
std::clog << "Wrote arrangement to " << params.outputFile << std::endl; 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)); points_message.reset(new TemplatePointsMessage(message));


if (binary) { if (binary) {
Expand Down Expand Up @@ -398,8 +398,27 @@ int main(int argc, char* argv[])
print_dims(message, std::cout); print_dims(message, std::cout);
std::cout << std::endl; std::cout << std::endl;
print_betti(message, std::cout); 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... //TODO: this seems a little abrupt...
std::cout.flush();
exit(0); exit(0);
} }
}); });
Expand Down
4 changes: 0 additions & 4 deletions visualizationwindow.cpp
Expand Up @@ -286,12 +286,8 @@ void VisualizationWindow::update_persistence_diagram()
BarcodeTemplate dbc = arrangement->get_barcode_template(angle_precise, offset_precise); BarcodeTemplate dbc = arrangement->get_barcode_template(angle_precise, offset_precise);
barcode = dbc.rescale(angle_precise, offset_precise, template_points->template_points, grades); 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 //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 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); barcode = barcode->shift(-1*ll_corner);


//TESTING //TESTING
Expand Down

0 comments on commit ce9b8e4

Please sign in to comment.