selxItkMeshSource.h 3.65 KB
Newer Older
1
2
/*=========================================================================
 *
3
 *  Copyright Leiden University Medical Center, Erasmus University Medical
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 *  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.
 *
 *=========================================================================*/

#ifndef selxItkMeshSource_h
#define selxItkMeshSource_h

23
#include "selxSuperElastixComponent.h"
24
#include "selxInterfaces.h"
25
26
#include <string.h>
#include "selxMacro.h"
27
28
29
30
#include "itkMeshFileReader.h"
#include "selxAnyFileReader.h"
#include "selxFileReaderDecorator.h"

31
32
namespace selx
{
33
34
35
36
template< int Dimensionality, class TPixel >
class ItkMeshSourceComponent :
  public SuperElastixComponent<
  Accepting< >,
37
  Providing< SourceInterface, itkMeshInterface< Dimensionality, TPixel > >
38
39
40
  >
{
public:
41

42
  selxNewMacro( ItkMeshSourceComponent, ComponentBase );
43

44
45
  ItkMeshSourceComponent();
  virtual ~ItkMeshSourceComponent();
46

47
48
49
  typedef itk::Mesh< TPixel, Dimensionality >         ItkMeshType;
  typedef typename itk::MeshFileReader< ItkMeshType > ItkMeshReaderType;
  typedef FileReaderDecorator< ItkMeshReaderType >    DecoratedReaderType;
50

51
  virtual typename ItkMeshType::Pointer GetItkMesh() override;
52

53
54
  virtual void SetMiniPipelineInput( itk::DataObject::Pointer ) override;
  virtual AnyFileReader::Pointer GetInputFileReader( void ) override;
55

56
  virtual bool MeetsCriterion( const ComponentBase::CriterionType & criterion ) override;
57

58
  static const char * GetDescription() { return "ItkMeshSource Component"; }
59

60
private:
61

62
  typename ItkMeshType::Pointer m_Mesh;
63

64
protected:
65

66
67
68
69
  /* The following struct returns the string name of computation type */
  /* default implementation */

  static inline const std::string GetTypeNameString()
70
  {
71
72
73
    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
74
75
76
  }


77
  static inline const std::string GetPixelTypeNameString()
78
  {
79
80
81
    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
82
  }
83
};
84

85
86
87
88
89
90
91
template< >
inline const std::string
ItkMeshSourceComponent< 2, float >
::GetPixelTypeNameString()
{
  return std::string( "float" );
}
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
template< >
inline const std::string
ItkMeshSourceComponent< 2, double >
::GetPixelTypeNameString()
{
  return std::string( "double" );
}


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


template< >
inline const std::string
ItkMeshSourceComponent< 3, double >
::GetPixelTypeNameString()
{
  return std::string( "double" );
}
119
120
121
122
123
} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
#include "selxItkMeshSource.hxx"
#endif
#endif // #define selxItkMeshSource_h