ITK  4.3.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 
21 #include "itkMapContainer.h"
22 #include "itkMatrix.h"
23 #include "itkMeshIOBase.h"
24 #include "itkRGBAPixel.h"
25 
26 #include "gifti_io.h"
27 
28 #include <fstream>
29 #include <string>
30 
31 namespace itk
32 {
39 class ITK_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);
83 
85  virtual void ReadMeshInformation();
86 
88  virtual void ReadPoints(void *buffer);
89 
90  virtual void ReadCells(void *buffer);
91 
92  virtual void ReadPointData(void *buffer);
93 
94  virtual void ReadCellData(void *buffer);
95 
96  /*-------- This part of the interfaces deals with writing data. ----- */
97 
103  virtual bool CanWriteFile(const char *FileNameToWrite);
104 
106  virtual void WriteMeshInformation();
107 
110  virtual void WritePoints(void *buffer);
111 
112  virtual void WriteCells(void *buffer);
113 
114  virtual void WritePointData(void *buffer);
115 
116  virtual void WriteCellData(void *buffer);
117 
118  virtual void Write();
119 
120 protected:
121  GiftiMeshIO();
122  virtual ~GiftiMeshIO();
123 
124  void PrintSelf(std::ostream & os, Indent indent) const;
125 
126  template< class TInput, class 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:
140  gifti_image * m_GiftiImage;
142 
143 private:
144  GiftiMeshIO(const Self &); // purposely not implemented
145  void operator=(const Self &); // purposely not implemented
146 
147 };
148 } // end namespace itk
149 
150 #endif
151