diff --git a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/pwsrec.ui b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/pwsrec.ui
index 229957863c0..4a2a9b0eda4 100644
--- a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/pwsrec.ui
+++ b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/pwsrec.ui
@@ -42,7 +42,7 @@
0
0
680
- 21
+ 22
diff --git a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/scene.h b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/scene.h
index 587f22ca60f..cd8c84b6bfd 100644
--- a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/scene.h
+++ b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/scene.h
@@ -227,9 +227,14 @@ public:
void load(const QString& filename, QWidget* qw) {
- if (filename.contains(".xy", Qt::CaseInsensitive)) {
+ if (filename.contains(".xyz", Qt::CaseInsensitive)) {
+ load_xyz_file(filename);
+ // normalize_points();
+ return;
+ }
+ else if (filename.contains(".xy", Qt::CaseInsensitive)) {
load_xy_file(filename);
- normalize_points();
+ // normalize_points();
return;
}
@@ -279,6 +284,25 @@ public:
ifs.close();
}
+ void load_xyz_file(const QString& fileName) {
+
+ std::cout << "filename: " << fileName.toUtf8().constData() << std::endl;
+ std::ifstream ifs(qPrintable(fileName));
+ std::cerr << "reading xyz...";
+ unsigned int nb = 0;
+ std::string str;
+ while (getline (ifs, str)) {
+ std::istringstream iss (str);
+ double x = 0., y = 0.;
+ iss >> x >> y;
+ str.clear();
+ add_sample(Point (x, y), 1.0);
+ nb++;
+ }
+ std::cerr << "done (" << nb << " points)" << std::endl;
+ ifs.close();
+ }
+
#ifdef CGAL_USE_CIMG
void load_image(const QString& fileName) {
@@ -486,6 +510,13 @@ public:
m_pwsrec->run_until(nv);
}
+ void reconstruct_wasserstein_tolerance (const double tolerance) {
+ std::cout << "reconstruct_wasserstein_tolerance" << std::endl;
+ if (!m_init_done)
+ init_reconstruction(m_percentage);
+ m_pwsrec->run_under_wasserstein_tolerance (tolerance);
+ }
+
void reconstruct(const unsigned int steps) {
std::cout << "reconstruct" << std::endl;
if (!m_init_done)
diff --git a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/window.cpp b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/window.cpp
index 31dbfff7da3..def2d275888 100644
--- a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/window.cpp
+++ b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/window.cpp
@@ -527,6 +527,22 @@ void MainWindow::on_actionReconstruction_until_triggered()
update();
}
+void MainWindow::on_actionReconstruction_Wasserstein_tolerance_triggered()
+{
+ bool ok;
+ double tolerance = QInputDialog::getDouble(
+ this, tr("Wasserstein tolerance"), tr("Tolerance:"), 0.1, 0., 1000000., 2, &ok);
+ if (!ok) return;
+
+ set_scene_options();
+
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+ m_scene->reconstruct_wasserstein_tolerance (tolerance);
+ QApplication::restoreOverrideCursor();
+
+ update();
+}
+
void MainWindow::on_actionRelocate_vertices_triggered()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
diff --git a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/window.h b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/window.h
index 07a80ac05b9..5913807cb4e 100644
--- a/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/window.h
+++ b/Optimal_transportation_reconstruction_2/demo/Optimal_transportation_reconstruction_2/window.h
@@ -95,6 +95,7 @@ public:
void on_actionReconstruction_100_steps_triggered();
void on_actionReconstruction_1000_steps_triggered();
void on_actionReconstruction_until_triggered();
+ void on_actionReconstruction_Wasserstein_tolerance_triggered();
void on_actionRelocate_vertices_triggered();
void on_actionReconstruction_reinit_triggered();
void on_actionOutput_console_triggered();