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