Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

IO/vtkImageReader.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkImageReader.h,v $
00005   Language:  C++
00006 
00007 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen 
00008 All rights reserved.
00009 
00010 Redistribution and use in source and binary forms, with or without
00011 modification, are permitted provided that the following conditions are met:
00012 
00013  * Redistributions of source code must retain the above copyright notice,
00014    this list of conditions and the following disclaimer.
00015 
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019 
00020  * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names
00021    of any contributors may be used to endorse or promote products derived
00022    from this software without specific prior written permission.
00023 
00024  * Modified source versions must be plainly marked as such, and must not be
00025    misrepresented as being the original software.
00026 
00027 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00028 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00029 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00030 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
00031 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00032 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00033 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00034 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00035 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00036 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 
00038 =========================================================================*/
00059 #ifndef __vtkImageReader_h
00060 #define __vtkImageReader_h
00061 
00062 #include "vtkImageSource.h"
00063 #include "vtkTransform.h"
00064 
00065 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
00066 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
00067 
00068 class VTK_IO_EXPORT vtkImageReader : public vtkImageSource
00069 {
00070 public:
00071   static vtkImageReader *New();
00072   vtkTypeMacro(vtkImageReader,vtkImageSource);
00073   void PrintSelf(ostream& os, vtkIndent indent);   
00074 
00076 
00079   void SetFileName(const char *);
00080   vtkGetStringMacro(FileName);
00082 
00084 
00087   void SetFilePrefix(const char *);
00088   vtkGetStringMacro(FilePrefix);
00090 
00092 
00093   void SetFilePattern(const char *);
00094   vtkGetStringMacro(FilePattern);
00096 
00098 
00100   vtkSetMacro(FileNameSliceOffset,int);
00101   vtkGetMacro(FileNameSliceOffset,int);
00103 
00105 
00108   vtkSetMacro(FileNameSliceSpacing,int);
00109   vtkGetMacro(FileNameSliceSpacing,int);
00111 
00113 
00117   void SetDataScalarType(int type);
00118   void SetDataScalarTypeToFloat(){this->SetDataScalarType(VTK_FLOAT);}
00119   void SetDataScalarTypeToDouble(){this->SetDataScalarType(VTK_DOUBLE);}
00120   void SetDataScalarTypeToInt(){this->SetDataScalarType(VTK_INT);}
00121   void SetDataScalarTypeToShort(){this->SetDataScalarType(VTK_SHORT);}
00122   void SetDataScalarTypeToUnsignedShort()
00123     {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
00124   void SetDataScalarTypeToUnsignedChar()
00125     {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
00127 
00129 
00130   vtkGetMacro(DataScalarType, int);
00132 
00134 
00135   vtkSetMacro(NumberOfScalarComponents,int);
00136   vtkGetMacro(NumberOfScalarComponents,int);
00138   
00140 
00141   vtkSetVector6Macro(DataExtent,int);
00142   vtkGetVector6Macro(DataExtent,int);
00144   
00146 
00148   vtkSetVector6Macro(DataVOI,int);
00149   vtkGetVector6Macro(DataVOI,int);
00151   
00153 
00154   vtkSetMacro(FileDimensionality, int);
00155   int GetFileDimensionality() {return this->FileDimensionality;}
00157   
00159 
00160   vtkSetVector3Macro(DataSpacing,float);
00161   vtkGetVector3Macro(DataSpacing,float);
00163   
00165 
00166   vtkSetVector3Macro(DataOrigin,float);
00167   vtkGetVector3Macro(DataOrigin,float);
00169 
00171 
00172   unsigned long GetHeaderSize();
00173   unsigned long GetHeaderSize(int slice);
00175 
00178   void SetHeaderSize(unsigned long size);
00179   
00181 
00182   vtkGetMacro(DataMask,unsigned short);
00183   void SetDataMask(int val) 
00184        {if (val == this->DataMask) { return; }
00185         this->DataMask = ((unsigned short)(val)); this->Modified();}
00187   
00189 
00192   vtkSetObjectMacro(Transform,vtkTransform);
00193   vtkGetObjectMacro(Transform,vtkTransform);
00195 
00197 
00207   void SetDataByteOrderToBigEndian();
00208   void SetDataByteOrderToLittleEndian();
00209   int GetDataByteOrder();
00210   void SetDataByteOrder(int);
00211   const char *GetDataByteOrderAsString();
00213 
00215 
00216   vtkSetMacro(SwapBytes,int);
00217   int GetSwapBytes() {return this->SwapBytes;}
00218   vtkBooleanMacro(SwapBytes,int);
00220 
00221 //BTX
00222   ifstream *GetFile() {return this->File;}
00223   vtkGetVectorMacro(DataIncrements,unsigned long,4);
00224 //ETX
00225 
00226   // Warning !!!
00227   // following should only be used by methods or template helpers, not users
00228   void ComputeInverseTransformedExtent(int inExtent[6],
00229                                        int outExtent[6]);
00230   void ComputeInverseTransformedIncrements(int inIncr[3],
00231                                            int outIncr[3]);
00232 
00233   void OpenFile();
00234   void OpenAndSeekFile(int extent[6], int slice);
00235 
00237 
00239   vtkBooleanMacro(FileLowerLeft, int);
00240   vtkGetMacro(FileLowerLeft, int);
00241   vtkSetMacro(FileLowerLeft, int);
00243 
00245 
00246   void ComputeInternalFileName(int slice);
00247   vtkGetStringMacro(InternalFileName);
00249   
00250   
00251 protected:
00252   vtkImageReader();
00253   ~vtkImageReader();
00254 
00255   char *InternalFileName;
00256   char *FileName;
00257   char *FilePrefix;
00258   char *FilePattern;
00259   int NumberOfScalarComponents;
00260   int FileLowerLeft;
00261   int FileNameSliceOffset;
00262   int FileNameSliceSpacing;
00263 
00264   ifstream *File;
00265   unsigned long DataIncrements[4];
00266   int DataExtent[6];
00267   unsigned short DataMask;  // Mask each pixel with ...
00268   int SwapBytes;
00269 
00270   int FileDimensionality;
00271   unsigned long HeaderSize;
00272   int DataScalarType;
00273   int ManualHeaderSize;
00274   int Initialized;
00275   vtkTransform *Transform;
00276 
00277   void ComputeTransformedSpacing (float Spacing[3]);
00278   void ComputeTransformedOrigin (float origin[3]);
00279   void ComputeTransformedExtent(int inExtent[6],
00280                                 int outExtent[6]);
00281   void ComputeTransformedIncrements(int inIncr[3],
00282                                     int outIncr[3]);
00283 
00284   int DataDimensions[3];
00285   float DataSpacing[3];
00286   float DataOrigin[3];
00287   int DataVOI[6];
00288   
00289   void ExecuteInformation();
00290   void ExecuteData(vtkDataObject *data);
00291   virtual void ComputeDataIncrements();
00292 private:
00293   vtkImageReader(const vtkImageReader&);  // Not implemented.
00294   void operator=(const vtkImageReader&);  // Not implemented.
00295 };
00296 
00297 #endif

Generated on Thu Mar 28 14:19:28 2002 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001