--- /dev/null
+/*=========================================================================
+
+ Program: gdcm
+ Module: $RCSfile: TestValidate.cxx,v $
+ Language: C++
+ Date: $Date: 2005/06/14 20:33:53 $
+ Version: $Revision: 1.1 $
+
+ 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.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+#include "gdcmFile.h"
+#include "gdcmValidator.h"
+
+
+int TestValidate(int argc, char *argv[])
+{
+ if( argc < 2 )
+ {
+ std::cerr << "ouh les cornes" << std::endl;
+ return 1;
+ }
+
+ const char *filename = argv[1];
+
+ gdcm::File *input = new gdcm::File( filename );
+ gdcm::Validator *v = new gdcm::Validator();
+ v->SetInput( input );
+
+ return 0;
+}
+
--- /dev/null
+/*=========================================================================
+
+ Program: gdcm
+ Module: $RCSfile: gdcmValidator.cxx,v $
+ Language: C++
+ Date: $Date: 2005/06/14 20:33:54 $
+ Version: $Revision: 1.1 $
+
+ 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.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#include "gdcmValidator.h"
+#include "gdcmElementSet.h"
+#include "gdcmBinEntry.h"
+#include "gdcmValEntry.h"
+
+namespace gdcm
+{
+
+Validator::Validator()
+{
+}
+
+Validator::~Validator()
+{
+}
+
+// Function to compare the VM found while parsing d->GetValue()
+// compare to the one from the dictionary
+bool CheckVM(ValEntry *v)
+{
+ const std::string &s = v->GetValue();
+ std::string::size_type n = s.find("\\");
+ if (n == s.npos) // none found
+ {
+ n = 0;
+ }
+ n++; //poteaux / intervalles
+
+ unsigned int m = atoi(v->GetVM().c_str());
+
+ return n == m;
+}
+
+void Validator::SetInput(ElementSet *input)
+{
+ // berk for now SetInput do two things at the same time
+ gdcm::DocEntry *d=input->GetFirstEntry();
+ while(d)
+ {
+ if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
+ {
+// copyH->InsertBinEntry( b->GetBinArea(),b->GetLength(),
+// b->GetGroup(),b->GetElement(),
+// b->GetVR() );
+ (void)b;
+ }
+ else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
+ {
+ if( !CheckVM(v))
+ {
+ std::cout << "Rah this DICOM contains one wrong tag:" <<
+ v->GetValue() << " " <<
+ v->GetGroup() << "," << v->GetElement() << "," <<
+ v->GetVR() << " " << v->GetVM() << " " << v->GetName() << std::endl;
+ }
+ }
+ else
+ {
+ // We skip pb of SQ recursive exploration
+ }
+ d=input->GetNextEntry();
+ }
+}
+
+} // end namespace gdcm
--- /dev/null
+/*=========================================================================
+
+ Program: gdcm
+ Module: $RCSfile: gdcmValidator.h,v $
+ Language: C++
+ Date: $Date: 2005/06/14 20:33:54 $
+ Version: $Revision: 1.1 $
+
+ 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.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#ifndef GDCMVALIDATOR_H
+#define GDCMVALIDATOR_H
+
+#include "gdcmBase.h"
+
+namespace gdcm
+{
+/**
+ * \brief
+ */
+class ElementSet;
+class GDCM_EXPORT Validator : public Base
+{
+public:
+ Validator();
+ ~Validator();
+
+ void SetInput(ElementSet *input);
+
+};
+
+} // end namespace gdcm
+
+//-----------------------------------------------------------------------------
+#endif