Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

gdcmFileHelper.h

Go to the documentation of this file.
00001 /*=========================================================================
00002                                                                                 
00003   Program:   gdcm
00004   Module:    $RCSfile: gdcmFileHelper.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/02/09 16:28:41 $
00007   Version:   $Revision: 1.12 $
00008                                                                                 
00009   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
00010   l'Image). All rights reserved. See Doc/License.txt or
00011   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
00012                                                                                 
00013      This software is distributed WITHOUT ANY WARRANTY; without even
00014      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00015      PURPOSE.  See the above copyright notices for more information.
00016                                                                                 
00017 =========================================================================*/
00018 
00019 #ifndef GDCMFILEHELPER_H
00020 #define GDCMFILEHELPER_H
00021 
00022 #include <iostream>
00023 #include "gdcmBase.h"
00024 
00025 namespace gdcm 
00026 {
00027 class File;
00028 class ValEntry;
00029 class BinEntry;
00030 class SeqEntry;
00031 class PixelReadConvert;
00032 class PixelWriteConvert;
00033 class DocEntryArchive;
00034 //-----------------------------------------------------------------------------
00040 class GDCM_EXPORT FileHelper : public Base
00041 {
00042 public:
00043    enum FileMode
00044    {
00045       WMODE_RAW,
00046       WMODE_RGB
00047    };
00048      
00049 public:
00050    FileHelper( );
00051    FileHelper( File *header );
00052    FileHelper( std::string const &filename );
00053  
00054    virtual ~FileHelper();
00055 
00056    void Print(std::ostream &os = std::cout, std::string const &indent = ""); 
00057 
00059    File *GetFile() { return FileInternal; }
00060 
00061    // File methods
00062    bool SetValEntry(std::string const &content,
00063                     uint16_t group, uint16_t elem);
00064    bool SetBinEntry(uint8_t *content, int lgth,
00065                     uint16_t group, uint16_t elem);
00066 
00067    ValEntry *InsertValEntry(std::string const &content,
00068                             uint16_t group, uint16_t elem);
00069    BinEntry *InsertBinEntry(uint8_t *binArea, int lgth,
00070                             uint16_t group, uint16_t elem);
00071    SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
00072 
00073    // File helpers
00074    size_t GetImageDataSize();
00075    size_t GetImageDataRawSize();
00076 
00077    uint8_t *GetImageData();
00078    uint8_t *GetImageDataRaw();
00079    size_t GetImageDataIntoVector(void *destination, size_t maxSize);
00080 
00081    void SetImageData(uint8_t *data, size_t expectedSize);
00082 
00083    // User data
00084    void SetUserData(uint8_t *data, size_t expectedSize);
00085    uint8_t *GetUserData();
00086    size_t GetUserDataSize();
00087    // RBG data (from file)
00088    uint8_t *GetRGBData();
00089    size_t GetRGBDataSize();
00090    // RAW data (from file)
00091    uint8_t *GetRawData();
00092    size_t GetRawDataSize();
00093 
00094    // LUT
00095    uint8_t* GetLutRGBA();
00096 
00097    // Write mode
00098 
00100   void SetWriteModeToRaw()           { SetWriteMode(WMODE_RAW);  };
00103    void SetWriteModeToRGB()           { SetWriteMode(WMODE_RGB);  };
00105    void SetWriteMode(FileMode mode)   { WriteMode = mode;         };
00107    FileMode GetWriteMode()            { return WriteMode;         };
00108 
00109    // Write format
00110 
00112    void SetWriteTypeToDcmImplVR()     { SetWriteType(ImplicitVR); };
00114    void SetWriteTypeToDcmExplVR()     { SetWriteType(ExplicitVR); };
00116    void SetWriteTypeToAcr()           { SetWriteType(ACR);        };
00118    void SetWriteTypeToAcrLibido()     { SetWriteType(ACR_LIBIDO); };
00121    void SetWriteType(FileType format) { WriteType = format;       };
00124    FileType GetWriteType()            { return WriteType;         };
00125 
00126    // Write pixels of ONE image on hard drive
00127    // No test is made on processor "endianness"
00128    // The user must call his reader correctly
00129    bool WriteRawData  (std::string const &fileName);
00130    bool WriteDcmImplVR(std::string const &fileName);
00131    bool WriteDcmExplVR(std::string const &fileName);
00132    bool WriteAcr      (std::string const &fileName);
00133    bool Write         (std::string const &fileName);
00134 
00135 protected:
00136    bool CheckWriteIntegrity();
00137 
00138    void SetWriteToRaw();
00139    void SetWriteToRGB();
00140    void RestoreWrite();
00141 
00142    void SetWriteFileTypeToACR();
00143    void SetWriteFileTypeToExplicitVR();
00144    void SetWriteFileTypeToImplicitVR();
00145    void RestoreWriteFileType();
00146 
00147    void SetWriteToLibido();
00148    void SetWriteToNoLibido();
00149    void RestoreWriteOfLibido();
00150 
00151    ValEntry *CopyValEntry(uint16_t group, uint16_t elem);
00152    BinEntry *CopyBinEntry(uint16_t group, uint16_t elem, 
00153                           const std::string &vr);
00154 
00155 private:
00156    void Initialize();
00157 
00158    uint8_t *GetRaw();
00159 
00160 // members variables:
00162    File *FileInternal;
00163 
00167    bool SelfHeader;
00168    
00170    bool Parsed;
00171 
00172    // Utility pixel converter
00174    PixelReadConvert *PixelReadConverter;
00176    PixelWriteConvert *PixelWriteConverter;
00177 
00178    // Utility header archive
00180    DocEntryArchive *Archive;
00181 
00182    // Write variables
00184    FileMode WriteMode;
00186    FileType WriteType;
00187 };
00188 } // end namespace gdcm
00189 
00190 //-----------------------------------------------------------------------------
00191 #endif

Generated on Thu Feb 10 22:17:59 2005 for gdcm by doxygen 1.3.6