diff --git a/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.cpp b/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.cpp index 48a8252420..8ccbd53a2f 100644 --- a/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.cpp +++ b/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.cpp @@ -1,193 +1,196 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "QmitkSurfaceRegistration.h" #include #include #include #include #include #include #include // Includes for image casting between ITK and MITK: added after using Plugin Generator #include // added for surface dynamic cast #include #include #include #include #include #include #include #include +#include const std::string QmitkSurfaceRegistration::VIEW_ID = "org.mitk.views.qmitksurfaceregistration"; QmitkSurfaceRegistration::QmitkSurfaceRegistration(QObject *parent) : m_ParentWidget(0), m_movingSurfaceNode(nullptr), m_targetSurfaceNode(nullptr) { } QmitkSurfaceRegistration::~QmitkSurfaceRegistration() { // delete pointer objects m_movingSurfaceNode = nullptr; m_targetSurfaceNode = nullptr; } // void QmitkSurfaceRegistration::SetFocus(){ m_Controls.groupBoxMoving->setFocus(); } void QmitkSurfaceRegistration::CreateQtPartControl(QWidget *parent) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi(parent); connect(m_Controls.pushButtonExecute, SIGNAL(clicked()), this, SLOT(doExecute())); - connect(m_Controls.radioButtonMirroring, SIGNAL(clicked()), this, SLOT(doMirroring())); m_ParentWidget = parent; } void QmitkSurfaceRegistration::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*part*/, const QList &nodes) { MITK_INFO << "On Selection Changed"; bool rotationEnabled = false; if (nodes.empty()) { MITK_INFO << "Nothing selected yet"; m_Controls.labelSelectMovingSurface->setStyleSheet(" QLabel { color: rgb(255, 0, 0) }"); m_Controls.labelSelectTargetSurface->setStyleSheet(" QLabel { color: rgb(255, 0, 0) }"); m_Controls.labelMovingSurfaceName->setText(QString::fromStdString("No moving surface selected")); m_Controls.labelTargetSurfaceName->setText(QString::fromStdString("No target surface selected")); m_Controls.groupBoxMoving->setEnabled(true); m_Controls.groupBoxMappedData->setEnabled(false); if (m_useTestConfig) { m_Controls.pushButtonExecute->setEnabled(true); } else{ m_Controls.pushButtonExecute->setEnabled(false); } m_Controls.radioButtonMirroring->setEnabled(false); return; } else { if (nodes.size() == 1) { if (nodes[0].IsNotNull() && dynamic_cast(nodes[0]->GetData())) { MITK_INFO << "There is exactly one image selected"; m_movingSurfaceNode = nodes[0]; m_Controls.labelSelectMovingSurface->setText("Selected moving surface:"); m_Controls.labelSelectMovingSurface->setStyleSheet(" QLabel { color: rgb(0, 0, 0) }"); m_Controls.labelMovingSurfaceName->setText( QString::fromStdString("File name: " + m_movingSurfaceNode->GetName())); m_Controls.radioButtonMirroring->setEnabled(true); m_Controls.groupBoxTarget->setEnabled(true); m_Controls.groupBoxMappedData->setEnabled(true); m_Controls.groupBoxTarget->setEnabled(true); } else { QMessageBox::information(nullptr, "Warning", "Are you sure? - I dont think this is a Surface! Try again!"); } } else if (nodes.size() == 2) { if (nodes[1].IsNotNull() && dynamic_cast(nodes[1]->GetData())) { MITK_INFO << "There are two images selected"; m_targetSurfaceNode = nodes[1]; m_Controls.labelSelectTargetSurface->setText("Selected target surface:"); m_Controls.labelSelectTargetSurface->setStyleSheet(" QLabel { color: rgb(0, 0, 0) }"); m_Controls.labelTargetSurfaceName->setText( QString::fromStdString("File name: " + m_targetSurfaceNode->GetName())); m_Controls.textMappedDataName->setEnabled(true); m_Controls.pushButtonExecute->setEnabled(true); } else { QMessageBox::information(nullptr, "Warning", "Are you sure? - I dont think this is a Surface!"); } } else { QMessageBox::information(nullptr, "Warning", "You do know that it only works with two surfaces, right? If you continue to click execute, this might crash one day!"); //wie kann ich die Auswahl zurueck setzen? } } } void QmitkSurfaceRegistration::doExecute() { - if (m_useTestConfig){ + if (m_useTestConfig) + { mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New(); mitk::IOUtil::Load("//ad/fs/E130-Projekte/BGLU/Fibula/Python/DataGAN/Registered/Surface/Tibia/tibia01_q0.stl", *ds); mitk::IOUtil::Load("//ad/fs/E130-Projekte/BGLU/Fibula/Python/DataGAN/Registered/Surface/Tibia/tibia02_q0.stl", *ds); m_movingSurfaceNode = ds->GetAll()->at(0); m_targetSurfaceNode = ds->GetAll()->at(1); this->GetDataStorageReference()->GetDataStorage()->Add(mitk::DataNode::Pointer(ds->GetAll()->at(0))); this->GetDataStorageReference()->GetDataStorage()->Add(mitk::DataNode::Pointer(ds->GetAll()->at(1))); m_Controls.pushButtonExecute->setEnabled(true); m_Controls.labelMovingSurfaceName->setText("tibia01_q0"); m_Controls.labelTargetSurfaceName->setText("tibia02_q0"); m_Controls.labelSelectMovingSurface->setText("Selected moving surface:"); m_Controls.labelSelectMovingSurface->setStyleSheet(" QLabel { color: rgb(0, 0, 0) }"); m_Controls.labelSelectTargetSurface->setText("Selected target surface:"); m_Controls.labelSelectTargetSurface->setStyleSheet(" QLabel { color: rgb(0, 0, 0) }"); - } MITK_INFO << "pushButtonExecute clicked"; /*mitk::Surface *movingSurface = dynamic_cast(m_movingSurfaceNode); mitk::Surface *targetSurface = dynamic_cast(m_targetSurfaceNode);*/ /*auto manager = MitkShapeComparisonManager::New(); manager->SetInput(0, dynamic_cast(m_movingSurfaceNode->GetData())); manager->SetInput(1, dynamic_cast(m_targetSurfaceNode->GetData()));*/ + performICPRegistration(); + +} +void QmitkSurfaceRegistration::performICPRegistration() +{ - /* vtkSmartPointer icp = vtkSmartPointer::New(); + vtkSmartPointer icp = vtkSmartPointer::New(); icp->SetCheckMeanDistance(1); - mitk::Surface::Pointer movingSurface = dynamic_cast (m_movingSurfaceNode); - + mitk::Surface::Pointer movingSurface = dynamic_cast (m_movingSurfaceNode.GetPointer());//null + mitk::Surface::Pointer targetSurface = dynamic_cast (m_targetSurfaceNode.GetPointer());//null icp->SetSource(movingSurface->GetVtkPolyData()); - icp->SetTarget(m_targetSurfaceNode->GetVtkPolyData()); + icp->SetTarget(targetSurface->GetVtkPolyData()); icp->SetMaximumNumberOfIterations(500); icp->SetMaximumMeanDistance(0.01); icp->SetMeanDistanceModeToRMS(); icp->StartByMatchingCentroidsOn(); icp->SetMaximumNumberOfLandmarks(100000); vtkSmartPointer transform = vtkSmartPointer::New(); transform = icp->GetLandmarkTransform(); -*/ - - + MITK_INFO << "registration done"; } \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.h b/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.h index f7c9c55068..9eafc89124 100644 --- a/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.h +++ b/Plugins/org.mitk.gui.qt.surfaceregistration/src/internal/QmitkSurfaceRegistration.h @@ -1,103 +1,105 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef QmitkSurfaceRegistration_h #define QmitkSurfaceRegistration_h #include #ifdef WIN32 #pragma warning( disable : 4250 ) #endif #include "QVTKWidget.h" #include "QmitkRegisterClasses.h" #include #include "ui_SurfaceRegistrationControls.h" #include "usServiceRegistration.h" /*! @brief QmitkSurfaceRegistrationView \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkFunctionality \ingroup ${plugin_target}_internal */ class QmitkSurfaceRegistration : public QmitkAbstractView { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) private: Q_OBJECT public: /*! @brief Constructor. Called by SampleApp (or other apps that use functionalities) */ QmitkSurfaceRegistration(QObject *parent = 0); virtual ~QmitkSurfaceRegistration(); static const std::string VIEW_ID; virtual void CreateQtPartControl(QWidget *parent); virtual void SetFocus() override; ///*! //@brief Creates the Qt connections needed //*/ QWidget* GetControls(); /// @brief Called when the user clicks the GUI button protected slots: void doExecute(); protected: // /*! //@brief called by QmitkFunctionality when DataManager's selection has changed // */ void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, const QList& nodes) override; private: /*! * The parent QWidget */ QWidget* m_ParentWidget; /*! * @brief A pointer to the node of the moving surface. */ - mitk::DataNode *m_movingSurfaceNode; + mitk::DataNode::Pointer m_movingSurfaceNode; /*! * @brief A pointer to the node of the target surface. */ - mitk::DataNode *m_targetSurfaceNode; + mitk::DataNode::Pointer m_targetSurfaceNode; Ui::SurfaceRegistrationControls m_Controls; bool m_useTestConfig = true; + + void performICPRegistration(); }; #endif // QmitkSurfaceRegistration_h \ No newline at end of file