From 8ea92706ea6ef5e97c3cdca1daa41c9a3063bd7a Mon Sep 17 00:00:00 2001 From: malaterre Date: Tue, 14 Jun 2005 20:33:53 +0000 Subject: [PATCH] ENH: proof of concept for usage of VM in gdcm. Extremely early alpha stage don't use --- Testing/TestValidate.cxx | 38 ++++++++++++++++++ src/CMakeLists.txt | 5 ++- src/gdcmValidator.cxx | 83 ++++++++++++++++++++++++++++++++++++++++ src/gdcmValidator.h | 43 +++++++++++++++++++++ 4 files changed, 167 insertions(+), 2 deletions(-) create mode 100644 Testing/TestValidate.cxx create mode 100644 src/gdcmValidator.cxx create mode 100644 src/gdcmValidator.h diff --git a/Testing/TestValidate.cxx b/Testing/TestValidate.cxx new file mode 100644 index 00000000..6162fcf6 --- /dev/null +++ b/Testing/TestValidate.cxx @@ -0,0 +1,38 @@ +/*========================================================================= + + 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; +} + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e6c9907c..8889cb60 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,7 +12,7 @@ INCLUDE_REGULAR_EXPRESSION("^gdcm.*$") #ENDIF (WIN32) SUBDIRS( gdcmjpeg - #gdcmmpeg2 + gdcmmpeg2 gdcmjasper gdcmjpegls ) @@ -28,6 +28,7 @@ INCLUDE_DIRECTORIES( ) SET(libgdcm_la_SOURCES + gdcmArgMgr.cxx gdcmBase.cxx gdcmBinEntry.cxx gdcmContentEntry.cxx @@ -71,8 +72,8 @@ SET(libgdcm_la_SOURCES gdcmTS.cxx gdcmUtil.cxx gdcmValEntry.cxx + gdcmValidator.cxx gdcmVR.cxx - gdcmArgMgr.cxx ${GDCM_BINARY_DIR}/src/gdcmDefaultDicts.cxx ) diff --git a/src/gdcmValidator.cxx b/src/gdcmValidator.cxx new file mode 100644 index 00000000..3b9ac39b --- /dev/null +++ b/src/gdcmValidator.cxx @@ -0,0 +1,83 @@ +/*========================================================================= + + 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(d) ) + { +// copyH->InsertBinEntry( b->GetBinArea(),b->GetLength(), +// b->GetGroup(),b->GetElement(), +// b->GetVR() ); + (void)b; + } + else if ( gdcm::ValEntry *v = dynamic_cast(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 diff --git a/src/gdcmValidator.h b/src/gdcmValidator.h new file mode 100644 index 00000000..0c50eaaa --- /dev/null +++ b/src/gdcmValidator.h @@ -0,0 +1,43 @@ +/*========================================================================= + + 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 -- 2.48.1