Update demo with Wasserstein tolerance API

This commit is contained in:
Simon Giraudot 2016-07-20 09:16:50 +02:00
parent c52b32b744
commit 685f8e4701
4 changed files with 60 additions and 3 deletions

View File

@ -42,7 +42,7 @@
<x>0</x>
<y>0</y>
<width>680</width>
<height>21</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@ -97,6 +97,7 @@
<addaction name="actionReconstruction_100_steps"/>
<addaction name="actionReconstruction_1000_steps"/>
<addaction name="actionReconstruction_until"/>
<addaction name="actionReconstruction_Wasserstein_tolerance"/>
<addaction name="separator"/>
<addaction name="actionRelocate_vertices"/>
<addaction name="actionReconstruction_reinit"/>
@ -596,6 +597,14 @@
<string>Output to console</string>
</property>
</action>
<action name="actionReconstruction_Wasserstein_tolerance">
<property name="text">
<string>Run under Wasserstein tolerance...</string>
</property>
<property name="shortcut">
<string>W</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -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)

View File

@ -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);

View File

@ -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();