1 /*=========================================================================
4 Module: $RCSfile: gdcmTS.cxx,v $
6 Date: $Date: 2005/01/18 08:01:42 $
7 Version: $Revision: 1.37 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
20 #include "gdcmDebug.h"
22 #include "gdcmDictSet.h"
29 // a lot of troubles expected with TS : 1.2.840.113619.5.2
30 // Implicit VR - Big Endian
31 // see : http://www.gemedicalsystemseurope.com/euen/it_solutions/pdf/lsqxi_rev2.pdf
36 //-----------------------------------------------------------------------------
37 static const char *SpecialStrings[] = {
38 // Implicit VR Little Endian
40 // Implicit VR Big Endian DLX (G.E Private)
42 // Explicit VR Little Endian
43 "1.2.840.10008.1.2.1",
44 // Deflated Explicit VR Little Endian
45 "1.2.840.10008.1.2.1.99",
46 // Explicit VR Big Endian
47 "1.2.840.10008.1.2.2",
48 // JPEG Baseline (Process 1)
49 "1.2.840.10008.1.2.4.50",
50 // JPEG Extended (Process 2 & 4)
51 "1.2.840.10008.1.2.4.51",
52 // JPEG Extended (Process 3 & 5)
53 "1.2.840.10008.1.2.4.52",
54 // JPEG Spectral Selection, Non-Hierarchical (Process 6 & 8)
55 "1.2.840.10008.1.2.4.53",
56 // JPEG Full Progression, Non-Hierarchical (Process 10 & 12)
57 "1.2.840.10008.1.2.4.55",
58 // JPEG Lossless, Non-Hierarchical (Process 14)
59 "1.2.840.10008.1.2.4.57",
60 // JPEG Lossless, Hierarchical, First-Order Prediction (Process 14, [Selection Value 1])
61 "1.2.840.10008.1.2.4.70",
63 "1.2.840.10008.1.2.4.90",
65 "1.2.840.10008.1.2.4.91",
67 "1.2.840.10008.1.2.5",
69 "Unknown Transfer Syntax"
72 void FillDefaultTSDict(TSHT &ts);
73 //-----------------------------------------------------------------------------
74 // Constructor / Destructor
77 std::string filename = DictSet::BuildDictPath() + DICT_TS;
78 std::ifstream from(filename.c_str());
81 gdcmVerboseMacro("Can't open dictionary" << filename.c_str());
82 FillDefaultTSDict( TsMap );
93 std::getline(from, name);
104 //-----------------------------------------------------------------------------
110 //-----------------------------------------------------------------------------
114 * @param os The output stream to be written to.
116 void TS::Print(std::ostream &os)
118 std::ostringstream s;
120 for (TSHT::const_iterator it = TsMap.begin(); it != TsMap.end(); ++it)
122 s << "TS : " << it->first << " = " << it->second << std::endl;
127 //-----------------------------------------------------------------------------
129 int TS::Count(TSKey const &key)
131 return TsMap.count(key);
134 TSAtr const & TS::GetValue(TSKey const &key)
136 // First thing clean up the string sometime the transfer syntax is padded with spaces
137 std::string copy = key;
138 while ( copy.size() && !isdigit((unsigned char)copy[copy.size()-1]) )
140 copy.erase(copy.size()-1, 1);
143 TSHT::const_iterator it = TsMap.find(copy);
144 if (it == TsMap.end())
151 bool TS::IsTransferSyntax(TSKey const &key)
153 TSHT::const_iterator it = TsMap.find(key);
154 return it != TsMap.end();
157 bool TS::IsRLELossless(TSKey const &key)
160 // First check this is an actual transfer syntax
161 if( IsTransferSyntax(key) )
163 if ( key == SpecialStrings[RLELossless] )
171 bool TS::IsJPEGLossless(TSKey const &key)
174 // First check this is an actual transfer syntax
175 if( IsTransferSyntax(key) )
177 if ( key == SpecialStrings[JPEGFullProgressionProcess10_12]
178 || key == SpecialStrings[JPEGLosslessProcess14]
179 || key == SpecialStrings[JPEGLosslessProcess14_1] )
188 * \brief Determines if the Transfer Syntax was already encountered
189 * and if it corresponds to a JPEG2000 one
190 * @return True when JPEG2000 (Lossly or LossLess) found. False in all
193 bool TS::IsJPEG2000(TSKey const &key)
196 // First check this is an actual transfer syntax
197 if( IsTransferSyntax(key) )
199 if ( key == SpecialStrings[JPEG2000Lossless]
200 || key == SpecialStrings[JPEG2000] )
209 * \brief Determines if the Transfer Syntax corresponds to any form
210 * of Jpeg encoded Pixel data.
211 * @return True when any form of JPEG found. False otherwise.
213 bool TS::IsJPEG(TSKey const &key)
216 // First check this is an actual transfer syntax
217 if( IsTransferSyntax(key) )
219 if ( key == SpecialStrings[JPEGBaselineProcess1]
220 || key == SpecialStrings[JPEGExtendedProcess2_4]
221 || key == SpecialStrings[JPEGExtendedProcess3_5]
222 || key == SpecialStrings[JPEGSpectralSelectionProcess6_8]
223 || IsJPEGLossless( key )
224 || IsJPEG2000( key ) )
233 * \brief Determines if the Transfer Syntax corresponds to encapsulated
234 * of encoded Pixel Data (as opposed to native).
235 * @return True when encapsulated. False when native.
237 bool TS::IsEncapsulate(TSKey const &key)
240 // First check this is an actual transfer syntax
241 if( IsTransferSyntax(key) )
243 if ( key == SpecialStrings[RLELossless]
252 TS::SpecialType TS::GetSpecialTransferSyntax(TSKey const &key)
254 for (int i = 0; SpecialStrings[i] != NULL; i++)
256 if ( SpecialStrings[i] == key )
258 return SpecialType(i);
265 const char* TS::GetSpecialTransferSyntax(SpecialType t)
267 return SpecialStrings[t];
270 //-----------------------------------------------------------------------------
273 //-----------------------------------------------------------------------------
276 //-----------------------------------------------------------------------------
278 } // end namespace gdcm