ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkGiftiMeshIO.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 #ifndef itkGiftiMeshIO_h
19 #define itkGiftiMeshIO_h
20 #include "ITKIOMeshExport.h"
21 
22 #include "itkAutoPointer.h"
23 #include "itkMapContainer.h"
24 #include "itkMatrix.h"
25 #include "itkMeshIOBase.h"
26 #include "itkRGBAPixel.h"
27 
28 #include <fstream>
29 #include <string>
30 
31 namespace itk
32 {
39 class ITKIOMesh_EXPORT GiftiMeshIO:public MeshIOBase
40 {
41 public:
43  typedef GiftiMeshIO Self;
47 
55 
57  itkNewMacro(Self);
58 
60  itkTypeMacro(GiftiMeshIO, MeshIOBase);
61 
62  itkGetConstMacro(ReadPointData, bool);
63  itkSetMacro(ReadPointData, bool);
64  itkBooleanMacro(ReadPointData);
65 
66  void SetDirection(const DirectionType & direction);
67 
68  itkGetConstReferenceMacro(Direction, DirectionType);
69 
70  LabelColorContainerPointer GetLabelColorTable();
71  LabelNameContainerPointer GetLabelNameTable();
72  void SetLabelColorTable(const LabelColorContainer * colorMap);
73  void SetLabelNameTable(const LabelNameContainer * labelMap);
74 
75  /*-------- This part of the interfaces deals with reading data. ----- */
76 
82  virtual bool CanReadFile(const char *FileNameToRead) ITK_OVERRIDE;
83 
85  virtual void ReadMeshInformation() ITK_OVERRIDE;
86 
88  virtual void ReadPoints(void *buffer) ITK_OVERRIDE;
89 
90  virtual void ReadCells(void *buffer) ITK_OVERRIDE;
91 
92  virtual void ReadPointData(void *buffer) ITK_OVERRIDE;
93 
94  virtual void ReadCellData(void *buffer) ITK_OVERRIDE;
95 
96  /*-------- This part of the interfaces deals with writing data. ----- */
97 
103  virtual bool CanWriteFile(const char *FileNameToWrite) ITK_OVERRIDE;
104 
106  virtual void WriteMeshInformation() ITK_OVERRIDE;
107 
110  virtual void WritePoints(void *buffer) ITK_OVERRIDE;
111 
112  virtual void WriteCells(void *buffer) ITK_OVERRIDE;
113 
114  virtual void WritePointData(void *buffer) ITK_OVERRIDE;
115 
116  virtual void WriteCellData(void *buffer) ITK_OVERRIDE;
117 
118  virtual void Write() ITK_OVERRIDE;
119 
120 protected:
121  GiftiMeshIO();
122  virtual ~GiftiMeshIO() ITK_OVERRIDE;
123 
124  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
125 
126  template< typename TInput, typename TOutput >
127  void ConvertBuffer(TInput *input, TOutput *output, SizeValueType numberOfElements)
128  {
129  if ( input && output )
130  {
131  for ( SizeValueType ii = 0; ii < numberOfElements; ii++ )
132  {
133  output[ii] = static_cast< TOutput >( input[ii] );
134  }
135  }
136  }
137 
138 private:
139  //This proxy class provides a gifti_image pointer interface to the internal implementation
140  //of itk::GiftiImageIO, while hiding the gifticlib interface from the external ITK interface.
141  class GiftiImageProxy;
142 
143  //Note that it is essential that m_GiftiImageHolder is defined before m_GiftiImage, to ensure that
144  //m_GiftiImage can directly get a proxy from m_GiftiImageHolder during GiftiImageIO construction.
146 
147  GiftiImageProxy& m_GiftiImage;
148 
151 
152 private:
153  ITK_DISALLOW_COPY_AND_ASSIGN(GiftiMeshIO);
154 
155 };
156 } // end namespace itk
157 
158 #endif
Light weight base class for most itk classes.
MapContainer< int, std::string > LabelNameContainer
A wrapper of the STL &quot;map&quot; container.
Superclass::SizeValueType SizeValueType
MapContainer< int, RGBAPixelType > LabelColorContainer
MeshIOBase Superclass
unsigned long SizeValueType
Definition: itkIntTypes.h:143
SmartPointer< Self > Pointer
GiftiMeshIO Self
Matrix< double, 4, 4 > DirectionType
RGBAPixel< float > RGBAPixelType
SmartPointer< const Self > ConstPointer
const AutoPointer< GiftiImageProxy > m_GiftiImageHolder
This class defines how to read and write Gifti file format.
LabelColorContainer::Pointer LabelColorContainerPointer
DirectionType m_Direction
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Abstract superclass defines mesh IO interface.
Definition: itkMeshIOBase.h:69
GiftiImageProxy & m_GiftiImage
LabelNameContainer::Pointer LabelNameContainerPointer