selxDisplacementFieldItkImageFilterSink.h 4.75 KB
Newer Older
Floris Berendsen's avatar
Floris Berendsen committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*=========================================================================
 *
 *  Copyright Leiden University Medical Center, Erasmus University Medical 
 *  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 selxDisplacementFieldItkImageFilterSink_h
#define selxDisplacementFieldItkImageFilterSink_h

23
24
#include "selxComponentBase.h"
#include "selxInterfaces.h"
25
#include <string.h>
26
#include "selxMacro.h"
27
#include "itkImageFileWriter.h"
28
29
#include "selxAnyFileWriter.h"
#include "selxFileWriterDecorator.h"
30
31
32
33
34
35
36

namespace selx
{
  template<int Dimensionality, class TPixel>
  class DisplacementFieldItkImageFilterSinkComponent :
    public Implements <
    Accepting< DisplacementFieldItkImageSourceInterface<Dimensionality, TPixel> >,
37
    Providing < SinkInterface >
38
39
40
    >
  {
  public:
41
    selxNewMacro(DisplacementFieldItkImageFilterSinkComponent, ComponentBase);
42

FBerendsen's avatar
FBerendsen committed
43
    //itkStaticConstMacro(Dimensionality, unsigned int, Dimensionality);
44
45
46
47
48
49

    DisplacementFieldItkImageFilterSinkComponent();
    virtual ~DisplacementFieldItkImageFilterSinkComponent();

    typedef TPixel PixelType;

50
    typedef DisplacementFieldItkImageSourceInterface<Dimensionality, TPixel> AcceptingDisplacementFieldInterfaceType;
51
52
53
    typedef typename itk::Image<itk::Vector<PixelType, Dimensionality>, Dimensionality> DeformationFieldImageType;
    typedef typename DeformationFieldImageType::Pointer DeformationFieldImageTypePointer;
    typedef typename itk::ImageFileWriter<DeformationFieldImageType> DeformationFieldImageWriterType;
54
    typedef FileWriterDecorator<DeformationFieldImageWriterType>  DecoratedWriterType;
55

56
    //Accepting Interfaces:
57
    virtual int Set(AcceptingDisplacementFieldInterfaceType*) override;
58
59
    
    //Providing Interfaces:
60
61
    virtual void SetMiniPipelineOutput(itk::DataObject::Pointer) override;
    virtual itk::DataObject::Pointer GetMiniPipelineOutput(void) override;
62
    virtual AnyFileWriter::Pointer GetOutputFileWriter(void) override;
63
    virtual itk::DataObject::Pointer GetInitializedOutput(void) override;
64

FBerendsen's avatar
FBerendsen committed
65
    virtual bool MeetsCriterion(const ComponentBase::CriterionType &criterion) override;
66
    static const char * GetDescription() { return "DisplacementFieldItkImageFilterSink Component"; };
67

68
  private:
69
70
71
72
    typename DeformationFieldImageType::Pointer m_MiniPipelineOutputImage;
    typename DeformationFieldImageType::Pointer m_OverlordOutputImage;
    

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
  protected:
    /* The following struct returns the string name of computation type */
    /* default implementation */

    static inline const std::string GetTypeNameString()
    {
      itkGenericExceptionMacro(<< "Unknown ScalarType" << typeid(TPixel).name());
      // TODO: provide the user instructions how to enable the compilation of the component with the required template types (if desired)
      // We might define an exception object that can communicate various error messages: for simple user, for developer user, etc
    }

    static inline const std::string GetPixelTypeNameString()
    {
      itkGenericExceptionMacro(<< "Unknown PixelType" << typeid(TPixel).name());
      // TODO: provide the user instructions how to enable the compilation of the component with the required template types (if desired)
      // We might define an exception object that can communicate various error messages: for simple user, for developer user, etc
    }

  };



  template <>
  inline const std::string
    DisplacementFieldItkImageFilterSinkComponent<2, float>
    ::GetPixelTypeNameString()
  {
    return std::string("float");
  }


  template <>
  inline const std::string
    DisplacementFieldItkImageFilterSinkComponent<2, double>
    ::GetPixelTypeNameString()
  {
    return std::string("double");
  }

  template <>
  inline const std::string
    DisplacementFieldItkImageFilterSinkComponent<3, float>
    ::GetPixelTypeNameString()
  {
    return std::string("float");
  }

  template <>
  inline const std::string
    DisplacementFieldItkImageFilterSinkComponent<3, double>
    ::GetPixelTypeNameString()
  {
    return std::string("double");
  }

} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
#include "selxDisplacementFieldItkImageFilterSink.hxx"
#endif
#endif // #define selxDisplacementFieldItkImageFilterSink_h