Skip to content

Commit

Permalink
#7 Update visualizer GUI to show Ruppert refinement results
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-ogre committed Oct 6, 2023
1 parent 8687b06 commit a51fee4
Showing 1 changed file with 53 additions and 8 deletions.
61 changes: 53 additions & 8 deletions visualizer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#include <QCheckBox>
#include <QColor>
#include <QDir>
#include <QFormLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QListWidget>
#include <QMessageBox>
#include <QPaintEvent>
Expand Down Expand Up @@ -82,6 +84,12 @@ public slots:
updateCDT();
}

void setRefinementLimit(int limit)
{
m_refinementLimit = static_cast<std::size_t>(limit);
updateCDT();
}

void hidePoints(int isHidePoints)
{
m_isHidePoints = (isHidePoints != 0);
Expand All @@ -94,6 +102,12 @@ public slots:
updateCDT();
}

void doRuppertRefinement(int isDoRuppert)
{
m_isDoRuppert = (isDoRuppert != 0);
updateCDT();
}

void removeOuterTriangles(int isRemoveOuter)
{
m_isRemoveOuter = (isRemoveOuter != 0);
Expand Down Expand Up @@ -220,24 +234,25 @@ public slots:
m_cdt.insertEdges(edges);
}

if(m_isRemoveOuterAndHoles)
if(m_isDoRuppert)
{
m_cdt.refineTriangles(
1000,
m_refinementLimit,
CDT::RefinementCriterion::SmallestAngle,
20 / 180.0 * M_PI);
}

if(m_isRemoveOuterAndHoles)
{
m_cdt.eraseOuterTrianglesAndHoles();
}
else if(m_isRemoveOuter)
m_cdt.eraseOuterTriangles();
else if(m_isHideSuperTri)
{
m_cdt.refineTriangles(
1000,
CDT::RefinementCriterion::SmallestAngle,
20 / 180.0 * M_PI);
m_cdt.eraseSuperTriangle();
}

const CDT::unordered_map<Edge, CDT::EdgeVec> tmp =
CDT::EdgeToPiecesMapping(m_cdt.pieceToOriginals);
const CDT::unordered_map<Edge, std::vector<CDT::VertInd> >
Expand Down Expand Up @@ -468,9 +483,11 @@ public slots:
std::vector<Edge> m_edges;
std::size_t m_ptLimit;
std::size_t m_edgeLimit;
std::size_t m_refinementLimit;
bool m_isConformToEdges;
bool m_isHidePoints;
bool m_isHideSuperTri;
bool m_isDoRuppert;
bool m_isRemoveOuter;
bool m_isRemoveOuterAndHoles;
bool m_isDisplayIndices;
Expand Down Expand Up @@ -507,6 +524,8 @@ class MainWindow : public QWidget
m_cdtWidget,
SLOT(setPointsLimit(int)));
ptsSpinbox->setValue(999999);
QFormLayout* ptsLayout = new QFormLayout;
ptsLayout->addRow(new QLabel(tr("# points:")), ptsSpinbox);

QSpinBox* edgesSpinbox = new QSpinBox;
edgesSpinbox->setRange(0, 999999);
Expand All @@ -516,6 +535,20 @@ class MainWindow : public QWidget
m_cdtWidget,
SLOT(setEdgeLimit(int)));
edgesSpinbox->setValue(999999);
QFormLayout* edgesLayout = new QFormLayout;
edgesLayout->addRow(new QLabel(tr("# edges:")), edgesSpinbox);

QSpinBox* refinementSpinbox = new QSpinBox;
refinementSpinbox->setRange(0, 999999);
connect(
refinementSpinbox,
SIGNAL(valueChanged(int)),
m_cdtWidget,
SLOT(setRefinementLimit(int)));
refinementSpinbox->setValue(999999);
QFormLayout* refinementLayout = new QFormLayout;
edgesLayout->addRow(
new QLabel(tr("# refinement points:")), refinementSpinbox);

QCheckBox* displayIndices =
new QCheckBox(QStringLiteral("Display point/triangle indices"));
Expand Down Expand Up @@ -576,6 +609,16 @@ class MainWindow : public QWidget
m_cdtWidget->removeOuterTrianglesAndHoles(0);
removeOuterHoles->setChecked(false);

QCheckBox* doRuppert =
new QCheckBox(QStringLiteral("Ruppert refinement"));
connect(
doRuppert,
SIGNAL(stateChanged(int)),
m_cdtWidget,
SLOT(doRuppertRefinement(int)));
m_cdtWidget->hideSuperTriangle(0);
hideSuperTri->setChecked(false);

QPushButton* screenshotBtn = new QPushButton(tr("Make Screenshot"));
connect(screenshotBtn, SIGNAL(clicked()), m_cdtWidget, SLOT(prtScn()));
screenshotBtn->setMinimumHeight(50);
Expand All @@ -587,14 +630,16 @@ class MainWindow : public QWidget
QGridLayout* rightLayout = new QGridLayout;
int cntr = 0;
rightLayout->addWidget(filesList, cntr++, 0);
rightLayout->addWidget(ptsSpinbox, cntr++, 0);
rightLayout->addWidget(edgesSpinbox, cntr++, 0);
rightLayout->addLayout(ptsLayout, cntr++, 0);
rightLayout->addLayout(edgesLayout, cntr++, 0);
rightLayout->addLayout(refinementLayout, cntr++, 0);
rightLayout->addWidget(displayIndices, cntr++, 0);
rightLayout->addWidget(conformToEdges, cntr++, 0);
rightLayout->addWidget(hidePoints, cntr++, 0);
rightLayout->addWidget(removeOuter, cntr++, 0);
rightLayout->addWidget(removeOuterHoles, cntr++, 0);
rightLayout->addWidget(hideSuperTri, cntr++, 0);
rightLayout->addWidget(doRuppert, cntr++, 0);
rightLayout->addWidget(screenshotBtn, cntr++, 0);
rightLayout->addWidget(saveBtn, cntr++, 0);

Expand Down

0 comments on commit a51fee4

Please sign in to comment.