SimpleITK  1.0.1
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  ImageFileWriter( void );
58 
60  virtual std::string ToString() const;
61 
63  virtual std::string GetName() const { return std::string("ImageFileWriter"); }
64 
71  SITK_RETURN_SELF_TYPE_HEADER SetUseCompression( bool UseCompression );
72  bool GetUseCompression( void ) const;
73 
74  SITK_RETURN_SELF_TYPE_HEADER UseCompressionOn( void ) { return this->SetUseCompression(true); }
75  SITK_RETURN_SELF_TYPE_HEADER UseCompressionOff( void ) { return this->SetUseCompression(false); }
87  SITK_RETURN_SELF_TYPE_HEADER SetKeepOriginalImageUID( bool KeepOriginalImageUID );
88  bool GetKeepOriginalImageUID( void ) const;
89 
90  SITK_RETURN_SELF_TYPE_HEADER KeepOriginalImageUIDOn( void ) { return this->SetKeepOriginalImageUID(true); }
91  SITK_RETURN_SELF_TYPE_HEADER KeepOriginalImageUIDOff( void ) { return this->SetKeepOriginalImageUID(false); }
94  SITK_RETURN_SELF_TYPE_HEADER SetFileName ( const std::string &fileName );
95  std::string GetFileName() const;
96 
97  SITK_RETURN_SELF_TYPE_HEADER Execute ( const Image& );
98  SITK_RETURN_SELF_TYPE_HEADER Execute ( const Image& , const std::string &inFileName, bool inUseCompression );
99 
100  private:
101 
102  itk::SmartPointer<ImageIOBase> GetImageIOBase(const std::string &fileName);
103 
104  template <class T> Self& ExecuteInternal ( const Image& );
105 
107  std::string m_FileName;
109 
110  // function pointer type
111  typedef Self& (Self::*MemberFunctionType)( const Image& );
112 
113  // friend to get access to executeInternal member
114  friend struct detail::MemberFunctionAddressor<MemberFunctionType>;
115 
116  nsstd::auto_ptr<detail::MemberFunctionFactory<MemberFunctionType> > m_MemberFactory;
117 
118  };
119 
120  SITKIO_EXPORT void WriteImage ( const Image& image, const std::string &fileName, bool useCompression=false );
121  }
122 }
123 
124 #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:34
The main Image class for SimpleITK.
Definition: sitkImage.h:54
nsstd::auto_ptr< detail::MemberFunctionFactory< MemberFunctionType > > m_MemberFactory
NonLabelPixelIDTypeList PixelIDTypeList
Base class for SimpleITK classes based on ProcessObject.