Main Page | File List | Related Pages

gdcmFile.h

00001 // gdcmFile.h
00002 //-----------------------------------------------------------------------------
00003 #ifndef GDCMFILE_H
00004 #define GDCMFILE_H
00005 
00006 #include "gdcmCommon.h"
00007 #include "gdcmHeader.h"
00008 
00009 //-----------------------------------------------------------------------------
00010 /*
00011  * In addition to Dicom header exploration, this class is designed
00012  * for accessing the image/volume content. One can also use it to
00013  * write Dicom/ACR-NEMA/RAW files.
00014  */
00015 class GDCM_EXPORT gdcmFile
00016 {
00017 public:
00018    gdcmFile(gdcmHeader *header);
00019    gdcmFile(std::string & filename);
00020    gdcmFile(const char * filename);
00021    virtual ~gdcmFile(void);
00022         
00023    gdcmHeader *GetHeader(void);
00024 
00025         // For promotion (performs a deepcopy of pointed header object)
00026         // TODO Swig gdcmFile(gdcmHeader* header);
00027         // TODO Swig ~gdcmFile();
00028 
00029         // On writing purposes. When instance was created through
00030         // gdcmFile(std::string filename) then the filename argument MUST be
00031         // different from the constructor's one (no overwriting allowed).
00032         // TODO Swig int SetFileName(std::string filename);
00033 
00034    void   SetPixelDataSizeFromHeader(void);
00035    size_t GetImageDataSize();
00036    size_t GetImageDataSizeRaw();
00037 
00038    void * GetImageData();
00039    size_t GetImageDataIntoVector(void* destination, size_t MaxSize);
00040    void * GetImageDataRaw();
00041    size_t GetImageDataIntoVectorRaw(void* destination, size_t MaxSize);
00042         
00043       // Allocates ExpectedSize bytes of memory at this->Data and copies the
00044       // pointed data to it. Copying the image might look useless but
00045       // the caller might destroy it's image (without knowing it: think
00046       // of a complicated interface where display is done with a library
00047       // e.g. VTK) before calling the Write
00048       
00049    // voir gdcmHeader::SetImageDataSize ?!?         
00050    bool SetImageData     (void * Data, size_t ExpectedSize);
00051       // When the caller is aware we simply point to the data:
00052       // TODO int SetImageDataNoCopy (void * Data, size_t ExpectedSize);
00053         
00054         // Push to disk.
00055         // A NE PAS OUBLIER : que fait-on en cas de Transfert Syntax (dans l'entete)
00056         // incohérente avec l'ordre des octets en mémoire ? 
00057         // TODO Swig int Write();
00058         
00059    // Write pixels of ONE image on hard drive
00060    // No test is made on processor "endianity"
00061    // The user must call his reader correctly
00062    bool WriteRawData  (std::string fileName);
00063    bool WriteDcmImplVR(std::string fileName);
00064    bool WriteDcmImplVR(const char * fileName);
00065    bool WriteDcmExplVR(std::string fileName);
00066    bool WriteAcr      (std::string fileName);
00067  
00068    // Body in file gdcmParse.cxx
00069    bool ParsePixelData(void);
00070      
00071 protected:
00072    bool WriteBase(std::string FileName, FileType type);
00073 
00074 private:
00075    void SwapZone(void* im, int swap, int lgr, int nb);
00076    
00077    bool ReadPixelData(void * destination);
00078    
00079    // For JPEG 8 Bits, body in file gdcmJpeg.cxx
00080    bool gdcm_read_JPEG_file     (FILE *fp,void * image_buffer); 
00081    static int gdcm_read_RLE_fragment(char **areaToRead, long lengthToDecode, 
00082                                      long uncompressedSegmentSize,FILE *fp);
00083    // For JPEG 12 Bits, body in file gdcmJpeg12.cxx
00084    bool gdcm_read_JPEG_file12   (FILE *fp,void * image_buffer);
00085    // For JPEG 2000, body in file gdcmJpeg2000.cxx
00086    bool gdcm_read_JPEG2000_file (FILE *fp,void * image_buffer);
00087 
00088    // For Run Length Encoding (TOCHECK)
00089    bool gdcm_read_RLE_file      (FILE *fp,void * image_buffer); 
00090 
00091 // Variables
00092    gdcmHeader *Header;   // Header to use to load the file
00093    bool SelfHeader;
00094 
00095    void* PixelData;
00096    size_t lgrTotaleRaw;  // Area length to receive the pixels
00097    size_t lgrTotale;     // Area length to receive the RGB pixels
00098                          // from Grey Plane + Palette Color
00099    int PixelRead;     // ==1  if GetImageDataRaw was used
00100                       // ==0  if GetImageData    was used
00101                       // ==-1 if ImageData never read.
00102 
00103    int Parsed;               // weather already parsed
00104    std::string OrigFileName; // To avoid file overwrite   
00105 };
00106 
00107 //-----------------------------------------------------------------------------
00108 #endif

Generated on Mon Feb 14 16:13:44 2005 for gdcm by doxygen 1.3.6