fw4spl
MedicalDataV1.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/Object.hpp>
8 #include <fwAtoms/Object.hxx>
9 #include <fwAtoms/Map.hpp>
10 
11 #include <fwAtomsPatch/helper/Object.hpp>
12 #include <fwAtomsPatch/helper/functions.hpp>
13 
14 #include <fwAtomsFilter/registry/macros.hpp>
15 
16 #include "filterVRRender/MedicalDataV1.hpp"
17 
18 namespace filterVRRender
19 {
20 
21 fwAtomsFilterRegisterMacro( ::filterVRRender::MedicalDataV1, "VRRenderMedicalDataV1" );
22 
24 {
25 }
26 
28 {
29 }
30 
31 void clearMapAttribute(const std::string& key, const ::fwAtoms::Map::sptr& values)
32 {
33  if(values->find(key) != values->end())
34  {
35  ::fwAtoms::Object::sptr obj = ::fwAtoms::Object::dynamicCast( (*values)[key] );
36  SLM_ASSERT("Failed to retrieve key '" + key + "' from atom", obj);
37 
38  ::fwAtoms::Map::sptr objValues = obj->getAttribute< ::fwAtoms::Map >("values");
39  SLM_ASSERT("Failed to retrieve 'values' attribute as ::fwAtoms::Map", objValues);
40  objValues->clear();
41  }
42 }
43 
45 {
47 
48  SLM_ASSERT("Unable to filter atom : invalid object", atom);
49 
50  const std::string& classname = ::fwAtomsPatch::helper::getClassname(atom);
51  FW_RAISE_IF("Unable to filter atom of class '" << classname << "'. Expected class is '::fwData::Composite'",
52  classname != "::fwData::Composite");
53 
54  ::fwAtoms::Map::sptr values = atom->getAttribute< ::fwAtoms::Map >("values");
55  SLM_ASSERT("Failed to retrieve 'values' attribute as ::fwAtoms::Map", values);
56 
57  clearMapAttribute("processingDB", values);
58  clearMapAttribute("planningDB", values);
59 }
60 
61 }
62 
#define SPTR(_cls_)
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Definition: spyLog.hpp:329
FWATOMS_API Base::sptr getAttribute(const std::string &key) const
Returns requested attribute if exists, empty sptr else.
Class represented a fwData::Object.
virtual FILTERVRRENDER_API void apply(const std::shared_ptr< ::fwAtoms::Object > &atom)
Apply filter onto given atom object.
static const std::string & classname()
return object&#39;s classname without its namespace, i.e. BaseObject
Filter associated to context "MedicalData" version "V1" in VR-Render.
Map is a container for mapping representation.
Definition: Map.hpp:31
The namespace filterVRRender contains filters for atoms: it allows to keep only the known atom object...
#define SLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:308
MedicalDataV1(::fwAtomsFilter::IFilter::Key key)
Constructor.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.