]> Creatis software - gdcm.git/commitdiff
ENH: proof of concept for usage of VM in gdcm. Extremely early alpha stage don't use
authormalaterre <malaterre>
Tue, 14 Jun 2005 20:33:53 +0000 (20:33 +0000)
committermalaterre <malaterre>
Tue, 14 Jun 2005 20:33:53 +0000 (20:33 +0000)
Testing/TestValidate.cxx [new file with mode: 0644]
src/CMakeLists.txt
src/gdcmValidator.cxx [new file with mode: 0644]
src/gdcmValidator.h [new file with mode: 0644]

diff --git a/Testing/TestValidate.cxx b/Testing/TestValidate.cxx
new file mode 100644 (file)
index 0000000..6162fcf
--- /dev/null
@@ -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;
+}
+
index e6c9907c3cdd345d5dec5558004fa5ff938b327d..8889cb60fe957bc4ee06937a46b7af13e91c14dc 100644 (file)
@@ -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 (file)
index 0000000..3b9ac39
--- /dev/null
@@ -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<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
diff --git a/src/gdcmValidator.h b/src/gdcmValidator.h
new file mode 100644 (file)
index 0000000..0c50eaa
--- /dev/null
@@ -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