Slicer 5.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkTeemNRRDReader.h
Go to the documentation of this file.
1/*=auto=========================================================================
2
3 Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
4
5 See COPYRIGHT.txt
6 or http://www.slicer.org/copyright/copyright.txt for details.
7
8 Program: 3D Slicer
9 Module: $RCSfile: vtkTeemNRRDReader.h,v $
10 Date: $Date: 2007/06/12 19:13:59 $
11 Version: $Revision: 1.3.2.1 $
12
13=========================================================================auto=*/
14/*=========================================================================
15
16 Program: Visualization Toolkit
17 Module: $RCSfile: vtkTeemNRRDReader.h,v $
18
19 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
20 All rights reserved.
21 See Copyright.txt or https://www.kitware.com/Copyright.htm for details.
22
23 This software is distributed WITHOUT ANY WARRANTY; without even
24 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
25 PURPOSE. See the above copyright notice for more information.
26
27=========================================================================*/
28
29#ifndef __vtkTeemNRRDReader_h
30#define __vtkTeemNRRDReader_h
31
32#include <string>
33#include <map>
34#include <iostream>
35
36#include "vtkTeemExport.h"
37#include "vtkMedicalImageReader2.h"
38
39// #include "vtkDataObject.h"
40// #include "vtkImageData.h"
41
42#include <vtkMatrix4x4.h>
43#include <vtkPointData.h>
44#include <vtkSmartPointer.h>
45#include <vtkVersion.h>
46
50//
52class VTK_Teem_EXPORT vtkTeemNRRDReader : public vtkMedicalImageReader2
53{
54public:
56
57 vtkTypeMacro(vtkTeemNRRDReader, vtkMedicalImageReader2);
58
61 vtkMatrix4x4* GetRasToIjkMatrix();
62
66
71 const char* GetHeaderKeys();
72
76 const std::vector<std::string> GetHeaderKeysVector();
77
81 const std::map<std::string, std::string> GetHeaderKeysMap();
82
85 const char* GetHeaderValue(const char* key);
86
88 const char* GetAxisLabel(unsigned int axis);
89
91 const char* GetAxisUnit(unsigned int axis);
92
93 void PrintSelf(ostream& os, vtkIndent indent) override;
94
96 int CanReadFile(const char* filename) override;
97
100 const char* GetFileExtensions() override { return ".nhdr .nrrd"; }
101
104 const char* GetDescriptiveName() override { return "NRRD - Nearly Raw Raster Data"; }
105
106 // Description:
110 vtkGetMacro(ReadStatus, int);
111
114 vtkSetMacro(PointDataType, int);
115 vtkGetMacro(PointDataType, int);
116
119 vtkSetMacro(DataType, int);
120 vtkGetMacro(DataType, int);
121
123 // Number of components
124 vtkSetMacro(NumberOfComponents, int);
125 vtkGetMacro(NumberOfComponents, int);
126
130
134
140 vtkSetMacro(DataArrayName, std::string);
141 vtkGetMacro(DataArrayName, std::string);
142
143 int NrrdToVTKScalarType(const int nrrdPixelType) const;
144 int VTKToNrrdPixelType(const int vtkPixelType) const;
145
146 vtkImageData* AllocateOutputData(vtkDataObject* out, vtkInformation* outInfo) override;
147 void AllocateOutputData(vtkImageData* out, vtkInformation* outInfo, int* uExtent) override { Superclass::AllocateOutputData(out, outInfo, uExtent); }
148 void AllocatePointData(vtkImageData* out, vtkInformation* outInfo);
149
150protected:
153
154 static bool GetPointType(void* nrrdTemp, int& pointDataType, int& numOfComponents);
155
156 vtkSmartPointer<vtkMatrix4x4> RasToIjkMatrix;
157 vtkSmartPointer<vtkMatrix4x4> MeasurementFrameMatrix;
158 vtkSmartPointer<vtkMatrix4x4> NRRDWorldToRasMatrix;
159
160 std::string CurrentFileName;
161
162 void* nrrd;
163
165
170 std::string DataArrayName;
171
172 std::map<std::string, std::string> HeaderKeyValue;
173 std::string HeaderKeys; // buffer for returning key list
174
175 std::map<unsigned int, std::string> AxisLabels;
176 std::map<unsigned int, std::string> AxisUnits;
177
178 void ExecuteInformation() override;
179 void ExecuteDataWithInformation(vtkDataObject* output, vtkInformation* outInfo) override;
180
181 int tenSpaceDirectionReduce(void* nout, const void* nin, double SD[9]);
182
183private:
184 vtkTeemNRRDReader(const vtkTeemNRRDReader&) = delete;
185 void operator=(const vtkTeemNRRDReader&) = delete;
186};
187
188#endif
static bool GetPointType(void *nrrdTemp, int &pointDataType, int &numOfComponents)
const char * GetAxisLabel(unsigned int axis)
Get label for specified axis.
void SetUseNativeOriginOff()
Use image center as origin.
static vtkTeemNRRDReader * New()
vtkSmartPointer< vtkMatrix4x4 > MeasurementFrameMatrix
const char * GetAxisUnit(unsigned int axis)
Get unit for specified axis.
const std::map< std::string, std::string > GetHeaderKeysMap()
void ExecuteDataWithInformation(vtkDataObject *output, vtkInformation *outInfo) override
vtkSmartPointer< vtkMatrix4x4 > RasToIjkMatrix
vtkImageData * AllocateOutputData(vtkDataObject *out, vtkInformation *outInfo) override
int VTKToNrrdPixelType(const int vtkPixelType) const
vtkMatrix4x4 * GetMeasurementFrameMatrix()
Returns the measurement frame matrix used for tensor valued data.
int NrrdToVTKScalarType(const int nrrdPixelType) const
void PrintSelf(ostream &os, vtkIndent indent) override
std::string CurrentFileName
void AllocatePointData(vtkImageData *out, vtkInformation *outInfo)
void AllocateOutputData(vtkImageData *out, vtkInformation *outInfo, int *uExtent) override
int CanReadFile(const char *filename) override
is the given file name a NRRD file?
const char * GetDescriptiveName() override
A descriptive name for this format.
const std::vector< std::string > GetHeaderKeysVector()
vtkSmartPointer< vtkMatrix4x4 > NRRDWorldToRasMatrix
vtkMatrix4x4 * GetRasToIjkMatrix()
Returns a IJK to RAS transformation matrix.
std::map< std::string, std::string > HeaderKeyValue
std::map< unsigned int, std::string > AxisLabels
const char * GetFileExtensions() override
Valid extensions.
void SetUseNativeOriginOn()
Use image origin from the file.
const char * GetHeaderValue(const char *key)
Get a value given a key in the header.
~vtkTeemNRRDReader() override
int tenSpaceDirectionReduce(void *nout, const void *nin, double SD[9])
std::map< unsigned int, std::string > AxisUnits
void ExecuteInformation() override
const char * GetHeaderKeys()