ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkCSVNumericObjectFileWriter.h
Go to the documentation of this file.
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 
00019 #ifndef __itkCSVNumericObjectFileWriter_h
00020 #define __itkCSVNumericObjectFileWriter_h
00021 
00022 #include "itkLightProcessObject.h"
00023 #include "itkMacro.h"
00024 #include "itkArray2D.h"
00025 #include "vnl/vnl_matrix.h"
00026 #include "vnl/vnl_matrix_fixed.h"
00027 #include "itkMatrix.h"
00028 #include <vector>
00029 #include "itkSize.h"
00030 
00031 namespace itk
00032 {
00060 template <class TValueType, unsigned int NRows = 0, unsigned int NColumns = 0>
00061 class ITK_EXPORT CSVNumericObjectFileWriter:public LightProcessObject
00062 {
00063 public:
00065   typedef CSVNumericObjectFileWriter    Self;
00066   typedef LightProcessObject            Superclass;
00067   typedef SmartPointer <Self>           Pointer;
00068   typedef SmartPointer <const Self>     ConstPointer;
00069 
00071   itkNewMacro(Self);
00072 
00074   itkTypeMacro(Self,Superclass);
00075 
00076   // Matrix types
00077   typedef vnl_matrix<TValueType>                        vnlMatrixType;
00078   typedef vnl_matrix_fixed<TValueType, NRows, NColumns> vnlFixedMatrixType;
00079   typedef itk::Matrix<TValueType,NRows,NColumns>        itkMatrixType;
00080 
00081   typedef std::vector<std::string> StringVectorType;
00082 
00083   typedef itk::Size<2>::SizeValueType SizeValueType;
00084 
00085   /* Specify the name of the output file */
00086   itkSetStringMacro(FileName);
00087   itkSetMacro(FieldDelimiterCharacter,char);
00088 
00090   void SetInput(const vnlMatrixType* obj);
00091 
00093   void SetInput(const vnlFixedMatrixType* obj);
00094 
00096   void SetInput(const itkMatrixType* obj);
00097 
00098   void ColumnHeadersPushBack(const std::string & );
00099   void RowHeadersPushBack(const std::string & );
00100   void SetColumnHeaders(const StringVectorType & columnheaders);
00101   void SetRowHeaders(const StringVectorType & rowheaders);
00102 
00103   /* Checks that all essential components are plugged in */
00104   void PrepareForWriting();
00105 
00107   virtual void Write();
00108 
00111   virtual void Update();
00112 
00113 protected:
00114 
00115   CSVNumericObjectFileWriter();
00116   virtual ~CSVNumericObjectFileWriter() {}
00117   void PrintSelf(std::ostream &os, Indent indent) const;
00118 
00119 private:
00120   std::string               m_FileName;
00121   TValueType               *m_InputObject;
00122   char                      m_FieldDelimiterCharacter;
00123   SizeValueType             m_Rows;
00124   SizeValueType             m_Columns;
00125   StringVectorType          m_ColumnHeaders;
00126   StringVectorType          m_RowHeaders;
00127 
00128   CSVNumericObjectFileWriter(const Self &);  //purposely not implemented
00129   void operator=(const Self &);                //purposely not implemented
00130 };
00131 
00132 } //end namespace itk
00133 
00134 #ifndef ITK_MANUAL_INSTANTIATION
00135 #include "itkCSVNumericObjectFileWriter.hxx"
00136 #endif
00137 
00138 #endif
00139