1 /*=========================================================================
4 Module: $RCSfile: gdcmVR.cxx,v $
6 Date: $Date: 2004/10/12 04:35:48 $
7 Version: $Revision: 1.19 $
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"
30 //-----------------------------------------------------------------------------
36 std::string filename=DictSet::BuildDictPath() + std::string(DICT_VR);
37 std::ifstream from(filename.c_str());
38 dbg.Error(!from, "VR::VR: can't open dictionary",filename.c_str());
46 from >> std::ws; // used to be eatwhite(from);
47 from.getline(buff, 1024, ' ');
49 from >> std::ws; // used to be eatwhite(from);
50 from.getline(buff, 1024, ';');
53 from >> std::ws; // used to be eatwhite(from);
54 from.getline(buff, 1024, '\n');
64 //-----------------------------------------------------------------------------
73 //-----------------------------------------------------------------------------
77 * @param os The output stream to be written to.
79 void VR::Print(std::ostream &os)
83 for (VRHT::iterator it = vr.begin(); it != vr.end(); ++it)
85 s << "VR : "<<it->first<<" = "<<it->second<<std::endl;
90 //-----------------------------------------------------------------------------
93 * \brief Get the count for an element
94 * @param key key to count
96 int VR::Count(VRKey key)
101 //-----------------------------------------------------------------------------
103 * \brief Simple predicate that checks wether the given argument
104 * corresponds to the Value Representation of a \ref BinEntry .
105 * This predicate is the negation of
106 * \ref VR::IsVROfGdcmStringRepresentable .
107 * @param tested value representation to check for.
109 bool VR::IsVROfGdcmBinaryRepresentable(VRKey tested)
111 //std::cout << "VR::IsVROfGdcmBinaryRepresentable===================="
112 // << tested << std::endl;
114 if ( tested == "unkn")
117 if ( ! Count(tested) )
119 dbg.Verbose(0, "VR::IsVROfGdcmBinaryRepresentable: tested not a VR!");
123 if ( IsVROfGdcmStringRepresentable(tested) )
125 dbg.Verbose(0, "VR::IsVROfGdcmBinaryRepresentable: binary VR !");
132 //-----------------------------------------------------------------------------
134 * \brief Simple predicate that checks wether the given argument
135 * corresponds to the Value Representation of a \ref ValEntry
136 * but NOT a \ref BinEntry.
137 * @param tested value representation to check for.
139 bool VR::IsVROfGdcmStringRepresentable(VRKey tested)
142 if ( ! Count(tested) )
144 dbg.Verbose(0, "VR::IsVROfGdcmStringRepresentable: tested not a VR!");
148 if (tested == "AE" || tested == "AS" || tested == "DA" || tested == "PN" ||
149 tested == "UI" || tested == "TM" || tested == "SH" || tested == "LO" ||
150 tested == "CS" || tested == "IS" || tested == "LO" || tested == "LT" ||
151 tested == "SH" || tested == "ST" || tested == "DS" || tested == "SL" ||
152 tested == "SS" || tested == "UL" || tested == "US" || tested == "UN")
159 //-----------------------------------------------------------------------------
162 //-----------------------------------------------------------------------------
165 //-----------------------------------------------------------------------------
167 } // end namespace gdcm