fw4spl
MedicalDataV2.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 
8 #include "filterVRRender/MedicalDataV2.hpp"
9 
10 #include <fwAtoms/Base.hpp>
11 #include <fwAtoms/Object.hpp>
12 #include <fwAtoms/Object.hxx>
13 #include <fwAtoms/Sequence.hpp>
14 #include <fwAtomsFilter/functions.hpp>
15 
16 #include <fwAtomsFilter/registry/macros.hpp>
17 
18 #include <fwAtomsPatch/helper/functions.hpp>
19 
20 namespace filterVRRender
21 {
22 
23 fwAtomsFilterRegisterMacro( ::filterVRRender::MedicalDataV2, "VRRenderMedicalDataV2" );
24 
26 {
27 }
28 
30 {
31 }
32 
34 {
36 
37  SLM_ASSERT("Unable to filter atom : invalid object", atom);
38 
39  const std::string expName = "::fwMedData::SeriesDB"; // expected classname
40  const std::string& classname = ::fwAtomsPatch::helper::getClassname(atom);
41  FW_RAISE_IF("Unable to filter atom of class '" << classname << "'. Expected class is '" + expName + "'",
42  classname != expName);
43 
44  ::fwAtoms::Sequence::sptr series = atom->getAttribute< ::fwAtoms::Sequence >("values");
45  SLM_ASSERT("Failed to retrieve 'values' attribute as ::fwAtoms::Sequence", series);
46 
47  ::fwAtoms::Sequence::sptr knownSeries = ::fwAtoms::Sequence::New();
48  for(::fwAtoms::Base::sptr serie : series->getValue())
49  {
50  ::fwAtoms::Object::sptr obj = ::fwAtoms::Object::dynamicCast(serie);
51  SLM_ASSERT("Failed to cast sequence element as ::fwAtoms::Object", obj);
52 
54  {
55  knownSeries->push_back(serie);
56  }
57  }
58 
59  series->clear();
60  for(::fwAtoms::Base::sptr serie : knownSeries->getValue())
61  {
62  series->push_back(serie);
63  }
64 }
65 
66 } // namespace filterVRRender
67 
#define SPTR(_cls_)
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Definition: spyLog.hpp:329
FWATOMSFILTER_API bool isSeriesKnown(const std::shared_ptr< ::fwAtoms::Object > &series)
Returns true if given atom matches a defined fwMedData::Series implementations.
FWATOMS_API Base::sptr getAttribute(const std::string &key) const
Returns requested attribute if exists, empty sptr else.
Filter associated to context "MedicalData" version "V2" in VR-Render.
virtual FILTERVRRENDER_API void apply(const std::shared_ptr< ::fwAtoms::Object > &atom)
Apply filter onto given atom object.
Class represented a fwData::Object.
static const std::string & classname()
return object&#39;s classname without its namespace, i.e. BaseObject
MedicalDataV2(::fwAtomsFilter::IFilter::Key key)
Constructor.
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
Sequence represented a list of meta object.
Definition: Sequence.hpp:22
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.