/usr/include/ITK-4.5/itkMetaArrayReader.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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | /*=========================================================================
*
* 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 __itkMetaArrayReader_h
#define __itkMetaArrayReader_h
#include "itkLightProcessObject.h"
#include "itkArray.h"
#include "itkCovariantVector.h"
#include "itkVariableLengthVector.h"
#include "metaArray.h"
namespace itk
{
class MetaArrayReader:public LightProcessObject
{
public:
/** SmartPointer typedef support */
typedef MetaArrayReader 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(MetaArrayReader, LightProcessObject);
/** Set the filename */
itkSetStringMacro(FileName);
/** Get the filename */
itkGetStringMacro(FileName);
/** Get a pointer to the metaArray so that you can change
* metaArray options (e.g., add comments and user-defined fields */
MetaArray * GetMetaArrayPointer(void);
/** Specify the buffer (already allocated) into which data should be read */
void SetBuffer(void *_buffer);
/** Read the Array in MetaIO format */
void Update();
/** Return the MetaIO type that corresponds to the element type */
MET_ValueEnumType GetDataType(void) const
{
return m_MetaArray.ElementType();
}
/** Size is used by itkArray and VariableLengthVector */
int Size(void) const
{
return m_MetaArray.Length();
}
/** GetNumberOfElements is used by itkArray and VariableLengthVector */
int GetNumberOfElements(void) const
{
return m_MetaArray.Length();
}
/** GetVectorDimension is used by itkVector */
int GetVectorDimension(void) const
{
return m_MetaArray.Length();
}
/** GetNumberOfComponents is used by itkVector and itkCovariantVector */
int GetNumberOfComponents(void) const
{
return m_MetaArray.Length();
}
/** GetCovariantVectorDimension is used by itkVector */
int GetCovariantVectorDimension(void) const
{
return m_MetaArray.Length();
}
/** GetElement is used by itkArray, itkFixedArray, and VariableLengthVector */
template< typename TValueType >
inline void GetElement(TValueType & value, unsigned int i,
unsigned int channel = 0) const
{
value = static_cast< TValueType >( m_MetaArray.ElementData(
i * m_MetaArray.ElementNumberOfChannels() + channel) );
}
/** Get itk Array
* Specify the MetaType of the elements of the Array and provide a
* pointer to the Array. The buffer of the Array is replaced by the
* buffer into which the data was directly read (a copy does not occur).
* If _letVectorManageData is true, the buffer persists even after this
* MetaArrayReader is destroyed. Otherwise, the buffer (and therefore
* the validity of the dat ain the Array) is destroyed when the
* MetaArrayReader is dstroyed. */
template< typename TValueType >
void GetOutput(MET_ValueEnumType _metaElementType,
Array< TValueType > *_array,
bool _letArrayManageData = true)
{
if ( m_MetaArray.ElementType() != _metaElementType )
{
m_MetaArray.ConvertElementDataTo(_metaElementType);
}
_array->SetData( (TValueType *)( m_MetaArray.ElementData() ),
m_MetaArray.Length(),
_letArrayManageData );
if ( _letArrayManageData )
{
m_MetaArray.AutoFreeElementData(false);
}
}
/** Get itk FixedArray */
template< typename TValueType, unsigned int VLength >
bool GetOutput(MET_ValueEnumType itkNotUsed(_metaElementType),
FixedArray< TValueType, VLength > *_array)
{
if ( static_cast< int >( VLength ) <= m_MetaArray.Length() )
{
unsigned int i;
for ( i = 0; i < VLength; i++ )
{
this->GetElement( ( *_array )[i], i );
}
return true;
}
return false;
}
/** Get itk Vector
* Specify the MetaType of the elements of the itkVector and provide
* a pointer to the itkVector into which the data should be copied */
template< typename TValueType, unsigned int VLength >
bool GetOutput(MET_ValueEnumType itkNotUsed(_metaElementType),
Vector< TValueType, VLength > *_vector)
{
if ( static_cast< int >( VLength ) <= m_MetaArray.Length() )
{
unsigned int i;
for ( i = 0; i < VLength; i++ )
{
this->GetElement( ( *_vector )[i], i );
}
return true;
}
return false;
}
/** Get itk CovariantVector
* Specify the MetaType of the elements of the itkCovariantVector and
* provide a pointer to the itkCovariantVector into which the data
* should be copied */
template< typename TValueType, unsigned int VLength >
bool GetOutput(MET_ValueEnumType itkNotUsed(_metaElementType),
CovariantVector< TValueType, VLength > *_vector)
{
if ( static_cast< int >( VLength ) <= m_MetaArray.Length() )
{
unsigned int i;
for ( i = 0; i < VLength; i++ )
{
this->GetElement( ( *_vector )[i], i );
}
return true;
}
return false;
}
/** Get itk VariableLengthVector
* Specify the MetaType of the elements of the VariableLengthVector and
* provide a pointer to the VariableLengthVector. The buffer of the
* VariableLengthVector is replaced by the buffer into which the data
* was directly read (a copy does not occur).
* If _letVectorManageData is true, the buffer persists even after this
* MetaArrayReader is destroyed. Otherwise, the buffer (and therefore
* the validity of the dat ain the VariableLengthVector) is destroyed
* when the MetaArrayReader is dstroyed. */
template< typename TValueType >
void GetOutput(MET_ValueEnumType _metaElementType,
VariableLengthVector< TValueType > *_vector,
bool _letVectorManageData = true)
{
if ( m_MetaArray.ElementType() != _metaElementType )
{
m_MetaArray.ConvertElementDataTo(_metaElementType);
}
_vector->SetData( (TValueType *)( m_MetaArray.ElementData() ),
m_MetaArray.Length(),
_letVectorManageData );
if ( _letVectorManageData )
{
m_MetaArray.AutoFreeElementData(false);
}
}
/** Get an itk Array of Arrays, itk::Array< itk::Array<short> >.
* Assumes all sub-arrays have the same length.
* Specify the MetaType of the elements of the Array< Array< * > > and
* provide a pointer to the Array of arrays. Elements are copied
* into the array of arrays. */
template< typename TValueType >
void GetMultiChannelOutput(MET_ValueEnumType _metaElementType,
Array< TValueType > *_array)
{
if ( m_MetaArray.ElementType() != _metaElementType )
{
m_MetaArray.ConvertElementDataTo(_metaElementType);
}
int rows = m_MetaArray.Length();
int cols = m_MetaArray.ElementNumberOfChannels();
_array->SetSize(rows);
for ( int i = 0; i < rows; i++ )
{
( *_array )[i].SetSize(cols);
for ( int j = 0; j < cols; j++ )
{
( *_array )[i][j] = static_cast< typename TValueType::ValueType >
( m_MetaArray.ElementData(i * cols + j) );
}
}
}
protected:
MetaArrayReader();
virtual ~MetaArrayReader();
void PrintSelf(std::ostream & os, Indent indent) const;
private:
MetaArray m_MetaArray;
std::string m_FileName;
void *m_Buffer;
};
} // namespace itk
#endif // __itkTransformFileReader_h
|