diff --git a/Plugins/org.mitk.gui.qt.remeshing/documentation/UserManual/QmitkRemeshing.dox b/Plugins/org.mitk.gui.qt.remeshing/documentation/UserManual/QmitkRemeshing.dox index 32ba21171f..c39a3e378e 100644 --- a/Plugins/org.mitk.gui.qt.remeshing/documentation/UserManual/QmitkRemeshing.dox +++ b/Plugins/org.mitk.gui.qt.remeshing/documentation/UserManual/QmitkRemeshing.dox @@ -1,19 +1,25 @@ /** \page org_mitk_views_remeshing The Remeshing View \imageMacro{RemeshingIcon.png,"Icon of the Remeshing Plugin.",2.00} \tableofcontents -\section org_mitk_views_remeshingOverview Overview +\section org_mitk_views_remeshingDecimate Decimate surfaces -The Remeshing View allows you to remesh surfaces. -If done right, remeshing can dramatically increase the quality of your surface mesh. -However, you might lose precision if you reduce the vertex density of your surface mesh too strong. -Even when you preserve the detail of your mesh, there might be a tiny distance between your original surface and the remeshed surface. -Hence, be careful when using remeshed surfaces for evaluation purposes and always keep the original versions. +Decimating surfaces effectively reduces their number of vertices and hence their number of polygons. +In other words, decimating surfaces coarsens their meshes. -\section org_mitk_views_remeshingUsage Usage +Vertices are successively eliminated until the desired relative number of vertices remain. +During this process, the decimation algorithm tries to keep the spatial difference between original meshes and decimated meshes to a minimum. -The Remeshing View provides details on its parameters in its user interface. When in doubt, start with the default parameters and iterate to your desired result by reducing the density parameter. +A surface may consist of multiple meshes in different time steps. +The decimation is applied to all time steps. + +Before the actual decimation, meshes are triangulated, i. e., polygons with more than three edges like quadrilaterals are converted to triangles. +Lines and points are ignored. +Resulting meshes are guaranteed to consist of triangles only. + +Vertex normals can be optionally (re-)calculated for decimated meshes. +To decide if you should flip normals, enable the Backface Culling property of the decimated surface in the Properties View - otherwise it is impossible to tell, as by default, both sides of polygons are shaded in MITK. */ diff --git a/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.cpp b/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.cpp index 9ed0a2ef58..aef064d831 100644 --- a/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.cpp +++ b/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.cpp @@ -1,123 +1,123 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "QmitkRemeshingView.h" #include #include #include #include #include #include #include #include const std::string QmitkRemeshingView::VIEW_ID = "org.mitk.views.remeshing"; QmitkRemeshingView::QmitkRemeshingView() : m_Controls(new Ui::QmitkRemeshingViewControls) { } QmitkRemeshingView::~QmitkRemeshingView() { } void QmitkRemeshingView::CreateQtPartControl(QWidget* parent) { m_Controls->setupUi(parent); m_Controls->decimatePushButton->setIcon(berry::QtStyleManager::ThemeIcon(QStringLiteral(":/Remeshing/RemeshingIcon.svg"))); m_Controls->selectionWidget->SetDataStorage(this->GetDataStorage()); m_Controls->selectionWidget->SetSelectionIsOptional(true); m_Controls->selectionWidget->SetEmptyInfo(QStringLiteral("Select a surface")); m_Controls->selectionWidget->SetAutoSelectNewNodes(true); m_Controls->selectionWidget->SetNodePredicate(mitk::NodePredicateAnd::New( mitk::TNodePredicateDataType::New(), mitk::NodePredicateNot::New(mitk::NodePredicateOr::New( mitk::NodePredicateProperty::New("helper object"), mitk::NodePredicateProperty::New("hidden object"))))); connect(m_Controls->selectionWidget, &QmitkSingleNodeSelectionWidget::CurrentSelectionChanged, this, &QmitkRemeshingView::OnSurfaceChanged); - connect(m_Controls->polygonCountSlider, SIGNAL(valueChanged(int)), this, SLOT(OnPolygonCountChanged(int))); - connect(m_Controls->polygonCountSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnPolygonCountChanged(int))); + connect(m_Controls->vertexCountSlider, SIGNAL(valueChanged(int)), this, SLOT(OnVertexCountChanged(int))); + connect(m_Controls->vertexCountSpinBox, SIGNAL(valueChanged(int)), this, SLOT(OnVertexCountChanged(int))); connect(m_Controls->calculateNormalsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnCalculateNormalsChanged(int))); connect(m_Controls->decimatePushButton, SIGNAL(clicked()), this, SLOT(OnDecimateButtonClicked())); this->OnSurfaceChanged(m_Controls->selectionWidget->GetSelectedNodes()); } void QmitkRemeshingView::OnSurfaceChanged(const QmitkSingleNodeSelectionWidget::NodeList& nodes) { this->EnableWidgets(!nodes.empty() && nodes.front().IsNotNull()); } -void QmitkRemeshingView::OnPolygonCountChanged(int polygonCount) +void QmitkRemeshingView::OnVertexCountChanged(int vertexCount) { - if (polygonCount != m_Controls->polygonCountSlider->value()) - m_Controls->polygonCountSlider->setValue(polygonCount); + if (vertexCount != m_Controls->vertexCountSlider->value()) + m_Controls->vertexCountSlider->setValue(vertexCount); - if (polygonCount != m_Controls->polygonCountSpinBox->value()) - m_Controls->polygonCountSpinBox->setValue(polygonCount); + if (vertexCount != m_Controls->vertexCountSpinBox->value()) + m_Controls->vertexCountSpinBox->setValue(vertexCount); } void QmitkRemeshingView::OnCalculateNormalsChanged(int checkState) { m_Controls->flipNormalsCheckBox->setEnabled(Qt::Unchecked != checkState); } void QmitkRemeshingView::OnDecimateButtonClicked() { mitk::DataNode::Pointer selectedNode = m_Controls->selectionWidget->GetSelectedNode(); mitk::Surface::ConstPointer input = static_cast(selectedNode->GetData()); mitk::Surface::Pointer output; try { output = mitk::Remeshing::Decimate(input, - 0.01 * m_Controls->polygonCountSpinBox->value(), + 0.01 * m_Controls->vertexCountSpinBox->value(), m_Controls->calculateNormalsCheckBox->isChecked(), m_Controls->flipNormalsCheckBox->isChecked()); } catch(const mitk::Exception& exception) { MITK_ERROR << exception.GetDescription(); return; } if (output.IsNull()) return; auto newNode = mitk::DataNode::New(); newNode->SetName(QString("%1 (decimated)").arg(selectedNode->GetName().c_str()).toStdString()); newNode->SetData(output); this->GetDataStorage()->Add(newNode, selectedNode); } void QmitkRemeshingView::EnableWidgets(bool enable) { - m_Controls->polygonCountSlider->setEnabled(enable); - m_Controls->polygonCountSpinBox->setEnabled(enable); + m_Controls->vertexCountSlider->setEnabled(enable); + m_Controls->vertexCountSpinBox->setEnabled(enable); m_Controls->calculateNormalsCheckBox->setEnabled(enable); m_Controls->flipNormalsCheckBox->setEnabled(enable && m_Controls->calculateNormalsCheckBox->isChecked()); m_Controls->decimatePushButton->setEnabled(enable); } void QmitkRemeshingView::SetFocus() { m_Controls->selectionWidget->setFocus(); } diff --git a/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.h b/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.h index 679f1679ec..e0f5b99b83 100644 --- a/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.h +++ b/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingView.h @@ -1,49 +1,49 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef QmitkRemeshingView_h #define QmitkRemeshingView_h #include #include namespace Ui { class QmitkRemeshingViewControls; } class QmitkRemeshingView : public QmitkAbstractView { Q_OBJECT public: static const std::string VIEW_ID; QmitkRemeshingView(); ~QmitkRemeshingView() override; void CreateQtPartControl(QWidget* parent) override; void SetFocus() override; private slots: void OnSurfaceChanged(const QmitkSingleNodeSelectionWidget::NodeList& nodes); - void OnPolygonCountChanged(int polygonCount); + void OnVertexCountChanged(int vertexCount); void OnCalculateNormalsChanged(int checkState); void OnDecimateButtonClicked(); private: void EnableWidgets(bool enable); Ui::QmitkRemeshingViewControls* m_Controls; }; #endif diff --git a/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingViewControls.ui b/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingViewControls.ui index d06d2ff7fc..78a31dde92 100644 --- a/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingViewControls.ui +++ b/Plugins/org.mitk.gui.qt.remeshing/src/internal/QmitkRemeshingViewControls.ui @@ -1,172 +1,172 @@ QmitkRemeshingViewControls true 0 0 253 573 Remeshing 0 0 Surface Flip normals - + 0 0 - Polygon count + Vertex count - + 0 0 1 100 10 50 Qt::Horizontal 0 40 - + % 1 100 1 50 Calculate normals true true Decimate :/Remeshing/RemeshingIcon.svg:/Remeshing/RemeshingIcon.svg 24 24 Qt::Vertical 20 40 QmitkSingleNodeSelectionWidget QWidget
QmitkSingleNodeSelectionWidget.h
1
- polygonCountSpinBox + vertexCountSpinBox decimatePushButton