ITK  5.4.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  * https://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 VRows = 0, unsigned int VColumns = 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 
77  itkOverrideGetNameOfClassMacro(CSVNumericObjectFileWriter);
78 
79  // Matrix types
80  using vnlMatrixType = vnl_matrix<TValue>;
81  using vnlFixedMatrixType = vnl_matrix_fixed<TValue, VRows, VColumns>;
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{};
135  char m_FieldDelimiterCharacter{};
136  SizeValueType m_Rows{};
137  SizeValueType m_Columns{};
138  StringVectorType m_ColumnHeaders{};
139  StringVectorType m_RowHeaders{};
140 };
141 
142 } // end namespace itk
143 
144 #ifndef ITK_MANUAL_INSTANTIATION
145 # include "itkCSVNumericObjectFileWriter.hxx"
146 #endif
147 
148 #endif
itk::CSVNumericObjectFileWriter::vnlFixedMatrixType
vnl_matrix_fixed< TValue, VRows, VColumns > vnlFixedMatrixType
Definition: itkCSVNumericObjectFileWriter.h:81
itk::LightProcessObject
LightProcessObject is the base class for all process objects (source, filters, mappers) in the Insigh...
Definition: itkLightProcessObject.h:72
itkMatrix.h
itkLightProcessObject.h
itk::Size::SizeValueType
itk::SizeValueType SizeValueType
Definition: itkSize.h:82
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itkMacro.h
itk::Matrix
A templated class holding a M x N size Matrix.
Definition: itkMatrix.h:52
itk::CSVNumericObjectFileWriter
Writes out numeric itk data objects to a csv file.
Definition: itkCSVNumericObjectFileWriter.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
itkArray2D.h
itk::CSVNumericObjectFileWriter::SizeValueType
itk::Size< 2 >::SizeValueType SizeValueType
Definition: itkCSVNumericObjectFileWriter.h:86
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itkSize.h