clitkExceptionObject.cxx
clitkFilterBase.cxx
clitkMemoryUsage.cxx
+ clitkMatrix.cxx
vvImage.cxx
vvImageReader.cxx
vvImageWriter.cxx
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+
+#include "clitkMatrix.h"
+
+//--------------------------------------------------------------------
+namespace clitk {
+
+//-------------------------------------------------------------------
+std::string
+Get4x4MatrixDoubleAsString(vtkMatrix4x4 *matrix,
+ const int precision)
+{
+ std::ostringstream strmatrix;
+
+ // Figure out the number of digits of the integer part of the largest absolute value
+ // for each column
+ unsigned width[4];
+ for (unsigned int j = 0; j < 4; j++){
+ double absmax = 0.;
+ for (unsigned int i = 0; i < 4; i++)
+ absmax = std::max(absmax, vnl_math_abs(matrix->GetElement(i, j)));
+ unsigned ndigits = (unsigned)std::max(0.,std::log10(absmax))+1;
+ width[j] = precision+ndigits+3;
+ }
+
+ // Output with correct width, aligned to the right
+ for (unsigned int i = 0; i < 4; i++) {
+ for (unsigned int j = 0; j < 4; j++) {
+ strmatrix.setf(ios::fixed,ios::floatfield);
+ strmatrix.precision(precision);
+ strmatrix.fill(' ');
+ strmatrix.width(width[j]);
+ strmatrix << std::right << matrix->GetElement(i, j);
+ }
+ strmatrix << std::endl;
+ }
+ std::string result = strmatrix.str().c_str();
+ return result;
+}
+//-------------------------------------------------------------------
+
+//-------------------------------------------------------------------
+std::string
+Get4x4MatrixDoubleAsString(itk::Matrix<double, 4, 4> m,
+ const int precision)
+{
+ vtkSmartPointer<vtkMatrix4x4> matrix = vtkSmartPointer<vtkMatrix4x4>::New();
+ for (unsigned int j = 0; j < 4; j++)
+ for (unsigned int i = 0; i < 4; i++)
+ matrix->SetElement(j,i,m[j][i]);
+ return Get4x4MatrixDoubleAsString(matrix, precision);
+}
+//-------------------------------------------------------------------
+}
+//-------------------------------------------------------------------
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+
+#ifndef clitkMatrix_h
+#define clitkMatrix_h
+
+#include <itkMatrix.h>
+#include <vtkMatrix4x4.h>
+#include <vtkSmartPointer.h>
+
+//--------------------------------------------------------------------
+namespace clitk {
+std::string
+Get4x4MatrixDoubleAsString(vtkMatrix4x4 *matrix,
+ const int precision=3);
+
+std::string
+Get4x4MatrixDoubleAsString(itk::Matrix<double, 4, 4> m,
+ const int precision=3);
+}
+//-------------------------------------------------------------------
+
+#endif
#include "clitkElastixTransformToMatrix_ggo.h"
#include "clitkAffineTransformGenericFilter.h"
#include "clitkElastix.h"
+#include "clitkMatrix.h"
//--------------------------------------------------------------------
int main(int argc, char * argv[])
// Print matrix
std::ofstream os;
clitk::openFileForWriting(os, args_info.output_arg);
- for(unsigned int i=0; i<4; i++) {
- for(unsigned int j=0; j<4; j++)
- os << m[i][j] << " ";
- os << std::endl;
- }
- os.close();
+ os << clitk::Get4x4MatrixDoubleAsString(m, 16);
+ os.close();
return EXIT_SUCCESS;
}// end main
#include "vvSaveState.h"
#include "vvReadState.h"
#include "clitkConfiguration.h"
+#include "clitkMatrix.h"
// ITK include
#include <itkImage.h>
infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
transformation = imageSelected->GetTransform()[tSlice]->GetMatrix();
- infoPanel->setTransformation(Get4x4MatrixDoubleAsString(transformation));
+ infoPanel->setTransformation(clitk::Get4x4MatrixDoubleAsString(transformation).c_str());
landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
mSlicerManagers[index]->GetTSlice());
}
//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-QString vvMainWindow::Get4x4MatrixDoubleAsString(vtkSmartPointer<vtkMatrix4x4> matrix, const int precision)
-{
- std::ostringstream strmatrix;
-
- // Figure out the number of digits of the integer part of the largest absolute value
- // for each column
- unsigned width[4];
- for (unsigned int j = 0; j < 4; j++){
- double absmax = 0.;
- for (unsigned int i = 0; i < 4; i++)
- absmax = std::max(absmax, vnl_math_abs(matrix->GetElement(i, j)));
- unsigned ndigits = (unsigned)std::max(0.,std::log10(absmax))+1;
- width[j] = precision+ndigits+3;
- }
-
- // Output with correct width, aligned to the right
- for (unsigned int i = 0; i < 4; i++) {
- for (unsigned int j = 0; j < 4; j++) {
- strmatrix.setf(ios::fixed,ios::floatfield);
- strmatrix.precision(precision);
- strmatrix.fill(' ');
- strmatrix.width(width[j]);
- strmatrix << std::right << matrix->GetElement(i, j);
- }
- strmatrix << std::endl;
- }
- QString result = strmatrix.str().c_str();
- return result;
-}
-//------------------------------------------------------------------------------
-
//------------------------------------------------------------------------------
QString vvMainWindow::GetVectorDoubleAsString(std::vector<double> vectorDouble)
{
void SaveCurrentStateAs(const std::string& stateFile);
void ReadSavedStateFile(const std::string& stateFile);
void LinkAllImages();
- QString Get4x4MatrixDoubleAsString(vtkSmartPointer<vtkMatrix4x4> matrix, const int precision=3);
virtual void UpdateCurrentSlicer();
virtual QTabWidget * GetTab();
// clitk
#include "clitkTransformUtilities.h"
+#include "clitkMatrix.h"
// qt
#include <QMessageBox>
for(int i=0; i<4; i++)
// TODO SR and BP: check on the list of transforms and not the first only
mInitialMatrix->SetElement(i,j, mCurrentSlicerManager->GetImage()->GetTransform()[0]->GetMatrix()->GetElement(i,j));
- QString origTransformString = dynamic_cast<vvMainWindow*>(mMainWindow)->Get4x4MatrixDoubleAsString(mInitialMatrix);
+ QString origTransformString(clitk::Get4x4MatrixDoubleAsString(mInitialMatrix).c_str());
transformationLabel->setText(origTransformString);
SetTransform(mInitialMatrix);
if (file.open(QFile::WriteOnly | QFile::Truncate)) {
// TODO SR and BP: check on the list of transforms and not the first only
vtkMatrix4x4* matrix = mCurrentSlicerManager->GetImage()->GetTransform()[0]->GetMatrix();
- QString matrixStr = dynamic_cast<vvMainWindow*>(mMainWindow)->Get4x4MatrixDoubleAsString(matrix,16);
+ QString matrixStr = clitk::Get4x4MatrixDoubleAsString(matrix,16).c_str();
QTextStream out(&file);
out << matrixStr;
}