ITK  5.2.0
Insight Toolkit
itkCSVNumericObjectFileWriter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 {
61 template <typename TValue, unsigned int NRows = 0, unsigned int NColumns = 0>
62 class ITK_TEMPLATE_EXPORT CSVNumericObjectFileWriter : public LightProcessObject
63 {
64 public:
65  ITK_DISALLOW_COPY_AND_MOVE(CSVNumericObjectFileWriter);
66 
72 
74  itkNewMacro(Self);
75 
78 
79  // Matrix types
80  using vnlMatrixType = vnl_matrix<TValue>;
81  using vnlFixedMatrixType = vnl_matrix_fixed<TValue, NRows, NColumns>;
83 
84  using StringVectorType = std::vector<std::string>;
85 
87 
88  /* Specify the name of the output file */
89  itkSetStringMacro(FileName);
90  itkSetMacro(FieldDelimiterCharacter, char);
91 
93  void
94  SetInput(const vnlMatrixType * obj);
95 
97  void
98  SetInput(const vnlFixedMatrixType * obj);
99 
101  void
102  SetInput(const itkMatrixType * obj);
103 
104  void
105  ColumnHeadersPushBack(const std::string &);
106  void
107  RowHeadersPushBack(const std::string &);
108  void
109  SetColumnHeaders(const StringVectorType & columnheaders);
110  void
111  SetRowHeaders(const StringVectorType & rowheaders);
112 
113  /* Checks that all essential components are plugged in */
114  void
115  PrepareForWriting();
116 
118  virtual void
119  Write();
120 
123  virtual void
124  Update();
125 
126 protected:
128  ~CSVNumericObjectFileWriter() override = default;
129  void
130  PrintSelf(std::ostream & os, Indent indent) const override;
131 
132 private:
133  std::string m_FileName;
134  TValue * m_InputObject;
140 };
141 
142 } // end namespace itk
143 
144 #ifndef ITK_MANUAL_INSTANTIATION
145 # include "itkCSVNumericObjectFileWriter.hxx"
146 #endif
147 
148 #endif
itk::LightProcessObject
LightProcessObject is the base class for all process objects (source, filters, mappers) in the Insigh...
Definition: itkLightProcessObject.h:72
itk::CSVNumericObjectFileWriter::vnlFixedMatrixType
vnl_matrix_fixed< TValue, NRows, NColumns > vnlFixedMatrixType
Definition: itkCSVNumericObjectFileWriter.h:81
itkMatrix.h
itk::CSVNumericObjectFileWriter::m_InputObject
TValue * m_InputObject
Definition: itkCSVNumericObjectFileWriter.h:134
itk::CSVNumericObjectFileWriter::m_Columns
SizeValueType m_Columns
Definition: itkCSVNumericObjectFileWriter.h:137
itkLightProcessObject.h
itk::CSVNumericObjectFileWriter::m_Rows
SizeValueType m_Rows
Definition: itkCSVNumericObjectFileWriter.h:136
itk::CSVNumericObjectFileWriter::SizeValueType
itk::Size< 2 >::SizeValueType SizeValueType
Definition: itkCSVNumericObjectFileWriter.h:86
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::CSVNumericObjectFileWriter::m_ColumnHeaders
StringVectorType m_ColumnHeaders
Definition: itkCSVNumericObjectFileWriter.h:138
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itkMacro.h
itk::CSVNumericObjectFileWriter::m_FieldDelimiterCharacter
char m_FieldDelimiterCharacter
Definition: itkCSVNumericObjectFileWriter.h:135
itk::Size::SizeValueType
::itk::SizeValueType SizeValueType
Definition: itkSize.h:80
itk::Matrix
A templated class holding a M x N size Matrix.
Definition: itkMatrix.h:51
itk::CSVNumericObjectFileWriter
Writes out numeric itk data objects to a csv file.
Definition: itkCSVNumericObjectFileWriter.h:62
itk::CSVNumericObjectFileWriter::m_RowHeaders
StringVectorType m_RowHeaders
Definition: itkCSVNumericObjectFileWriter.h:139
itkArray2D.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::CSVNumericObjectFileWriter::m_FileName
std::string m_FileName
Definition: itkCSVNumericObjectFileWriter.h:133
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itk::CSVNumericObjectFileWriter::vnlMatrixType
vnl_matrix< TValue > vnlMatrixType
Definition: itkCSVNumericObjectFileWriter.h:80
itk::CSVNumericObjectFileWriter::StringVectorType
std::vector< std::string > StringVectorType
Definition: itkCSVNumericObjectFileWriter.h:84
itkSize.h