7 #include "fwMDSemanticPatch/V09ALA/V10/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> 36 this->
addContext(
"MedicalData",
"V09ALA",
"V10");
55 const ::fwAtoms::Object::sptr& previous,
56 const ::fwAtoms::Object::sptr& current,
57 ::fwAtomsPatch::IPatch::NewVersionsType& newVersions)
59 ISemanticPatch::apply(previous, current, newVersions);
60 ::fwAtomsPatch::helper::cleanFields( current );
63 ::fwAtoms::Map::csptr previousFieldMap = ::fwAtoms::Map::dynamicCast(previous->getAttribute(
"fields"));
64 SLM_ASSERT(
"Image does not have field map", previousFieldMap);
66 const auto& iter = previousFieldMap->find(
"m_imageLandmarksId");
67 if (iter != previousFieldMap->end())
72 ::fwAtoms::Object::sptr currentLandmarks = creators->create(
"::fwData::Landmarks",
"1");
75 ::fwAtoms::Map::sptr currentFieldMap = ::fwAtoms::Map::dynamicCast(current->getAttribute(
"fields"));
76 currentFieldMap->insert(
"m_landmarksId", currentLandmarks);
78 ::fwAtoms::Map::sptr landmarksMap = ::fwAtoms::Map::dynamicCast(currentLandmarks->getAttribute(
"landmarks"));
81 ::fwAtoms::Object::sptr previousPL = ::fwAtoms::Object::dynamicCast(iter->second);
83 ::fwAtoms::Sequence::sptr previousPLSeq = ::fwAtoms::Sequence::dynamicCast(previousPL->getAttribute(
"points"));
86 for (
const auto& obj : previousPLSeq->getValue())
89 ::fwAtoms::Object::csptr
point = ::fwAtoms::Object::dynamicCast(obj);
90 ::fwAtoms::Sequence::csptr pointCoords = ::fwAtoms::Sequence::dynamicCast(point->getAttribute(
"coord"));
91 ::fwAtoms::Numeric::csptr coordX = ::fwAtoms::Numeric::dynamicCast(pointCoords->getValue()[0]);
92 ::fwAtoms::Numeric::csptr coordY = ::fwAtoms::Numeric::dynamicCast(pointCoords->getValue()[1]);
93 ::fwAtoms::Numeric::csptr coordZ = ::fwAtoms::Numeric::dynamicCast(pointCoords->getValue()[2]);
94 const std::string coords = coordX->getString() +
";" + coordY->getString() +
";" + coordZ->getString();
97 ::fwAtoms::Map::csptr pointFieldMap = ::fwAtoms::Map::dynamicCast(point->getAttribute(
"fields"));
100 const auto& it = pointFieldMap->find(
"m_labelId");
101 if (it != pointFieldMap->end())
103 ::fwAtoms::Object::csptr labelObj = ::fwAtoms::Object::dynamicCast(it->second);
104 ::fwAtoms::String::csptr labelStr = ::fwAtoms::String::dynamicCast(labelObj->getAttribute(
"value"));
105 label = labelStr->getValue();
109 label =
"label_" + std::to_string(count++);
113 ::fwAtoms::Object::sptr atomGroup = ::fwAtoms::Object::New();
121 ::fwAtoms::Sequence::sptr seq = ::fwAtoms::Sequence::New();
124 atomGroup->setAttribute(
"points", seq);
125 landmarksMap->insert(label, atomGroup);
Contains the semantic patches within the context "MedicalData".
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.
FWMDSEMANTICPATCH_API ~Image()
Destructor.
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) ...
static StructuralCreatorDB::sptr getDefault()
Returns the default instance of StructuralCreatorDB.
Patch the 'landmarks' field of an image from version 'V9ALA' to 'V10' within 'MedicalData' context...
Contains the representation of the data objects used in the framework.
FWMDSEMANTICPATCH_API Image()
Constructor.
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 Boolean::sptr New(std::string value)
Construct an object storing a bool value.