/usr/include/ITK-4.5/itkCSVNumericObjectFileWriter.h is in libinsighttoolkit4-dev 4.5.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | /*=========================================================================
*
* Copyright Insight Software Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef __itkCSVNumericObjectFileWriter_h
#define __itkCSVNumericObjectFileWriter_h
#include "itkLightProcessObject.h"
#include "itkMacro.h"
#include "itkArray2D.h"
#include "vnl/vnl_matrix.h"
#include "vnl/vnl_matrix_fixed.h"
#include "itkMatrix.h"
#include <vector>
#include "itkSize.h"
namespace itk
{
/** \class CSVNumericObjectFileWriter
* \brief Writes out numeric itk data objects to a csv file.
*
* CSVNumericObjectFileWriter writes numeric data from an itk object into a
* csv file. It is templated over the type of data being written, the number
* of rows and the number of columns. The writer uses the datablock member from
* vnl_matrix or vnl_matrix_fixed. As of now the objects itkMatrix, itkArray2D,
* and any vnl_matrix based objects are supported.
*
* The user specifies the file name and the field delimiter character using
* the Set macro method for each. The user can also write out row and column
* headers. The methods ColumnHeadersPushBack() and RowHeadersPushBack() can be
* used to push strings into the vectors for row and column headers. The row
* and column headers can also be set using the Set macro methods for each if
* vectors for the headers are already set. The SetInput() method is overloaded
* to allow various itk objects to be set as input.
*
* The method Write() is used to output the object data to a csv file.
*
* The writer will output a warning if the number of row headers is not
* consistent with the number of rows in the input object or if the number of
* column headers is not consistent with the number of columns in the input
* object. It is up to the user to check this.
*
*
* \ingroup ITKIOCSV
*/
template <typename TValueType, unsigned int NRows = 0, unsigned int NColumns = 0>
class CSVNumericObjectFileWriter:public LightProcessObject
{
public:
/** Standard class typedefs */
typedef CSVNumericObjectFileWriter Self;
typedef LightProcessObject Superclass;
typedef SmartPointer <Self> Pointer;
typedef SmartPointer <const Self> ConstPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(Self,Superclass);
// Matrix types
typedef vnl_matrix<TValueType> vnlMatrixType;
typedef vnl_matrix_fixed<TValueType, NRows, NColumns> vnlFixedMatrixType;
typedef itk::Matrix<TValueType,NRows,NColumns> itkMatrixType;
typedef std::vector<std::string> StringVectorType;
typedef itk::Size<2>::SizeValueType SizeValueType;
/* Specify the name of the output file */
itkSetStringMacro(FileName);
itkSetMacro(FieldDelimiterCharacter,char);
/** Set the input object if the matrix is of vnl_matrix type or Array2D. */
void SetInput(const vnlMatrixType* obj);
/** Set the input object if the matrix is of vnl_matrix_fixed type. */
void SetInput(const vnlFixedMatrixType* obj);
/** Set the input object if the matrix is of itkMatrixType. */
void SetInput(const itkMatrixType* obj);
void ColumnHeadersPushBack(const std::string & );
void RowHeadersPushBack(const std::string & );
void SetColumnHeaders(const StringVectorType & columnheaders);
void SetRowHeaders(const StringVectorType & rowheaders);
/* Checks that all essential components are plugged in */
void PrepareForWriting();
/** Write out the object */
virtual void Write();
/** Aliased to the Write() method to be consistent with the rest of the
* pipeline. */
virtual void Update();
protected:
CSVNumericObjectFileWriter();
virtual ~CSVNumericObjectFileWriter() {}
void PrintSelf(std::ostream &os, Indent indent) const;
private:
std::string m_FileName;
TValueType *m_InputObject;
char m_FieldDelimiterCharacter;
SizeValueType m_Rows;
SizeValueType m_Columns;
StringVectorType m_ColumnHeaders;
StringVectorType m_RowHeaders;
CSVNumericObjectFileWriter(const Self &); //purposely not implemented
void operator=(const Self &); //purposely not implemented
};
} //end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkCSVNumericObjectFileWriter.hxx"
#endif
#endif
|