ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkVTKImageImport.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkVTKImageImport_h
00019 #define __itkVTKImageImport_h
00020 
00021 #include "itkImageSource.h"
00022 #include "itkImportImageContainer.h"
00023 
00024 #define itkSetMacro2(name, type)                     \
00025   virtual void Set##name (type _arg)               \
00026     {                                                \
00027     itkDebugMacro("setting " #name " to " << _arg); \
00028     if ( this->m_##name != _arg )                  \
00029       {                                              \
00030       this->m_##name = _arg;                       \
00031       this->Modified();                              \
00032       }                                              \
00033     }
00034 
00035 namespace itk
00036 {
00055 template< typename TOutputImage >
00056 class ITK_EXPORT VTKImageImport:public ImageSource< TOutputImage >
00057 {
00058 public:
00060   typedef VTKImageImport              Self;
00061   typedef ImageSource< TOutputImage > Superclass;
00062   typedef SmartPointer< Self >        Pointer;
00063 
00065   itkNewMacro(Self);
00066 
00068   itkTypeMacro(VTKImageImport, ImageSource);
00069 
00071   typedef TOutputImage                         OutputImageType;
00072   typedef typename OutputImageType::Pointer    OutputImagePointer;
00073   typedef typename OutputImageType::PixelType  OutputPixelType;
00074   typedef typename OutputImageType::SizeType   OutputSizeType;
00075   typedef typename OutputImageType::IndexType  OutputIndexType;
00076   typedef typename OutputImageType::RegionType OutputRegionType;
00077 
00079   itkStaticConstMacro(OutputImageDimension, unsigned int,
00080                       OutputImageType::ImageDimension);
00081 
00084   typedef void ( *        UpdateInformationCallbackType )(void *);
00085   typedef int ( *         PipelineModifiedCallbackType )(void *);
00086   typedef int * ( *       WholeExtentCallbackType )(void *);
00087   typedef double * ( *    SpacingCallbackType )(void *);
00088   typedef double * ( *    OriginCallbackType )(void *);
00089   typedef const char * ( *ScalarTypeCallbackType )(void *);
00090   typedef int ( *         NumberOfComponentsCallbackType )(void *);
00091   typedef void ( *        PropagateUpdateExtentCallbackType )(void *, int *);
00092   typedef void ( *        UpdateDataCallbackType )(void *);
00093   typedef int * ( *       DataExtentCallbackType )(void *);
00094   typedef void * ( *      BufferPointerCallbackType )(void *);
00096 
00098   typedef float * ( *FloatSpacingCallbackType )(void *);
00099   typedef float * ( *FloatOriginCallbackType )(void *);
00101 
00103   itkSetMacro(UpdateInformationCallback, UpdateInformationCallbackType);
00104   itkGetConstMacro(UpdateInformationCallback, UpdateInformationCallbackType);
00106 
00108   itkSetMacro(PipelineModifiedCallback, PipelineModifiedCallbackType);
00109   itkGetConstMacro(PipelineModifiedCallback, PipelineModifiedCallbackType);
00111 
00113   itkSetMacro(WholeExtentCallback, WholeExtentCallbackType);
00114   itkGetConstMacro(WholeExtentCallback, WholeExtentCallbackType);
00116 
00118   itkSetMacro(SpacingCallback, SpacingCallbackType);
00119   itkGetConstMacro(SpacingCallback, SpacingCallbackType);
00120   itkSetMacro(FloatSpacingCallback, FloatSpacingCallbackType);
00121   itkGetConstMacro(FloatSpacingCallback, FloatSpacingCallbackType);
00122   void SetSpacingCallback(FloatSpacingCallbackType f)
00123   { this->SetFloatSpacingCallback(f); }
00125 
00127   itkSetMacro(OriginCallback, OriginCallbackType);
00128   itkGetConstMacro(OriginCallback, OriginCallbackType);
00129   itkSetMacro(FloatOriginCallback, FloatOriginCallbackType);
00130   itkGetConstMacro(FloatOriginCallback, FloatOriginCallbackType);
00131   void SetOriginCallback(FloatOriginCallbackType f)
00132   { this->SetFloatOriginCallback(f); }
00134 
00136   itkSetMacro(ScalarTypeCallback, ScalarTypeCallbackType);
00137   itkGetConstMacro(ScalarTypeCallback, ScalarTypeCallbackType);
00139 
00141   itkSetMacro(NumberOfComponentsCallback, NumberOfComponentsCallbackType);
00142   itkGetConstMacro(NumberOfComponentsCallback, NumberOfComponentsCallbackType);
00144 
00146   itkSetMacro(PropagateUpdateExtentCallback, PropagateUpdateExtentCallbackType);
00147   itkGetConstMacro(PropagateUpdateExtentCallback, PropagateUpdateExtentCallbackType);
00149 
00151   itkSetMacro(UpdateDataCallback, UpdateDataCallbackType);
00152   itkGetConstMacro(UpdateDataCallback, UpdateDataCallbackType);
00154 
00156   itkSetMacro(DataExtentCallback, DataExtentCallbackType);
00157   itkGetConstMacro(DataExtentCallback, DataExtentCallbackType);
00159 
00161   itkSetMacro(BufferPointerCallback, BufferPointerCallbackType);
00162   itkGetConstMacro(BufferPointerCallback, BufferPointerCallbackType);
00164 
00166   itkSetMacro2(CallbackUserData, void *);
00167   itkGetConstMacro(CallbackUserData, void *);
00168 protected:
00169   VTKImageImport();
00170   ~VTKImageImport() {}
00171   void PrintSelf(std::ostream & os, Indent indent) const;
00173 
00174   virtual void PropagateRequestedRegion(DataObject *);
00175 
00176   virtual void UpdateOutputInformation();
00177 
00178   virtual void GenerateData();
00179 
00180   virtual void GenerateOutputInformation();
00181 
00182 private:
00183   VTKImageImport(const Self &); //purposely not implemented
00184   void operator=(const Self &); //purposely not implemented
00185 
00186   void *                            m_CallbackUserData;
00187   UpdateInformationCallbackType     m_UpdateInformationCallback;
00188   PipelineModifiedCallbackType      m_PipelineModifiedCallback;
00189   WholeExtentCallbackType           m_WholeExtentCallback;
00190   SpacingCallbackType               m_SpacingCallback;
00191   FloatSpacingCallbackType          m_FloatSpacingCallback;
00192   OriginCallbackType                m_OriginCallback;
00193   FloatOriginCallbackType           m_FloatOriginCallback;
00194   ScalarTypeCallbackType            m_ScalarTypeCallback;
00195   NumberOfComponentsCallbackType    m_NumberOfComponentsCallback;
00196   PropagateUpdateExtentCallbackType m_PropagateUpdateExtentCallback;
00197   UpdateDataCallbackType            m_UpdateDataCallback;
00198   DataExtentCallbackType            m_DataExtentCallback;
00199   BufferPointerCallbackType         m_BufferPointerCallback;
00200 
00201   std::string m_ScalarTypeName;
00202 };
00203 } // namespace itk
00204 
00205 #ifndef ITK_MANUAL_INSTANTIATION
00206 #include "itkVTKImageImport.hxx"
00207 #endif
00208 
00209 #endif // __itkVTKImageImport_h
00210