]> Creatis software - gdcm.git/blob - src/gdcmFile.h
* src/gdcm.h splitted in gdcmCommon.h, gdcmDict.h, gdcmDictEntry.h,
[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 ////// QUESTION: this looks still like an open question whether the
14 //////           relationship between a gdcmFile and gdcmHeader is of
15 //////           type IS_A or HAS_A !
16
17 class GDCM_EXPORT gdcmFile: public gdcmHeader
18 {
19 private:
20         // QUESTION :
21         // Data pointe sur quoi?
22         // sur les Pixels lus?
23         // --> j'ajoute un champ public : Pixels
24         // (il faudra que l'utilisateur puisse modifier les pixels ?)
25         
26         void* Data;
27         int Parsed;          // weather allready parsed
28         string OrigFileName; // To avoid file overwrite
29 public:
30         // je ne suis pas sur d'avoir compris *où* il serait légitime de ranger ca.
31         // on pourra tjs le deplacer, et mettre des accesseurs
32         void * Pixels;
33         size_t lgrTotale;
34         
35         // Constructor dedicated to writing a new DICOMV3 part10 compliant
36         // file (see SetFileName, SetDcmTag and Write)
37         // TODO Swig gdcmFile();
38         // Opens (in read only and when possible) an existing file and checks
39         // for DICOM compliance. Returns NULL on failure.
40         // Note: the in-memory representation of all available tags found in
41         //    the DICOM header is post-poned to first header information access.
42         //    This avoid a double parsing of public part of the header when
43         //    one sets an a posteriori shadow dictionary (efficiency can be
44         //    seen as a side effect).
45         
46         gdcmFile(string & filename);
47         
48         // For promotion (performs a deepcopy of pointed header object)
49         // TODO Swig gdcmFile(gdcmHeader* header);
50         // TODO Swig ~gdcmFile();
51
52         // On writing purposes. When instance was created through
53         // gdcmFile(string filename) then the filename argument MUST be different
54         // from the constructor's one (no overwriting allowed).
55         // TODO Swig int SetFileName(string filename);
56
57         // Allocates necessary memory, copies the data (image[s]/volume[s]) to
58         // newly allocated zone and return a pointer to it:
59         
60          void * GetImageData();
61         
62         // Returns size (in bytes) of required memory to contain data
63         // represented in this file.
64         
65         size_t GetImageDataSize();
66         
67         // Copies (at most MaxSize bytes) of data to caller's memory space.
68         // Returns an error code on failure (if MaxSize is not big enough)
69         
70         int GetImageDataIntoVector(void* destination, size_t MaxSize );
71         
72         // Question :
73         //
74         //      GetImageData et GetImageDataIntoVector
75         // Get et Put pour 2 fonctions qui font presque la meme chose :-(
76         //
77         
78         // Allocates ExpectedSize bytes of memory at this->Data and copies the
79         // pointed data to it.
80         
81         // Question :
82         // Pourquoi dupliquer les pixels, alors qu'on les a deja en mémoire,
83         // et que Data (dans le gdcmHeader) est un pointeur ?
84         
85         // TODO Swig int SetImageData(void * Data, size_t ExpectedSize);
86         
87         // Push to disk.
88         // A NE PAS OUBLIER : que fait-on en cas de Transfert Syntax (dans l'entete)
89         // incohérente avec l'ordre des octets en mémoire  
90         // TODO Swig int Write();
91         
92         // Ecrit sur disque les pixels d'UNE image
93         // Aucun test n'est fait sur l'"Endiannerie" du processeur.
94         // Ca sera à l'utilisateur d'appeler son Reader correctement
95                 
96         int WriteRawData (string nomFichier);
97         int WriteDcm     (string nomFichier);
98 };
99
100 #endif