1 /*=========================================================================
2 
3   Program: GDCM (Grassroots DICOM). A DICOM library
4 
5   Copyright (c) 2006-2011 Mathieu Malaterre
6   All rights reserved.
7   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8 
9      This software is distributed WITHOUT ANY WARRANTY; without even
10      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11      PURPOSE.  See the above copyright notice for more information.
12 
13 =========================================================================*/
14 #ifndef GDCMMEDIASTORAGE_H
15 #define GDCMMEDIASTORAGE_H
16 
17 #include "gdcmTransferSyntax.h"
18 
19 namespace gdcm { class Tag; }
20 namespace gdcm_ns
21 {
22 #if !defined(SWIGPYTHON) && !defined(SWIGCSHARP) && !defined(SWIGJAVA) && !defined(SWIGPHP)
23 using namespace gdcm;
24 #endif
25 class DataSet;
26 class FileMetaInformation;
27 class File;
28 
29 // WARNING: This class will be deprecated in the future. There is no reason to extend this class.
30 // Please check the gdcm::UIDs class if adding new well known UID.
31 
32 /**
33  * \brief MediaStorage
34  *
35  * \note
36  * FIXME There should not be any notion of Image and/or PDF at that point
37  * Only the codec can answer yes I support this Media Storage or not...
38  * For instance an ImageCodec will answer yes to most of them
39  * while a PDFCodec will answer only for the Encapsulated PDF
40  *
41  * \see UIDs
42  */
43 class GDCM_EXPORT MediaStorage
44 {
45 public:
46   typedef enum {
47     MediaStorageDirectoryStorage = 0,
48     ComputedRadiographyImageStorage,
49     DigitalXRayImageStorageForPresentation,
50     DigitalXRayImageStorageForProcessing,
51     DigitalMammographyImageStorageForPresentation,
52     DigitalMammographyImageStorageForProcessing,
53     DigitalIntraoralXrayImageStorageForPresentation,
54     DigitalIntraoralXRayImageStorageForProcessing,
55     CTImageStorage,
56     EnhancedCTImageStorage,
57     UltrasoundImageStorageRetired,
58     UltrasoundImageStorage,
59     UltrasoundMultiFrameImageStorageRetired,
60     UltrasoundMultiFrameImageStorage,
61     MRImageStorage,
62     EnhancedMRImageStorage,
63     MRSpectroscopyStorage,
64     NuclearMedicineImageStorageRetired,
65     SecondaryCaptureImageStorage,
66     MultiframeSingleBitSecondaryCaptureImageStorage,
67     MultiframeGrayscaleByteSecondaryCaptureImageStorage,
68     MultiframeGrayscaleWordSecondaryCaptureImageStorage,
69     MultiframeTrueColorSecondaryCaptureImageStorage,
70     StandaloneOverlayStorage,
71     StandaloneCurveStorage,
72     LeadECGWaveformStorage, // 12-
73     GeneralECGWaveformStorage,
74     AmbulatoryECGWaveformStorage,
75     HemodynamicWaveformStorage,
76     CardiacElectrophysiologyWaveformStorage,
77     BasicVoiceAudioWaveformStorage,
78     StandaloneModalityLUTStorage,
79     StandaloneVOILUTStorage,
80     GrayscaleSoftcopyPresentationStateStorageSOPClass,
81     XRayAngiographicImageStorage,
82     XRayRadiofluoroscopingImageStorage,
83     XRayAngiographicBiPlaneImageStorageRetired,
84     NuclearMedicineImageStorage,
85     RawDataStorage,
86     SpacialRegistrationStorage, // Spatial
87     SpacialFiducialsStorage, // Spatial..
88     PETImageStorage,
89     RTImageStorage,
90     RTDoseStorage,
91     RTStructureSetStorage,
92     RTPlanStorage,
93     CSANonImageStorage,
94     Philips3D,
95     EnhancedSR,
96     BasicTextSR,
97     HardcopyGrayscaleImageStorage,
98     ComprehensiveSR,
99     DetachedStudyManagementSOPClass,
100     EncapsulatedPDFStorage,
101     EncapsulatedCDAStorage,
102     StudyComponentManagementSOPClass,
103     DetachedVisitManagementSOPClass,
104     DetachedPatientManagementSOPClass,
105     VideoEndoscopicImageStorage,
106     GeneralElectricMagneticResonanceImageStorage,
107     GEPrivate3DModelStorage,
108     ToshibaPrivateDataStorage,
109     MammographyCADSR,
110     KeyObjectSelectionDocument,
111     HangingProtocolStorage,
112     ModalityPerformedProcedureStepSOPClass,
113     PhilipsPrivateMRSyntheticImageStorage,
114     VLPhotographicImageStorage,
115     SegmentationStorage, // "1.2.840.10008.5.1.4.1.1.66.4"
116     RTIonPlanStorage, // 1.2.840.10008.5.1.4.1.1.481.8
117     XRay3DAngiographicImageStorage, // 1.2.840.10008.5.1.4.1.1.13.1.1
118     EnhancedXAImageStorage,
119     RTIonBeamsTreatmentRecordStorage, // 1.2.840.10008.5.1.4.1.1.481.9
120     SurfaceSegmentationStorage, // "1.2.840.10008.5.1.4.1.1.66.5"
121     VLWholeSlideMicroscopyImageStorage, // 1.2.840.10008.5.1.4.1.1.77.1.6
122     RTTreatmentSummaryRecordStorage, // 1.2.840.10008.5.1.4.1.1.481.7
123     EnhancedUSVolumeStorage, // 1.2.840.10008.5.1.4.1.1.6.2
124     XRayRadiationDoseSR, // 1.2.840.10008.5.1.4.1.1.88.67
125     VLEndoscopicImageStorage, // 1.2.840.10008.5.1.4.1.1.77.1.1
126     BreastTomosynthesisImageStorage, // 1.2.840.10008.5.1.4.1.1.13.1.3
127     FujiPrivateCRImageStorage, // 1.2.392.200036.9125.1.1.2
128     OphthalmicPhotography8BitImageStorage, // 1.2.840.10008.5.1.4.1.1.77.1.5.1
129     OphthalmicTomographyImageStorage, // 1.2.840.10008.5.1.4.1.1.77.1.5.4
130     VLMicroscopicImageStorage,
131     EnhancedPETImageStorage,
132     VideoPhotographicImageStorage,
133     XRay3DCraniofacialImageStorage,
134     IVOCTForPresentation,
135     IVOCTForProcessing,
136     LegacyConvertedEnhancedCTImageStorage,
137     LegacyConvertedEnhancedMRImageStorage,
138     LegacyConvertedEnhancedPETImageStorage,
139     BreastProjectionXRayImageStorageForPresentation,
140     BreastProjectionXRayImageStorageForProcessing,
141     MS_END
142   } MSType; // Media Storage Type
143 
144 typedef enum {
145     NoObject = 0, // DICOMDIR
146     Video, // Most common, include image, video and volume
147     Waveform, // Isn't it simply a 1D video ?
148     Audio, // ???
149     PDF,
150     URI, // URL...
151     Segmentation, // TODO
152     ObjectEnd
153   } ObjectType;
154 
155   /// Return the Media String associated. Will return NULL for MS_END
156   static const char* GetMSString(MSType ts);
157 
158   /// Return the Media String of the object.
159   const char* GetString() const;
160   static MSType GetMSType(const char *str);
161 
MSField(type)162   MediaStorage(MSType type = MS_END):MSField(type) {}
163 
164   /// Returns whether DICOM has a Pixel Data element (7fe0,0010)
165   /// \warning MRSpectroscopyStorage could be image but are not
166   static bool IsImage(MSType ts);
167 
MSType()168   operator MSType () const { return MSField; }
169 
170   const char *GetModality() const;
171   unsigned int GetModalityDimension() const;
172 
173   static unsigned int GetNumberOfMSType();
174   static unsigned int GetNumberOfMSString();
175   static unsigned int GetNumberOfModality();
176 
177 
178   /// Attempt to set the MediaStorage from a file:
179   /// WARNING: When no MediaStorage & Modality are found BUT a PixelData element is found
180   /// then MediaStorage is set to the default SecondaryCaptureImageStorage (return value is
181   /// false in this case)
182   bool SetFromFile(File const &file);
183 
184   /// Advanced user only (functions should be protected level...)
185   /// Those function are lower level than SetFromFile
186   bool SetFromDataSet(DataSet const &ds); // Will get the SOP Class UID
187   bool SetFromHeader(FileMetaInformation const &fmi); // Will get the Media Storage SOP Class UID
188   bool SetFromModality(DataSet const &ds);
189   void GuessFromModality(const char *modality, unsigned int dimension = 2);
190 
191   friend std::ostream &operator<<(std::ostream &os, const MediaStorage &ms);
192 
IsUndefined()193   bool IsUndefined() const { return MSField == MS_END; }
194 
195 protected:
196   void SetFromSourceImageSequence(DataSet const &ds);
197 
198 private:
199   bool SetFromDataSetOrHeader(DataSet const &ds, const Tag & tag);
200   /// NOT THREAD SAFE
201   const char* GetFromDataSetOrHeader(DataSet const &ds, const Tag & tag);
202   /// NOT THREAD SAFE
203   const char* GetFromHeader(FileMetaInformation const &fmi);
204   /// NOT THREAD SAFE
205   const char* GetFromDataSet(DataSet const &ds);
206 
207 private:
208   MSType MSField;
209 };
210 //-----------------------------------------------------------------------------
211 inline std::ostream &operator<<(std::ostream &_os, const MediaStorage &ms)
212 {
213   const char *msstring = MediaStorage::GetMSString(ms);
214   _os << (msstring ? msstring : "INVALID MEDIA STORAGE");
215   return _os;
216 
217 }
218 
219 } // end namespace gdcm_ns
220 
221 #endif // GDCMMEDIASTORAGE_H
222