fw4spl
Reconstruction/V2ToV3.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 <fwAtoms/Numeric.hpp>
8 #include <fwAtoms/Numeric.hxx>
9 #include <fwAtoms/String.hpp>
10 
11 #include "fwStructuralPatch/fwData/Reconstruction/V2ToV3.hpp"
12 
13 namespace fwStructuralPatch
14 {
15 
16 namespace fwData
17 {
18 
19 namespace Reconstruction
20 {
21 
22 V2ToV3::V2ToV3() : ::fwAtomsPatch::IStructuralPatch()
23 {
24  m_originClassname = "::fwData::Reconstruction";
25  m_targetClassname = "::fwData::Reconstruction";
26  m_originVersion = "2";
27  m_targetVersion = "3";
28 
29 }
30 
31 // ----------------------------------------------------------------------------
32 
34 {
35 }
36 
37 // ----------------------------------------------------------------------------
38 
40 {
41 }
42 
43 // ----------------------------------------------------------------------------
44 
46  const ::fwAtoms::Object::sptr& previous,
47  const ::fwAtoms::Object::sptr& current,
48  ::fwAtomsPatch::IPatch::NewVersionsType& newVersions)
49 {
50  IStructuralPatch::apply(previous, current, newVersions);
51 
52  // Update object version
53  this->updateVersion(current);
54 
55  // Create helper
56  ::fwAtomsPatch::helper::Object helper(current);
57 
58  // Set to -1 to inform that no mask has been computed yet (::fwData::Reconstruction::s_NO_COMPUTED_MASK_VOLUME)
59  helper.addAttribute("volume", ::fwAtoms::Numeric::New<double>(-1.));
60 }
61 
62 } // namespace Reconstruction
63 
64 } // namespace fwData
65 
66 } // namespace fwStructuralPatch
67 
FWATOMSPATCH_API void updateVersion(std::shared_ptr< ::fwAtoms::Object > current)
Updates the version of the patched object.
Structural patch to convert a fwData::Reconstruction from version &#39;2&#39; to version &#39;3&#39;.
Contains base functionalities used to transform objects from a version to another.
Definition: Abstract.hpp:16
std::string m_targetClassname
Target type.
FWATOMSPATCH_API IStructuralPatch()
Constructor.
virtual FWSTRUCTURALPATCH_API void apply(const ::fwAtoms::Object::sptr &previous, const ::fwAtoms::Object::sptr &current,::fwAtomsPatch::IPatch::NewVersionsType &newVersions) override
Applies patch.
std::string m_originClassname
Origin classname of the object.
Definition: IPatch.hpp:64
Contains creators and structural patches.
Definition: Landmarks1.hpp:13
std::string m_originVersion
Origin version of the object.
Definition: IPatch.hpp:67
FWATOMSPATCH_API void addAttribute(const std::string &name,::fwAtoms::Base::sptr value, conditions::Abstract::sptr condition=conditions::Abstract::New())
Adds a new attribute in the current object.
std::string m_targetVersion
Target version.
Contains the representation of the data objects used in the framework.