SimpleITK  1.2.4
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 decalaration 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); }
97  virtual SITK_RETURN_SELF_TYPE_HEADER SetImageIO(const std::string &imageio);
98  virtual std::string GetImageIO( void ) const;
99  /* @} */
100 
101 
110  SITK_RETURN_SELF_TYPE_HEADER SetKeepOriginalImageUID( bool KeepOriginalImageUID );
111  bool GetKeepOriginalImageUID( void ) const;
112 
113  SITK_RETURN_SELF_TYPE_HEADER KeepOriginalImageUIDOn( void ) { return this->SetKeepOriginalImageUID(true); }
114  SITK_RETURN_SELF_TYPE_HEADER KeepOriginalImageUIDOff( void ) { return this->SetKeepOriginalImageUID(false); }
117  SITK_RETURN_SELF_TYPE_HEADER SetFileName ( const std::string &fileName );
118  std::string GetFileName() const;
119 
120  SITK_RETURN_SELF_TYPE_HEADER Execute ( const Image& );
121  SITK_RETURN_SELF_TYPE_HEADER Execute ( const Image& , const std::string &inFileName, bool useCompression );
122 
123  private:
124 
125  itk::SmartPointer<ImageIOBase> GetImageIOBase(const std::string &fileName);
126 
127  template <class T> Self& ExecuteInternal ( const Image& );
128 
130  std::string m_FileName;
132  std::string m_ImageIOName;
133 
134  // function pointer type
135  typedef Self& (Self::*MemberFunctionType)( const Image& );
136 
137  // friend to get access to executeInternal member
138  friend struct detail::MemberFunctionAddressor<MemberFunctionType>;
139 
140  nsstd::auto_ptr<detail::MemberFunctionFactory<MemberFunctionType> > m_MemberFactory;
141 
142  };
143 
144  SITKIO_EXPORT void WriteImage ( const Image& image, const std::string &fileName, bool useCompression=false );
145  }
146 }
147 
148 #endif
typelist::Append< typelist::Append< BasicPixelIDTypeList, ComplexPixelIDTypeList >::Type, VectorPixelIDTypeList >::Type NonLabelPixelIDTypeList
Self & UseCompressionOn(void)
Enable compression if available for file type.
SITKIO_EXPORT void WriteImage(const Image &image, const std::string &fileName, bool useCompression=false)
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.
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.