SimpleITK  1.1.0
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); }
94  SITK_RETURN_SELF_TYPE_HEADER SetKeepOriginalImageUID( bool KeepOriginalImageUID );
95  bool GetKeepOriginalImageUID( void ) const;
96 
97  SITK_RETURN_SELF_TYPE_HEADER KeepOriginalImageUIDOn( void ) { return this->SetKeepOriginalImageUID(true); }
98  SITK_RETURN_SELF_TYPE_HEADER KeepOriginalImageUIDOff( void ) { return this->SetKeepOriginalImageUID(false); }
101  SITK_RETURN_SELF_TYPE_HEADER SetFileName ( const std::string &fileName );
102  std::string GetFileName() const;
103 
104  SITK_RETURN_SELF_TYPE_HEADER Execute ( const Image& );
105  SITK_RETURN_SELF_TYPE_HEADER Execute ( const Image& , const std::string &inFileName, bool useCompression );
106 
107  private:
108 
109  itk::SmartPointer<ImageIOBase> GetImageIOBase(const std::string &fileName);
110 
111  template <class T> Self& ExecuteInternal ( const Image& );
112 
114  std::string m_FileName;
116 
117  // function pointer type
118  typedef Self& (Self::*MemberFunctionType)( const Image& );
119 
120  // friend to get access to executeInternal member
121  friend struct detail::MemberFunctionAddressor<MemberFunctionType>;
122 
123  nsstd::auto_ptr<detail::MemberFunctionFactory<MemberFunctionType> > m_MemberFactory;
124 
125  };
126 
127  SITKIO_EXPORT void WriteImage ( const Image& image, const std::string &fileName, bool useCompression=false );
128  }
129 }
130 
131 #endif
itk::simple::Image
The main Image class for SimpleITK.
Definition: sitkImage.h:54
itk::simple::ImageFileWriter::m_MemberFactory
nsstd::auto_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
Definition: sitkImageFileWriter.h:123
itk::simple::WriteImage
SITKIO_EXPORT void WriteImage(const Image &image, const std::string &fileName, bool useCompression=false)
itk::simple::detail::MemberFunctionAddressor
Definition: sitkDetail.h:32
itk::simple::ImageFileWriter::KeepOriginalImageUIDOn
Self & KeepOriginalImageUIDOn(void)
Use the original study/series/frame of reference.
Definition: sitkImageFileWriter.h:97
itk::simple::ImageFileWriter::m_UseCompression
bool m_UseCompression
Definition: sitkImageFileWriter.h:113
SITKIO_EXPORT
#define SITKIO_EXPORT
Definition: sitkIO.h:33
itk::simple::NonLabelPixelIDTypeList
typelist::Append< typelist::Append< BasicPixelIDTypeList, ComplexPixelIDTypeList >::Type, VectorPixelIDTypeList >::Type NonLabelPixelIDTypeList
Definition: sitkPixelIDTypeLists.h:180
sitkImage.h
itk::SmartPointer
Definition: sitkImage.h:40
itk::simple::ioutils::GetRegisteredImageIOs
SITKIO_HIDDEN std::vector< std::string > GetRegisteredImageIOs()
sitkMemberFunctionFactory.h
itk::simple::ImageFileWriter::Self
ImageFileWriter Self
Definition: sitkImageFileWriter.h:52
itk::simple::ImageFileWriter::m_KeepOriginalImageUID
bool m_KeepOriginalImageUID
Definition: sitkImageFileWriter.h:115
sitkProcessObject.h
sitkMacro.h
itk::simple::ImageFileWriter::m_FileName
std::string m_FileName
Definition: sitkImageFileWriter.h:114
itk
itk::simple::ProcessObject
Base class for SimpleITK classes based on ProcessObject.
Definition: sitkProcessObject.h:50
itk::simple::ImageFileWriter::PixelIDTypeList
NonLabelPixelIDTypeList PixelIDTypeList
Definition: sitkImageFileWriter.h:55
itk::simple::ImageFileWriter::MemberFunctionType
Self &(Self::* MemberFunctionType)(const Image &)
Definition: sitkImageFileWriter.h:118
itk::simple::ImageFileWriter::GetName
virtual std::string GetName() const
Definition: sitkImageFileWriter.h:65
sitkIO.h
itk::simple::ImageFileWriter::KeepOriginalImageUIDOff
Self & KeepOriginalImageUIDOff(void)
Use the original study/series/frame of reference.
Definition: sitkImageFileWriter.h:98
itk::simple::ImageFileWriter
Write out a SimpleITK image to the specified file location.
Definition: sitkImageFileWriter.h:48
itk::simple::ImageFileWriter::UseCompressionOff
Self & UseCompressionOff(void)
Enable compression if available for file type.
Definition: sitkImageFileWriter.h:82
itk::simple::ImageFileWriter::UseCompressionOn
Self & UseCompressionOn(void)
Enable compression if available for file type.
Definition: sitkImageFileWriter.h:81