X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmTS.cxx;h=26c672df9f9107b02e145d1c724742415cd56218;hb=faf9f777a09c115e44b29d40a0c6ea2d122fc1e7;hp=7f5043856bc86ec21b918462549ad165bb5cd153;hpb=7589d23967892c94462e22a49ec50fcd225c5c38;p=gdcm.git diff --git a/src/gdcmTS.cxx b/src/gdcmTS.cxx index 7f504385..26c672df 100644 --- a/src/gdcmTS.cxx +++ b/src/gdcmTS.cxx @@ -1,43 +1,111 @@ -// gdcmTS.cxx - -#include +/*========================================================================= + + Program: gdcm + Module: $RCSfile: gdcmTS.cxx,v $ + Language: C++ + Date: $Date: 2004/11/03 18:08:56 $ + Version: $Revision: 1.28 $ + + 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. + +=========================================================================*/ #include "gdcmTS.h" +#include "gdcmDebug.h" +#include "gdcmUtil.h" +#include "gdcmDictSet.h" + +#include +#include +#include -gdcmTS::gdcmTS(void) { - ts["1.2.840.10008.1.2"] = "Implicit VR - Little Endian"; - ts["1.2.840.10008.1.2.1"] = "Explicit VR - Little Endian"; - ts["1.2.840.10008.1.2.1.99"] = "Deflated Explicit VR - Little Endian"; - ts["1.2.840.10008.1.2.2"] = "Explicit VR - Big Endian"; - ts["1.2.840.10008.1.2.4.50"] = "JPEG Baseline (Process 1)"; - ts["1.2.840.10008.1.2.4.51"] = "JPEG Extended (Process 2 & 4)"; - ts["1.2.840.10008.1.2.4.52"] = "JPEG Extended (Process 3 & 5)"; - ts["1.2.840.10008.1.2.4.53"] = "JPEG Spectral Selection, Non-Hierarchical (Process 6 & 8)"; - ts["1.2.840.10008.1.2.4.54"] = "JPEG Spectral Selection, Non-Hierarchical (Process 7 & 9)"; - ts["1.2.840.10008.1.2.4.55"] = "JPEG Spectral Selection, Non-Hierarchical (Process 10 & 12)"; - ts["1.2.840.10008.1.2.4.56"] = "JPEG Spectral Selection, Non-Hierarchical (Process 11 & 13)"; - ts["1.2.840.10008.1.2.4.57"] = "JPEG Baseline (Process 14)"; - ts["1.2.840.10008.1.2.4.58"] = "JPEG Baseline (Process 15)"; - ts["1.2.840.10008.1.2.4.59"] = "JPEG Spectral Selection, Non-Hierarchical (Process 16 & 18)"; - ts["1.2.840.10008.1.2.4.60"] = "JPEG Spectral Selection, Non-Hierarchical (Process 17 & 19)"; - ts["1.2.840.10008.1.2.4.61"] = "JPEG Spectral Selection, Non-Hierarchical (Process 20 & 22)"; - ts["1.2.840.10008.1.2.4.62"] = "JPEG Spectral Selection, Non-Hierarchical (Process 21 & 23)"; - ts["1.2.840.10008.1.2.4.63"] = "JPEG Spectral Selection, Non-Hierarchical (Process 24 & 26)"; - ts["1.2.840.10008.1.2.4.64"] = "JPEG Spectral Selection, Non-Hierarchical (Process 25 & 27)"; - ts["1.2.840.10008.1.2.4.65"] = "JPEG Lossless, Hierarchical (Process 28)"; - ts["1.2.840.10008.1.2.4.66"] = "JPEG Lossless, Hierarchical (Process 29)"; - ts["1.2.840.10008.1.2.4.70"] = "Non-Hierarchical, First-Order Prediction (Process 14 [Selection Value 1])"; - ts["1.2.840.10008.1.2.5"] = "RLE Lossless"; +namespace gdcm +{ +void FillDefaultTSDict(TSHT & ts); +//----------------------------------------------------------------------------- +// Constructor / Destructor +TS::TS() +{ + std::string filename = DictSet::BuildDictPath() + DICT_TS; + std::ifstream from(filename.c_str()); + if( !from ) + { + dbg.Verbose(2, "TS::TS: can't open dictionary", filename.c_str()); + FillDefaultTSDict( TsMap ); + } + else + { + TSKey key; + TSAtr name; + + while (!from.eof()) + { + from >> key; + from >> std::ws; + std::getline(from, name); + + if(key != "") + { + TsMap[key] = name; + } + } + from.close(); + } } -gdcmTS::~gdcmTS() { - ts.clear(); +//----------------------------------------------------------------------------- +TS::~TS() +{ + TsMap.clear(); +} + +//----------------------------------------------------------------------------- +// Print +/** + * \ingroup VR + * \brief Print all + * @param os The output stream to be written to. + */ +void TS::Print(std::ostream &os) +{ + std::ostringstream s; + + for (TSHT::const_iterator it = TsMap.begin(); it != TsMap.end(); ++it) + { + s << "TS : " << it->first << " = " << it->second << std::endl; + } + os << s.str(); } -int gdcmTS::Count(TSKey key) { - return ts.count(key); +//----------------------------------------------------------------------------- +// Public +int TS::Count(TSKey const & key) +{ + return TsMap.count(key); } -std::string gdcmTS::GetValue(TSKey key) { - return ts[key]; +TSAtr const & TS::GetValue(TSKey const & key) +{ + TSHT::const_iterator it = TsMap.find(key); + if (it == TsMap.end()) + { + return GDCM_UNFOUND; + } + return it->second; } + +//----------------------------------------------------------------------------- +// Protected + +//----------------------------------------------------------------------------- +// Private + +//----------------------------------------------------------------------------- + +} // end namespace gdcm