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

imaging/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 =========================================================================*/
00055 #ifndef __vtkImageReader_h
00056 #define __vtkImageReader_h
00057 
00058 #include "vtkImageSource.h"
00059 #include "vtkTransform.h"
00060 
00061 #define VTK_FILE_BYTE_ORDER_BIG_ENDIAN 0
00062 #define VTK_FILE_BYTE_ORDER_LITTLE_ENDIAN 1
00063 
00064 class VTK_EXPORT vtkImageReader : public vtkImageSource
00065 {
00066 public:
00067   static vtkImageReader *New();
00068   vtkTypeMacro(vtkImageReader,vtkImageSource);
00069   void PrintSelf(ostream& os, vtkIndent indent);   
00070 
00074   void SetFileName(const char *);
00075   vtkGetStringMacro(FileName);
00076 
00080   void SetFilePrefix(const char *);
00081   vtkGetStringMacro(FilePrefix);
00082 
00084   void SetFilePattern(const char *);
00085   vtkGetStringMacro(FilePattern);
00086 
00091   void SetDataScalarType(int type);
00092   void SetDataScalarTypeToFloat(){this->SetDataScalarType(VTK_FLOAT);}
00093   void SetDataScalarTypeToDouble(){this->SetDataScalarType(VTK_DOUBLE);}
00094   void SetDataScalarTypeToInt(){this->SetDataScalarType(VTK_INT);}
00095   void SetDataScalarTypeToShort(){this->SetDataScalarType(VTK_SHORT);}
00096   void SetDataScalarTypeToUnsignedShort()
00097     {this->SetDataScalarType(VTK_UNSIGNED_SHORT);}
00098   void SetDataScalarTypeToUnsignedChar()
00099     {this->SetDataScalarType(VTK_UNSIGNED_CHAR);}
00100 
00102   vtkGetMacro(DataScalarType, int);
00103 
00105   vtkSetMacro(NumberOfScalarComponents,int);
00106   vtkGetMacro(NumberOfScalarComponents,int);
00107   
00109   vtkSetVector6Macro(DataExtent,int);
00110   vtkGetVector6Macro(DataExtent,int);
00111   
00114   vtkSetVector6Macro(DataVOI,int);
00115   vtkGetVector6Macro(DataVOI,int);
00116   
00118   vtkSetMacro(FileDimensionality, int);
00119   int GetFileDimensionality() {return this->FileDimensionality;}
00120   
00122   vtkSetVector3Macro(DataSpacing,float);
00123   vtkGetVector3Macro(DataSpacing,float);
00124   
00126   vtkSetVector3Macro(DataOrigin,float);
00127   vtkGetVector3Macro(DataOrigin,float);
00128 
00130   int GetHeaderSize();
00131   int GetHeaderSize(int slice);
00132 
00135   void SetHeaderSize(int size);
00136   
00138   vtkGetMacro(DataMask,unsigned short);
00139   void SetDataMask(int val) 
00140        {if (val == this->DataMask) { return; }
00141         this->DataMask = ((unsigned short)(val)); this->Modified();}
00142   
00146   vtkSetObjectMacro(Transform,vtkTransform);
00147   vtkGetObjectMacro(Transform,vtkTransform);
00148 
00159   void SetDataByteOrderToBigEndian();
00160   void SetDataByteOrderToLittleEndian();
00161   int GetDataByteOrder();
00162   void SetDataByteOrder(int);
00163   const char *GetDataByteOrderAsString();
00164 
00166   vtkSetMacro(SwapBytes,int);
00167   int GetSwapBytes() {return this->SwapBytes;}
00168   vtkBooleanMacro(SwapBytes,int);
00169 
00170 //BTX
00171   ifstream *GetFile() {return this->File;}
00172   vtkGetVectorMacro(DataIncrements,unsigned long,4);
00173 //ETX
00174 
00175   // Warning !!!
00176   // following should only be used by methods or template helpers, not users
00177   void ComputeInverseTransformedExtent(int inExtent[6],
00178                    int outExtent[6]);
00179   void ComputeInverseTransformedIncrements(int inIncr[3],
00180                   int outIncr[3]);
00181 
00182   void OpenFile();
00183   void OpenAndSeekFile(int extent[6], int slice);
00184 
00187   vtkBooleanMacro(FileLowerLeft, int);
00188   vtkGetMacro(FileLowerLeft, int);
00189   vtkSetMacro(FileLowerLeft, int);
00190 
00192   void ComputeInternalFileName(int slice);
00193   vtkGetStringMacro(InternalFileName);
00194   
00195   
00196 protected:
00197   vtkImageReader();
00198   ~vtkImageReader();
00199   vtkImageReader(const vtkImageReader&) {};
00200   void operator=(const vtkImageReader&) {};
00201 
00202   char *InternalFileName;
00203   char *FileName;
00204   char *FilePrefix;
00205   char *FilePattern;
00206   int NumberOfScalarComponents;
00207   int FileLowerLeft;
00208 
00209   ifstream *File;
00210   unsigned long DataIncrements[4];
00211   int DataExtent[6];
00212   unsigned short DataMask;  // Mask each pixel with ...
00213   int SwapBytes;
00214 
00215   int FileDimensionality;
00216   int HeaderSize;
00217   int DataScalarType;
00218   int ManualHeaderSize;
00219   int Initialized;
00220   vtkTransform *Transform;
00221 
00222   void ComputeTransformedSpacing (float Spacing[3]);
00223   void ComputeTransformedOrigin (float origin[3]);
00224   void ComputeTransformedExtent(int inExtent[6],
00225             int outExtent[6]);
00226   void ComputeTransformedIncrements(int inIncr[3],
00227                 int outIncr[3]);
00228 
00229   int DataDimensions[3];
00230   float DataSpacing[3];
00231   float DataOrigin[3];
00232   int DataVOI[6];
00233   
00234   void ExecuteInformation();
00235   void Execute() { this->vtkImageSource::Execute(); };
00236   void Execute(vtkImageData *data);
00237   virtual void ComputeDataIncrements();
00238 };
00239 
00240 #endif

Generated on Wed Nov 21 12:27:08 2001 for VTK by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001