dox/IO/vtkLSMReader.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   BioImageXD
00004   Module:    $RCSfile: vtkLSMReader.h,v $
00005   Language:  C++
00006 
00007 
00008  Copyright (C) 2005  BioImageXD Project
00009  See CREDITS.txt for details
00010 
00011  This program is free software; you can redistribute it and/or modify
00012  it under the terms of the GNU General Public License as published by
00013  the Free Software Foundation; either version 2 of the License, or
00014  (at your option) any later version.
00015 
00016  This program is distributed in the hope that it will be useful,
00017  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  GNU General Public License for more details.
00020 
00021  You should have received a copy of the GNU General Public License
00022  along with this program; if not, write to the Free Software
00023  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024 
00025 =========================================================================*/
00026 
00027 #define TIF_NEWSUBFILETYPE 254
00028 #define TIF_IMAGEWIDTH 256
00029 #define TIF_IMAGELENGTH 257
00030 #define TIF_BITSPERSAMPLE 258
00031 #define TIF_COMPRESSION 259
00032 #define TIF_PHOTOMETRICINTERPRETATION 262
00033 #define TIF_STRIPOFFSETS 273
00034 #define TIF_SAMPLESPERPIXEL 277
00035 #define TIF_STRIPBYTECOUNTS 279
00036 #define TIF_PLANARCONFIGURATION 284
00037 #define TIF_PREDICTOR 317
00038 #define TIF_COLORMAP 320
00039 #define TIF_CZ_LSMINFO 34412
00040 
00061 #ifndef __vtkLSMReader_h
00062 #define __vtkLSMReader_h
00063 
00064 #include "vtkImageSource.h"
00065 #include "vtkIntArray.h"
00066 #include "vtkUnsignedIntArray.h"
00067 #include "vtkDoubleArray.h"
00068 #include "vtkUnsignedShortArray.h"
00069 #include "vtkUnsignedCharArray.h"
00070 
00071 #define TIFF_BYTE 1
00072 #define TIFF_ASCII 2
00073 #define TIFF_SHORT 3
00074 #define TIFF_LONG 4
00075 #define TIFF_RATIONAL 5
00076 
00077 #define LSM_MAGIC_NUMBER 42
00078 
00079 #define LSM_COMPRESSED 5
00080 
00081 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
00082 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
00083 
00084 
00085 class VTK_IO_EXPORT vtkLSMReader : public vtkImageSource
00086 {
00087 public:
00088  
00089   static vtkLSMReader *New();
00090   vtkTypeMacro(vtkLSMReader,vtkImageSource);
00091   virtual void PrintSelf(ostream& os, vtkIndent indent);
00092 
00094 
00096   const char* GetFileExtensions()
00097     {
00098     return ".lsm .LSM";
00099     }
00101 
00102   int GetHeaderIdentifier();
00103   int IsValidLSMFile();
00104   int IsCompressed();
00105   int GetNumberOfTimePoints();
00106   int GetNumberOfChannels();
00107   int OpenFile();
00108 
00109   int GetChannelColorComponent(int,int);
00110   char* GetChannelName(int);
00111   void SetFileName(const char *);
00112   void ExecuteInformation();
00113   void SetUpdateTimePoint(int);
00114   void SetUpdateChannel(int);
00115 
00116   void SetDataByteOrderToBigEndian();
00117   void SetDataByteOrderToLittleEndian();
00118   void SetDataByteOrder(int);
00119   int GetDataByteOrder();
00120   const char *GetDataByteOrderAsString();
00121 
00123 
00124   vtkSetMacro(SwapBytes,int);
00125   virtual int GetSwapBytes() {return this->SwapBytes;}
00126   vtkBooleanMacro(SwapBytes,int);
00128 
00129   vtkGetStringMacro(FileName);
00130   vtkGetVector3Macro(VoxelSizes,double);
00131   vtkGetVectorMacro(Dimensions,int,5);
00132   vtkGetVectorMacro(NumberOfIntensityValues,int,4);
00133   vtkGetMacro(Identifier,unsigned short);
00134   vtkGetMacro(NewSubFileType,unsigned int);
00135   vtkGetMacro(Compression,unsigned int);
00136   vtkGetMacro(SamplesPerPixel,unsigned int);
00137   vtkGetMacro(ScanType,unsigned short);
00138   vtkGetMacro(DataType,int);
00139   vtkGetObjectMacro(TimeStampInformation,vtkDoubleArray);
00140   vtkGetObjectMacro(ChannelColors,vtkIntArray);
00141 
00142   vtkImageData* GetTimePointOutput(int,int);
00143 
00144 protected:
00145 
00146   vtkLSMReader();
00147   ~vtkLSMReader();
00148 
00149   int TIFF_BYTES(unsigned short);
00150   int BYTES_BY_DATA_TYPE(int);
00151   void ClearFileName();
00152   void Clean();
00153   unsigned long ReadImageDirectory(ifstream *,unsigned long);
00154   int AllocateChannelNames(int);
00155   int SetChannelName(const char *,int);
00156   int ClearChannelNames();
00157   int FindChannelNameStart(const char *, int);
00158   int ReadChannelName(const char *, int, char *);
00159   int ReadChannelColorsAndNames(ifstream *,unsigned long);
00160   int ReadTimeStampInformation(ifstream *,unsigned long);
00161   int ReadLSMSpecificInfo(ifstream *,unsigned long);
00162   int AnalyzeTag(ifstream *,unsigned long);
00163   int NeedToReadHeaderInformation();
00164   void NeedToReadHeaderInformationOn();
00165   void NeedToReadHeaderInformationOff();
00166   unsigned long SeekFile(int);
00167   unsigned long GetOffsetToImage(int, int);
00168   ifstream *GetFile();
00169 
00170   void ExecuteData(vtkDataObject *out);
00171   void CalculateExtentAndSpacing(int extent[6],double spacing[3]);
00172   //  void DecodeHorizontalDifferencing(unsigned char *,int);
00173   //  void DecodeLZWCompression(unsigned  char *,int);
00174   //  unsigned char *decode_string(unsigned char *buffer,unsigned int code);
00175   //  unsigned int input_code(char *input);
00176 
00177   int SwapBytes;
00178 
00179   int UpdateExtent[5];
00180   unsigned long OffsetToLastAccessedImage;
00181   int NumberOfLastAccessedImage;
00182   int FileNameChanged;
00183   ifstream *File;
00184   char *FileName;
00185   double VoxelSizes[3];
00186   int Dimensions[5];// x,y,z,time,channels
00187   int NumberOfIntensityValues[4];
00188   unsigned short Identifier;
00189   unsigned int NewSubFileType;
00190   vtkUnsignedShortArray *BitsPerSample;
00191   unsigned int Compression;
00192   vtkUnsignedIntArray *StripOffset;
00193   unsigned int SamplesPerPixel;
00194   vtkUnsignedIntArray *StripByteCount;
00195   unsigned int LSMSpecificInfoOffset;
00196   unsigned short PhotometricInterpretation;
00197   unsigned long ColorMapOffset;
00198   unsigned short PlanarConfiguration;
00199   unsigned short Predictor;
00200   unsigned short ScanType;
00201   int DataType;
00202   unsigned long ChannelInfoOffset;
00203   vtkIntArray *ChannelColors;
00204   char **ChannelNames;
00205   vtkDoubleArray *TimeStampInformation;
00206 
00207   unsigned char CharPointerToUnsignedChar(char *);
00208   int CharPointerToInt(char *);
00209   unsigned int CharPointerToUnsignedInt(char *);
00210   short CharPointerToShort(char *);
00211   unsigned short CharPointerToUnsignedShort(char *);
00212   double CharPointerToDouble(char *);
00213 
00214   int ReadInt(ifstream *,unsigned long *);
00215   unsigned int ReadUnsignedInt(ifstream *,unsigned long *);
00216   short ReadShort(ifstream *,unsigned long *);
00217   unsigned short ReadUnsignedShort(ifstream *,unsigned long *);
00218   double ReadDouble(ifstream *,unsigned long *);
00219   int ReadFile(ifstream *,unsigned long *,int,char *,bool swap=0);
00220   int ReadData(ifstream *,unsigned long *,int,char *);
00221 
00222 
00223 private:
00224   vtkLSMReader(const vtkLSMReader&);  // Not implemented.
00225   void operator=(const vtkLSMReader&);  // Not implemented.
00226 };
00227 #endif

Generated on Fri Sep 7 17:44:07 2007 for VTK by  doxygen 1.5.3