ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkMetaImageIO.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 __itkMetaImageIO_h
00019 #define __itkMetaImageIO_h
00020 
00021 
00022 #include <fstream>
00023 #include "itkImageIOBase.h"
00024 #include "metaObject.h"
00025 #include "metaImage.h"
00026 
00027 namespace itk
00028 {
00036 class ITK_EXPORT MetaImageIO:public ImageIOBase
00037 {
00038 public:
00040   typedef MetaImageIO          Self;
00041   typedef ImageIOBase          Superclass;
00042   typedef SmartPointer< Self > Pointer;
00043 
00045   itkNewMacro(Self);
00046 
00048   itkTypeMacro(MetaImageIO, Superclass);
00049 
00055   virtual bool SupportsDimension(unsigned long)
00056   {
00057     return true;
00058   }
00059 
00060   /*-------- This part of the interfaces deals with reading data. ----- */
00061 
00064   virtual bool CanReadFile(const char *);
00065 
00067   virtual void ReadImageInformation();
00068 
00070   virtual void Read(void *buffer);
00071 
00072   MetaImage * GetMetaImagePointer(void);
00073 
00074   /*-------- This part of the interfaces deals with writing data. ----- */
00075 
00078   virtual bool CanWriteFile(const char *);
00079 
00081   virtual void WriteImageInformation();
00082 
00085   virtual void Write(const void *buffer);
00086 
00090   virtual void SetDataFileName(const char *filename);
00091 
00094   virtual void SetDoublePrecision(unsigned int precision)
00095   {
00096     m_MetaImage.SetDoublePrecision(precision);
00097   }
00098 
00103   virtual ImageIORegion
00104   GenerateStreamableReadRegionFromRequestedRegion(const ImageIORegion & requested) const;
00105 
00106   virtual unsigned int
00107   GetActualNumberOfSplitsForWriting(unsigned int numberOfRequestedSplits,
00108                                     const ImageIORegion & pasteRegion,
00109                                     const ImageIORegion & largestPossibleRegion);
00110 
00111   virtual ImageIORegion
00112   GetSplitRegionForWriting(unsigned int ithPiece,
00113                            unsigned int numberOfActualSplits,
00114                            const ImageIORegion & pasteRegion,
00115                            const ImageIORegion & largestPossibleRegion);
00116 
00120   virtual bool CanStreamRead()
00121   {
00122     if ( m_MetaImage.CompressedData() )
00123       {
00124       return false;
00125       }
00126     return true;
00127   }
00129 
00135   virtual bool CanStreamWrite()
00136   {
00137     if ( this->GetUseCompression() )
00138       {
00139       return false;
00140       }
00141     return true;
00142   }
00144 
00148   itkSetMacro(SubSamplingFactor, unsigned int);
00149   itkGetConstMacro(SubSamplingFactor, unsigned int);
00150 protected:
00151   MetaImageIO();
00152   ~MetaImageIO();
00153   void PrintSelf(std::ostream & os, Indent indent) const;
00155 
00156 private:
00157 
00158   MetaImage m_MetaImage;
00159 
00160   MetaImageIO(const Self &);    //purposely not implemented
00161   void operator=(const Self &); //purposely not implemented
00162 
00163   unsigned int m_SubSamplingFactor;
00164 };
00165 } // end namespace itk
00166 
00167 #endif // __itkMetaImageIO_h
00168