fw4spl
src/fwData/Reconstruction.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 
8 #include "fwData/Exception.hpp"
9 #include "fwData/Image.hpp"
10 #include "fwData/Material.hpp"
11 #include "fwData/Mesh.hpp"
12 #include "fwData/Reconstruction.hpp"
13 #include "fwData/registry/macros.hpp"
14 
15 #include <fwCom/Signal.hpp>
16 #include <fwCom/Signal.hxx>
17 #include <fwCom/Signals.hpp>
18 
19 #include <fwCore/base.hpp>
20 
21 fwDataRegisterMacro( ::fwData::Reconstruction );
22 namespace fwData
23 {
24 
26 
27 const ::fwCom::Signals::SignalKeyType Reconstruction::s_MESH_CHANGED_SIG = "meshModified";
28 const ::fwCom::Signals::SignalKeyType Reconstruction::s_VISIBILITY_MODIFIED_SIG = "visibilityModified";
29 
30 //------------------------------------------------------------------------------
31 
33  m_bIsVisible(false),
34  m_sOrganName(""),
35  m_sStructureType(""),
36  m_material( ::fwData::factory::New< ::fwData::Material>() ),
37  m_computedMaskVolume(Reconstruction::s_NO_COMPUTED_MASK_VOLUME)
38 {
39  m_sigMeshChanged = MeshChangedSignalType::New();
40  m_sigVisibilityModified = VisibilityModifiedSignalType::New();
43 }
44 
45 //------------------------------------------------------------------------------
46 
48 {
50 }
51 
52 //------------------------------------------------------------------------------
53 
54 void Reconstruction::shallowCopy(const Object::csptr &_source )
55 {
56  Reconstruction::csptr other = Reconstruction::dynamicConstCast(_source);
57  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
58  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
59  + " to " + this->getClassname()), !bool(other) );
60  this->fieldShallowCopy( _source );
61 
62  m_bIsVisible = other->m_bIsVisible;
63  m_sOrganName = other->m_sOrganName;
64  m_sStructureType = other->m_sStructureType;
65 
66  m_material = other->m_material;
67  m_image = other->m_image;
68  m_mesh = other->m_mesh;
69 
70  m_computedMaskVolume = other->m_computedMaskVolume;
71 }
72 
73 //------------------------------------------------------------------------------
74 
75 void Reconstruction::cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache)
76 {
77  Reconstruction::csptr other = Reconstruction::dynamicConstCast(_source);
78  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
79  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
80  + " to " + this->getClassname()), !bool(other) );
81  this->fieldDeepCopy( _source, cache );
82 
83  m_bIsVisible = other->m_bIsVisible;
84  m_sOrganName = other->m_sOrganName;
85  m_sStructureType = other->m_sStructureType;
86 
87  m_material = ::fwData::Object::copy(other->m_material, cache);
88  m_image = ::fwData::Object::copy(other->m_image, cache);
89  m_mesh = ::fwData::Object::copy(other->m_mesh, cache);
90 
91  m_computedMaskVolume = other->m_computedMaskVolume;
92 }
93 
94 //------------------------------------------------------------------------------
95 
96 } // end namespace fwData
This class defines a reconstruction object.
bool m_bIsVisible
true if this reconstruction is visible
MeshChangedSignalType::sptr m_sigMeshChanged
Signal emitted when mesh changed, mesh parameter is used to store old mesh.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Definition: spyLog.hpp:329
This class defines a material. A material is represented by an ambient color and a diffuse color...
VisibilityModifiedSignalType::sptr m_sigVisibilityModified
Signal emitted when visibility is modified.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Implements data exception class.
Contains fwAtomsFilter::factory utilities.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_MESH_CHANGED_SIG
Key in m_signals map of signal m_sigMeshModified.
virtual const std::string & getClassname() const override
return full object&#39;s classname with its namespace, i.e. fwCore::BaseObject
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
FWDATA_API void cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) override
Defines deep copy.
static FWDATA_API const double s_NO_COMPUTED_MASK_VOLUME
Constant to inform that mask volume has not been computed yet.
static FWDATA_API::fwData::Object::sptr copy(const ::fwData::Object::csptr &source)
return a copy of the source. if source is a null pointer, return a null pointer.
double m_computedMaskVolume
Reconstruction&#39;s mask volume.
FWDATA_API void shallowCopy(const Object::csptr &_source) override
Defines shallow copy.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_VISIBILITY_MODIFIED_SIG
Key in m_signals map of signal m_sigVisibilityModified.
virtual FWDATA_API ~Reconstruction()
Destructor.
std::shared_ptr< ::fwData::Image > m_image
Reconstruction&#39;s mask.
std::shared_ptr< ::fwData::Mesh > m_mesh
Reconstruction&#39;s mesh.
std::string m_sStructureType
Structure type.
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)
std::shared_ptr< ::fwData::Material > m_material
Reconstruction&#39;s material.
FWDATA_API Reconstruction(::fwData::Object::Key key)
Constructor.