mirror of https://github.com/CGAL/cgal
Update demo with Wasserstein tolerance API
This commit is contained in:
parent
c52b32b744
commit
685f8e4701
|
|
@ -42,7 +42,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>680</width>
|
<width>680</width>
|
||||||
<height>21</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
|
|
@ -97,6 +97,7 @@
|
||||||
<addaction name="actionReconstruction_100_steps"/>
|
<addaction name="actionReconstruction_100_steps"/>
|
||||||
<addaction name="actionReconstruction_1000_steps"/>
|
<addaction name="actionReconstruction_1000_steps"/>
|
||||||
<addaction name="actionReconstruction_until"/>
|
<addaction name="actionReconstruction_until"/>
|
||||||
|
<addaction name="actionReconstruction_Wasserstein_tolerance"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionRelocate_vertices"/>
|
<addaction name="actionRelocate_vertices"/>
|
||||||
<addaction name="actionReconstruction_reinit"/>
|
<addaction name="actionReconstruction_reinit"/>
|
||||||
|
|
@ -596,6 +597,14 @@
|
||||||
<string>Output to console</string>
|
<string>Output to console</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</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>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
||||||
|
|
@ -227,9 +227,14 @@ public:
|
||||||
|
|
||||||
void load(const QString& filename, QWidget* qw) {
|
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);
|
load_xy_file(filename);
|
||||||
normalize_points();
|
// normalize_points();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -279,6 +284,25 @@ public:
|
||||||
ifs.close();
|
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
|
#ifdef CGAL_USE_CIMG
|
||||||
void load_image(const QString& fileName) {
|
void load_image(const QString& fileName) {
|
||||||
|
|
@ -486,6 +510,13 @@ public:
|
||||||
m_pwsrec->run_until(nv);
|
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) {
|
void reconstruct(const unsigned int steps) {
|
||||||
std::cout << "reconstruct" << std::endl;
|
std::cout << "reconstruct" << std::endl;
|
||||||
if (!m_init_done)
|
if (!m_init_done)
|
||||||
|
|
|
||||||
|
|
@ -527,6 +527,22 @@ void MainWindow::on_actionReconstruction_until_triggered()
|
||||||
update();
|
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()
|
void MainWindow::on_actionRelocate_vertices_triggered()
|
||||||
{
|
{
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ public:
|
||||||
void on_actionReconstruction_100_steps_triggered();
|
void on_actionReconstruction_100_steps_triggered();
|
||||||
void on_actionReconstruction_1000_steps_triggered();
|
void on_actionReconstruction_1000_steps_triggered();
|
||||||
void on_actionReconstruction_until_triggered();
|
void on_actionReconstruction_until_triggered();
|
||||||
|
void on_actionReconstruction_Wasserstein_tolerance_triggered();
|
||||||
void on_actionRelocate_vertices_triggered();
|
void on_actionRelocate_vertices_triggered();
|
||||||
void on_actionReconstruction_reinit_triggered();
|
void on_actionReconstruction_reinit_triggered();
|
||||||
void on_actionOutput_console_triggered();
|
void on_actionOutput_console_triggered();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue