X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmVR.cxx;h=77bbf2313bea542f05c03e027f7fcb9587f2307e;hb=bd1e1aea88a95e4d14cd59088a7e5280703402ea;hp=3fcb456cd0774173e51602ae22be8882d0a67ead;hpb=e40fc77cef3155aab87305ce2f8f14d1acbf158f;p=gdcm.git diff --git a/src/gdcmVR.cxx b/src/gdcmVR.cxx index 3fcb456c..77bbf231 100644 --- a/src/gdcmVR.cxx +++ b/src/gdcmVR.cxx @@ -3,12 +3,12 @@ Program: gdcm Module: $RCSfile: gdcmVR.cxx,v $ Language: C++ - Date: $Date: 2004/07/02 13:55:28 $ - Version: $Revision: 1.15 $ + Date: $Date: 2005/10/18 08:35:51 $ + Version: $Revision: 1.41 $ 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.htm for details. + 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 @@ -16,131 +16,152 @@ =========================================================================*/ -#include - -#include - #include "gdcmVR.h" #include "gdcmUtil.h" #include "gdcmDictSet.h" #include "gdcmDebug.h" +#include +#include + +namespace gdcm +{ //----------------------------------------------------------------------------- +/// \brief auto generated function, to fill up the 'Value Representation' +/// Dictionnary, if relevant file is not found on user's disk +void FillDefaultVRDict(VRHT &vr); + +//----------------------------------------------------------------------------- +// Constructor / Destructor /** * \brief Constructor */ -gdcmVR::gdcmVR(void) +VR::VR() { - std::string filename=gdcmDictSet::BuildDictPath() + std::string(DICT_VR); + std::string filename = DictSet::BuildDictPath() + DICT_VR; std::ifstream from(filename.c_str()); - dbg.Error(!from, "gdcmVR::gdcmVR: can't open dictionary",filename.c_str()); - - char buff[1024]; - std::string key; - std::string name; - - while (!from.eof()) + if ( !from ) { - eatwhite(from); - from.getline(buff, 1024, ' '); - key = buff; - eatwhite(from); - from.getline(buff, 1024, ';'); - name = buff; - - eatwhite(from); - from.getline(buff, 1024, '\n'); - - if(key!="") + gdcmWarningMacro("Can't open dictionary" << filename.c_str()); + FillDefaultVRDict(vr); + } + else + { + char buff[1024]; + VRKey key; + VRAtr name; + + while (!from.eof()) { - vr[key]=name; + from >> std::ws; + from.getline(buff, 1024, ' '); + key = buff; + from >> std::ws; + from.getline(buff, 1024, ';'); + name = buff; + + from >> std::ws; + from.getline(buff, 1024, '\n'); + + if ( key != "" ) + { + vr[key] = name; + } } + from.close(); } - from.close(); } /** * \brief Destructor */ -gdcmVR::~gdcmVR() { - vr.clear(); -} - -//----------------------------------------------------------------------------- -// Print -/** - * \brief Print all - * @param os The output stream to be written to. - */ -void gdcmVR::Print(std::ostream &os) +VR::~VR() { - std::ostringstream s; - - for (gdcmVRHT::iterator it = vr.begin(); it != vr.end(); ++it) - { - s << "VR : "<first<<" = "<second< But it doesn't work : revert to old code +/* + return tested != "FL" && + tested != "FD" && + tested != "OB" && + tested != "OW" && + tested != "AT" && // Attribute Tag ?!? + tested != "SQ" ; +*/ +} - if (tested == "AE" || tested == "AS" || tested == "DA" || tested == "PN" || - tested == "UI" || tested == "TM" || tested == "SH" || tested == "LO" || - tested == "CS" || tested == "IS" || tested == "LO" || tested == "LT" || - tested == "SH" || tested == "ST" || tested == "DS" || tested == "SL" || - tested == "SS" || tested == "UL" || tested == "US" || tested == "UN") - { - return true; - } - return false; +unsigned short VR::GetAtomicElementLength(VRKey const &vr) +{ + // Unsigned & signed short + if( vr == "US" || vr == "SS" ) + return 2; + // Unsigned & signed long + if( vr == "UL" || vr == "SL" ) + return 4; + // Float + if( vr == "FL" ) + return 4; + // Double + if( vr == "FD" ) + return 8; + // Word string + if( vr == "OW" ) + return 2; + return 1; } //----------------------------------------------------------------------------- @@ -150,3 +171,21 @@ bool gdcmVR::IsVROfGdcmStringRepresentable(gdcmVRKey tested) // Private //----------------------------------------------------------------------------- +// Print +/** + * \brief Print all + * @param os The output stream to be written to. + */ +void VR::Print(std::ostream &os) +{ + std::ostringstream s; + + for (VRHT::iterator it = vr.begin(); it != vr.end(); ++it) + { + s << "VR : " << it->first << " = " << it->second << std::endl; + } + os << s.str(); +} + +//----------------------------------------------------------------------------- +} // end namespace gdcm