ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkFDFImageIO.h
Go to the documentation of this file.
1 /* Copyright (C) 2004 Glenn Pierce.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU Library General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16  */
17 
18 #ifndef __itkFDFImageIO_h
19 #define __itkFDFImageIO_h
20 #include "ITKIOFDFExport.h"
21 #include "itkImageIOBase.h"
22 
23 namespace itk
24 {
25 
26 /* \brief ImageIO object for reading and writing FDF images
27  *
28  * \ingroup IOFilters
29  *
30  */
31 class ITKIOFDF_EXPORT FDFImageIO : public ImageIOBase
32 {
33 public:
35  typedef FDFImageIO Self;
38 
40  itkNewMacro(Self);
41 
43  itkTypeMacro(FDFImageIO, ImageIOBase);
44 
45  virtual bool SupportsDimension( unsigned long dim )
46  {
47  if( dim == 2 || dim == 3 )
48  {
49  return true;
50  }
51  else
52  {
53  return false;
54  }
55  }
56 
57 
58  /*-------- This part of the interface deals with reading data. ------ */
59 
62  virtual bool CanReadFile(const char*);
63 
65  virtual void ReadImageInformation();
66 
68 // virtual const std::type_info& GetPixelType() const;
69 
71  virtual void Read(void* buffer);
72 
74  virtual void ReadVolume(void* buffer);
75 
79 // virtual unsigned int GetComponentSize() const;
80 
81  /*-------- This part of the interfaces deals with writing data. ----- */
82 
85  virtual bool CanWriteFile(const char*);
86 
89  virtual void WriteImageInformation();
90 
93  virtual void Write(const void* buffer);
94 
95 protected:
96  FDFImageIO();
97  ~FDFImageIO();
98  void PrintSelf(std::ostream& os, Indent indent) const;
99 
100  void WriteSlice(std::string& fileName, const void* buffer);
101 
102  int ReadHeader(const char *FileNameToRead);
103 
104 private:
105  FDFImageIO(const Self&); //purposely not implemented
106  void operator=(const Self&); //purposely not implemented
107 
108  void SwapBytesIfNecessary(void* buffer, unsigned long numberOfPixels);
109 
110  // Position after ReadImageInformation.
112 
113  std::string m_SpatialRank;
114  std::string m_Checksum;
115  std::string m_Bits;
116  std::vector<int> m_Size;
117  std::vector<float> m_Location;
118  std::vector<float> m_Span;
119  std::vector<float> m_Roi;
120 };
121 
122 } // end namespace itk
123 
124 
125 #define RAISE_EXCEPTION() \
126  { ExceptionObject exception(__FILE__, __LINE__); \
127  exception.SetDescription("File cannot be read"); \
128  throw exception; }
129 
130 #endif
ImageIOBase Superclass
Definition: itkFDFImageIO.h:36
Light weight base class for most itk classes.
FDFImageIO Self
Definition: itkFDFImageIO.h:35
virtual bool SupportsDimension(unsigned long dim)
Definition: itkFDFImageIO.h:45
std::string m_Bits
Abstract superclass defines image IO interface.
std::string m_Checksum
std::vector< float > m_Location
std::vector< float > m_Span
std::string m_SpatialRank
SmartPointer< Self > Pointer
Definition: itkFDFImageIO.h:37
vcl_size_t m_InputPosition
std::vector< float > m_Roi
std::vector< int > m_Size
Control indentation during Print() invocation.
Definition: itkIndent.h:49