ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkVTKImageIO.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 /*=========================================================================
00019  *
00020  *  Portions of this file are subject to the VTK Toolkit Version 3 copyright.
00021  *
00022  *  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00023  *
00024  *  For complete copyright, license and disclaimer of warranty information
00025  *  please refer to the NOTICE file at the top of the ITK source tree.
00026  *
00027  *=========================================================================*/
00028 #ifndef __itkVTKImageIO_h
00029 #define __itkVTKImageIO_h
00030 
00031 
00032 #include <fstream>
00033 #include "itkStreamingImageIOBase.h"
00034 
00035 namespace itk
00036 {
00048 class ITK_EXPORT VTKImageIO:
00049   public StreamingImageIOBase
00050 {
00051 public:
00053   typedef VTKImageIO                 Self;
00054   typedef StreamingImageIOBase       Superclass;
00055   typedef SmartPointer< Self >       Pointer;
00056   typedef SmartPointer< const Self > ConstPointer;
00057 
00059   itkNewMacro(Self);
00060 
00062   itkTypeMacro(VTKImageIO, StreamingImageIOBase);
00063 
00064 // see super class for documentation
00065   //
00066   // overidden to return true only when supported
00067   virtual bool CanStreamWrite(void);
00068 
00069   // see super class for documentation
00070   //
00071   // overidden to return true only when supported
00072   virtual bool CanStreamRead(void);
00073 
00074 
00075   /*-------- This part of the interface deals with reading data. ------ */
00076 
00079   virtual bool CanReadFile(const char *);
00080 
00082   virtual void ReadImageInformation();
00083 
00085   virtual void Read(void *buffer);
00086 
00087   /*-------- This part of the interfaces deals with writing data. ----- */
00088 
00091   virtual bool CanWriteFile(const char *);
00092 
00095   virtual void WriteImageInformation() {}
00096 
00099   virtual void Write(const void *buffer);
00100 
00102   virtual SizeType GetHeaderSize() const { return this->m_HeaderSize; }
00103 
00104 protected:
00105   VTKImageIO();
00106   ~VTKImageIO();
00107 
00108   void PrintSelf(std::ostream & os, Indent indent) const;
00109 
00110   void InternalReadImageInformation(std::ifstream & file);
00111 
00112   void WriteImageInformation(const void *buffer);
00113 
00114   void ReadHeaderSize(std::ifstream & file);
00115 
00117   virtual void ReadBufferAsASCII(std::istream & os, void *buffer,
00118                          IOComponentType ctype,
00119                          SizeType numberOfBytesToBeRead);
00120 
00122   virtual void WriteBufferAsASCII(std::ostream & os, const void *buffer,
00123                           IOComponentType ctype,
00124                           SizeType numberOfBytesToWrite);
00125 
00128   virtual void ReadSymmetricTensorBufferAsBinary(std::istream& os,
00129     void *buffer,
00130     StreamingImageIOBase::SizeType num);
00131 
00134   virtual void WriteSymmetricTensorBufferAsBinary(std::ostream& os,
00135     const void *buffer,
00136     StreamingImageIOBase::SizeType num);
00137 
00138 private:
00139   VTKImageIO(const Self &);    //purposely not implemented
00140   void operator=(const Self &); //purposely not implemented
00141   void SetPixelTypeFromString(const std::string & pixelType);
00142 
00143   SizeType m_HeaderSize;
00144 };
00145 } // end namespace itk
00146 
00147 #endif // __itkVTKImageIO_h
00148