]> Creatis software - gdcm.git/blob - src/gdcmFile.h
* src/gdcmHeader>[h/cxx] added gdcmHeader::GetPixelSize()
[gdcm.git] / src / gdcmFile.h
1 // gdcmFile.h
2
3 #ifndef GDCMFILE_H
4 #define GDCMFILE_H
5
6 #include "gdcmCommon.h"
7 #include "gdcmHeader.h"
8
9 ////////////////////////////////////////////////////////////////////////////
10 // In addition to Dicom header exploration, this class is designed
11 // for accessing the image/volume content. One can also use it to
12 // write Dicom files.
13
14 class GDCM_EXPORT gdcmFile: public gdcmHeader
15 {
16 private:
17         void* PixelData;
18         size_t lgrTotale;
19         int Parsed;          // weather allready parsed
20         string OrigFileName; // To avoid file overwrite
21    void SwapZone(void* im, int swap, int lgr, int nb);
22    bool ReadPixelData(void * destination);
23 protected:
24    int WriteBase(string FileName, FileType type);
25 public:
26         gdcmFile(string & filename);
27         gdcmFile(const char * filename);
28         
29         // For promotion (performs a deepcopy of pointed header object)
30         // TODO Swig gdcmFile(gdcmHeader* header);
31         // TODO Swig ~gdcmFile();
32
33         // On writing purposes. When instance was created through
34         // gdcmFile(string filename) then the filename argument MUST be different
35         // from the constructor's one (no overwriting allowed).
36         // TODO Swig int SetFileName(string filename);
37
38    void   SetPixelDataSizeFromHeader(void);
39         size_t GetImageDataSize();
40         void * GetImageData();
41         size_t GetImageDataIntoVector(void* destination, size_t MaxSize );
42         
43         // Allocates ExpectedSize bytes of memory at this->Data and copies the
44         // pointed data to it. Copying the image might look useless but
45    // the caller might destroy it's image (without knowing it: think
46    // of a complicated interface where display is done with a library
47    // e.g. VTK) before calling the Write
48         int SetImageData     (void * Data, size_t ExpectedSize);
49    // When the caller is aware we simply point to the data:
50         // TODO int SetImageDataNoCopy (void * Data, size_t ExpectedSize);
51         void SetImageDataSize (size_t ExpectedSize);
52         
53         // Push to disk.
54         // A NE PAS OUBLIER : que fait-on en cas de Transfert Syntax (dans l'entete)
55         // incohérente avec l'ordre des octets en mémoire  
56         // TODO Swig int Write();
57         
58         // Ecrit sur disque les pixels d'UNE image
59         // Aucun test n'est fait sur l'"Endiannerie" du processeur.
60         // Ca sera à l'utilisateur d'appeler son Reader correctement
61                 
62         int WriteRawData        (string nomFichier);
63         int WriteDcmImplVR(string nomFichier);
64         int WriteDcmImplVR(const char * nomFichier);
65         int WriteDcmExplVR(string nomFichier);
66         int WriteAcr            (string nomFichier);
67 };
68
69 #endif