fw4spl
Transform.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "fwItkIO/helper/Transform.hpp"
8 
9 namespace fwItkIO
10 {
11 namespace helper
12 {
13 
14 //-----------------------------------------------------------------------------
15 
16 Transform::MatrixType Transform::convertToITK(const ::fwData::TransformationMatrix3D::csptr& _inTrf)
17 {
18  MatrixType itkMat;
19 
20  for(std::uint8_t i = 0; i < 4; ++i)
21  {
22  for(std::uint8_t j = 0; j < 4; ++j)
23  {
24  itkMat(i, j) = _inTrf->getCoefficient(i, j);
25  }
26  }
27 
28  return itkMat;
29 }
30 
31 //-----------------------------------------------------------------------------
32 
33 void Transform::convertFromITK(const MatrixType& _inTrf, ::fwData::TransformationMatrix3D::sptr& _outTrf)
34 {
35  SLM_ASSERT("Input itk Matrix should be 4x4", _inTrf.ColumnDimensions == 4 && _inTrf.RowDimensions == 4);
36 
37  for(std::uint8_t i = 0; i < 4; ++i)
38  {
39  for(std::uint8_t j = 0; j < 4; ++j)
40  {
41  _outTrf->setCoefficient(i, j, _inTrf(i, j));
42  }
43  }
44 }
45 
46 //-----------------------------------------------------------------------------
47 
48 }// namespace helper
49 }// namespace fwItkIO
static FWITKIO_API MatrixType convertToITK(const ::fwData::TransformationMatrix3D::csptr &_inTrf)
convert a F4S transformation to itk
Definition: Transform.cpp:16
#define SLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:308
static FWITKIO_API void convertFromITK(const MatrixType &_inTrf,::fwData::TransformationMatrix3D::sptr &_outTrf)
convert an itk::Transform<double, 4, 4> to a F4S one
Definition: Transform.cpp:33
The namespace fwItkIO contains reader, writer and helper for itk image.
::itk::Matrix< double, 4, 4 > MatrixType
Typedef to a itk Transform <double, 4,4>
Definition: Transform.hpp:27