1 /*=========================================================================
4 Module: $RCSfile: gdcmVR.cxx,v $
6 Date: $Date: 2004/10/08 04:43:38 $
7 Version: $Revision: 1.18 $
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 =========================================================================*/
21 #include "gdcmDictSet.h"
22 #include "gdcmDebug.h"
27 //-----------------------------------------------------------------------------
33 std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_VR);
34 std::ifstream from(filename.c_str());
35 dbg.Error(!from, "gdcmVR::gdcmVR: can't open dictionary",filename.c_str());
43 from >> std::ws; // used to be eatwhite(from);
44 from.getline(buff, 1024, ' ');
46 from >> std::ws; // used to be eatwhite(from);
47 from.getline(buff, 1024, ';');
50 from >> std::ws; // used to be eatwhite(from);
51 from.getline(buff, 1024, '\n');
61 //-----------------------------------------------------------------------------
70 //-----------------------------------------------------------------------------
74 * @param os The output stream to be written to.
76 void gdcmVR::Print(std::ostream &os)
80 for (gdcmVRHT::iterator it = vr.begin(); it != vr.end(); ++it)
82 s << "VR : "<<it->first<<" = "<<it->second<<std::endl;
87 //-----------------------------------------------------------------------------
90 * \brief Get the count for an element
91 * @param key key to count
93 int gdcmVR::Count(gdcmVRKey key)
98 //-----------------------------------------------------------------------------
100 * \brief Simple predicate that checks wether the given argument
101 * corresponds to the Value Representation of a \ref gdcmBinEntry .
102 * This predicate is the negation of
103 * \ref gdcmVR::IsVROfGdcmStringRepresentable .
104 * @param tested value representation to check for.
106 bool gdcmVR::IsVROfGdcmBinaryRepresentable(gdcmVRKey tested)
108 //std::cout << "gdcmVR::IsVROfGdcmBinaryRepresentable===================="
109 // << tested << std::endl;
111 if ( tested == "unkn")
114 if ( ! Count(tested) )
116 dbg.Verbose(0, "gdcmVR::IsVROfGdcmBinaryRepresentable: tested not a VR!");
120 if ( IsVROfGdcmStringRepresentable(tested) )
122 dbg.Verbose(0, "gdcmVR::IsVROfGdcmBinaryRepresentable: binary VR !");
129 //-----------------------------------------------------------------------------
131 * \brief Simple predicate that checks wether the given argument
132 * corresponds to the Value Representation of a \ref gdcmValEntry
133 * but NOT a \ref gdcmBinEntry.
134 * @param tested value representation to check for.
136 bool gdcmVR::IsVROfGdcmStringRepresentable(gdcmVRKey tested)
139 if ( ! Count(tested) )
141 dbg.Verbose(0, "gdcmVR::IsVROfGdcmStringRepresentable: tested not a VR!");
145 if (tested == "AE" || tested == "AS" || tested == "DA" || tested == "PN" ||
146 tested == "UI" || tested == "TM" || tested == "SH" || tested == "LO" ||
147 tested == "CS" || tested == "IS" || tested == "LO" || tested == "LT" ||
148 tested == "SH" || tested == "ST" || tested == "DS" || tested == "SL" ||
149 tested == "SS" || tested == "UL" || tested == "US" || tested == "UN")
156 //-----------------------------------------------------------------------------
159 //-----------------------------------------------------------------------------
162 //-----------------------------------------------------------------------------