ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkCSVNumericObjectFileWriter.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 
19 #ifndef itkCSVNumericObjectFileWriter_h
20 #define itkCSVNumericObjectFileWriter_h
21 
22 #include "itkLightProcessObject.h"
23 #include "itkMacro.h"
24 #include "itkArray2D.h"
25 #include "vnl/vnl_matrix.h"
26 #include "vnl/vnl_matrix_fixed.h"
27 #include "itkMatrix.h"
28 #include <vector>
29 #include "itkSize.h"
30 
31 namespace itk
32 {
60 template <typename TValue, unsigned int NRows = 0, unsigned int NColumns = 0>
61 class ITK_TEMPLATE_EXPORT CSVNumericObjectFileWriter:public LightProcessObject
62 {
63 public:
64  ITK_DISALLOW_COPY_AND_ASSIGN(CSVNumericObjectFileWriter);
65 
71 
73  itkNewMacro(Self);
74 
77 
78  // Matrix types
79  using vnlMatrixType = vnl_matrix<TValue>;
80  using vnlFixedMatrixType = vnl_matrix_fixed<TValue, NRows, NColumns>;
82 
83  using StringVectorType = std::vector<std::string>;
84 
86 
87  /* Specify the name of the output file */
88  itkSetStringMacro(FileName);
89  itkSetMacro(FieldDelimiterCharacter,char);
90 
92  void SetInput(const vnlMatrixType* obj);
93 
95  void SetInput(const vnlFixedMatrixType* obj);
96 
98  void SetInput(const itkMatrixType* obj);
99 
100  void ColumnHeadersPushBack(const std::string & );
101  void RowHeadersPushBack(const std::string & );
102  void SetColumnHeaders(const StringVectorType & columnheaders);
103  void SetRowHeaders(const StringVectorType & rowheaders);
104 
105  /* Checks that all essential components are plugged in */
106  void PrepareForWriting();
107 
109  virtual void Write();
110 
113  virtual void Update();
114 
115 protected:
116 
118  ~CSVNumericObjectFileWriter() override = default;
119  void PrintSelf(std::ostream &os, Indent indent) const override;
120 
121 private:
122  std::string m_FileName;
123  TValue *m_InputObject;
129 
130 };
131 
132 } //end namespace itk
133 
134 #ifndef ITK_MANUAL_INSTANTIATION
135 #include "itkCSVNumericObjectFileWriter.hxx"
136 #endif
137 
138 #endif
A templated class holding a M x N size Matrix.
Definition: itkMatrix.h:49
Light weight base class for most itk classes.
Writes out numeric itk data objects to a csv file.
::itk::SizeValueType SizeValueType
Definition: itkSize.h:79
LightProcessObject is the base class for all process objects (source, filters, mappers) in the Insigh...
Control indentation during Print() invocation.
Definition: itkIndent.h:49
vnl_matrix_fixed< TValue, NRows, NColumns > vnlFixedMatrixType
itk::Size< 2 >::SizeValueType SizeValueType
Base class for most ITK classes.
Definition: itkObject.h:60