fw4spl
Point.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/Point.hpp"
10 
11 #include <fwCore/base.hpp>
12 
13 fwDataRegisterMacro( ::fwData::Point );
14 
15 namespace fwData
16 {
17 
18 //------------------------------------------------------------------------------
19 
21 {
22  m_vCoord[0] = 0.0;
23  m_vCoord[1] = 0.0;
24  m_vCoord[2] = 0.0;
25 }
26 
27 //------------------------------------------------------------------------------
28 
29 Point::sptr Point::PointFactory(float x, float y, float z)
30 {
31  Point::sptr point = ::fwData::Point::New();
32  point->m_vCoord[0] = x;
33  point->m_vCoord[1] = y;
34  point->m_vCoord[2] = z;
35  return point;
36 }
37 
38 //------------------------------------------------------------------------------
39 
40 Point::sptr Point::PointFactory(double x, double y, double z)
41 {
42  Point::sptr point = ::fwData::Point::New();
43  point->m_vCoord[0] = x;
44  point->m_vCoord[1] = y;
45  point->m_vCoord[2] = z;
46  return point;
47 }
48 
49 //------------------------------------------------------------------------------
50 
51 Point::sptr Point::PointFactory(const PointCoordArrayType& coord)
52 {
53  Point::sptr point = ::fwData::Point::New();
54  point->m_vCoord = coord;
55  return point;
56 }
57 
58 //------------------------------------------------------------------------------
59 
60 Point::sptr Point::PointFactory( Point::sptr p )
61 {
62  Point::sptr point = ::fwData::Point::New();
63  point->m_vCoord[0] = p->m_vCoord[0];
64  point->m_vCoord[1] = p->m_vCoord[1];
65  point->m_vCoord[2] = p->m_vCoord[2];
66  return point;
67 }
68 
69 //------------------------------------------------------------------------------
70 
72 {
73 }
74 
75 //------------------------------------------------------------------------------
76 
77 void Point::shallowCopy(const Object::csptr &_source )
78 {
79  Point::csptr other = Point::dynamicConstCast(_source);
80  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
81  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
82  + " to " + this->getClassname()), !bool(other) );
83  this->fieldShallowCopy( _source );
84  m_vCoord = other->m_vCoord;
85 }
86 
87 //------------------------------------------------------------------------------
88 
89 void Point::cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache)
90 {
91  Point::csptr other = Point::dynamicConstCast(_source);
92  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
93  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
94  + " to " + this->getClassname()), !bool(other) );
95  this->fieldDeepCopy( _source, cache );
96  m_vCoord = other->m_vCoord;
97 }
98 
99 //------------------------------------------------------------------------------
100 
101 } // namespace fwData
102 
103 
FWDATA_API Point(::fwData::Object::Key key)
Constructor.
Definition: Point.cpp:20
FWDATA_API void shallowCopy(const Object::csptr &_source) override
Defines shallow copy.
Definition: Point.cpp:77
This class define a 3D point.
Definition: Point.hpp:22
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Implements data exception class.
static FWDATA_API Point::sptr PointFactory(float x, float y, float z)
Point factory.
Definition: Point.cpp:29
virtual FWDATA_API ~Point()
Destructor.
Definition: Point.cpp:71
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
virtual const std::string & getClassname() const override
return full object&#39;s classname with its namespace, i.e. fwCore::BaseObject
Definition: Point.hpp:36
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)
FWDATA_API void cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) override
Defines deep copy.
Definition: Point.cpp:89
PointCoordArrayType m_vCoord
point coordinates
Definition: Point.hpp:71