00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "gdcmValidator.h"
00020 #include "gdcmElementSet.h"
00021 #include "gdcmDataEntry.h"
00022 #include "gdcmUtil.h"
00023 #include "gdcmDebug.h"
00024 #include <map>
00025
00026
00027 namespace GDCM_NAME_SPACE
00028 {
00029
00030 typedef std::map<uint16_t, int> GroupHT;
00031
00033 Validator::Validator()
00034 {
00035 }
00037 Validator::~Validator()
00038 {
00039 }
00040
00041
00042
00043 bool CheckVM(DataEntry *entry)
00044 {
00045
00046
00047
00048 if ( entry->GetVR() == "OB" || entry->GetVR() == "OW" )
00049 return true;
00050
00051 const std::string &s = entry->GetString();
00052
00053 unsigned int n = Util::CountSubstring( s , "\\");
00054
00055 n++;
00056
00057 std::string vmFromDict = entry->GetVM();
00058 if ( vmFromDict == "1-n" || vmFromDict == "2-n" || vmFromDict == "3-n" )
00059 return true;
00060
00061 unsigned int m;
00062 std::istringstream is;
00063 is.str( vmFromDict );
00064 is >> m;
00065
00066 return n == m;
00067 }
00068
00069 void Validator::SetInput(ElementSet *input)
00070 {
00071
00072 DocEntry *d;
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 d=input->GetFirstEntry();
00090 if (!d)
00091 {
00092 std::cout << "No Entry found" << std::endl;
00093 return;
00094 }
00095 while(d)
00096 {
00097 if ( DataEntry *v = dynamic_cast<DataEntry *>(d) )
00098 {
00099 if ( v->GetVM() != GDCM_NAME_SPACE::GDCM_UNKNOWN )
00100 if ( !CheckVM(v) )
00101 {
00102 if (v->GetVM() == "FIXME" )
00103 std::cout << "For Tag " << v->GetKey() << " VM = ["
00104 << v->GetVM() << "]" << std::endl;
00105
00106 std::cout << "Tag (" << v->GetKey()
00107 << ")-> [" << v->GetName() << "] VR :" << v->GetVR()
00108 << " contains an illegal VM. Expected VM :["
00109 << v->GetVM() << "], value [" << v->GetString() << "]"
00110 << std::endl;
00111 }
00112
00113 if ( v->GetReadLength() % 2 )
00114 {
00115 std::cout << "Tag (" << v->GetKey()
00116 << ")-> [" << v->GetName() << "] has an uneven length :"
00117 << v->GetReadLength()
00118 << " [" << v->GetString() << "] "
00119 << std::endl;
00120 }
00121 }
00122 else
00123 {
00124
00125 }
00126 d=input->GetNextEntry();
00127 }
00128 }
00129
00130 }