ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkImportImageFilter.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 __itkImportImageFilter_h
00019 #define __itkImportImageFilter_h
00020 
00021 #include "itkImageSource.h"
00022 
00023 namespace itk
00024 {
00042 template< typename TPixel, unsigned int VImageDimension = 2 >
00043 class ITK_EXPORT ImportImageFilter:
00044   public ImageSource< Image< TPixel, VImageDimension > >
00045 {
00046 public:
00048   typedef Image< TPixel, VImageDimension >      OutputImageType;
00049   typedef typename OutputImageType::Pointer     OutputImagePointer;
00050   typedef typename OutputImageType::SpacingType SpacingType;
00051   typedef typename OutputImageType::PointType   OriginType;
00052 
00054   typedef ImportImageFilter              Self;
00055   typedef ImageSource< OutputImageType > Superclass;
00056   typedef SmartPointer< Self >           Pointer;
00057   typedef SmartPointer< const Self >     ConstPointer;
00058 
00060   itkNewMacro(Self);
00061 
00063   itkTypeMacro(ImportImageFilter, ImageSource);
00064 
00066   typedef Index< VImageDimension > IndexType;
00067 
00069   typedef Size< VImageDimension > SizeType;
00070 
00073   typedef ImageRegion< VImageDimension > RegionType;
00074 
00076   typedef TPixel OutputImagePixelType;
00077 
00079   TPixel * GetImportPointer();
00080 
00088   void SetImportPointer(TPixel *ptr, SizeValueType num,
00089                         bool LetFilterManageMemory);
00090 
00095   void SetRegion(const RegionType & region)
00096   { if ( m_Region != region ) { m_Region = region; this->Modified(); } }
00097 
00102   const RegionType & GetRegion() const
00103   { return m_Region; }
00104 
00107   itkSetMacro(Spacing, SpacingType);
00108   itkGetConstReferenceMacro(Spacing, SpacingType);
00109   itkSetVectorMacro(Spacing, const float, VImageDimension);
00111 
00114   itkSetMacro(Origin, OriginType);
00115   itkGetConstReferenceMacro(Origin, OriginType);
00116   itkSetVectorMacro(Origin, const float, VImageDimension);
00118 
00119   typedef Matrix< double, VImageDimension, VImageDimension > DirectionType;
00120 
00123   virtual void SetDirection(const DirectionType direction);
00124 
00127   itkGetConstReferenceMacro(Direction, DirectionType);
00128 protected:
00129   ImportImageFilter();
00130   ~ImportImageFilter();
00131   void PrintSelf(std::ostream & os, Indent indent) const;
00133 
00136   virtual void GenerateData();
00137 
00141   virtual void GenerateOutputInformation();
00142 
00150   virtual void EnlargeOutputRequestedRegion(DataObject *output);
00151 
00152 private:
00153   ImportImageFilter(const ImportImageFilter &); //purposely not implemented
00154   void operator=(const ImportImageFilter &);    //purposely not implemented
00155 
00156   RegionType    m_Region;
00157   SpacingType   m_Spacing;
00158   OriginType    m_Origin;
00159   DirectionType m_Direction;
00160 
00161   TPixel *      m_ImportPointer;
00162   bool          m_FilterManageMemory;
00163   SizeValueType m_Size;
00164 };
00165 } // end namespace itk
00166 
00167 #ifndef ITK_MANUAL_INSTANTIATION
00168 #include "itkImportImageFilter.hxx"
00169 #endif
00170 
00171 #endif
00172