fw4spl
SrcLib/core/fwData/src/fwData/TransformationMatrix3D.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
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 "fwData/registry/macros.hpp"
8 #include "fwData/Exception.hpp"
9 #include "fwData/TransformationMatrix3D.hpp"
10 
11 fwDataRegisterMacro( ::fwData::TransformationMatrix3D );
12 
13 namespace fwData
14 {
15 
16 //------------------------------------------------------------------------------
17 
19 {
20  //default initialization
21  m_vCoefficients.fill(0.);
22  for(size_t t = 0; t < MATRIX_SIZE; ++t)
23  {
24  m_vCoefficients[t*MATRIX_SIZE + t] = 1.;
25  }
26 }
27 
28 //------------------------------------------------------------------------------
29 
31 {
32 }
33 
34 //-----------------------------------------------------------------------------
35 
36 void TransformationMatrix3D::shallowCopy(const Object::csptr &_source )
37 {
38  TransformationMatrix3D::csptr other = TransformationMatrix3D::dynamicConstCast(_source);
39  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
40  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
41  + " to " + this->getClassname()), !bool(other) );
42  this->fieldShallowCopy( _source );
43  m_vCoefficients = other->m_vCoefficients;
44 }
45 
46 //-----------------------------------------------------------------------------
47 
48 void TransformationMatrix3D::cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache)
49 {
50  TransformationMatrix3D::csptr other = TransformationMatrix3D::dynamicConstCast(_source);
51  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
52  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
53  + " to " + this->getClassname()), !bool(other) );
54  this->fieldDeepCopy( _source, cache );
55  m_vCoefficients = other->m_vCoefficients;
56 }
57 
58 //------------------------------------------------------------------------------
59 
60 } // namespace fwData
FWDATA_API TransformationMatrix3D(::fwData::Object::Key key)
Constructor.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Implements data exception class.
virtual const std::string & getClassname() const override
return full object&#39;s classname with its namespace, i.e. fwCore::BaseObject
FWDATA_API void cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) override
Defines deep copy.
static const size_t MATRIX_SIZE
maximum size of the matrix (MATRIX_SIZE x MATRIX_SIZE)
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
This class represents a 3D transformation matrix (4x4).
Contains the representation of the data objects used in the framework.
FWDATA_API void fieldShallowCopy(const ::fwData::Object::csptr &source)
A shallow copy of fields (objects in m_children)
TMCoefArray m_vCoefficients
Matrix coefficient number (4x4). m_vCoefficients[0] to m_vCoefficients[3] is the first row of the mat...
FWDATA_API void shallowCopy(const Object::csptr &_source) override
Defines shallow copy.