selxItkImageSink.h 3.05 KB
Newer Older
Floris Berendsen's avatar
Floris Berendsen committed
1
2
/*=========================================================================
 *
3
 *  Copyright Leiden University Medical Center, Erasmus University Medical
Floris Berendsen's avatar
Floris Berendsen committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 *  Center and contributors
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/

20
21
22
#ifndef selxItkImageSink_h
#define selxItkImageSink_h

23
#include "selxSuperElastixComponent.h"
24
#include "selxSinksAndSourcesInterfaces.h"
25
#include <string.h>
26
#include "selxMacro.h"
27
#include "itkImageFileWriter.h"
FBerendsen's avatar
FBerendsen committed
28
#include "itkSmartPointer.h"
29
30
#include "selxAnyFileWriter.h"
#include "selxFileWriterDecorator.h"
31
32
33

namespace selx
{
34
35
36
template< int Dimensionality, class TPixel >
class ItkImageSinkComponent :
  public SuperElastixComponent<
37
  Accepting< itkImageInterface< Dimensionality, TPixel > >,
38
39
40
41
  Providing< SinkInterface >
  >
{
public:
42

43
  selxNewMacro( ItkImageSinkComponent, ComponentBase );
44

45
  //itkStaticConstMacro(Dimensionality, unsigned int, Dimensionality);
46

47
48
  ItkImageSinkComponent();
  virtual ~ItkImageSinkComponent();
49

50
51
52
53
54
  typedef itkImageInterface< Dimensionality, TPixel >        AcceptingImageInterfaceType;
  typedef typename AcceptingImageInterfaceType::ItkImageType ItkImageType;
  typedef typename ItkImageType::Pointer                     ItkImagePointer;
  typedef typename itk::ImageFileWriter< ItkImageType >      ItkImageWriterType;
  typedef FileWriterDecorator< ItkImageWriterType >          DecoratedWriterType;
55

56
  virtual int Set( AcceptingImageInterfaceType * ) override;
57

58
59
  virtual void SetMiniPipelineOutput( itk::DataObject::Pointer ) override;
  virtual itk::DataObject::Pointer GetMiniPipelineOutput( void ) override;
60

61
  virtual AnyFileWriter::Pointer GetOutputFileWriter( void ) override;
62

63
  virtual itk::DataObject::Pointer GetInitializedOutput( void ) override;
64

65
  virtual bool MeetsCriterion( const ComponentBase::CriterionType & criterion ) override;
66

67
  static const char * GetDescription() { return "ItkImageSink Component"; }
68

69
private:
70

71
72
  typename ItkImageType::Pointer m_MiniPipelineOutputImage;
  typename ItkImageType::Pointer m_OverlordOutputImage;
73

74
protected:
75

76
  // return the class name and the template arguments to uniquely identify this component.
Floris Berendsen's avatar
Floris Berendsen committed
77
  static inline const std::map< std::string, std::string > TemplateProperties()
78
  {
Floris Berendsen's avatar
Floris Berendsen committed
79
    return { { keys::NameOfClass, "ItkImageSinkComponent" }, { keys::PixelType, PodString< TPixel >::Get() }, { keys::Dimensionality, std::to_string( Dimensionality ) } };
80
  }
81
};
82
83
84
85
} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
#include "selxItkImageSink.hxx"
#endif
86
#endif // #define selxItkImageSink_h