7 #include "fwMDSemanticPatch/V10/V09ALA/fwData/Image.hpp" 9 #include <fwAtoms/Boolean.hpp> 10 #include <fwAtoms/Map.hpp> 11 #include <fwAtoms/Numeric.hpp> 12 #include <fwAtoms/Numeric.hxx> 13 #include <fwAtoms/Object.hpp> 14 #include <fwAtoms/Object.hxx> 15 #include <fwAtoms/String.hpp> 17 #include <fwAtomsPatch/helper/functions.hpp> 18 #include <fwAtomsPatch/StructuralCreatorDB.hpp> 20 #include <fwTools/UUID.hpp> 22 #include <boost/algorithm/string.hpp> 38 this->
addContext(
"MedicalData",
"V10",
"V09ALA");
57 const ::fwAtoms::Object::sptr& previous,
58 const ::fwAtoms::Object::sptr& current,
59 ::fwAtomsPatch::IPatch::NewVersionsType& newVersions)
61 ISemanticPatch::apply(previous, current, newVersions);
62 ::fwAtomsPatch::helper::cleanFields( current );
65 ::fwAtoms::Map::csptr previousFieldMap = ::fwAtoms::Map::dynamicCast(previous->getAttribute(
"fields"));
66 SLM_ASSERT(
"Image does not have field map", previousFieldMap);
68 const auto& iter = previousFieldMap->find(
"m_landmarksId");
69 if (iter != previousFieldMap->end())
74 ::fwAtoms::Object::sptr currentPL = creators->create(
"::fwData::PointList",
"1");
77 ::fwAtoms::Map::sptr currentFieldMap = ::fwAtoms::Map::dynamicCast(current->getAttribute(
"fields"));
78 currentFieldMap->insert(
"m_imageLandmarksId", currentPL);
80 ::fwAtoms::Sequence::sptr plSeq = ::fwAtoms::Sequence::dynamicCast(currentPL->getAttribute(
"points"));
83 ::fwAtoms::Object::sptr previousLandmarks = ::fwAtoms::Object::dynamicCast(iter->second);
85 ::fwAtoms::Map::sptr previousLandmarksMap =
86 ::fwAtoms::Map::dynamicCast(previousLandmarks->getAttribute(
"landmarks"));
88 for (
const auto& elt : previousLandmarksMap->getValue())
90 ::fwAtoms::Object::csptr atomGroup = ::fwAtoms::Object::dynamicCast(elt.second);
91 ::fwAtoms::Sequence::csptr points = ::fwAtoms::Sequence::dynamicCast(atomGroup->getAttribute(
"points"));
94 for (
const auto& ptObj : points->getValue())
96 ::fwAtoms::String::csptr previousPt = ::fwAtoms::String::dynamicCast(ptObj);
97 std::vector<std::string> res;
98 const std::string coords = previousPt->getValue();
99 ::boost::split(res, coords, ::boost::is_any_of(
";"));
101 ::fwAtoms::Object::sptr
point = ::fwAtoms::Object::New();
102 ::fwAtomsPatch::helper::setClassname(point,
"::fwData::Point");
103 ::fwAtomsPatch::helper::setVersion(point,
"1");
104 ::fwAtomsPatch::helper::generateID(point);
106 plSeq->push_back(point);
109 ::fwAtoms::Sequence::sptr pointCoord = ::fwAtoms::Sequence::New();
116 ::fwAtoms::Map::sptr pointFieldMap = ::fwAtoms::Map::New();
119 const std::string label = elt.first +
"_" + std::to_string(count);
Patch the 'landmarks' field of an image from version 'V10' to 'V09ALA' within 'MedicalData' context...
FWMDSEMANTICPATCH_API ~Image()
Destructor.
Contains the semantic patches within the context "MedicalData".
virtual FWMDSEMANTICPATCH_API void apply(const ::fwAtoms::Object::sptr &previous, const ::fwAtoms::Object::sptr ¤t,::fwAtomsPatch::IPatch::NewVersionsType &newVersions) override
Applies patch.
static FWATOMS_API String::sptr New(std::string value)
Construct a new Object represented a string.
Contains base functionalities used to transform objects from a version to another.
std::string m_originClassname
Origin classname of the object.
virtual FWATOMSPATCH_API void addContext(const std::string &context, const std::string &originVersion, const std::string &targetVersion)
Add a context where the patch can be applied.
std::string m_originVersion
Origin version of the object.
FWATOMSPATCH_API ISemanticPatch()
Constructor.
static Numeric::sptr New(T value)
Build a new numeric type.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
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.
FWMDSEMANTICPATCH_API Image()
Constructor.
static StructuralCreatorDB::sptr getDefault()
Returns the default instance of StructuralCreatorDB.
Contains the representation of the data objects used in the framework.