ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkImageFileWriter_h 00019 #define __itkImageFileWriter_h 00020 00021 #include "itkProcessObject.h" 00022 #include "itkImageIOBase.h" 00023 #include "itkMacro.h" 00024 00025 namespace itk 00026 { 00032 class ITK_ABI_EXPORT ImageFileWriterException:public ExceptionObject 00033 { 00034 public: 00036 itkTypeMacro(ImageFileWriterException, ExceptionObject); 00037 00039 ImageFileWriterException(const char *file, unsigned int line, 00040 const char *message = "Error in IO", 00041 const char *loc = "Unknown"): 00042 ExceptionObject(file, line, message, loc) 00043 {} 00044 00046 ImageFileWriterException(const std::string & file, unsigned int line, 00047 const char *message = "Error in IO", 00048 const char *loc = "Unknown"): 00049 ExceptionObject(file, line, message, loc) 00050 {} 00051 }; 00053 00080 template< class TInputImage > 00081 class ITK_EXPORT ImageFileWriter:public ProcessObject 00082 { 00083 public: 00085 typedef ImageFileWriter Self; 00086 typedef ProcessObject Superclass; 00087 typedef SmartPointer< Self > Pointer; 00088 typedef SmartPointer< const Self > ConstPointer; 00089 00091 itkNewMacro(Self); 00092 00094 itkTypeMacro(ImageFileWriter, ProcessObject); 00095 00097 typedef TInputImage InputImageType; 00098 typedef typename InputImageType::Pointer InputImagePointer; 00099 typedef typename InputImageType::RegionType InputImageRegionType; 00100 typedef typename InputImageType::PixelType InputImagePixelType; 00101 00103 using Superclass::SetInput; 00104 void SetInput(const InputImageType *input); 00105 00106 const InputImageType * GetInput(void); 00107 00108 const InputImageType * GetInput(unsigned int idx); 00109 00111 itkSetStringMacro(FileName); 00112 itkGetStringMacro(FileName); 00114 00125 void SetImageIO(ImageIOBase *io) 00126 { 00127 if ( this->m_ImageIO != io ) 00128 { 00129 this->Modified(); 00130 this->m_ImageIO = io; 00131 } 00132 m_FactorySpecifiedImageIO = false; 00133 } 00135 00136 itkGetObjectMacro(ImageIO, ImageIOBase); 00137 00145 virtual void Write(void); 00146 00149 void SetIORegion(const ImageIORegion & region); 00150 00151 const ImageIORegion & GetIORegion(void) const 00152 { 00153 return m_PasteIORegion; 00154 } 00155 00158 itkSetMacro(NumberOfStreamDivisions, unsigned int); 00159 itkGetConstReferenceMacro(NumberOfStreamDivisions, unsigned int); 00161 00164 virtual void Update() 00165 { 00166 this->Write(); 00167 } 00168 00174 virtual void UpdateLargestPossibleRegion() 00175 { 00176 m_PasteIORegion = ImageIORegion(TInputImage::ImageDimension); 00177 m_UserSpecifiedIORegion = false; 00178 this->Write(); 00179 } 00180 00182 itkSetMacro(UseCompression, bool); 00183 itkGetConstReferenceMacro(UseCompression, bool); 00184 itkBooleanMacro(UseCompression); 00186 00193 itkSetMacro(UseInputMetaDataDictionary, bool); 00194 itkGetConstReferenceMacro(UseInputMetaDataDictionary, bool); 00195 itkBooleanMacro(UseInputMetaDataDictionary); 00196 protected: 00197 ImageFileWriter(); 00198 ~ImageFileWriter(); 00199 void PrintSelf(std::ostream & os, Indent indent) const; 00201 00203 void GenerateData(void); 00204 00205 private: 00206 ImageFileWriter(const Self &); //purposely not implemented 00207 void operator=(const Self &); //purposely not implemented 00208 00209 std::string m_FileName; 00210 00211 ImageIOBase::Pointer m_ImageIO; 00212 bool m_UserSpecifiedImageIO; // track whether the ImageIO 00213 // is user specified 00214 00215 ImageIORegion m_PasteIORegion; 00216 unsigned int m_NumberOfStreamDivisions; 00217 bool m_UserSpecifiedIORegion; // track whether the region 00218 // is user specified 00219 bool m_FactorySpecifiedImageIO; //track whether the factory 00220 // mechanism set the ImageIO 00221 bool m_UseCompression; 00222 bool m_UseInputMetaDataDictionary; // whether to use the 00223 // MetaDataDictionary from the 00224 // input or not. 00225 }; 00226 } // end namespace itk 00227 00228 #ifndef ITK_MANUAL_INSTANTIATION 00229 #include "itkImageFileWriter.hxx" 00230 #endif 00231 00232 #ifdef ITK_IO_FACTORY_REGISTER_MANAGER 00233 #include "itkImageIOFactoryRegisterManager.h" 00234 #endif 00235 00236 #endif // __itkImageFileWriter_h 00237