fw4spl
Mesh/V2ToV3.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 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/String.hpp>
8 #include <fwAtoms/Map.hpp>
9 #include <fwAtomsPatch/StructuralCreatorDB.hpp>
10 
11 #include "fwStructuralPatch/fwData/Mesh/V2ToV3.hpp"
12 
13 namespace fwStructuralPatch
14 {
15 
16 namespace fwData
17 {
18 
19 namespace Mesh
20 {
21 
22 V2ToV3::V2ToV3() : ::fwAtomsPatch::IStructuralPatch()
23 {
24  m_originClassname = "::fwData::Mesh";
25  m_targetClassname = "::fwData::Mesh";
26  m_originVersion = "2";
27  m_targetVersion = "3";
28 }
29 
30 // ----------------------------------------------------------------------------
31 
33 {
34 }
35 
36 // ----------------------------------------------------------------------------
37 
39 {
40 }
41 
42 // ----------------------------------------------------------------------------
43 
44 void V2ToV3::apply( const ::fwAtoms::Object::sptr& previous,
45  const ::fwAtoms::Object::sptr& current,
46  ::fwAtomsPatch::IPatch::NewVersionsType& newVersions)
47 {
48  IStructuralPatch::apply(previous, current, newVersions);
49 
50  // Update object version
51  this->updateVersion(current);
52 
53  // Create helper
54  ::fwAtomsPatch::helper::Object helper(current);
55  if (current->getAttributes().find("point_tex_coords") == current->getAttributes().end())
56  {
57  helper.addAttribute("point_tex_coords", ::fwAtoms::Object::sptr() );
58  }
59  if (current->getAttributes().find("cell_tex_coords") == current->getAttributes().end())
60  {
61  helper.addAttribute("cell_tex_coords", ::fwAtoms::Object::sptr() );
62  }
63 }
64 
65 } // namespace Mesh
66 
67 } // namespace fwData
68 
69 } // namespace fwStructuralPatch
70 
FWSTRUCTURALPATCH_API ~V2ToV3()
Destructor.
Definition: Mesh/V2ToV3.cpp:32
FWATOMSPATCH_API void updateVersion(std::shared_ptr< ::fwAtoms::Object > current)
Updates the version of the patched object.
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.
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.
Structural patch to convert a fwData::Mesh from version &#39;2&#39; to version &#39;3&#39;.
Definition: Mesh/V2ToV3.hpp:24
FWSTRUCTURALPATCH_API V2ToV3()
Constructor.
Definition: Mesh/V2ToV3.cpp:22
Contains the representation of the data objects used in the framework.
virtual FWSTRUCTURALPATCH_API void apply(const ::fwAtoms::Object::sptr &previous, const ::fwAtoms::Object::sptr &current,::fwAtomsPatch::IPatch::NewVersionsType &newVersions) override
Applies patch.
Definition: Mesh/V2ToV3.cpp:44