1 /*=========================================================================
4 Module: $RCSfile: gdcmVR.cxx,v $
6 Date: $Date: 2004/10/27 22:31:12 $
7 Version: $Revision: 1.21 $
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"
29 //-----------------------------------------------------------------------------
35 std::string filename = DictSet::BuildDictPath() + DICT_VR;
36 std::ifstream from(filename.c_str());
37 dbg.Error(!from, "VR::VR: can't open dictionary", filename.c_str());
46 from.getline(buff, 1024, ' ');
49 from.getline(buff, 1024, ';');
53 from.getline(buff, 1024, '\n');
63 //-----------------------------------------------------------------------------
72 //-----------------------------------------------------------------------------
76 * @param os The output stream to be written to.
78 void VR::Print(std::ostream &os)
82 for (VRHT::iterator it = vr.begin(); it != vr.end(); ++it)
84 s << "VR : " << it->first << " = " << it->second << std::endl;
89 //-----------------------------------------------------------------------------
92 * \brief Get the count for an element
93 * @param key key to count
95 int VR::Count(VRKey const & key)
100 //-----------------------------------------------------------------------------
102 * \brief Simple predicate that checks wether the given argument
103 * corresponds to the Value Representation of a \ref BinEntry .
104 * This predicate is the negation of
105 * \ref VR::IsVROfGdcmStringRepresentable .
106 * @param tested value representation to check for.
108 bool VR::IsVROfGdcmBinaryRepresentable(VRKey const & tested)
110 //std::cout << "VR::IsVROfGdcmBinaryRepresentable===================="
111 // << tested << std::endl;
113 if ( tested == "unkn")
116 if ( ! Count(tested) )
118 dbg.Verbose(0, "VR::IsVROfGdcmBinaryRepresentable: tested not a VR!");
122 if ( IsVROfGdcmStringRepresentable(tested) )
124 dbg.Verbose(0, "VR::IsVROfGdcmBinaryRepresentable: binary VR !");
131 //-----------------------------------------------------------------------------
133 * \brief Simple predicate that checks wether the given argument
134 * corresponds to the Value Representation of a \ref ValEntry
135 * but NOT a \ref BinEntry.
136 * @param tested value representation to check for.
138 bool VR::IsVROfGdcmStringRepresentable(VRKey const & tested)
141 if ( ! Count(tested) )
143 dbg.Verbose(0, "VR::IsVROfGdcmStringRepresentable: tested not a VR!");
147 if (tested == "AE" || tested == "AS" || tested == "DA" || tested == "PN" ||
148 tested == "UI" || tested == "TM" || tested == "SH" || tested == "LO" ||
149 tested == "CS" || tested == "IS" || tested == "LO" || tested == "LT" ||
150 tested == "SH" || tested == "ST" || tested == "DS" || tested == "SL" ||
151 tested == "SS" || tested == "UL" || tested == "US" || tested == "UN")
158 //-----------------------------------------------------------------------------
161 //-----------------------------------------------------------------------------
164 //-----------------------------------------------------------------------------
166 } // end namespace gdcm