From 4a5d4517e48bf9a17c464d8384bd1cdd0397738c Mon Sep 17 00:00:00 2001 From: tbaudier Date: Fri, 26 Feb 2016 13:51:49 +0100 Subject: [PATCH] Avoid crash with non-orthogonal matrices --- vv/vvToolRigidReg.cxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/vv/vvToolRigidReg.cxx b/vv/vvToolRigidReg.cxx index e050426..d2c889c 100644 --- a/vv/vvToolRigidReg.cxx +++ b/vv/vvToolRigidReg.cxx @@ -378,7 +378,17 @@ void vvToolRigidReg::SetTransform(vtkMatrix4x4 *matrix) itk::Euler3DTransform::Pointer euler; euler = itk::Euler3DTransform::New(); euler->SetCenter(center); - euler->SetMatrix(rotMat); + try { + euler->SetMatrix(rotMat); + } catch (itk::ExceptionObject) { + QString warning = "The matrice is a non-orthogonal rotation matrix.\nThe manual registration doesn't work."; + QMessageBox msgBox(QMessageBox::Warning, tr("Reset transform"),warning, 0, this); + msgBox.addButton(tr("OK"), QMessageBox::AcceptRole); + if (msgBox.exec() == QMessageBox::AcceptRole) { + //SetTransform(mInitialMatrix); + vvToolWidgetBase::close(); + } + } euler->SetOffset(transVec); // Modify GUI according to the new parameters -- 2.47.1