fw4spl
ImageDimensionsSplitter.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2016.
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 <dcmtk/config/osconfig.h>
8 #include <dcmtk/dcmnet/diutil.h>
9 #include <dcmtk/dcmdata/dcfilefo.h>
10 #include <dcmtk/dcmdata/dcdeftag.h>
11 #include <dcmtk/dcmimgle/dcmimage.h>
12 
13 #include "fwDicomIOFilter/helper/Filter.hpp"
14 #include "fwDicomIOFilter/registry/macros.hpp"
15 #include "fwDicomIOFilter/exceptions/FilterFailure.hpp"
16 #include "fwDicomIOFilter/splitter/TagValueSplitter.hpp"
17 #include "fwDicomIOFilter/splitter/ImageDimensionsSplitter.hpp"
18 
19 fwDicomIOFilterRegisterMacro( ::fwDicomIOFilter::splitter::ImageDimensionsSplitter );
20 
21 namespace fwDicomIOFilter
22 {
23 namespace splitter
24 {
25 
26 const std::string ImageDimensionsSplitter::s_FILTER_NAME = "Image dimensions splitter";
28  "Split instances according to image dimensions.";
29 
30 //-----------------------------------------------------------------------------
31 
33 {
34 }
35 
36 //-----------------------------------------------------------------------------
37 
39 {
40 }
41 
42 //-----------------------------------------------------------------------------
43 
45 {
47 }
48 
49 //-----------------------------------------------------------------------------
50 
52 {
54 }
55 
56 //-----------------------------------------------------------------------------
57 
58 ImageDimensionsSplitter::DicomSeriesContainerType ImageDimensionsSplitter::apply(
59  const ::fwMedData::DicomSeries::sptr& series, const ::fwLog::Logger::sptr& logger) const
60 {
61  DicomSeriesContainerType result;
62  result.push_back(series);
63 
64  // Columns splitter
65  auto columnsSplitter = ::fwDicomIOFilter::splitter::TagValueSplitter::New();
66  columnsSplitter->setTag(DCM_Columns);
67  ::fwDicomIOFilter::helper::Filter::applyFilter(result, columnsSplitter, false, logger);
68 
69  // Rows splitter
70  auto rowsSplitter = ::fwDicomIOFilter::splitter::TagValueSplitter::New();
71  rowsSplitter->setTag(DCM_Rows);
72  ::fwDicomIOFilter::helper::Filter::applyFilter(result, rowsSplitter, false, logger);
73 
74  return result;
75 
76 }
77 
78 } // namespace splitter
79 } // namespace fwDicomIOFilter
FWDICOMIOFILTER_API ImageDimensionsSplitter(::fwDicomIOFilter::IFilter::Key key)
Constructor.
Filter that uses the image dimensions to split the instances.
fwDicomIOFilter contains filters used to pre-process images before reading.
static FWDICOMIOFILTER_API bool applyFilter(DicomSeriesContainerType &dicomSeriesContainer,::fwDicomIOFilter::IFilter::sptr filter, bool forcedApply=false, const ::fwLog::Logger::sptr &logger=::fwLog::Logger::New())
Apply a filter to the DicomSeries.
Definition: Filter.cpp:17
virtual FWDICOMIOFILTER_API std::string getDescription() const override
Return the description of the filter.
Key class used to restrict access to Filter construction. See http://www.drdobbs.com/184402053.
virtual FWDICOMIOFILTER_API ~ImageDimensionsSplitter()
Destructor.
static const std::string s_FILTER_DESCRIPTION
Filter description.
virtual FWDICOMIOFILTER_API std::string getName() const override
Return the name of the filter.
virtual FWDICOMIOFILTER_API DicomSeriesContainerType apply(const ::fwMedData::DicomSeries::sptr &series, const ::fwLog::Logger::sptr &logger) const override
Override.
Base class for Dicom instance splitter.
Definition: ISplitter.hpp:23