ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkGiftiMeshIO.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkGiftiMeshIO_h
00019 #define __itkGiftiMeshIO_h
00020 
00021 #include "itkMapContainer.h"
00022 #include "itkMatrix.h"
00023 #include "itkMeshIOBase.h"
00024 #include "itkRGBAPixel.h"
00025 
00026 #include "gifti_io.h"
00027 
00028 #include <fstream>
00029 #include <string>
00030 
00031 namespace itk
00032 {
00039 class ITK_EXPORT GiftiMeshIO:public MeshIOBase
00040 {
00041 public:
00043   typedef GiftiMeshIO                         Self;
00044   typedef MeshIOBase                          Superclass;
00045   typedef SmartPointer< const Self >          ConstPointer;
00046   typedef SmartPointer< Self >                Pointer;
00047 
00048   typedef Superclass::SizeValueType           SizeValueType;
00049   typedef Matrix< double, 4, 4 >              DirectionType;
00050   typedef RGBAPixel<float>                    RGBAPixelType;
00051   typedef MapContainer<int, RGBAPixelType>    LabelColorContainer;
00052   typedef MapContainer<int, std::string>      LabelNameContainer;
00053   typedef LabelColorContainer::Pointer        LabelColorContainerPointer;
00054   typedef LabelNameContainer::Pointer         LabelNameContainerPointer;
00055 
00057   itkNewMacro(Self);
00058 
00060   itkTypeMacro(GiftiMeshIO, MeshIOBase);
00061 
00062   itkGetConstMacro(ReadPointData, bool);
00063   itkSetMacro(ReadPointData, bool);
00064   itkBooleanMacro(ReadPointData);
00065 
00066   void SetDirection(const DirectionType direction);
00067 
00068   itkGetConstReferenceMacro(Direction, DirectionType);
00069 
00070   LabelColorContainerPointer GetLabelColorTable();
00071   LabelNameContainerPointer  GetLabelNameTable();
00072   void SetLabelColorTable(const LabelColorContainer * colorMap);
00073   void SetLabelNameTable(const LabelNameContainer * labelMap);
00074 
00075   /*-------- This part of the interfaces deals with reading data. ----- */
00076 
00082   virtual bool CanReadFile(const char *FileNameToRead);
00083 
00085   virtual void ReadMeshInformation();
00086 
00088   virtual void ReadPoints(void *buffer);
00089 
00090   virtual void ReadCells(void *buffer);
00091 
00092   virtual void ReadPointData(void *buffer);
00093 
00094   virtual void ReadCellData(void *buffer);
00095 
00096   /*-------- This part of the interfaces deals with writing data. ----- */
00097 
00103   virtual bool CanWriteFile(const char *FileNameToWrite);
00104 
00106   virtual void WriteMeshInformation();
00107 
00110   virtual void WritePoints(void *buffer);
00111 
00112   virtual void WriteCells(void *buffer);
00113 
00114   virtual void WritePointData(void *buffer);
00115 
00116   virtual void WriteCellData(void *buffer);
00117 
00118   virtual void Write();
00119 
00120 protected:
00121   GiftiMeshIO();
00122   virtual ~GiftiMeshIO();
00123 
00124   void PrintSelf(std::ostream & os, Indent indent) const;
00125 
00126   template< class TInput, class TOutput >
00127   void ConvertBuffer(TInput *input, TOutput *output, SizeValueType numberOfElements)
00128   {
00129     if ( input && output )
00130       {
00131       for ( SizeValueType ii = 0; ii < numberOfElements; ii++ )
00132         {
00133         output[ii] = static_cast< TOutput >( input[ii] );
00134         }
00135       }
00136   }
00137 
00138 private:
00139   bool          m_ReadPointData;
00140   gifti_image * m_GiftiImage;
00141   DirectionType m_Direction;
00142 
00143 private:
00144   GiftiMeshIO(const Self &);    // purposely not implemented
00145   void operator=(const Self &); // purposely not implemented
00146 
00147 };
00148 } // end namespace itk
00149 
00150 #endif
00151