SimpleITK  1.3.0.dev466
sitkImageFileWriter.h
Go to the documentation of this file.
1 /*=========================================================================
2 *
3 * Copyright Insight Software Consortium
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18 #ifndef sitkImageFileWriter_h
19 #define sitkImageFileWriter_h
20 
21 #include "sitkMacro.h"
22 #include "sitkImage.h"
24 #include "sitkIO.h"
25 #include "sitkProcessObject.h"
26 
27 #include <memory>
28 
29 namespace itk {
30 
31 // Forward declaration for pointer
32 class ImageIOBase;
33 
34 template<class T>
35 class SmartPointer;
36 
37  namespace simple {
38 
49  public ProcessObject
50  {
51  public:
53 
54  // list of pixel types supported
56 
57  virtual ~ImageFileWriter();
58 
60 
62  virtual std::string ToString() const;
63 
65  virtual std::string GetName() const { return std::string("ImageFileWriter"); }
66 
69  virtual std::vector<std::string> GetRegisteredImageIOs() const;
70 
71 
78  SITK_RETURN_SELF_TYPE_HEADER SetUseCompression( bool UseCompression );
79  bool GetUseCompression( void ) const;
80 
81  SITK_RETURN_SELF_TYPE_HEADER UseCompressionOn( void ) { return this->SetUseCompression(true); }
82  SITK_RETURN_SELF_TYPE_HEADER UseCompressionOff( void ) { return this->SetUseCompression(false); }
92  SITK_RETURN_SELF_TYPE_HEADER SetCompressionLevel(int);
93  int GetCompressionLevel(void) const;
102  SITK_RETURN_SELF_TYPE_HEADER SetCompressor(const std::string &);
103  std::string GetCompressor(void);
118  virtual SITK_RETURN_SELF_TYPE_HEADER SetImageIO(const std::string &imageio);
119  virtual std::string GetImageIO( void ) const;
120  /* @} */
121 
122 
131  SITK_RETURN_SELF_TYPE_HEADER SetKeepOriginalImageUID( bool KeepOriginalImageUID );
132  bool GetKeepOriginalImageUID( void ) const;
133 
134  SITK_RETURN_SELF_TYPE_HEADER KeepOriginalImageUIDOn( void ) { return this->SetKeepOriginalImageUID(true); }
135  SITK_RETURN_SELF_TYPE_HEADER KeepOriginalImageUIDOff( void ) { return this->SetKeepOriginalImageUID(false); }
138  SITK_RETURN_SELF_TYPE_HEADER SetFileName ( const std::string &fileName );
139  std::string GetFileName() const;
140 
141  SITK_RETURN_SELF_TYPE_HEADER Execute ( const Image& );
142  SITK_RETURN_SELF_TYPE_HEADER Execute ( const Image& , const std::string &inFileName, bool useCompression, int compressionLevel );
143 
144  private:
145 
146  itk::SmartPointer<ImageIOBase> GetImageIOBase(const std::string &fileName);
147 
148  template <class T> Self& ExecuteInternal ( const Image& );
149 
152  std::string m_Compressor;
153 
154  std::string m_FileName;
156  std::string m_ImageIOName;
157 
158  // function pointer type
159  typedef Self& (Self::*MemberFunctionType)( const Image& );
160 
161  // friend to get access to executeInternal member
162  friend struct detail::MemberFunctionAddressor<MemberFunctionType>;
163 
164  nsstd::auto_ptr<detail::MemberFunctionFactory<MemberFunctionType> > m_MemberFactory;
165 
166  };
167 
168  SITKIO_EXPORT void WriteImage ( const Image& image,
169  const std::string &fileName,
170  bool useCompression=false,
171  int compressionLevel=-1);
172  }
173 }
174 
175 #endif
typelist::Append< typelist::Append< BasicPixelIDTypeList, ComplexPixelIDTypeList >::Type, VectorPixelIDTypeList >::Type NonLabelPixelIDTypeList
Self & UseCompressionOn(void)
Enable compression if available for file type.
Self & KeepOriginalImageUIDOff(void)
Use the original study/series/frame of reference.
virtual std::string GetName() const
Self &(Self::* MemberFunctionType)(const Image &)
Write out a SimpleITK image to the specified file location.
SITKIO_EXPORT void WriteImage(const Image &image, const std::string &fileName, bool useCompression=false, int compressionLevel=-1)
Self & UseCompressionOff(void)
Enable compression if available for file type.
Self & KeepOriginalImageUIDOn(void)
Use the original study/series/frame of reference.
#define SITKIO_EXPORT
Definition: sitkIO.h:33
The Image class for SimpleITK.
Definition: sitkImage.h:78
nsstd::auto_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
NonLabelPixelIDTypeList PixelIDTypeList
SITKIO_HIDDEN std::vector< std::string > GetRegisteredImageIOs()
Base class for SimpleITK classes based on ProcessObject.