X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmFile.h;h=b8275b03b548033e869361fb80b6c698bb8f1dc3;hb=5b89bede4607999aeb8d5b45311e7ee82f9471ef;hp=e9bf7081b0321b3c8ff4516253f3469f294095a2;hpb=cbdf7d814e2c43c37dff624581dd77ac178e9ce7;p=gdcm.git diff --git a/src/gdcmFile.h b/src/gdcmFile.h index e9bf7081..b8275b03 100644 --- a/src/gdcmFile.h +++ b/src/gdcmFile.h @@ -1,72 +1,193 @@ -// gdcmFile.h +/*========================================================================= + + Program: gdcm + Module: $RCSfile: gdcmFile.h,v $ + Language: C++ + Date: $Date: 2005/02/02 16:18:48 $ + Version: $Revision: 1.102 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ #ifndef GDCMFILE_H #define GDCMFILE_H -#include "gdcmCommon.h" -#include "gdcmHeader.h" +#include "gdcmDocument.h" -//////////////////////////////////////////////////////////////////////////// -// In addition to Dicom header exploration, this class is designed -// for accessing the image/volume content. One can also use it to -// write Dicom files. +namespace gdcm +{ +class RLEFramesInfo; +class JPEGFragmentsInfo; + +//----------------------------------------------------------------------------- +// Dicom Part 3.3 Compliant +enum ModalityType { + Unknow, + AU, // Voice Audio + AS, // Angioscopy + BI, // Biomagnetic Imaging + CF, // Cinefluorography + CP, // Culposcopy + CR, // Computed Radiography + CS, // Cystoscopy + CT, // Computed Tomography + DD, // Duplex Dopler + DF, // Digital Fluoroscopy + DG, // Diaphanography + DM, // Digital Microscopy + DS, // Digital Substraction Angiography + DX, // Digital Radiography + ECG, // Echocardiography + EPS, // Basic Cardiac EP + ES, // Endoscopy + FA, // Fluorescein Angiography + FS, // Fundoscopy + HC, // Hard Copy + HD, // Hemodynamic + LP, // Laparoscopy + LS, // Laser Surface Scan + MA, // Magnetic Resonance Angiography + MR, // Magnetic Resonance + NM, // Nuclear Medicine + OT, // Other + PT, // Positron Emission Tomography + RF, // Radio Fluoroscopy + RG, // Radiographic Imaging + RTDOSE, // Radiotherapy Dose + RTIMAGE, // Radiotherapy Image + RTPLAN, // Radiotherapy Plan + RTSTRUCT, // Radiotherapy Structure Set + SM, // Microscopic Imaging + ST, // Single-photon Emission Computed Tomography + TG, // Thermography + US, // Ultrasound + VF, // Videofluorography + XA, // X-Ray Angiography + XC // Photographic Imaging +}; + +//----------------------------------------------------------------------------- -class GDCM_EXPORT gdcmFile: public gdcmHeader +/** + * \brief DICOM elements and their corresponding values (and + * additionaly the corresponding DICOM dictionary entry) of the header + * of a DICOM file. + * + * The typical usage of instances of class File is to classify a set of + * dicom files according to header information e.g. to create a file hierarchy + * reflecting the Patient/Study/Serie informations, or extracting a given + * SerieId. Accessing the content (image[s] or volume[s]) is beyond the + * functionality of this class and belongs to gdmcFile. + * \note The various entries of the explicit value representation (VR) shall + * be managed within a dictionary which is shared by all File + * instances. + * \note The File::Set*Tag* family members cannot be defined as + * protected due to Swig limitations for as Has_a dependency between + * File and FileHelper. + */ +class GDCM_EXPORT File : public Document { -private: - void* PixelData; - size_t lgrTotale; - int Parsed; // weather already parsed - std::string OrigFileName; // To avoid file overwrite - void SwapZone(void* im, int swap, int lgr, int nb); - bool ReadPixelData(void * destination); - - int gdcm_read_JPEG_file (void * image_buffer); - -protected: - int WriteBase(std::string FileName, FileType type); public: - gdcmFile(std::string & filename); - gdcmFile(const char * filename); - - // For promotion (performs a deepcopy of pointed header object) - // TODO Swig gdcmFile(gdcmHeader* header); - // TODO Swig ~gdcmFile(); - - // On writing purposes. When instance was created through - // gdcmFile(std::string filename) then the filename argument MUST be - // different from the constructor's one (no overwriting allowed). - // TODO Swig int SetFileName(std::string filename); - - void SetPixelDataSizeFromHeader(void); - size_t GetImageDataSize(); - void * GetImageData(); - size_t GetImageDataIntoVector(void* destination, size_t MaxSize ); - - // Allocates ExpectedSize bytes of memory at this->Data and copies the - // pointed data to it. Copying the image might look useless but - // the caller might destroy it's image (without knowing it: think - // of a complicated interface where display is done with a library - // e.g. VTK) before calling the Write - int SetImageData (void * Data, size_t ExpectedSize); - // When the caller is aware we simply point to the data: - // TODO int SetImageDataNoCopy (void * Data, size_t ExpectedSize); - void SetImageDataSize (size_t ExpectedSize); - - // Push to disk. - // A NE PAS OUBLIER : que fait-on en cas de Transfert Syntax (dans l'entete) - // incohérente avec l'ordre des octets en mémoire ? - // TODO Swig int Write(); - - // Ecrit sur disque les pixels d'UNE image - // Aucun test n'est fait sur l'"Endiannerie" du processeur. - // Ca sera à l'utilisateur d'appeler son Reader correctement - - int WriteRawData (std::string nomFichier); - int WriteDcmImplVR(std::string nomFichier); - int WriteDcmImplVR(const char * nomFichier); - int WriteDcmExplVR(std::string nomFichier); - int WriteAcr (std::string nomFichier); + File(); + File( std::string const &filename ); + ~File(); + + // Standard values and informations contained in the header + bool IsReadable(); + + // Some heuristic based accessors, end user intended + int GetImageNumber(); + ModalityType GetModality(); + + int GetXSize(); + int GetYSize(); + int GetZSize(); + + float GetXSpacing(); + float GetYSpacing(); + float GetZSpacing(); + + float GetXOrigin(); + float GetYOrigin(); + float GetZOrigin(); + + void GetImageOrientationPatient( float iop[6] ); + + int GetBitsStored(); + int GetBitsAllocated(); + int GetHighBitPosition(); + int GetSamplesPerPixel(); + int GetPlanarConfiguration(); + int GetPixelSize(); + std::string GetPixelType(); + bool IsSignedPixelData(); + bool IsMonochrome(); + bool IsPaletteColor(); + bool IsYBRFull(); + + bool HasLUT(); + int GetLUTNbits(); + + // For rescaling graylevel: + float GetRescaleIntercept(); + float GetRescaleSlope(); + + int GetNumberOfScalarComponents(); + int GetNumberOfScalarComponentsRaw(); + + /// Accessor to \ref File::GrPixel + uint16_t GetGrPixel() { return GrPixel; } + /// Accessor to \ref File::NumPixel + uint16_t GetNumPixel() { return NumPixel; } + + size_t GetPixelOffset(); + size_t GetPixelAreaLength(); + + /// returns the RLE info + RLEFramesInfo *GetRLEInfo() { return RLEInfo; } + /// Returns the JPEG Fragments info + JPEGFragmentsInfo *GetJPEGInfo() { return JPEGInfo; } + + /// Replace patient's specific information by 'anonymous' + bool AnonymizeFile(); + + bool Write(std::string fileName, FileType filetype); + +protected: + /// Initialize DICOM File when none + void InitializeDefaultFile(); + + /// Store the RLE frames info obtained during parsing of pixels. + RLEFramesInfo *RLEInfo; + /// Store the JPEG fragments info obtained during parsing of pixels. + JPEGFragmentsInfo *JPEGInfo; + + /// \brief In some cases (e.g. for some ACR-NEMA images) the Entry Element + /// Number of the 'Pixel Element' is *not* found at 0x0010. In order to + /// make things easier the parser shall store the proper value in + /// NumPixel to provide a unique access facility. + uint16_t NumPixel; + /// \brief In some cases (e.g. for some ACR-NEMA images) the header entry for + /// the group of pixels is *not* found at 0x7fe0. In order to + /// make things easier the parser shall store the proper value in + /// GrPixel to provide a unique access facility. + uint16_t GrPixel; + +private: + void ComputeRLEInfo(); + void ComputeJPEGFragmentInfo(); + bool ReadTag(uint16_t, uint16_t); + uint32_t ReadTagLength(uint16_t, uint16_t); + void ReadAndSkipEncapsulatedBasicOffsetTable(); }; +} // end namespace gdcm +//----------------------------------------------------------------------------- #endif