ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkVTKImageImport.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkVTKImageImport_h
19 #define __itkVTKImageImport_h
20 
21 #include "itkImageSource.h"
23 
24 #define itkSetMacro2(name, type) \
25  virtual void Set##name (type _arg) \
26  { \
27  itkDebugMacro("setting " #name " to " << _arg); \
28  if ( this->m_##name != _arg ) \
29  { \
30  this->m_##name = _arg; \
31  this->Modified(); \
32  } \
33  }
34 
35 namespace itk
36 {
55 template< typename TOutputImage >
56 class ITK_EXPORT VTKImageImport:public ImageSource< TOutputImage >
57 {
58 public:
63 
65  itkNewMacro(Self);
66 
68  itkTypeMacro(VTKImageImport, ImageSource);
69 
71  typedef TOutputImage OutputImageType;
72  typedef typename OutputImageType::Pointer OutputImagePointer;
73  typedef typename OutputImageType::PixelType OutputPixelType;
74  typedef typename OutputImageType::SizeType OutputSizeType;
75  typedef typename OutputImageType::IndexType OutputIndexType;
76  typedef typename OutputImageType::RegionType OutputRegionType;
77 
79  itkStaticConstMacro(OutputImageDimension, unsigned int,
80  OutputImageType::ImageDimension);
81 
84  typedef void ( * UpdateInformationCallbackType )(void *);
85  typedef int ( * PipelineModifiedCallbackType )(void *);
86  typedef int * ( * WholeExtentCallbackType )(void *);
87  typedef double * ( * SpacingCallbackType )(void *);
88  typedef double * ( * OriginCallbackType )(void *);
89  typedef const char * ( *ScalarTypeCallbackType )(void *);
90  typedef int ( * NumberOfComponentsCallbackType )(void *);
91  typedef void ( * PropagateUpdateExtentCallbackType )(void *, int *);
92  typedef void ( * UpdateDataCallbackType )(void *);
93  typedef int * ( * DataExtentCallbackType )(void *);
94  typedef void * ( * BufferPointerCallbackType )(void *);
96 
98  typedef float * ( *FloatSpacingCallbackType )(void *);
99  typedef float * ( *FloatOriginCallbackType )(void *);
101 
103  itkSetMacro(UpdateInformationCallback, UpdateInformationCallbackType);
104  itkGetConstMacro(UpdateInformationCallback, UpdateInformationCallbackType);
106 
108  itkSetMacro(PipelineModifiedCallback, PipelineModifiedCallbackType);
109  itkGetConstMacro(PipelineModifiedCallback, PipelineModifiedCallbackType);
111 
113  itkSetMacro(WholeExtentCallback, WholeExtentCallbackType);
114  itkGetConstMacro(WholeExtentCallback, WholeExtentCallbackType);
116 
118  itkSetMacro(SpacingCallback, SpacingCallbackType);
119  itkGetConstMacro(SpacingCallback, SpacingCallbackType);
120  itkSetMacro(FloatSpacingCallback, FloatSpacingCallbackType);
121  itkGetConstMacro(FloatSpacingCallback, FloatSpacingCallbackType);
122  void SetSpacingCallback(FloatSpacingCallbackType f)
123  { this->SetFloatSpacingCallback(f); }
125 
127  itkSetMacro(OriginCallback, OriginCallbackType);
128  itkGetConstMacro(OriginCallback, OriginCallbackType);
129  itkSetMacro(FloatOriginCallback, FloatOriginCallbackType);
130  itkGetConstMacro(FloatOriginCallback, FloatOriginCallbackType);
131  void SetOriginCallback(FloatOriginCallbackType f)
132  { this->SetFloatOriginCallback(f); }
134 
136  itkSetMacro(ScalarTypeCallback, ScalarTypeCallbackType);
137  itkGetConstMacro(ScalarTypeCallback, ScalarTypeCallbackType);
139 
141  itkSetMacro(NumberOfComponentsCallback, NumberOfComponentsCallbackType);
142  itkGetConstMacro(NumberOfComponentsCallback, NumberOfComponentsCallbackType);
144 
146  itkSetMacro(PropagateUpdateExtentCallback, PropagateUpdateExtentCallbackType);
147  itkGetConstMacro(PropagateUpdateExtentCallback, PropagateUpdateExtentCallbackType);
149 
151  itkSetMacro(UpdateDataCallback, UpdateDataCallbackType);
152  itkGetConstMacro(UpdateDataCallback, UpdateDataCallbackType);
154 
156  itkSetMacro(DataExtentCallback, DataExtentCallbackType);
157  itkGetConstMacro(DataExtentCallback, DataExtentCallbackType);
159 
161  itkSetMacro(BufferPointerCallback, BufferPointerCallbackType);
162  itkGetConstMacro(BufferPointerCallback, BufferPointerCallbackType);
164 
166  itkSetMacro2(CallbackUserData, void *);
167  itkGetConstMacro(CallbackUserData, void *);
168 protected:
169  VTKImageImport();
171  void PrintSelf(std::ostream & os, Indent indent) const;
173 
174  virtual void PropagateRequestedRegion(DataObject *);
175 
176  virtual void UpdateOutputInformation();
177 
178  virtual void GenerateData();
179 
180  virtual void GenerateOutputInformation();
181 
182 private:
183  VTKImageImport(const Self &); //purposely not implemented
184  void operator=(const Self &); //purposely not implemented
185 
187  UpdateInformationCallbackType m_UpdateInformationCallback;
188  PipelineModifiedCallbackType m_PipelineModifiedCallback;
189  WholeExtentCallbackType m_WholeExtentCallback;
190  SpacingCallbackType m_SpacingCallback;
191  FloatSpacingCallbackType m_FloatSpacingCallback;
192  OriginCallbackType m_OriginCallback;
193  FloatOriginCallbackType m_FloatOriginCallback;
194  ScalarTypeCallbackType m_ScalarTypeCallback;
195  NumberOfComponentsCallbackType m_NumberOfComponentsCallback;
196  PropagateUpdateExtentCallbackType m_PropagateUpdateExtentCallback;
197  UpdateDataCallbackType m_UpdateDataCallback;
198  DataExtentCallbackType m_DataExtentCallback;
199  BufferPointerCallbackType m_BufferPointerCallback;
200 
201  std::string m_ScalarTypeName;
202 };
203 } // namespace itk
204 
205 #ifndef ITK_MANUAL_INSTANTIATION
206 #include "itkVTKImageImport.hxx"
207 #endif
208 
209 #endif // __itkVTKImageImport_h
210