]> Creatis software - gdcm.git/commitdiff
* Minor coding-style clean up
authorregrain <regrain>
Tue, 18 Oct 2005 08:35:42 +0000 (08:35 +0000)
committerregrain <regrain>
Tue, 18 Oct 2005 08:35:42 +0000 (08:35 +0000)
   * Replace the ContentEntry and its derived classes (BinEntry and ValEntry)
     by the DataEntry. This unique entry considers all datas like binary datas.
     Some methods are added to interpret - at fly - the binary datas.
     Due to this important change, some methods of the DocEntrySet, concerning
     the BinEntry and ValEntry classes, are erased ; and new methods for the
     DataEntry class are created.
     Some methods to set the ValEntry or the BinEntry are renamed to
     correspond to the new DataEntry, like for example :
      - SetValEntry -> SetEntryString
      - SetBinEntry -> SetEntryBinArea
     This change will remove all useless creation of the string when working
     directly on values.
   -- BeNours

78 files changed:
ChangeLog
Example/AnonymizeDicomDir.cxx
Example/FindTags.cxx
Example/PrintDicomDir.cxx
Example/PrintFile.cxx
Example/ReWrite.cxx
Example/TestChangeHeader.cxx
Example/TestCopyDicom.cxx
Example/Volume2Dicom.cxx
Example/WriteDicomSimple.cxx
Example/exColorToRGB.cxx
Example/exCurveData.cxx
Example/exExtractDicomTags.cxx
Example/exExtractTag.cxx
Example/exGC.cxx
Example/exGrey2RGB.cxx
Example/exImageLighten.cxx
Example/exOverlaysACR.cxx
Example/exPrintWritePrint.cxx
Example/exReadPapyrus.cxx
Example/exReadWriteFile.cxx
Testing/CMakeLists.txt
Testing/TestAllEntryVerify.cxx
Testing/TestAllPrint.cxx
Testing/TestAllReadCompareDicom.cxx
Testing/TestAnonymize.cxx
Testing/TestBuildUpDicomDir.cxx
Testing/TestCopyDicom.cxx
Testing/TestCopyRescaleDicom.cxx
Testing/TestDataEntry.cxx [new file with mode: 0644]
Testing/TestDicomDir.cxx
Testing/TestFileAccessors.cxx
Testing/TestImageSet.cxx
Testing/TestLoadAllDocumentsNoPrivNoSeq.cxx
Testing/TestMakeIcon.cxx
Testing/TestPrintAllDocument.cxx
Testing/TestReadWriteReadCompare.cxx
Testing/TestWriteSimple.cxx
gdcmPython/demo/PrintDicomDir.py.in
src/CMakeLists.txt
src/gdcm.h
src/gdcmBinEntry.cxx [deleted file]
src/gdcmBinEntry.h [deleted file]
src/gdcmContentEntry.cxx [deleted file]
src/gdcmContentEntry.h [deleted file]
src/gdcmDataEntry.cxx [new file with mode: 0644]
src/gdcmDataEntry.h [new file with mode: 0644]
src/gdcmDicomDir.cxx
src/gdcmDicomDirImage.cxx
src/gdcmDicomDirObject.cxx
src/gdcmDicomDirVisit.cxx
src/gdcmDictEntry.h
src/gdcmDocEntry.cxx
src/gdcmDocEntry.h
src/gdcmDocEntrySet.cxx
src/gdcmDocEntrySet.h
src/gdcmDocument.cxx
src/gdcmDocument.h
src/gdcmElementSet.cxx
src/gdcmElementSet.h
src/gdcmFile.cxx
src/gdcmFileHelper.cxx
src/gdcmFileHelper.h
src/gdcmOrientation.cxx
src/gdcmPixelReadConvert.cxx
src/gdcmSQItem.cxx
src/gdcmSeqEntry.cxx
src/gdcmSeqEntry.h
src/gdcmSerieHelper.cxx
src/gdcmUtil.cxx
src/gdcmUtil.h
src/gdcmVR.cxx
src/gdcmVR.h
src/gdcmValEntry.cxx [deleted file]
src/gdcmValEntry.h [deleted file]
src/gdcmValidator.cxx
vtk/vtkGdcmWriter.cxx
vtk/vtkgdcmSerieViewer.cxx

index d1ced5d25ff7cc7b61603ec049e41a37a328992e..2ed79e6faaa5b2846395eb92f2ac5017175ae1e8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+Mon Oct 18 10:27:49 2005 by regrain
+   * Minor coding-style clean up
+   * Replace the ContentEntry and its derived classes (BinEntry and ValEntry)
+     by the DataEntry. This unique entry considers all datas like binary datas.
+     Some methods are added to interpret - at fly - the binary datas.
+     Due to this important change, some methods of the DocEntrySet, concerning
+     the BinEntry and ValEntry classes, are erased ; and new methods for the
+     DataEntry class are created.
+     Some methods to set the ValEntry or the BinEntry are renamed to
+     correspond to the new DataEntry, like for example :
+      - SetValEntry -> SetEntryString
+      - SetBinEntry -> SetEntryBinArea
+     This change will remove all useless creation of the string when working
+     directly on values.
+
 Thu Aug 25 16:59:49 2005 by jpr
    gdcmBinEntry.cxx
    Now Print displays the BinEntry Content (if it's printable, and loaded)
index 388a92e04cd548e8c1f34fa47bbb92041f468f80..02190c34f61bd63ab2c715f2d5e1533b1a2a6291 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: AnonymizeDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/21 04:55:50 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2005/10/18 08:35:43 $
+  Version:   $Revision: 1.8 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -22,7 +22,7 @@
 
 #include "gdcmSQItem.h"
 #include "gdcmSeqEntry.h"
-#include "gdcmValEntry.h"
+#include "gdcmDataEntry.h"
 
 #include "gdcmDocument.h"
 #include "gdcmFile.h"
@@ -55,7 +55,7 @@ void AnoNoLoad(gdcm::SQItem *s, std::fstream *fp,
    if ( d == NULL)
       return;
 
-   if ( ! dynamic_cast<gdcm::ValEntry *>(d) )
+   if ( ! dynamic_cast<gdcm::DataEntry *>(d) )
       return;
 
    offset = d->GetOffset();
@@ -148,13 +148,13 @@ int main(int argc, char *argv[])
    while(tmpSI)
    {
       d = tmpSI->GetDocEntry(0x0004, 0x1430); // Directory Record Type
-      if ( gdcm::ValEntry* valEntry = dynamic_cast<gdcm::ValEntry *>(d) )
+      if ( gdcm::DataEntry *dataEntry = dynamic_cast<gdcm::DataEntry *>(d) )
       {
-         v = valEntry->GetValue();
+         v = dataEntry->GetString();
       }
       else
       {
-         std::cout << "(0004,1430) not a ValEntry ?!?" << std::endl;
+         std::cout << "(0004,1430) not a DataEntry ?!?" << std::endl;
          continue;
       }
 
index 3805438d79a746fea4e07943389255f3f92c140c..a1b9e4f7c5f213f5dd2d725d79131a5ae7ae71c3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: FindTags.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 12:02:02 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2005/10/18 08:35:43 $
+  Version:   $Revision: 1.15 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -55,14 +55,14 @@ int main(int argc, char *argv[])
    int dataSize = h->GetImageDataSize();
    std::cout << "---> pourFindTaggs : dataSize " << dataSize << std::endl;
 
-   h->SetValEntry(RecCode ,0x0008,0x0010);
-   h->SetValEntry(ManufacturerName ,0x0008,0x0070);
+   h->SetEntryString(RecCode ,0x0008,0x0010);
+   h->SetEntryString(ManufacturerName ,0x0008,0x0070);
 
 // ImagePositionPatient
-   ImagePositionPatient = h->GetFile()->GetEntryValue(0x0020,0x0032);
+   ImagePositionPatient = h->GetFile()->GetEntryString(0x0020,0x0032);
 
 // Image Position (RET)
-   h->SetValEntry(ImagePositionPatient, 0x0020,0x0030);
+   h->SetEntryString(ImagePositionPatient, 0x0020,0x0030);
 
    sscanf(ImagePositionPatient.c_str(), "%f%c%f%c%f", &x,&c,&y,&c,&z);
 
@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
 // Location
    std::string zizi = gdcm::Util::Format("%f",l);
    Location = gdcm::Util::DicomString(zizi.c_str());
-   h->SetValEntry(Location, 0x0020,0x0050);
+   h->SetEntryString(Location, 0x0020,0x0050);
 
 // sinon, la longueur du champ est erronée (?!?) 
 // Probable sac de noeud entre strlen(xxx.c_str()) et xxx.length()
@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
 
    zizi = gdcm::Util::Format("%d",0x7FE0);
    ImageLocation = gdcm::Util::DicomString(zizi.c_str());
-//h->SetValEntry(Location, 0x0028,0x0200);
+//h->SetEntryString(Location, 0x0028,0x0200);
 //h->GetFile()->SetEntryLength(strlen(ImageLocation.c_str())-1, 0x0020,0x0050); // prudence !
 
 // void *imageData= h->GetImageData();
index 7025c18d1b050e9a59c62a40465f464184a70b89..2d40b7df35723832e6570febd2800222daa78eea 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: PrintDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/21 04:55:50 $
-  Version:   $Revision: 1.28 $
+  Date:      $Date: 2005/10/18 08:35:43 $
+  Version:   $Revision: 1.29 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -17,7 +17,6 @@
 =========================================================================*/
 #include "gdcmDocument.h"
 #include "gdcmDicomDir.h"
-#include "gdcmValEntry.h"
 #include "gdcmDicomDirPatient.h"
 #include "gdcmDicomDirStudy.h"
 #include "gdcmDicomDirVisit.h"
@@ -123,9 +122,9 @@ int main(int argc, char* argv[])
       pa = f->GetFirstPatient();
       while (pa) 
       {
-         std::cout << "Pat.Name:[" << pa->GetEntryValue(0x0010, 0x0010) <<"]"; // Patient's Name
+         std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
          std::cout << " Pat.ID:[";
-         std::cout << pa->GetEntryValue(0x0010, 0x0020) << "]" << std::endl; // Patient ID
+         std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
          pa = f->GetNextPatient();    
       }
       break;
@@ -138,13 +137,13 @@ int main(int argc, char* argv[])
       pa = f->GetFirstPatient();
       while ( pa ) // on degouline les PATIENT de ce DICOMDIR
       {  
-         std::cout << "Pat.Name:[" << pa->GetEntryValue(0x0010, 0x0010) <<"]"; // Patient's Name
+         std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
          std::cout << " Pat.ID:[";
-         std::cout << pa->GetEntryValue(0x0010, 0x0020) << "]" << std::endl; // Patient ID
+         std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
          st = pa->GetFirstStudy();
          while ( st ) { // on degouline les STUDY de ce patient
-            std::cout << "--- Stud.descr:["    << st->GetEntryValue(0x0008, 0x1030) << "]"; // Study Description 
-            std::cout << " Stud.ID:["          << st->GetEntryValue(0x0020, 0x0010) << "]"; // Study ID
+            std::cout << "--- Stud.descr:["    << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description 
+            std::cout << " Stud.ID:["          << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID
             std::cout << std::endl; 
             st = pa->GetNextStudy();
          }
@@ -161,21 +160,21 @@ int main(int argc, char* argv[])
       while ( pa )   // on degouline les PATIENT de ce DICOMDIR
       {
        // Patient's Name, Patient ID 
-         std::cout << "Pat.Name:[" << pa->GetEntryValue(0x0010, 0x0010) <<"]"; // Patient's Name
+         std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
          std::cout << " Pat.ID:[";
-         std::cout << pa->GetEntryValue(0x0010, 0x0020) << "]" << std::endl; // Patient ID
+         std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
 
          st = pa->GetFirstStudy();
          while ( st ) { // on degouline les STUDY de ce patient
-            std::cout << "--- Stud.descr:["    << st->GetEntryValue(0x0008, 0x1030) << "]"; // Study Description 
-            std::cout << " Stud.ID:["          << st->GetEntryValue(0x0020, 0x0010) << "]"; // Study ID
+            std::cout << "--- Stud.descr:["    << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description 
+            std::cout << " Stud.ID:["          << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID
             std::cout << std::endl;
 
             se = st->GetFirstSerie();
             while ( se ) { // on degouline les SERIES de cette study
-               std::cout << "--- --- Ser.Descr:["<< se->GetEntryValue(0x0008, 0x103e)<< "]";  // Series Description
-               std::cout << " Ser.nb:["          << se->GetEntryValue(0x0020, 0x0011);        // Series number
-               std::cout << "] Mod.:["           << se->GetEntryValue(0x0008, 0x0060) << "]"; // Modality
+               std::cout << "--- --- Ser.Descr:["<< se->GetEntryString(0x0008, 0x103e)<< "]";  // Series Description
+               std::cout << " Ser.nb:["          << se->GetEntryString(0x0020, 0x0011);        // Series number
+               std::cout << "] Mod.:["           << se->GetEntryString(0x0008, 0x0060) << "]"; // Modality
                std::cout << std::endl;    
                se = st->GetNextSerie();   
             }
@@ -183,10 +182,10 @@ int main(int argc, char* argv[])
             vs = st->GetFirstVisit();
             while ( vs ) { // on degouline les VISIT de cette study
                std::cout << "--- --- VISIT: ";
-               std::cout << " Ref. File ID :[" << vs->GetEntryValue(0x0004, 0x1500) << "]"; // Referenced File ID
-               std::cout << " Inst.Name:["    << vs->GetEntryValue(0x0008,0x0080)   << "]"; // Institution Name
-               std::cout << " Adm.ID:["      << vs->GetEntryValue(0x0038, 0x0010)   << "]"; // Admission ID
-               std::cout << " Adm. date:["   << vs->GetEntryValue(0x0038, 0x0020)   << "]"; // Admitting Date
+               std::cout << " Ref. File ID :[" << vs->GetEntryString(0x0004, 0x1500) << "]"; // Referenced File ID
+               std::cout << " Inst.Name:["    << vs->GetEntryString(0x0008,0x0080)   << "]"; // Institution Name
+               std::cout << " Adm.ID:["      << vs->GetEntryString(0x0038, 0x0010)   << "]"; // Admission ID
+               std::cout << " Adm. date:["   << vs->GetEntryString(0x0038, 0x0020)   << "]"; // Admitting Date
                std::cout << std::endl;    
                vs = st->GetNextVisit();    
             }
@@ -205,37 +204,37 @@ int main(int argc, char* argv[])
       pa = f->GetFirstPatient(); 
       while ( pa ) {  // les PATIENT de ce DICOMDIR
        // Patient's Name, Patient ID 
-         std::cout << "Pat.Name:[" << pa->GetEntryValue(0x0010, 0x0010) <<"]"; // Patient's Name
+         std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
          std::cout << " Pat.ID:[";
-         std::cout << pa->GetEntryValue(0x0010, 0x0020) << "]" << std::endl; // Patient ID
+         std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
 
          st = pa->GetFirstStudy();
          while ( st ) { // on degouline les STUDY de ce patient
-            std::cout << "--- Stud.descr:["    << st->GetEntryValue(0x0008, 0x1030) << "]"; // Study Description 
-            std::cout << " Stud.ID:["          << st->GetEntryValue(0x0020, 0x0010) << "]"; // Study ID
+            std::cout << "--- Stud.descr:["    << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description 
+            std::cout << " Stud.ID:["          << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID
             std::cout << std::endl;
   
             vs = st->GetFirstVisit();
             while ( vs ) { // on degouline les VISIT de cette study
                std::cout << "--- --- VISIT: ";
-               std::cout << " Ref. File ID :[" << vs->GetEntryValue(0x0004, 0x1500) << "]"; // Referenced File ID
-               std::cout << " Inst.Name:["    << vs->GetEntryValue(0x0008,0x0080)   << "]"; // Institution Name
-               std::cout << " Adm.ID:["      << vs->GetEntryValue(0x0038, 0x0010)   << "]"; // Admission ID
-               std::cout << " Adm. date:["   << vs->GetEntryValue(0x0038, 0x0020)   << "]"; // Admitting Date
+               std::cout << " Ref. File ID :[" << vs->GetEntryString(0x0004, 0x1500) << "]"; // Referenced File ID
+               std::cout << " Inst.Name:["    << vs->GetEntryString(0x0008,0x0080)   << "]"; // Institution Name
+               std::cout << " Adm.ID:["      << vs->GetEntryString(0x0038, 0x0010)   << "]"; // Admission ID
+               std::cout << " Adm. date:["   << vs->GetEntryString(0x0038, 0x0020)   << "]"; // Admitting Date
                std::cout << std::endl;    
                vs = st->GetNextVisit();    
             }
 
             se = st->GetFirstSerie();
             while ( se ) { // on degouline les SERIES de cette study
-               std::cout << "--- --- Ser.Descr:["<< se->GetEntryValue(0x0008, 0x103e)<< "]";  // Series Description
-               std::cout << " Ser.nb:["         <<  se->GetEntryValue(0x0020, 0x0011);        // Series number
-               std::cout << "] Mod.:["          <<  se->GetEntryValue(0x0008, 0x0060) << "]"; // Modality
+               std::cout << "--- --- Ser.Descr:["<< se->GetEntryString(0x0008, 0x103e)<< "]";  // Series Description
+               std::cout << " Ser.nb:["         <<  se->GetEntryString(0x0020, 0x0011);        // Series number
+               std::cout << "] Mod.:["          <<  se->GetEntryString(0x0008, 0x0060) << "]"; // Modality
                std::cout << std::endl;    
 
                im = se->GetFirstImage();
                while ( im ) { // on degouline les Images de cette serie
-                  std::cout << "--- --- --- "<< " IMAGE Ref. File ID :[" << im->GetEntryValue(0x0004, 0x1500) 
+                  std::cout << "--- --- --- "<< " IMAGE Ref. File ID :[" << im->GetEntryString(0x0004, 0x1500) 
                             << "]" << std::endl; // File name (Referenced File ID)
                   im = se->GetNextImage();   
                }
@@ -271,16 +270,16 @@ int main(int argc, char* argv[])
  
    itPatient = f->GetDicomDirPatients().begin();
    while ( itPatient != f->GetDicomDirPatients().end() ) {  // on degouline les PATIENT de ce DICOMDIR
-      std::cout << (*itPatient)->GetEntryValue(0x0010, 0x0010) << std::endl; // Patient's Name
+      std::cout << (*itPatient)->GetEntryString(0x0010, 0x0010) << std::endl; // Patient's Name
       itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
       while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
-         std::cout << "--- "<< (*itStudy)->GetEntryValue(0x0008, 0x1030) << std::endl; // Study Description
+         std::cout << "--- "<< (*itStudy)->GetEntryString(0x0008, 0x1030) << std::endl; // Study Description
          itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
          while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
-            std::cout << "--- --- "<< (*itSerie)->GetEntryValue(0x0008, 0x103e) << std::endl; // Serie Description
+            std::cout << "--- --- "<< (*itSerie)->GetEntryString(0x0008, 0x103e) << std::endl; // Serie Description
             itImage = ((*itSerie)->GetDicomDirImages()).begin();
             while (itImage != (*itSerie)->GetDicomDirImages().end() ) { // on degouline les IMAGES de cette serie
-               std::cout << "--- --- --- "<< (*itImage)->GetEntryValue(0x0004, 0x1500) << std::endl; // File name
+               std::cout << "--- --- --- "<< (*itImage)->GetEntryString(0x0004, 0x1500) << std::endl; // File name
                ++itImage;   
             }
             ++itSerie;   
index 0fe29970120b8b4e525fbb17b3e290948e89778b..71ef4ab5d2916a8c04d5523f1c8fcb9696a132fe 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: PrintFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/13 09:18:34 $
-  Version:   $Revision: 1.62 $
+  Date:      $Date: 2005/10/18 08:35:43 $
+  Version:   $Revision: 1.63 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,7 +19,7 @@
 #include "gdcmDocument.h"
 #include "gdcmSeqEntry.h"
 #include "gdcmSQItem.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
 
 #include "gdcmFileHelper.h"
 #include "gdcmDebug.h"
@@ -46,7 +46,7 @@ void ShowLutData(gdcm::File *f)
          gdcm::SQItem *sqi= modLutSeq->GetFirstSQItem();
          if ( sqi != 0 )
          {
-            std::string lutDescriptor = sqi->GetEntryValue(0x0028,0x3002);
+            std::string lutDescriptor = sqi->GetEntryString(0x0028,0x3002);
            if (   /*lutDescriptor   == GDCM_UNFOUND*/ 0 )
            {
               //gdcmWarningMacro( "LUT Descriptor is missing" );
@@ -72,7 +72,7 @@ void ShowLutData(gdcm::File *f)
                 std::cout << "Wrong LUT descriptor" << std::endl;
             }
             //LUT Data (CTX dependent)    
-            gdcm::BinEntry *b = sqi->GetBinEntry(0x0028,0x3006); 
+            gdcm::DataEntry *b = sqi->GetDataEntry(0x0028,0x3006); 
             if ( b != 0 )
             { 
                int BitsAllocated = f->GetBitsAllocated();
@@ -108,7 +108,7 @@ void ShowLutData(gdcm::File *f)
                }
             }  
             else
-               std::cout << "No LUT Data BinEntry (0x0028,0x3006) found?!? " 
+               std::cout << "No LUT Data DataEntry (0x0028,0x3006) found?!? " 
                          << std::endl;
          }
          else
@@ -272,7 +272,7 @@ int main(int argc, char *argv[])
                 << "] PlanarConfiguration= [" << planarConfig 
                 << "] "<< std::endl 
                 << " PhotometricInterpretation= [" 
-                                << f->GetEntryValue(0x0028,0x0004)
+                                << f->GetEntryString(0x0028,0x0004)
                 << "] "<< std::endl;
 
       int numberOfScalarComponents=f->GetNumberOfScalarComponents();
@@ -281,19 +281,21 @@ int main(int argc, char *argv[])
                 << " LUT = " << (f->HasLUT() ? "TRUE" : "FALSE")
                 << std::endl;
 
-      if ( f->GetEntryValue(0x0002,0x0010) == gdcm::GDCM_NOTLOADED ) 
-      {
-         std::cout << "Transfer Syntax not loaded. " << std::endl
-                   << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
-                << std::endl;
-         return 0;
-      }
+      if ( f->GetDataEntry(0x0002,0x0010) )
+         if ( f->GetDataEntry(0x0002,0x0010)->IsNotLoaded() ) 
+         {
+            std::cout << "Transfer Syntax not loaded. " << std::endl
+                     << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
+                  << std::endl;
+            return 0;
+         }
   
       std::string transferSyntaxName = f->GetTransferSyntaxName();
       std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" 
                 << std::endl;
       std::cout << " SwapCode= " << f->GetSwapCode() << std::endl;
       std::cout << " ------" << std::endl;
+
       //std::cout << "\n\n" << std::endl; 
       //std::cout << "X spacing " << f->GetXSpacing() << std::endl;
       //std::cout << "Y spacing " << f->GetYSpacing() << std::endl;
@@ -304,35 +306,35 @@ int main(int argc, char *argv[])
       // ------------------------------------------------------------
 
       std::string strPatientPosition = 
-                                      f->GetEntryValue(0x0018,0x5100);
+                                      f->GetEntryString(0x0018,0x5100);
       if ( strPatientPosition != gdcm::GDCM_UNFOUND 
         && strPatientPosition != "" )  
             std::cout << "PatientPosition (0x0010,0x5100)= [" 
                       << strPatientPosition << "]" << std::endl;
  
       std::string strViewPosition = 
-                                      f->GetEntryValue(0x0018,0x5101);
+                                      f->GetEntryString(0x0018,0x5101);
       if ( strViewPosition != gdcm::GDCM_UNFOUND 
         && strViewPosition != "" )  
             std::cout << "strViewPosition (0x0010,0x5101)= [" 
                       << strViewPosition << "]" << std::endl;
       
      std::string strPatientOrientation = 
-                                      f->GetEntryValue(0x0020,0x0020);
+                                      f->GetEntryString(0x0020,0x0020);
       if ( strPatientOrientation != gdcm::GDCM_UNFOUND
         && strPatientOrientation != "")  
          std::cout << "PatientOrientation (0x0020,0x0020)= [" 
                    << strPatientOrientation << "]" << std::endl;
 
       std::string strImageOrientationPatient = 
-                                      f->GetEntryValue(0x0020,0x0037);  
+                                      f->GetEntryString(0x0020,0x0037);  
       if ( strImageOrientationPatient != gdcm::GDCM_UNFOUND
         && strImageOrientationPatient != "" )  
          std::cout << "ImageOrientationPatient (0x0020,0x0037)= [" 
                    << strImageOrientationPatient << "]" << std::endl;
 
       std::string strImageOrientationRET = 
-                                      f->GetEntryValue(0x0020,0x0035);
+                                      f->GetEntryString(0x0020,0x0035);
       if ( strImageOrientationRET != gdcm::GDCM_UNFOUND
         && strImageOrientationRET != "" )  
          std::cout << "ImageOrientationRET (0x0020,0x0035)= [" 
@@ -377,7 +379,7 @@ int main(int argc, char *argv[])
                gdcm::SQItem *sqi= modLutSeq->GetFirstSQItem();
                if ( !sqi )
                {
-               std::string lutDescriptor = sqi->GetEntryValue(0x0028,0x3002);
+               std::string lutDescriptor = sqi->GetEntryString(0x0028,0x3002);
                   int length;   // LUT length in Bytes
                   int deb;      // Subscript of the first Lut Value
                   int nbits;    // Lut item size (in Bits)
@@ -391,7 +393,7 @@ int main(int argc, char *argv[])
                       //gdcmWarningMacro( "Wrong LUT descriptor" );
                       std::cout << "Wrong LUT descriptor" << std::endl;
                   }                                                  
-                  gdcm::BinEntry *b = sqi->GetBinEntry(0x0028,0x3006);
+                  gdcm::DataEntry *b = sqi->GetDataEntry(0x0028,0x3006);
                   if ( b != 0 )
                   {
                      if ( b->GetLength() != 0 )
@@ -515,35 +517,35 @@ int main(int argc, char *argv[])
       // ------------------------------------------------------------
 
       std::string strPatientPosition = 
-                                      f->GetEntryValue(0x0018,0x5100);
+                                      f->GetEntryString(0x0018,0x5100);
       if ( strPatientPosition != gdcm::GDCM_UNFOUND 
         && strPatientPosition != "" )  
             std::cout << "PatientPosition (0x0010,0x5100)= [" 
                       << strPatientPosition << "]" << std::endl;
  
       std::string strViewPosition = 
-                                      f->GetEntryValue(0x0018,0x5101);
+                                      f->GetEntryString(0x0018,0x5101);
       if ( strViewPosition != gdcm::GDCM_UNFOUND 
         && strViewPosition != "" )  
             std::cout << "strViewPosition (0x0010,0x5101)= [" 
                       << strViewPosition << "]" << std::endl;
       
      std::string strPatientOrientation = 
-                                      f->GetEntryValue(0x0020,0x0020);
+                                      f->GetEntryString(0x0020,0x0020);
       if ( strPatientOrientation != gdcm::GDCM_UNFOUND
         && strPatientOrientation != "")  
          std::cout << "PatientOrientation (0x0020,0x0020)= [" 
                    << strPatientOrientation << "]" << std::endl;
 
       std::string strImageOrientationPatient = 
-                                      f->GetEntryValue(0x0020,0x0037);  
+                                      f->GetEntryString(0x0020,0x0037);  
       if ( strImageOrientationPatient != gdcm::GDCM_UNFOUND
         && strImageOrientationPatient != "" )  
          std::cout << "ImageOrientationPatient (0x0020,0x0037)= [" 
                    << strImageOrientationPatient << "]" << std::endl;
 
       std::string strImageOrientationRET = 
-                                      f->GetEntryValue(0x0020,0x0035);
+                                      f->GetEntryString(0x0020,0x0035);
       if ( strImageOrientationRET != gdcm::GDCM_UNFOUND
         && strImageOrientationRET != "" )  
          std::cout << "ImageOrientationRET (0x0020,0x0035)= [" 
index 131c687fb9f2cae212ec36f57710a8c81448fed9..1aa4b8f9075f8b7d965fac783ad03d8ff120f6b3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: ReWrite.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/17 10:29:32 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2005/10/18 08:35:43 $
+  Version:   $Revision: 1.13 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -150,7 +150,7 @@ int main(int argc, char *argv[])
              << " SampleserPixel="      << sPP
              << " PlanarConfiguration=" << planarConfig 
              << " PhotometricInterpretation=" 
-                                << f->GetEntryValue(0x0028,0x0004) 
+             << f->GetEntryString(0x0028,0x0004) 
              << std::endl;
 
    int numberOfScalarComponents=f->GetNumberOfScalarComponents();
index bbc4d6fae8a5a54857d1457e30275cebe8e5b752..95bfbf882a6baab124d455706f0db42bbb76ce51 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestChangeHeader.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 12:02:02 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2005/10/18 08:35:43 $
+  Version:   $Revision: 1.16 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -47,11 +47,11 @@ int main(int argc, char *argv[])
        f2->GetFile()->GetPubDict()->GetEntry( 0x0018, 1310 );
     std::cerr << std::hex << dictEntry->GetGroup() << "," << dictEntry->GetElement() << std::endl;
 
-    std::string matrix = f2->GetFile()->GetEntryValue(0x0018, 0x1310);
+    std::string matrix = f2->GetFile()->GetEntryString(0x0018, 0x1310);
     if(matrix != "gdcm::Unfound")
     {
        std::cerr << "Aquisition Matrix:" << matrix << std::endl;
-       f1->GetFile()->InsertValEntry( matrix, 0x0018, 0x1310);
+       f1->GetFile()->InsertEntryString( matrix, 0x0018, 0x1310);
     }
 
     f1->GetImageData();
index f44754df43536380cc070e53b7aee2f8f7f03820..081c58c1ee7da1ddd4c7394830048f009661ace7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestCopyDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/17 10:41:59 $
-  Version:   $Revision: 1.30 $
+  Date:      $Date: 2005/10/18 08:35:43 $
+  Version:   $Revision: 1.31 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -18,8 +18,7 @@
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
 #include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
 
 #ifndef _WIN32
 #include <unistd.h> //for access, unlink
@@ -110,17 +109,11 @@ int main(int argc, char *argv[])
       gdcm::DocEntry *d = original->GetFile()->GetFirstEntry();
       while(d)
       {
-         if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
+         if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
          {              
-            copy->GetFile()->InsertBinEntry( b->GetBinArea(),b->GetLength(),
-                                             b->GetGroup(),b->GetElement(),
-                                             b->GetVR() );
-         }
-         else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
-         {   
-            copy->GetFile()->InsertValEntry( v->GetValue(),
-                                             v->GetGroup(),v->GetElement(),
-                                             v->GetVR() ); 
+            copy->GetFile()->InsertEntryBinArea( de->GetBinArea(),de->GetLength(),
+                                                 de->GetGroup(),de->GetElement(),
+                                                 de->GetVR() );
          }
          else
          {
index facc30a4a43de64a12cf66b4921a6f8ee5aa60f8..8d18a440b81fd7d75749fb605a9a19d8b3203dd1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: Volume2Dicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/09/07 08:35:20 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2005/10/18 08:35:43 $
+  Version:   $Revision: 1.9 $
                                                                                  
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -25,7 +25,6 @@
 
 #include "gdcmFile.h"
 #include "gdcmDocEntry.h"
-#include "gdcmBinEntry.h"
 #include "gdcmFileHelper.h"
 #include "gdcmUtil.h"
 
index 84d98a928ee611c6a79938c46b77bd4342d4c4c5..455b9063f9c0761406facdbd77f4b92baa538ca1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: WriteDicomSimple.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 12:02:02 $
-  Version:   $Revision: 1.13 $
+  Date:      $Date: 2005/10/18 08:35:43 $
+  Version:   $Revision: 1.14 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -63,39 +63,39 @@ int main(int argc, char *argv[])
    // Set the image size
    str.str("");
    str << SIZE_X;
-   header->InsertValEntry(str.str(),0x0028,0x0011); // Columns
+   header->InsertEntryString(str.str(),0x0028,0x0011); // Columns
 
    str.str("");
    str << SIZE_Y;
-   header->InsertValEntry(str.str(),0x0028,0x0010); // Rows
+   header->InsertEntryString(str.str(),0x0028,0x0010); // Rows
 
    // Set the pixel type
    str.str("");
    str << COMPONENT_SIZE * 8;
-   header->InsertValEntry(str.str(),0x0028,0x0100); // Bits Allocated
-   header->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored
+   header->InsertEntryString(str.str(),0x0028,0x0100); // Bits Allocated
+   header->InsertEntryString(str.str(),0x0028,0x0101); // Bits Stored
 
    str.str("");
    str << ( COMPONENT_SIZE * 8 ) - 1;
-   header->InsertValEntry(str.str(),0x0028,0x0102); // High Bit
+   header->InsertEntryString(str.str(),0x0028,0x0102); // High Bit
 
    // Set the pixel representation
    str.str("");
    str << "0"; // Unsigned
-   header->InsertValEntry(str.str(),0x0028,0x0103); // Pixel Representation
+   header->InsertEntryString(str.str(),0x0028,0x0103); // Pixel Representation
 
    // Set the samples per pixel
    str.str("");
    str << COMPONENT;
-   header->InsertValEntry(str.str(),0x0028,0x0002); // Samples per Pixel
+   header->InsertEntryString(str.str(),0x0028,0x0002); // Samples per Pixel
 
    // Set the Window / Level
    str.str("");
    str << COLOR_WINDOW;
-   header->InsertValEntry(str.str(),0x0028,0x1051); // Window Width
+   header->InsertEntryString(str.str(),0x0028,0x1051); // Window Width
    str.str("");
    str << COLOR_LEVEL;
-   header->InsertValEntry(str.str(),0x0028,0x1050); // Window Center
+   header->InsertEntryString(str.str(),0x0028,0x1050); // Window Center
 
    if( !header->IsReadable() )
    {
index 583d44f6e60bbe682550c34a8d53b46dd3195d1f..12964570530162b71ebace9b7d27f840179257ba 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exColorToRGB.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/09/06 11:10:03 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2005/10/18 08:35:43 $
+  Version:   $Revision: 1.8 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,8 +19,7 @@
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
 #include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
 #include "gdcmSeqEntry.h"
 
 #include <stdlib.h> // for exit
@@ -112,17 +111,11 @@ int main(int argc, char *argv[])
            && !( d->GetGroup()%2 ) )
       { 
 
-         if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
+         if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
          {              
-            copy->GetFile()->InsertBinEntry( b->GetBinArea(),b->GetLength(),
-                                             b->GetGroup(),b->GetElement(),
-                                             b->GetVR() );
-         }
-         else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
-         {   
-             copy->GetFile()->InsertValEntry( v->GetValue(),
-                                              v->GetGroup(),v->GetElement(),
-                                              v->GetVR() ); 
+            copy->GetFile()->InsertEntryBinArea( de->GetBinArea(),de->GetLength(),
+                                                 de->GetGroup(),de->GetElement(),
+                                                 de->GetVR() );
          }
          else
          {
index 434a0dfe93bf65cd202a072de96745da9ec8956d..47ec1b3cdb88380f93e4d0a2bbb6ad3cefc32241 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exCurveData.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/16 17:07:05 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2005/10/18 08:35:43 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -20,7 +20,7 @@
 #include "gdcmCommon.h"
 #include "gdcmDebug.h"
 #include "gdcmDocEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
 
 static const char* TypeOfDataArrays[13][2] = {
     { "TAC" , "time activity curve" },
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
 // ============================================================
 
    //* B 5004|3000 [OW]                    [Curve Data] [gdcm::Binary data loaded;length = 1938]
-   std::string curve_data_str = f->GetEntryValue(0x5004, 0x3000);
+   std::string curve_data_str = f->GetEntryString(0x5004, 0x3000);
    if (curve_data_str == gdcm::GDCM_UNFOUND)
    {
       std::cout << " Image doesn't contain any Curve Data" << std::endl;
@@ -142,27 +142,27 @@ int main(int argc, char *argv[])
 // ============================================================
   std::istringstream convert;
  //* V 5004|0005 [US]              [Curve Dimensions] [1] x(1)
-   std::string curve_dim_str = f->GetEntryValue(0x5004,0x0005);
+   std::string curve_dim_str = f->GetEntryString(0x5004,0x0005);
    unsigned short curve_dim;
    convert.str(curve_dim_str);
    convert >> curve_dim;
    std::cout << "Curve Dimensions: " << curve_dim << std::endl;
  //* V 5004|0010 [US]              [Number of Points] [969] x(3c9)
-   std::string num_points_str = f->GetEntryValue(0x5004,0x0010);
+   std::string num_points_str = f->GetEntryString(0x5004,0x0010);
    unsigned short num_points;
    convert.clear(); //important
    convert.str(num_points_str);
    convert >> num_points;
    std::cout << "Number of Points: " << num_points << std::endl;
  //* V 5004|0020 [CS]                  [Type of Data] [PHYSIO]
-   std::string data_type = f->GetEntryValue(0x5004,0x0020);
+   std::string data_type = f->GetEntryString(0x5004,0x0020);
    std::cout << "Type of Data: " << data_type << std::endl;
    std::cout << " this is thus a : " << ConvertTypeOfData(data_type) << std::endl;
  //* V 5004|0022 [LO]             [Curve Description] []
-   std::string curve_desc = f->GetEntryValue(0x5004,0x0022);
+   std::string curve_desc = f->GetEntryString(0x5004,0x0022);
    std::cout << "Curve Description: " << curve_desc << std::endl;
  //* V 5004|0103 [US]     [Data Value Representation] [0] x(0)
-   std::string data_rep_str = f->GetEntryValue(0x5004,0x0103);
+   std::string data_rep_str = f->GetEntryString(0x5004,0x0103);
    unsigned short data_rep;
    convert.clear(); //important
    convert.str(data_rep_str);
@@ -170,33 +170,33 @@ int main(int argc, char *argv[])
 
 
    gdcm::DocEntry *pCurveDataDoc = f->GetDocEntry(0x5004, 0x3000);
-   gdcm::BinEntry *pCurveData = dynamic_cast<gdcm::BinEntry*>(pCurveDataDoc);
+   gdcm::DataEntry *pCurveData = dynamic_cast<gdcm::DataEntry *>(pCurveDataDoc);
    uint8_t *curve_data = pCurveData->GetBinArea();
    
    // From Part3, C.10.2.1.2 Data value representation (p668)
    size_t sz;
    switch( data_rep)
-     {
-   case 0:
-     sz = PrintCurveData((unsigned short*)(curve_data), num_points);
-     break;
-   case 1:
-     sz = PrintCurveData((signed short*)(curve_data), num_points);
-     break;
-   case 2:
-     sz = PrintCurveData((float*)(curve_data), num_points);
-     break;
-   case 3:
-     sz = PrintCurveData((double*)(curve_data), num_points);
-     break;
-   case 4:
-     sz = PrintCurveData((signed long*)(curve_data), num_points);
-     break;
-   default:
-     std::cerr << "Error don't know the type: " << data_rep_str << std::endl;
-     delete f;
-     return 1;
-     }
+   {
+      case 0:
+         sz = PrintCurveData((unsigned short*)(curve_data), num_points);
+         break;
+      case 1:
+         sz = PrintCurveData((signed short*)(curve_data), num_points);
+         break;
+      case 2:
+         sz = PrintCurveData((float*)(curve_data), num_points);
+         break;
+      case 3:
+         sz = PrintCurveData((double*)(curve_data), num_points);
+         break;
+      case 4:
+         sz = PrintCurveData((signed long*)(curve_data), num_points);
+         break;
+      default:
+         std::cerr << "Error don't know the type: " << data_rep_str << std::endl;
+         delete f;
+         return 1;
+   }
    // Just to make sure that values read are consistant and we won't read out of bound data:
    assert( sz*num_points == pCurveData->GetLength());
 
index f94d6ca57125835ed6e8030a33d14fafb528494d..c799f927acf3132ec8342688594bd17cd14274ff 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exExtractDicomTags.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/09/29 08:49:27 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2005/10/18 08:35:44 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -18,8 +18,6 @@
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
 #include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
 #include "gdcmSeqEntry.h"
 #include "gdcmSQItem.h"
 #include "gdcmDebug.h"
@@ -132,26 +130,26 @@ int main(int argc, char *argv[])
 //  Modality, Transfer Syntax, Study Date, Study Time
 // Patient Name, Media Storage SOP Instance UID, etc
 
-   MediaStSOPinstUID   = f->GetEntryValue(0x0002,0x0002);
-   TransferSyntax      = f->GetEntryValue(0x0002,0x0010);
-   StudyDate           = f->GetEntryValue(0x0008,0x0020);
-   StudyTime           = f->GetEntryValue(0x0008,0x0030);
-   PatientName         = f->GetEntryValue(0x0010,0x0010);
-   PatientID           = f->GetEntryValue(0x0010,0x0020);  //patientid
-   PatientSex          = f->GetEntryValue(0x0010,0x0040);  //sexe
-   SOPInstanceUID      = f->GetEntryValue(0x0008,0x0018);  //imageid = SOPinsUID
-   StudyInstanceUID    = f->GetEntryValue(0x0020,0x000d);  //STUInsUID                                              [Study Instance UID] [1.2.840.113680.1.103.56887.1017329008.714317]
-   SeriesInstanceUID   = f->GetEntryValue(0x0020,0x000e);  //SerInsUID
-   AcquistionDate      = f->GetEntryValue(0x0008,0x0022);
-   AcquisitionTime     = f->GetEntryValue(0x0008,0x0032);
-   AcquisitionDateTime = f->GetEntryValue(0x0008,0x002a);
-
-
-   Modality            = f->GetEntryValue(0x0008,0x0060);  //modality
-   InstitutionName     = f->GetEntryValue(0x0008,0x0080);  //hospital
+   MediaStSOPinstUID   = f->GetEntryString(0x0002,0x0002);
+   TransferSyntax      = f->GetEntryString(0x0002,0x0010);
+   StudyDate           = f->GetEntryString(0x0008,0x0020);
+   StudyTime           = f->GetEntryString(0x0008,0x0030);
+   PatientName         = f->GetEntryString(0x0010,0x0010);
+   PatientID           = f->GetEntryString(0x0010,0x0020);  //patientid
+   PatientSex          = f->GetEntryString(0x0010,0x0040);  //sexe
+   SOPInstanceUID      = f->GetEntryString(0x0008,0x0018);  //imageid = SOPinsUID
+   StudyInstanceUID    = f->GetEntryString(0x0020,0x000d);  //STUInsUID                                              [Study Instance UID] [1.2.840.113680.1.103.56887.1017329008.714317]
+   SeriesInstanceUID   = f->GetEntryString(0x0020,0x000e);  //SerInsUID
+   AcquistionDate      = f->GetEntryString(0x0008,0x0022);
+   AcquisitionTime     = f->GetEntryString(0x0008,0x0032);
+   AcquisitionDateTime = f->GetEntryString(0x0008,0x002a);
+
+
+   Modality            = f->GetEntryString(0x0008,0x0060);  //modality
+   InstitutionName     = f->GetEntryString(0x0008,0x0080);  //hospital
    // always empty :-(
    InstitutionalDepartmentName     
-                     = f->GetEntryValue(0x0008,0x1040);  //departement
+                     = f->GetEntryString(0x0008,0x1040);  //departement
 
    // Radiologist :
    // 0008|0090  [Referring Physician's Name]
@@ -162,7 +160,7 @@ int main(int argc, char *argv[])
 
    // --> I'll have to ask people working on PACS which one they use. JPRx
 
-   ProtocolName = f->GetEntryValue(0x0018,0x1030); 
+   ProtocolName = f->GetEntryString(0x0018,0x1030); 
   
    // --> Big trouble with nz (mb of planes) and nt (number of 'times')
    // --> that belong to LibIDO, not to DICOM.
@@ -183,15 +181,15 @@ int main(int argc, char *argv[])
    std::string PixelRepresentation;
    std::string PixelType;
    
-   SamplesPerPixel     = f->GetEntryValue(0x0028,0x0002);  // 3 -> RGB
-   Rows                = f->GetEntryValue(0x0028,0x0010);  //ny
-   Columns             = f->GetEntryValue(0x0028,0x0011);  //nx
-   Planes              = f->GetEntryValue(0x0028,0x0012);  //nz
-
-   BitsAllocated       = f->GetEntryValue(0x0028,0x0100);
-   BitsStored          = f->GetEntryValue(0x0028,0x0101);
-   HighBit             = f->GetEntryValue(0x0028,0x0102);
-   PixelRepresentation = f->GetEntryValue(0x0028,0x0103);
+   SamplesPerPixel     = f->GetEntryString(0x0028,0x0002);  // 3 -> RGB
+   Rows                = f->GetEntryString(0x0028,0x0010);  //ny
+   Columns             = f->GetEntryString(0x0028,0x0011);  //nx
+   Planes              = f->GetEntryString(0x0028,0x0012);  //nz
+
+   BitsAllocated       = f->GetEntryString(0x0028,0x0100);
+   BitsStored          = f->GetEntryString(0x0028,0x0101);
+   HighBit             = f->GetEntryString(0x0028,0x0102);
+   PixelRepresentation = f->GetEntryString(0x0028,0x0103);
 
    PixelType           = f->GetPixelType();                //type 
 /*
index 297b149c53e7483406b7a3b87c554378383cf8de..b1097a8e71b95a4a50d53d7a29d31c83f898cd5d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exExtractTag.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/10 21:57:57 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2005/10/18 08:35:44 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -20,7 +20,7 @@
 #include "gdcmCommon.h"
 #include "gdcmDebug.h"
 #include "gdcmDocEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
 
 #include <iomanip>
 
@@ -29,11 +29,11 @@ int main(int argc, char *argv[])
    gdcm::File *f;
  
    if( argc < 5 )
-     {
-     std::cerr << "Usage :" << argv[0] << " input.dcm  group element outputfile" << std::endl;
-     std::cerr << "  Ex: " << argv[0] << " /tmp/bla.dcm 0029 2110 /tmp/out.raw" << std::endl;
-     return 1;
-     }
+   {
+      std::cerr << "Usage :" << argv[0] << " input.dcm  group element outputfile" << std::endl;
+      std::cerr << "  Ex: " << argv[0] << " /tmp/bla.dcm 0029 2110 /tmp/out.raw" << std::endl;
+      return 1;
+   }
    std::string fileName = argv[1];
 
    std::cout << fileName << std::endl;
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
    convert >> std::hex >> elem;
    std::cout << "Extracting tag: (0x" << std::hex << std::setw(4) << std::setfill('0')
      << group << ",0x" << std::setw(4) << std::setfill('0') << elem << ")" << std::endl;
-   std::string dicom_tag_value = f->GetEntryValue(group, elem);
+   std::string dicom_tag_value = f->GetEntryString(group, elem);
    if (dicom_tag_value == gdcm::GDCM_UNFOUND)
    {
      gdcm::DictEntry *dictEntry = f->GetPubDict()->GetEntry( group, elem);
@@ -82,22 +82,22 @@ int main(int argc, char *argv[])
    }
 
    gdcm::DocEntry *dicom_tag_doc = f->GetDocEntry(group, elem);
-   gdcm::BinEntry *dicom_tag = dynamic_cast<gdcm::BinEntry*>(dicom_tag_doc);
+   gdcm::DataEntry *dicom_tag = dynamic_cast<gdcm::DataEntry *>(dicom_tag_doc);
    if( !dicom_tag )
-     {
-     std::cerr << "Sorry BinEntry only please" << std::endl; //TODO support ValEntry
-     delete f;
-     return 1;
-     }
+   {
+      std::cerr << "Sorry DataEntry only please" << std::endl;
+      delete f;
+      return 1;
+   }
 
    // Write out the data as a file:
    std::ofstream o(argv[4]);
    if( !o )
-     {
-     std::cerr << "Problem opening file: " << argv[4] << std::endl;
-     delete f;
-     return 1;
-     }
+   {
+      std::cerr << "Problem opening file: " << argv[4] << std::endl;
+      delete f;
+      return 1;
+   }
    o.write((char*)dicom_tag->GetBinArea(), dicom_tag->GetLength());
    o.close();
 
index 9e1d4c48aff2b02ef5e14b9dbd1fdda07bc931fd..68f8adff80f712850b6aa75a0266e1167e35324b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exGC.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/30 15:13:06 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2005/10/18 08:35:44 $
+  Version:   $Revision: 1.9 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,8 +19,7 @@
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
 #include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
 #include "gdcmSeqEntry.h"
 
 #include <stdlib.h> // for exit
@@ -132,17 +131,11 @@ int main(int argc, char *argv[])
            && !( d->GetGroup()%2 ) )
       { 
 
-         if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
+         if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
          {              
-            copy->GetFile()->InsertBinEntry( b->GetBinArea(),b->GetLength(),
-                                             b->GetGroup(),b->GetElement(),
-                                             b->GetVR() );
-         }
-         else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
-         {   
-             copy->GetFile()->InsertValEntry( v->GetValue(),
-                                              v->GetGroup(),v->GetElement(),
-                                              v->GetVR() ); 
+            copy->GetFile()->InsertEntryBinArea( de->GetBinArea(),de->GetLength(),
+                                                 de->GetGroup(),de->GetElement(),
+                                                 de->GetVR() );
          }
          else
          {
index cc3d5e4b4c1f8cfb881f236e0054c9a3543a819b..768228bb42cd6b9478e0cd85c3c3812428963bde 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exGrey2RGB.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/19 15:19:25 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2005/10/18 08:35:44 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -18,8 +18,6 @@
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
 #include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
 #include "gdcmDebug.h"
 
 #ifndef _WIN32
@@ -90,7 +88,7 @@ int main(int argc, char *argv[])
 
    uint8_t *imageDataRGB = new uint8_t[dataSize*3];
 
-   if (fh->GetFile()->GetEntryValue(0x0028,0x0100) == "8" )
+   if (fh->GetFile()->GetEntryString(0x0028,0x0100) == "8" )
    {
       for (unsigned int i=0;i<dataSize;i++)
       {
@@ -110,11 +108,11 @@ int main(int argc, char *argv[])
       }
    }
    // Samples Per Pixel  
-   fh->GetFile()->InsertValEntry( "3 " ,0x0028,0x0002);
+   fh->GetFile()->InsertEntryString( "3 " ,0x0028,0x0002);
    // Photometric Interpretation
-   fh->GetFile()->InsertValEntry( "RGB ",0x0028,0x0004 );
+   fh->GetFile()->InsertEntryString( "RGB ",0x0028,0x0004 );
    // Planar Configuration
-   fh->GetFile()->InsertValEntry( "1 ",0x0028,0x0006 );
+   fh->GetFile()->InsertEntryString( "1 ",0x0028,0x0006 );
 
    // TODO  : free existing PixelData first !
 
index b82beab40733659ad4719b0339ef4eee9d6b42f4..fe3ff4214c18fde9097978e391043a3ce0da20ab 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exImageLighten.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/09/08 14:33:50 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2005/10/18 08:35:44 $
+  Version:   $Revision: 1.8 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,8 +19,7 @@
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
 #include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
 #include "gdcmSeqEntry.h"
 
 #include <stdlib.h> // for exit
@@ -106,17 +105,11 @@ int main(int argc, char *argv[])
            && !( d->GetGroup()%2 ) )
       { 
 
-         if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
+         if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
          {              
-            copy->GetFile()->InsertBinEntry( b->GetBinArea(),b->GetLength(),
-                                             b->GetGroup(),b->GetElement(),
-                                             b->GetVR() );
-         }
-         else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
-         {   
-             copy->GetFile()->InsertValEntry( v->GetValue(),
-                                              v->GetGroup(),v->GetElement(),
-                                              v->GetVR() ); 
+            copy->GetFile()->InsertEntryBinArea( de->GetBinArea(),de->GetLength(),
+                                                 de->GetGroup(),de->GetElement(),
+                                                 de->GetVR() );
          }
          else
          {
index 3af7774caf20e25d6a3584fb27404f9aba3083c4..f5eb508e0a3818b94e1b844ef8c84e425054f437 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exOverlaysACR.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/30 15:13:06 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2005/10/18 08:35:44 $
+  Version:   $Revision: 1.8 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -118,7 +118,7 @@ int main(int argc, char *argv[])
       delete f;
       return 0;
    }
-   std::string s1 = f->GetEntryValue(0x6000, 0x0102);
+   std::string s1 = f->GetEntryString(0x6000, 0x0102);
    if (s1 == gdcm::GDCM_UNFOUND)
    {
       std::cout << " Image doesn't contain any Overlay " << std::endl;
@@ -199,11 +199,11 @@ int main(int argc, char *argv[])
    gdcm::FileHelper *fh = 0;
 
       
-while ( (strOvlBitPosition = f->GetEntryValue(currentOvlGroup, 0x0102)) 
+while ( (strOvlBitPosition = f->GetEntryString(currentOvlGroup, 0x0102)) 
           != gdcm::GDCM_UNFOUND )
 {
 
-      strOverlayLocation = f->GetEntryValue(currentOvlGroup, 0x0200);
+      strOverlayLocation = f->GetEntryString(currentOvlGroup, 0x0200);
       if ( strOverlayLocation != gdcm::GDCM_UNFOUND )
       {
          overlayLocation = atoi(strOverlayLocation.c_str());
@@ -241,18 +241,18 @@ while ( (strOvlBitPosition = f->GetEntryValue(currentOvlGroup, 0x0102))
 
       str.str("");
       str << nx;
-      fileToBuild->InsertValEntry(str.str(),0x0028,0x0011); // Columns
+      fileToBuild->InsertEntryString(str.str(),0x0028,0x0011); // Columns
       str.str("");
       str << ny;
-      fileToBuild->InsertValEntry(str.str(),0x0028,0x0010); // Rows
+      fileToBuild->InsertEntryString(str.str(),0x0028,0x0010); // Rows
 
-      fileToBuild->InsertValEntry("8",0x0028,0x0100); // Bits Allocated
-      fileToBuild->InsertValEntry("8",0x0028,0x0101); // Bits Stored
-      fileToBuild->InsertValEntry("7",0x0028,0x0102); // High Bit
-      fileToBuild->InsertValEntry("0",0x0028,0x0103); // Pixel Representation
-      fileToBuild->InsertValEntry("1",0x0028,0x0002); // Samples per Pixel
+      fileToBuild->InsertEntryString("8",0x0028,0x0100); // Bits Allocated
+      fileToBuild->InsertEntryString("8",0x0028,0x0101); // Bits Stored
+      fileToBuild->InsertEntryString("7",0x0028,0x0102); // High Bit
+      fileToBuild->InsertEntryString("0",0x0028,0x0103); // Pixel Representation
+      fileToBuild->InsertEntryString("1",0x0028,0x0002); // Samples per Pixel
 
-      fileToBuild->InsertValEntry("MONOCHROME2 ",0x0028,0x0004);
+      fileToBuild->InsertEntryString("MONOCHROME2 ",0x0028,0x0004);
       // Other mandatory fields will be set automatically,
       // just before Write(), by FileHelper::CheckMandatoryElements()
 
index 8a6ea7594a07cef8446d80f7707d3de652cae267..476063b185b433a6dfb126f521f37ab62ea520aa 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exPrintWritePrint.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/30 15:13:06 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2005/10/18 08:35:44 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -17,9 +17,6 @@
 =========================================================================*/
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
-
 
 int main(int argc, char *argv[])
 {  
index 99badbf87958d3f38cefa1e4550dc82588f40810..185c84ae20d06e3b4af4d4c2fb361476b0b0ea65 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exReadPapyrus.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/07 17:31:54 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2005/10/18 08:35:44 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -18,8 +18,7 @@
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
 #include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
 #include "gdcmSeqEntry.h"
 #include "gdcmSQItem.h"
 #include "gdcmDebug.h"
@@ -178,12 +177,12 @@ int main(int argc, char *argv[])
 //  Modality, Transfer Syntax, Study Date, Study Time
 // Patient Name, Media Storage SOP Instance UID, etc
 
-   MediaStSOPinstUID   =  f->GetEntryValue(0x0002,0x0002);
-   TransferSyntax      =  f->GetEntryValue(0x0002,0x0010);
-   StudyDate           = sqi->GetEntryValue(0x0008,0x0020);
-   StudyTime           = sqi->GetEntryValue(0x0008,0x0030);
-   Modality            = sqi->GetEntryValue(0x0008,0x0060);
-   PatientName         = sqi->GetEntryValue(0x0010,0x0010);
+   MediaStSOPinstUID   =  f->GetEntryString(0x0002,0x0002);
+   TransferSyntax      =  f->GetEntryString(0x0002,0x0010);
+   StudyDate           = sqi->GetEntryString(0x0008,0x0020);
+   StudyTime           = sqi->GetEntryString(0x0008,0x0030);
+   Modality            = sqi->GetEntryString(0x0008,0x0060);
+   PatientName         = sqi->GetEntryString(0x0010,0x0010);
 
    std::cout << "TransferSyntax " << TransferSyntax << std::endl;
 
@@ -198,17 +197,17 @@ int main(int argc, char *argv[])
 
    // we brutally suppose all the images within a Papyrus file
    // have the same caracteristics.
-   // if you're aware they have not, just move the GetEntryValue
+   // if you're aware they have not, just move the GetEntryString
    // inside the loop
 
    // Get caracteristics of the first image
-   SamplesPerPixel     = sqi->GetEntryValue(0x0028,0x0002);
-   Rows                = sqi->GetEntryValue(0x0028,0x0010);
-   Columns             = sqi->GetEntryValue(0x0028,0x0011);
-   BitsAllocated       = sqi->GetEntryValue(0x0028,0x0100);
-   BitsStored          = sqi->GetEntryValue(0x0028,0x0101);
-   HighBit             = sqi->GetEntryValue(0x0028,0x0102);
-   PixelRepresentation = sqi->GetEntryValue(0x0028,0x0103);
+   SamplesPerPixel     = sqi->GetEntryString(0x0028,0x0002);
+   Rows                = sqi->GetEntryString(0x0028,0x0010);
+   Columns             = sqi->GetEntryString(0x0028,0x0011);
+   BitsAllocated       = sqi->GetEntryString(0x0028,0x0100);
+   BitsStored          = sqi->GetEntryString(0x0028,0x0101);
+   HighBit             = sqi->GetEntryString(0x0028,0x0102);
+   PixelRepresentation = sqi->GetEntryString(0x0028,0x0103);
 
    // just convert those needed to compute PixelArea length
    int iRows            = (uint32_t) atoi( Rows.c_str() );
@@ -225,7 +224,7 @@ int main(int argc, char *argv[])
    //  allocate enough room to get the pixels of all images.
    uint8_t *PixelArea = new uint8_t[lgrImage*nbImages];
    uint8_t *currentPosition = PixelArea;
-   gdcm::BinEntry *pixels;
+   gdcm::DataEntry *pixels;
 
    // declare and open the file
    std::ifstream *Fp;
@@ -247,7 +246,7 @@ int main(int argc, char *argv[])
    while (sqi)
    {
       std::cout << "One more image read. Keep waiting" << std::endl;
-      Rows = sqi->GetEntryValue(0x0028,0x0010);
+      Rows = sqi->GetEntryString(0x0028,0x0010);
       // minimum integrity check
       if (Rows != previousRows)
       {
@@ -255,7 +254,7 @@ int main(int argc, char *argv[])
          return 1;
       }
       // get the images pixels
-      pixels = sqi->GetBinEntry(0x7fe0,0x0010);
+      pixels = sqi->GetDataEntry(0x7fe0,0x0010);
       offset = pixels->GetOffset();
       // perform a fseek, on offset length on the 'right' length
       Fp->seekg(offset, std::ios::beg);
@@ -274,23 +273,23 @@ int main(int argc, char *argv[])
 
    gdcm::File *n = new gdcm::File();
 
-   n->InsertValEntry(MediaStSOPinstUID,  0x0002,0x0002);
+   n->InsertEntryString(MediaStSOPinstUID,  0x0002,0x0002);
   // Whe keep default gdcm Transfer Syntax (Explicit VR Little Endian)
   // since using Papyrus one (Implicit VR Little Endian) is a mess
-   //n->InsertValEntry(TransferSyntax,     0x0002,0x0010);
-   n->InsertValEntry(StudyDate,          0x0008,0x0020);
-   n->InsertValEntry(StudyTime,          0x0008,0x0030);
-   n->InsertValEntry(Modality,           0x0008,0x0060);
-   n->InsertValEntry(PatientName,        0x0010,0x0010);
-
-   n->InsertValEntry(SamplesPerPixel,    0x0028,0x0002);
-   n->InsertValEntry(NumberOfFrames,     0x0028,0x0008);
-   n->InsertValEntry(Rows,               0x0028,0x0010);
-   n->InsertValEntry(Columns,            0x0028,0x0011);
-   n->InsertValEntry(BitsAllocated,      0x0028,0x0100);
-   n->InsertValEntry(BitsStored,         0x0028,0x0101);
-   n->InsertValEntry(HighBit,            0x0028,0x0102);
-   n->InsertValEntry(PixelRepresentation,0x0028,0x0103);
+   //n->InsertEntryString(TransferSyntax,     0x0002,0x0010);
+   n->InsertEntryString(StudyDate,          0x0008,0x0020);
+   n->InsertEntryString(StudyTime,          0x0008,0x0030);
+   n->InsertEntryString(Modality,           0x0008,0x0060);
+   n->InsertEntryString(PatientName,        0x0010,0x0010);
+
+   n->InsertEntryString(SamplesPerPixel,    0x0028,0x0002);
+   n->InsertEntryString(NumberOfFrames,     0x0028,0x0008);
+   n->InsertEntryString(Rows,               0x0028,0x0010);
+   n->InsertEntryString(Columns,            0x0028,0x0011);
+   n->InsertEntryString(BitsAllocated,      0x0028,0x0100);
+   n->InsertEntryString(BitsStored,         0x0028,0x0101);
+   n->InsertEntryString(HighBit,            0x0028,0x0102);
+   n->InsertEntryString(PixelRepresentation,0x0028,0x0103);
 
    // create the file
    gdcm::FileHelper *file = new gdcm::FileHelper(n);
index 757296ef740249644feabbbd1ecb71f7e6639819..3666c6eefed4d46d50ab290c85d1efc3eefa03b0 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exReadWriteFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/19 15:19:25 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2005/10/18 08:35:44 $
+  Version:   $Revision: 1.7 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,8 +19,7 @@
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
 #include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
 #include "gdcmSeqEntry.h"
 
 #include <stdlib.h> // for exit
@@ -80,7 +79,7 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
              << "--- Display only human readable values -----------------------"
              << std::endl;
 
-   gdcm::ValEntry *valEntry;
+   gdcm::DataEntry *dataEntry;
    std::string value;
    std::string vr;   // value representation
    std::string vm;   // value multiplicity
@@ -93,34 +92,31 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
       // We skip SeqEntries, since user cannot do much with them
       if ( !(dynamic_cast<gdcm::SeqEntry*>(d))
       // We skip Shadow Groups, since nobody knows what they mean
-           && !( d->GetGroup()%2 )
-     // we skip BinEntries, since their content is not human-readable
-           && !dynamic_cast<gdcm::BinEntry*>(d) )
+           && !( d->GetGroup()%2 ) )
      {      
          // If user just 'wants to see'
          //d->Print();
          //std::cout << std::endl;
 
          // If user wants to get info about the entry
-         // (he is sure, here that DocEntry is a ValEntry)
-         valEntry = dynamic_cast<gdcm::ValEntry*>(d);
+         // (he is sure, here that DocEntry is a DataEntry)
+         dataEntry = dynamic_cast<gdcm::DataEntry *>(d);
          // Let's be carefull -maybe he commented out some previous line-
-         if (!valEntry)
+         if (!dataEntry)
             continue;
 
-         value  = valEntry->GetValue();
-         vr     = valEntry->GetVR();
+         value  = dataEntry->GetString();
+         vr     = dataEntry->GetVR();
          // user wants really to know everything about entry!
-         vm     = valEntry->GetVM();
-         name   = valEntry->GetName();
+         vm     = dataEntry->GetVM();
+         name   = dataEntry->GetName();
 
          std::cout //<< std::hex << group << "," << elem 
-          << valEntry->GetKey()
-               << "     VR :[" << vr    << "] VM : [" << vm 
+             << dataEntry->GetKey()
+             << "     VR :[" << vr    << "] VM : [" << vm 
              << "] name : [" << name  << "]"
              << " value : [" << value << "]" 
-              << std::endl;
+             << std::endl;
       }
       d = f1->GetNextEntry();
    }
@@ -197,21 +193,21 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
              << std::endl;
    // ------ User is aware, and wants to get fields with no accesor --------
 
-   std::cout << "Manufacturer :["     << f1->GetEntryValue(0x0008,0x0070)
+   std::cout << "Manufacturer :["     << f1->GetEntryString(0x0008,0x0070)
              << "]" << std::endl; 
-   std::cout << "Institution :["      << f1->GetEntryValue(0x0008,0x0080)
+   std::cout << "Institution :["      << f1->GetEntryString(0x0008,0x0080)
              << "]" << std::endl;
-   std::cout << "Patient's name :["   << f1->GetEntryValue(0x0010,0x0010)
+   std::cout << "Patient's name :["   << f1->GetEntryString(0x0010,0x0010)
              << "]" << std::endl;
-   std::cout << "Physician's name :[" << f1->GetEntryValue(0x0008,0x0090)
+   std::cout << "Physician's name :[" << f1->GetEntryString(0x0008,0x0090)
              << "]" << std::endl; 
-   std::cout << "Study Date :["       << f1->GetEntryValue(0x0008,0x0020)
+   std::cout << "Study Date :["       << f1->GetEntryString(0x0008,0x0020)
              << "]" << std::endl; 
-   std::cout << "Study inst UID :["   << f1->GetEntryValue(0x0020,0x000d)
+   std::cout << "Study inst UID :["   << f1->GetEntryString(0x0020,0x000d)
              << "]" << std::endl;
-   std::cout << "Serie inst UID :["   << f1->GetEntryValue(0x0020,0x000e)
+   std::cout << "Serie inst UID :["   << f1->GetEntryString(0x0020,0x000e)
              << "]" << std::endl;
-   std::cout << "Frame ref UID :["   << f1->GetEntryValue(0x0020,0x0052)
+   std::cout << "Frame ref UID :["   << f1->GetEntryString(0x0020,0x0052)
              << "]" << std::endl;
  
    // User wants to get info about the 'real world' vs image
@@ -270,17 +266,11 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
            && !( d->GetGroup()%2 ) )
       { 
 
-         if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
+         if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
          {              
-            copy->GetFile()->InsertBinEntry( b->GetBinArea(),b->GetLength(),
-                                             b->GetGroup(),b->GetElement(),
-                                             b->GetVR() );
-         }
-         else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
-         {   
-             copy->GetFile()->InsertValEntry( v->GetValue(),
-                                              v->GetGroup(),v->GetElement(),
-                                              v->GetVR() ); 
+            copy->GetFile()->InsertEntryBinArea( de->GetBinArea(),de->GetLength(),
+                                                 de->GetGroup(),de->GetElement(),
+                                                 de->GetVR() );
          }
          else
          {
index 0dd7dbc93a8398854ab94e3b40c4d762b1f0328a..02295475d4af09fc6aa1f6733a00b4437fb90620 100644 (file)
@@ -15,6 +15,7 @@ SET(TEST_SOURCES
   TestVR.cxx
   TestDictGroupName.cxx
   TestDict.cxx
+  TestDataEntry.cxx
   TestWriteSimple.cxx
   TestImageSet.cxx
   TestDicomDirElement.cxx
@@ -145,6 +146,9 @@ SET(BLACK_LIST
   "MR_Philips_Intera_No_PrivateSequenceImplicitVR.dcm"
   "MR_Philips_Intera_PrivateSequenceImplicitVR.dcm"
   "MR_SIEMENS_forceLoad29-1010_29-1020.dcm"
+  # An element contains a value of 4, but no data follows
+  # So, the next (group, elem) is not correctly read
+  "gdcm-MR-PHILIPS-16-Multi-Seq.dcm"
   )
 
 # Create a specific list of dicom files that we know are part of a sequence
index d506661a5c283f37faaa43a5d1749f2f1413ac28..641b8f7829c384b4803d8292a7a68c91180a8445 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestAllEntryVerify.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/11 14:47:19 $
-  Version:   $Revision: 1.28 $
+  Date:      $Date: 2005/10/18 08:35:45 $
+  Version:   $Revision: 1.29 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -23,7 +23,7 @@
 #include <iostream>
 #include <sstream>
 
-typedef std::string EntryValueType;   // same type as ValEntry::value
+typedef std::string EntryValueType;   // same type as DataEntry::value
 typedef std::map< gdcm::TagKey, EntryValueType > MapEntryValues;
 typedef MapEntryValues *MapEntryValuesPtr;
 typedef std::string FileNameType;
index 3962137b3a4d3b3d1ade514fa56cc444a1db8d67..e1d59cb277e417ecac0e797f3053bf3b8d3d8662 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestAllPrint.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/30 15:13:07 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2005/10/18 08:35:46 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include "gdcmFileHelper.h"
 #include "gdcmUtil.h"
 #include "gdcmCommon.h"
-#include "gdcmBinEntry.h"  
 #include "gdcmDocEntry.h" 
 #include "gdcmDocEntrySet.h"           
 #include "gdcmDocument.h"          
 #include "gdcmElementSet.h"        
 #include "gdcmSeqEntry.h" 
 #include "gdcmSQItem.h" 
-#include "gdcmValEntry.h" 
 
 #include <iostream>
 
index 7a7ab5c6f4f79ba630bb947d523798702d42d610..bb428fd0903b006f0668f019cf88ece83c7c53fe 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestAllReadCompareDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/30 15:13:07 $
-  Version:   $Revision: 1.47 $
+  Date:      $Date: 2005/10/18 08:35:46 $
+  Version:   $Revision: 1.48 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -485,10 +485,12 @@ int InternalTest(std::string const &filename,
                    << "        Scalar size: " << tested->GetFile()->GetPixelSize() << " # " 
                    << reference->GetScalarSize() << std::endl
                    << "        Number of scalar: " << tested->GetFile()->GetNumberOfScalarComponents() << " # " 
-                   << reference->GetNumberOfComponents() << std::endl;
+                   << reference->GetNumberOfComponents() << std::endl
+                   << "        Pixel type: " << tested->GetFile()->GetPixelType() << std::endl;
          delete reference;
          delete tested;
          delete f;
+         return 1;
       }
 
       // Test the data size
index ab359e14d91068f90ee5b24f26fe9edbc4b341fb..0fff3b83c8c649e6c7ee116d3255eb67014461cd 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestAnonymize.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 13:39:56 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2005/10/18 08:35:46 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -17,8 +17,6 @@
 =========================================================================*/
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
 #include "gdcmGlobal.h"
 #include "gdcmDebug.h"
 
index 524e583730cb812bcf179dbb8830d99da03b1831..da7c881f31044cb562dbba01092e4ea4d7d6b080 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestBuildUpDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/31 09:29:11 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2005/10/18 08:35:46 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -57,7 +57,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
    // Create patient ONE
    // ------------------
    p1 = dcmdir->NewPatient();
-   p1->SetValEntry("patientONE",0x0010, 0x0010);
+   p1->SetEntryString("patientONE",0x0010, 0x0010);
    // fill here other patient characteristics
 
    gdcm::DicomDirStudy *s11;
@@ -71,19 +71,19 @@ int TestBuildUpDicomDir(int argc, char *argv[])
 
    // Let's create and add a Study for this Patient
    s11 = p1->NewStudy();  
-   s11->SetValEntry("StudyDescrOne.One_",0x0008, 0x1030);
+   s11->SetEntryString("StudyDescrOne.One_",0x0008, 0x1030);
    // we know entry (0008,1060) is not yet created
-   s11->InsertValEntry("Dr Mabuse",     0x0008, 0x1060);
+   s11->InsertEntryString("Dr Mabuse",     0x0008, 0x1060);
    // fill here other Study characteristics
 
    gdcm::DicomDirStudy *s12 = p1->NewStudy();    
-   s12->SetValEntry("StudyDescrOne.Two",0x0008, 0x1030);
-   s12->InsertValEntry("Dr Zorglub",    0x0008, 0x1060);
+   s12->SetEntryString("StudyDescrOne.Two",0x0008, 0x1030);
+   s12->InsertEntryString("Dr Zorglub",    0x0008, 0x1060);
    // fill here other Study characteristics
 
    gdcm::DicomDirStudy *s13 = p1->NewStudy();  
-   s13->SetValEntry("StudyDescrOne.Tree",0x0008, 0x1030);
-   s13->InsertValEntry("Dr Follamour",   0x0008, 0x1060);
+   s13->SetEntryString("StudyDescrOne.Tree",0x0008, 0x1030);
+   s13->InsertEntryString("Dr Follamour",   0x0008, 0x1060);
    // fill here other Study characteristics
  
    gdcm::DicomDirSerie *s111;
@@ -97,7 +97,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
 
    // Let's create and add a Serie for this Study
    s111 = s11->NewSerie();
-   s111->SetValEntry("01-01-111", 0x0008, 0x0021);
+   s111->SetEntryString("01-01-111", 0x0008, 0x0021);
    // fill here other Serie characteristics
 
    gdcm::DicomDirImage *s1111;
@@ -112,47 +112,47 @@ int TestBuildUpDicomDir(int argc, char *argv[])
 
    // Let's create and add a Image for this Serie
    s1111 = s111->NewImage();
-   s1111->SetValEntry("imageFileName1111",0x0004,0x1500);
+   s1111->SetEntryString("imageFileName1111",0x0004,0x1500);
 
    gdcm::DicomDirImage *s1112 = s111->NewImage();
-   s1112->SetValEntry("imageFileName1112",0x0004,0x1500);
+   s1112->SetEntryString("imageFileName1112",0x0004,0x1500);
 
    // Create patient TWO
    // ------------------
    gdcm::DicomDirPatient *p2 = dcmdir->NewPatient();
-   p2->SetValEntry("patientTWO",0x0010, 0x0010); 
+   p2->SetEntryString("patientTWO",0x0010, 0x0010); 
    // fill here other patient characteristics
     
    gdcm::DicomDirStudy *s21 = p2->NewStudy();  
-   s21->SetValEntry("StudyDescrTwo.One",0x0008, 0x1030);        
+   s21->SetEntryString("StudyDescrTwo.One",0x0008, 0x1030);        
    // fill here other Study characteristics
 
    gdcm::DicomDirSerie *s211 = s21->NewSerie();
-   s111->SetValEntry("01-01-211", 0x0008, 0x0021);
+   s111->SetEntryString("01-01-211", 0x0008, 0x0021);
    // fill here other Serie characteristics
 
    gdcm::DicomDirImage *s2111 = s211->NewImage();
-   s2111->SetValEntry("imageFileName2111",0x0004,0x1500);
+   s2111->SetEntryString("imageFileName2111",0x0004,0x1500);
    // fill here other Image characteristics
 
    gdcm::DicomDirImage *s2112 = s211->NewImage();
-   s2112->SetValEntry("imageFileName1122",0x0004,0x1500);
+   s2112->SetEntryString("imageFileName1122",0x0004,0x1500);
    // fill here other Image characteristics
 
    // Create patient TREE
    // -------------------
    gdcm::DicomDirPatient *p3 = dcmdir->NewPatient();
-   p3->SetValEntry("patientTHREE",0x0010, 0x0010);
+   p3->SetEntryString("patientTHREE",0x0010, 0x0010);
    // fill here other Patient characteristics
 
    // Add a new Serie/Image for a Patient's Study created a long time ago
    // -------------------------------------------------------------------
    gdcm::DicomDirSerie *s131 = s13->NewSerie();
-   s111->SetValEntry("01-01-131", 0x0008, 0x0021);
+   s111->SetEntryString("01-01-131", 0x0008, 0x0021);
    // fill here other Serie characteristics
 
    gdcm::DicomDirImage *s1311 = s131->NewImage();
-   s1311->SetValEntry("imageFileName1311",0x0004,0x1500);
+   s1311->SetEntryString("imageFileName1311",0x0004,0x1500);
    // fill here other Image characteristics
      
    // Print
@@ -218,16 +218,16 @@ int TestBuildUpDicomDir(int argc, char *argv[])
    std::string valueStuff;  
    for (;;) // exit on 'break'
    {
-      if ( p1->GetEntryValue(0x0010, 0x0010) != "patientONE" )
+      if ( p1->GetEntryString(0x0010, 0x0010) != "patientONE" )
       {
          std::cout << "0x0010,0x0010 [" 
-                   << p1->GetEntryValue(0x0010, 0x0010)
+                   << p1->GetEntryString(0x0010, 0x0010)
                    << "]" << std::endl;
          errorFound = true;
          break;
       }
       std::cout << "Patient : [" 
-                << p1->GetEntryValue(0x0010, 0x0010)
+                << p1->GetEntryString(0x0010, 0x0010)
                 << "]" << std::endl;
 
       if ( !(s11 = p1->GetFirstStudy()) )
@@ -236,7 +236,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
          errorFound = true;
          break;
       }
-      valueStuff = s11->GetEntryValue(0x0008, 0x1030);
+      valueStuff = s11->GetEntryString(0x0008, 0x1030);
       if ( valueStuff.find("StudyDescrOne.One_") >= valueStuff.length() )
       {
          std::cout << "1 : 0x0008,0x1030 [" 
@@ -249,11 +249,11 @@ int TestBuildUpDicomDir(int argc, char *argv[])
                 << valueStuff
                 << "]" << std::endl;
  
-      valueStuff = s11->GetEntryValue(0x0008, 0x1060);
+      valueStuff = s11->GetEntryString(0x0008, 0x1060);
       if (!gdcm::Util::DicomStringEqual(valueStuff, "Dr Mabuse") )
       {
          std::cout << "2 : 0x0008,0x1060 [" 
-                   << s11->GetEntryValue(0x0008,0x1060)
+                   << s11->GetEntryString(0x0008,0x1060)
                    << "]" << std::endl;
          errorFound = true;
          break;
@@ -266,30 +266,30 @@ int TestBuildUpDicomDir(int argc, char *argv[])
          errorFound = true;
          break;
       }
-      if ( gdcm::Util::DicomStringEqual(s12->GetEntryValue(0x0008,
+      if ( gdcm::Util::DicomStringEqual(s12->GetEntryString(0x0008,
                                            0x1030),"StudyDescrOne.Two " ))
       {
          std::cout << "3 0x0008,0x1030 [" 
-                   << s12->GetEntryValue(0x0008,0x1030)
+                   << s12->GetEntryString(0x0008,0x1030)
                    << "]" << std::endl;
          errorFound = true;
          break;
       }
       std::cout << "Study Descr : [" 
-                << s12->GetEntryValue(0x0008,0x1030)
+                << s12->GetEntryString(0x0008,0x1030)
                 << "]" << std::endl;
 
-      if ( gdcm::Util::DicomStringEqual(s12->GetEntryValue(0x0008,
+      if ( gdcm::Util::DicomStringEqual(s12->GetEntryString(0x0008,
                                            0x1060),"Dr Zorglub " ))
       {
          std::cout << "4 0x0008,0x1060 [" 
-                   << s12->GetEntryValue(0x0008,0x1060)
+                   << s12->GetEntryString(0x0008,0x1060)
                    << "]" << std::endl;
          errorFound = true;
          break;
       }
       std::cout << "Pysician : [" 
-                << s12->GetEntryValue(0x0008,0x1060)
+                << s12->GetEntryString(0x0008,0x1060)
                 << "]" << std::endl;
 
       if ( (s13 = p1->GetNextStudy()) == 0 )
@@ -297,7 +297,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
          std::cout << "Study StudyDescrOne.Tree missing" << std::endl;
          break;
       }         
-      if ( s13->GetEntryValue(0x0008, 0x1030) != "StudyDescrOne.Tree" )
+      if ( s13->GetEntryString(0x0008, 0x1030) != "StudyDescrOne.Tree" )
       {
          errorFound = true;
          break;
@@ -306,7 +306,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
                 << valueStuff
                 << "]" << std::endl;
 
-      valueStuff = s13->GetEntryValue(0x0008, 0x1060);
+      valueStuff = s13->GetEntryString(0x0008, 0x1060);
       if (!gdcm::Util::DicomStringEqual(valueStuff, "Dr Follamour") )
       {
          std::cout << "5 0x0008,0x1060 [" 
@@ -326,7 +326,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
          break;
       }
 
-      valueStuff = s111->GetEntryValue(0x0008, 0x0021);
+      valueStuff = s111->GetEntryString(0x0008, 0x0021);
       if (!gdcm::Util::DicomStringEqual(valueStuff, "01-01-131") )
       {
          std::cout << "6 0x0008,0x0021 [" 
@@ -346,7 +346,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
          break;
       } 
 /*
-      if ( s1111->GetEntryValue(0x0004,0x1500) != "imageFileName1111 " )
+      if ( s1111->GetEntryString(0x0004,0x1500) != "imageFileName1111 " )
       {
          errorFound = true;
          break;
@@ -359,7 +359,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
          break;
       }
 /*
-      if ( s1112->GetEntryValue(0x0004,0x1500) != "imageFileName1112 " )
+      if ( s1112->GetEntryString(0x0004,0x1500) != "imageFileName1112 " )
       {
          errorFound = true;
          break;
index c0c5164ca429c9d0ccb4478f6b2b814b02217462..212e0d02d5528238326b88aa44f9788e8287ad6d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestCopyDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 13:39:57 $
-  Version:   $Revision: 1.41 $
+  Date:      $Date: 2005/10/18 08:35:46 $
+  Version:   $Revision: 1.42 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -17,8 +17,7 @@
 =========================================================================*/
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
 
 //Generated file:
 #include "gdcmDataImages.h"
@@ -55,17 +54,11 @@ int CopyDicom(std::string const &filename,
       gdcm::DocEntry *d=originalH->GetFirstEntry();
       while(d)
       {
-         if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
-         {
-            copyH->InsertBinEntry( b->GetBinArea(),b->GetLength(),
-                                   b->GetGroup(),b->GetElement(),
-                                   b->GetVR() );
-         }
-         else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
-         {   
-             copyH->InsertValEntry( v->GetValue(),
-                                    v->GetGroup(),v->GetElement(),
-                                    v->GetVR() ); 
+         if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
+         {              
+            copyH->InsertEntryBinArea( de->GetBinArea(),de->GetLength(),
+                                       de->GetGroup(),de->GetElement(),
+                                       de->GetVR() );
          }
          else
          {
@@ -82,7 +75,7 @@ int CopyDicom(std::string const &filename,
       uint8_t *imageData = original->GetImageData();
 
       // Useless to set the image data, because it's already made when
-      // copying the corresponding BinEntry that contains the pixel data
+      // copying the corresponding DataEntry that contains the pixel data
       copy->SetImageData(imageData, dataSize);
 
       //////////////// Step 3:
index 3d25e33cdfdfeb0b983b24910ed955a1c908f54e..58491763c3c61c91b099360d6a5a39039b9af670 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestCopyRescaleDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 13:39:57 $
-  Version:   $Revision: 1.20 $
+  Date:      $Date: 2005/10/18 08:35:46 $
+  Version:   $Revision: 1.21 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -17,8 +17,7 @@
 =========================================================================*/
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
 
 #include <time.h>
 #include <sys/times.h>
@@ -89,17 +88,11 @@ int CopyRescaleDicom(std::string const &filename,
    gdcm::DocEntry *d = originalF.GetFirstEntry();
    while(d)
    {
-      if ( gdcm::BinEntry *b = dynamic_cast<gdcm::BinEntry*>(d) )
-      {
-         copyF.InsertBinEntry( b->GetBinArea(),b->GetLength(),
-                               b->GetGroup(),b->GetElement(),
-                               b->GetVR() );
-      }
-      else if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
-      {   
-          copyF.InsertValEntry( v->GetValue(),
-                                v->GetGroup(),v->GetElement(),
-                                v->GetVR() ); 
+      if ( gdcm::DataEntry *de = dynamic_cast<gdcm::DataEntry *>(d) )
+      {              
+         copyF.InsertEntryBinArea( de->GetBinArea(),de->GetLength(),
+                                   de->GetGroup(),de->GetElement(),
+                                   de->GetVR() );
       }
       else
       {
@@ -121,10 +114,10 @@ int CopyRescaleDicom(std::string const &filename,
    if( bitsStored == "16" )
    {
       std::cout << "Rescale...";
-      copyF.InsertValEntry( "8", 0x0028, 0x0100); // Bits Allocated
-      copyF.InsertValEntry( "8", 0x0028, 0x0101); // Bits Stored
-      copyF.InsertValEntry( "7", 0x0028, 0x0102); // High Bit
-      copyF.InsertValEntry( "0", 0x0028, 0x0103); // Pixel Representation
+      copyF.InsertEntryString( "8", 0x0028, 0x0100); // Bits Allocated
+      copyF.InsertEntryString( "8", 0x0028, 0x0101); // Bits Stored
+      copyF.InsertEntryString( "7", 0x0028, 0x0102); // High Bit
+      copyF.InsertEntryString( "0", 0x0028, 0x0103); // Pixel Representation
 
       // We assume the value were from 0 to uint16_t max
       rescaleSize = dataSize / 2;
diff --git a/Testing/TestDataEntry.cxx b/Testing/TestDataEntry.cxx
new file mode 100644 (file)
index 0000000..b9b2e54
--- /dev/null
@@ -0,0 +1,495 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: TestDataEntry.cxx,v $
+  Language:  C++
+  Date:      $Date: 2005/10/18 08:35:46 $
+  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 "gdcmDictEntry.h"
+#include "gdcmDataEntry.h"
+
+// ===============================================================
+
+char data[]="1\\2\\3\\4\\5";
+char fdata[]="1.1\\2.2\\3.3\\4.4\\5.5";
+
+short svalue[]={1,2,3,4,5};
+long lvalue[]={1,2,3,4,5};
+float fvalue[]={1.1f,2.2f,3.3f,4.4f,5.5f};
+double dvalue[]={1.1,2.2,3.3,4.4,5.5};
+
+unsigned long nbvalue = 5;
+
+/**
+  * \brief Test the DataEntry object
+  */  
+int TestDataEntry(int argc, char *argv[])
+{
+   unsigned int error = 0;
+   gdcm::DictEntry *dict;
+   gdcm::DataEntry *entry;
+
+   //------------------------------------------------------------------
+   dict = new gdcm::DictEntry(0x0000,0x0000);
+   entry = new gdcm::DataEntry(dict);
+   dict->SetVR("US");
+
+   std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl;
+
+   entry->SetString("1");
+   std::cout << "1: ";
+   entry->Print(std::cout);
+   std::cout << std::endl;
+   if( entry->GetValueCount() != 1 )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Number of content values is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+
+   entry->SetString("1\\2");
+   std::cout << "2: ";
+   entry->Print(std::cout);
+   std::cout << std::endl;
+   if( entry->GetValueCount() != 2 )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Number of content values is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+
+   entry->SetString("");
+   std::cout << "3: ";
+   entry->Print(std::cout);
+   std::cout << std::endl;
+   if( entry->GetValueCount() != 0 )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Number of content values is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+
+   std::cout << std::endl;
+   delete dict;
+   delete entry;
+
+   //------------------------------------------------------------------
+   dict = new gdcm::DictEntry(0x0000,0x0000);
+   entry = new gdcm::DataEntry(dict);
+   dict->SetVR("LT");
+
+   std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl;
+   entry->SetString(data);
+   entry->Print(std::cout);
+   std::cout << std::endl;
+
+   if( entry->GetLength() != strlen(data) + strlen(data)%2 )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Size of string is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   if( entry->GetValueCount() != nbvalue )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Number of content values is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   if( memcmp(entry->GetBinArea(),data,entry->GetLength()) != 0 )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Content of bin area is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   if( memcmp(entry->GetString().c_str(),data,entry->GetLength()) != 0 )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Content of string is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   for(unsigned int i=0;i<entry->GetValueCount();i++)
+   {
+      if( entry->GetValue(i) != svalue[i] )
+      {
+         std::cout << "   Failed" << std::endl
+                   << "   Content of entry's values is incorrect : id " << i << std::endl
+                   << "   Found " << entry->GetValue(i) << " - Must be " << svalue[i] << std::endl;
+         delete dict;
+         delete entry;
+         return(1);
+      }
+   }
+
+   std::cout << std::endl;
+   delete dict;
+   delete entry;
+
+   //------------------------------------------------------------------
+   dict = new gdcm::DictEntry(0x0000,0x0000);
+   entry = new gdcm::DataEntry(dict);
+   dict->SetVR("US");
+
+   std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl;
+   entry->SetString(data);
+   std::cout << "1: ";
+   entry->Print(std::cout);
+   std::cout << std::endl;
+
+   if( entry->GetLength() != nbvalue*sizeof(uint16_t) )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   BinArea length is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   if( memcmp(entry->GetString().c_str(),data,strlen(data)) != 0 )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Content of string is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   if( entry->GetValueCount() != nbvalue )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Number of content values is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   for(unsigned int i=0;i<entry->GetValueCount();i++)
+   {
+      if( entry->GetValue(i) != svalue[i] )
+      {
+         std::cout << "   Failed" << std::endl
+                   << "   Content of entry's values is incorrect : id " << i << std::endl;
+         delete dict;
+         delete entry;
+         return(1);
+      }
+   }
+
+   entry->SetLength(nbvalue*sizeof(uint16_t));
+   entry->SetBinArea((uint8_t *)svalue,false);
+   std::cout << "2: ";
+   entry->Print(std::cout);
+   std::cout << std::endl;
+
+   if( memcmp(entry->GetString().c_str(),data,strlen(data)) != 0 )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Content of string is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   if( entry->GetValueCount() != nbvalue )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Number of content values is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   for(unsigned int i=0;i<entry->GetValueCount();i++)
+   {
+      if( entry->GetValue(i) != svalue[i] )
+      {
+         std::cout << "   Failed" << std::endl
+                   << "   Content of entry's values is incorrect : id " << i << std::endl;
+         delete dict;
+         delete entry;
+         return(1);
+      }
+   }
+
+   std::cout << std::endl;
+   delete dict;
+   delete entry;
+
+   //------------------------------------------------------------------
+   dict = new gdcm::DictEntry(0x0000,0x0000);
+   entry = new gdcm::DataEntry(dict);
+   dict->SetVR("UL");
+
+   std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl;
+   entry->SetString(data);
+   std::cout << "1: ";
+   entry->Print(std::cout);
+   std::cout << std::endl;
+
+   if( entry->GetLength() != nbvalue*sizeof(uint32_t) )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   BinArea length is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   if( memcmp(entry->GetString().c_str(),data,strlen(data)) != 0 )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Content of string is incorrect" << std::endl;
+      std::cout<<"#"<<entry->GetString()<<"#"<<" / "<<"#"<<data<<"#"<<std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   if( entry->GetValueCount() != nbvalue )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Number of content values is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   for(unsigned int i=0;i<entry->GetValueCount();i++)
+   {
+      if( entry->GetValue(i) != lvalue[i] )
+      {
+         std::cout << "   Failed" << std::endl
+                   << "   Content of entry's values is incorrect : id " << i << std::endl;
+         delete dict;
+         delete entry;
+         return(1);
+      }
+   }
+
+   entry->SetLength(nbvalue*sizeof(uint32_t));
+   entry->SetBinArea((uint8_t *)lvalue,false);
+   std::cout << "2: ";
+   entry->Print(std::cout);
+   std::cout << std::endl;
+
+   if( memcmp(entry->GetString().c_str(),data,strlen(data)) != 0 )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Content of string is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   if( entry->GetValueCount() != nbvalue )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Number of content values is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   for(unsigned int i=0;i<entry->GetValueCount();i++)
+   {
+      if( entry->GetValue(i) != lvalue[i] )
+      {
+         std::cout << "   Failed" << std::endl
+                   << "   Content of entry's values is incorrect : id " << i << std::endl;
+         delete dict;
+         delete entry;
+         return(1);
+      }
+   }
+
+   std::cout << std::endl;
+   delete dict;
+   delete entry;
+
+   //------------------------------------------------------------------
+   dict = new gdcm::DictEntry(0x0000,0x0000);
+   entry = new gdcm::DataEntry(dict);
+   dict->SetVR("FL");
+
+   std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl;
+   entry->SetString(fdata);
+   std::cout << "1: ";
+   entry->Print(std::cout);
+   std::cout << std::endl;
+
+   if( entry->GetLength() != nbvalue*sizeof(float) )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   BinArea length is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   if( memcmp(entry->GetString().c_str(),fdata,strlen(fdata)) != 0 )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Content of string is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   if( entry->GetValueCount() != nbvalue )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Number of content values is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   for(unsigned int i=0;i<entry->GetValueCount();i++)
+   {
+      if( entry->GetValue(i) != fvalue[i] )
+      {
+         std::cout << "   Failed" << std::endl
+                   << "   Content of entry's values is incorrect : id " << i << std::endl;
+         delete dict;
+         delete entry;
+         return(1);
+      }
+   }
+
+   entry->SetLength(nbvalue*sizeof(float));
+   entry->SetBinArea((uint8_t *)fvalue,false);
+   std::cout << "2: ";
+   entry->Print(std::cout);
+   std::cout << std::endl;
+
+   if( memcmp(entry->GetString().c_str(),fdata,strlen(fdata)) != 0 )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Content of string is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   if( entry->GetValueCount() != nbvalue )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Number of content values is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   for(unsigned int i=0;i<entry->GetValueCount();i++)
+   {
+      if( entry->GetValue(i) != fvalue[i] )
+      {
+         std::cout << "   Failed" << std::endl
+                   << "   Content of entry's values is incorrect : id " << i << std::endl;
+         delete dict;
+         delete entry;
+         return(1);
+      }
+   }
+
+   std::cout << std::endl;
+   delete dict;
+   delete entry;
+
+   //------------------------------------------------------------------
+   dict = new gdcm::DictEntry(0x0000,0x0000);
+   entry = new gdcm::DataEntry(dict);
+   dict->SetVR("FD");
+
+   std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl;
+   entry->SetString(fdata);
+   std::cout << "1: ";
+   entry->Print(std::cout);
+   std::cout << std::endl;
+
+   if( entry->GetLength() != nbvalue*sizeof(double) )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   BinArea length is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   if( memcmp(entry->GetString().c_str(),fdata,strlen(fdata)) != 0 )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Content of string is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   if( entry->GetValueCount() != nbvalue )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Number of content values is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   for(unsigned int i=0;i<entry->GetValueCount();i++)
+   {
+      if( entry->GetValue(i) != dvalue[i] )
+      {
+         std::cout << "   Failed" << std::endl
+                   << "   Content of entry's values is incorrect : id " << i << std::endl;
+         delete dict;
+         delete entry;
+         return(1);
+      }
+   }
+
+   entry->SetLength(nbvalue*sizeof(double));
+   entry->SetBinArea((uint8_t *)dvalue,false);
+   std::cout << "2: ";
+   entry->Print(std::cout);
+   std::cout << std::endl;
+
+   if( memcmp(entry->GetString().c_str(),fdata,strlen(fdata)) != 0 )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Content of string is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   if( entry->GetValueCount() != nbvalue )
+   {
+      std::cout << "   Failed" << std::endl
+                << "   Number of content values is incorrect" << std::endl;
+      delete dict;
+      delete entry;
+      return(1);
+   }
+   for(unsigned int i=0;i<entry->GetValueCount();i++)
+   {
+      if( entry->GetValue(i) != dvalue[i] )
+      {
+         std::cout << "   Failed" << std::endl
+                   << "   Content of entry's values is incorrect : id " << i << std::endl;
+         delete dict;
+         delete entry;
+         return(1);
+      }
+   }
+
+   std::cout << std::endl;
+   delete dict;
+   delete entry;
+
+   //------------------------------------------------------------------
+   std::cout<<std::flush;
+   return 0;
+}
index af76b111b4e2f01c161b31e52a636e46fdddaf48..886120b3b6076f19fa162ad3a4d6b3c98e7d538c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/31 09:29:11 $
-  Version:   $Revision: 1.40 $
+  Date:      $Date: 2005/10/18 08:35:46 $
+  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
@@ -16,7 +16,7 @@
                                                                                 
 =========================================================================*/
 #include "gdcmDocEntry.h"
-#include "gdcmValEntry.h"
+#include "gdcmDataEntry.h"
 #include "gdcmDicomDir.h"
 #include "gdcmDicomDirPatient.h"
 #include "gdcmDicomDirStudy.h"
@@ -48,12 +48,12 @@ int CompareSQItem(gdcm::SQItem *pa1, gdcm::SQItem *pa2 )
        return 1; 
       }
       // skip SeqEntries (I don't want to deal with 'recursion pbs' here)
-      if ( !dynamic_cast<gdcm::ValEntry*>(e1) ||
-           !dynamic_cast<gdcm::ValEntry*>(e2) )
+      if ( !dynamic_cast<gdcm::DataEntry *>(e1) ||
+           !dynamic_cast<gdcm::DataEntry *>(e2) )
          continue;
 
       // a value is read as GDCM_UNFOUND 
-      if ( ((gdcm::ValEntry*)e1)->GetValue() == gdcm::GDCM_UNFOUND )
+      if ( ((gdcm::DataEntry *)e1)->GetString() == gdcm::GDCM_UNFOUND )
       {
          std::cout << "for gdcm source DicomDir : element (" << std::hex 
                    << e1->GetGroup() << "," <<e1->GetElement() 
@@ -63,16 +63,16 @@ int CompareSQItem(gdcm::SQItem *pa1, gdcm::SQItem *pa2 )
       }
 
       // values differ in source file and destination file
-      if ( ((gdcm::ValEntry*)e1)->GetValue() != 
-           ((gdcm::ValEntry*)e2)->GetValue() )
+      if ( ((gdcm::DataEntry *)e1)->GetString() != 
+           ((gdcm::DataEntry *)e2)->GetString() )
       {
  
          // serious trouble : values differ in source and destination file
          std::cout << "for gdcm DicomDir element (" << std::hex 
                    << e2->GetGroup() << "," <<e2->GetElement() 
                    << ") values differ [" 
-                   << ((gdcm::ValEntry*)e1)->GetValue() << "] != [" 
-                   << ((gdcm::ValEntry*)e2)->GetValue() << "]"
+                   << ((gdcm::DataEntry *)e1)->GetString() << "] != [" 
+                   << ((gdcm::DataEntry *)e2)->GetString() << "]"
                    << std::endl;
           return 1;
       }
@@ -144,26 +144,26 @@ int TestDicomDir(int argc, char *argv[])
    pa1 = dicomdir->GetFirstPatient(); 
    while ( pa1 ) 
    {  // we process all the PATIENT of this DICOMDIR 
-      std::cout << pa1->GetEntryValue(0x0010, 0x0010) << std::endl; // Patient's Name
+      std::cout << pa1->GetEntryString(0x0010, 0x0010) << std::endl; // Patient's Name
 
       st1 = pa1->GetFirstStudy();
       while ( st1 ) 
       { // we process all the STUDY of this patient
-         std::cout << "--- "<< st1->GetEntryValue(0x0008, 0x1030) // Study Description
+         std::cout << "--- "<< st1->GetEntryString(0x0008, 0x1030) // Study Description
          << std::endl;  
-         std::cout << " Stud.ID:[" << st1->GetEntryValue(0x0020, 0x0010) // Study ID
+         std::cout << " Stud.ID:[" << st1->GetEntryString(0x0020, 0x0010) // Study ID
          << "]"; 
 
          se1 = st1->GetFirstSerie();
          while ( se1 ) 
          { // we process all the SERIES of this study
-            std::cout << "--- --- "<< se1->GetEntryValue(0x0008, 0x103e) << std::endl;      // Serie Description
-            std::cout << " Ser.nb:["         <<  se1->GetEntryValue(0x0020, 0x0011);        // Series number
-            std::cout << "] Mod.:["          <<  se1->GetEntryValue(0x0008, 0x0060) << "]"; // Modality
+            std::cout << "--- --- "<< se1->GetEntryString(0x0008, 0x103e) << std::endl;      // Serie Description
+            std::cout << " Ser.nb:["         <<  se1->GetEntryString(0x0020, 0x0011);        // Series number
+            std::cout << "] Mod.:["          <<  se1->GetEntryString(0x0008, 0x0060) << "]"; // Modality
 
             im1 = se1->GetFirstImage();
             while ( im1 ) { // we process all the IMAGE of this serie
-               std::cout << "--- --- --- "<< im1->GetEntryValue(0x0004, 0x1500) << std::endl; // File name
+               std::cout << "--- --- --- "<< im1->GetEntryString(0x0004, 0x1500) << std::endl; // File name
                im1 = se1->GetNextImage();   
             }
             se1 = st1->GetNextSerie();   
@@ -228,7 +228,7 @@ int TestDicomDir(int argc, char *argv[])
       }
   
       // just to allow human reader to be sure ...
-      std::cout << pa2->GetEntryValue(0x0010, 0x0010) 
+      std::cout << pa2->GetEntryString(0x0010, 0x0010) 
                 << std::endl; // Patient's Name
  
       st1 = pa1->GetFirstStudy();
@@ -244,10 +244,10 @@ int TestDicomDir(int argc, char *argv[])
          }
 
          // just to allow human reader to be sure ...
-         std::cout << "--- "<< st2->GetEntryValue(0x0008, 0x1030);
+         std::cout << "--- "<< st2->GetEntryString(0x0008, 0x1030);
          // << std::endl;    // Study Description
          std::cout << " Stud.ID:["          
-                   << st2->GetEntryValue(0x0020, 0x0010)
+                   << st2->GetEntryString(0x0020, 0x0010)
                    << "]" << std::endl; // Study ID
   
          se1 = st1->GetFirstSerie();
@@ -257,9 +257,9 @@ int TestDicomDir(int argc, char *argv[])
          { // we process all the SERIE of this study
             if ( CompareSQItem(se2,se1) == 1 )
               return 1; 
-            std::cout << "--- --- " << se2->GetEntryValue(0x0008, 0x103e);      // Serie Description
-            std::cout << " Ser.nb:["<< se2->GetEntryValue(0x0020, 0x0011);        // Series number
-            std::cout << "] Mod.:[" << se2->GetEntryValue(0x0008, 0x0060) << "]" << std::endl; // Modality
+            std::cout << "--- --- " << se2->GetEntryString(0x0008, 0x103e);      // Serie Description
+            std::cout << " Ser.nb:["<< se2->GetEntryString(0x0020, 0x0011);        // Series number
+            std::cout << "] Mod.:[" << se2->GetEntryString(0x0008, 0x0060) << "]" << std::endl; // Modality
             im1 = se1->GetFirstImage();
             im2 = se2->GetFirstImage();
 
index 8be0e831db225953eabe9a396c9a61faa9d9a781..a6251ca5327d3c25ba3ac946ae66bee690be40ea 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestFileAccessors.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 13:39:57 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2005/10/18 08:35:46 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include "gdcmFileHelper.h"
 #include "gdcmUtil.h"
 #include "gdcmCommon.h"
-#include "gdcmBinEntry.h"  
 #include "gdcmDocEntry.h" 
 #include "gdcmDocEntrySet.h"           
 #include "gdcmDocument.h"          
 #include "gdcmElementSet.h"        
 #include "gdcmSeqEntry.h" 
 #include "gdcmSQItem.h" 
-#include "gdcmValEntry.h" 
 
 #include <iostream>
 
 //Generated file:
 #include "gdcmDataImages.h"
 
+#define TestMethodMacro(mode,obj,name) \
+   try \
+   { \
+      std::cout << "   " << #name << "() : "      << mode << obj->name() << std::endl; \
+   } \
+   catch(...) \
+   { \
+      std::cout << "   --> Can't access to the '" << #name << "' method !" << std::endl; \
+      delete f; \
+      return 1; \
+   }
+
+
 int TestFileAccessors(int, char *[])
 {
    int i = 0;
@@ -51,6 +62,7 @@ int TestFileAccessors(int, char *[])
       filename += "/";  //doh!
       filename += gdcmDataImages[i];
       
+      std::cout << "Begin with " << filename << std::endl;
       gdcm::File *f= new gdcm::File( );
       f->SetFileName( filename );
       f->Load( );
@@ -59,44 +71,44 @@ int TestFileAccessors(int, char *[])
 // We just want to be sure no accessor seg faults on any image  ...
 // And this will improve test coverage ;-)
 
-      std::cout << "GetSwapCode()"      << f->GetSwapCode()      << std::endl;
-      std::cout << "GetImageNumber()"   << f->GetImageNumber()   << std::endl;
-      std::cout << "GetModality()"      << f->GetModality()      << std::endl;
-      std::cout << "GetXSize()"         << f->GetXSize()         << std::endl;
-      std::cout << "GetYSize()"         << f->GetYSize()         << std::endl;
-      std::cout << "GetZSize()"         << f->GetZSize()         << std::endl;
-      std::cout << "GetXSpacing()"      << f->GetXSpacing()      << std::endl;
-      std::cout << "GetYSpacing()"      << f->GetYSpacing()      << std::endl;
-      std::cout << "GetZSpacing()"      << f->GetZSpacing()      << std::endl;
-      std::cout << "GetXOrigin()"       << f->GetXOrigin()       << std::endl;
-      std::cout << "GetYOrigin()"       << f->GetYOrigin()       << std::endl;
-      std::cout << "GetZOrigin()"       << f->GetZOrigin()       << std::endl;
-      std::cout << "GetBitsStored()"    << f->GetBitsStored()    << std::endl;
-      std::cout << "GetBitsAllocated()" << f->GetBitsAllocated() << std::endl;
-      std::cout << "GetHighBitPosition()" << f->GetHighBitPosition()  << std::endl;
-      std::cout << "GetSamplesPerPixel()" << f->GetSamplesPerPixel()  << std::endl;
-      std::cout << "GetPlanarConfiguration()" << f->GetPlanarConfiguration()    << std::endl;
-      std::cout << "GetPixelSize()"        << f->GetPixelSize()        << std::endl;
-      std::cout << "GetPixelType()"        << f->GetPixelType()        << std::endl;
-      std::cout << "GetLUTNbits()"         << f->GetLUTNbits()         << std::endl;
-      std::cout << "GetRescaleIntercept()" << f->GetRescaleIntercept() << std::endl;
-      std::cout << "GetRescaleSlope()"     << f->GetRescaleSlope()     << std::endl;
-      std::cout << "GetGrPixel()"  << std::hex << f->GetGrPixel()  << std::endl;
-      std::cout << "GetNumPixel()" << std::hex << f->GetNumPixel() << std::endl;
-      std::cout << "GetPixelOffset()" << f->GetPixelOffset() << std::endl;
-
-      std::cout << "GetPixelAreaLength()"     << f->GetPixelAreaLength()<< std::endl;
-      std::cout << "GetNumberOfScalarComponents()"    << f->GetNumberOfScalarComponents()<< std::endl;
-      std::cout << "GetNumberOfScalarComponentsRaw()" << f->GetNumberOfScalarComponentsRaw()<< std::endl;
-      std::cout << "IsSignedPixelData()"      << f->IsSignedPixelData()<< std::endl;
-      std::cout << "IsMonochrome()"           << f->IsMonochrome()     << std::endl;
-      std::cout << "IsPaletteColor()"         << f->IsPaletteColor()   << std::endl;
-      std::cout << "IsYBRFull()"              << f->IsYBRFull()        << std::endl;
-      std::cout << "HasLut()   "              << f->HasLUT()           << std::endl;
-      std::cout << "GetTransferSyntax()"      << f->GetTransferSyntax()      << std::endl;
-      std::cout << "GetTransferSyntaxName()"  << f->GetTransferSyntaxName()  << std::endl;
-      std::cout << "GetFileType()"            << f->GetFileType()            << std::endl;
-      std::cout << "GetFileName()"            << f->GetFileName()            << std::endl;
+      TestMethodMacro(std::dec,f,GetSwapCode)
+      TestMethodMacro(std::dec,f,GetImageNumber)
+      TestMethodMacro(std::dec,f,GetModality)
+      TestMethodMacro(std::dec,f,GetXSize)
+      TestMethodMacro(std::dec,f,GetYSize)
+      TestMethodMacro(std::dec,f,GetZSize)
+      TestMethodMacro(std::dec,f,GetXSpacing)
+      TestMethodMacro(std::dec,f,GetYSpacing)
+      TestMethodMacro(std::dec,f,GetZSpacing)
+      TestMethodMacro(std::dec,f,GetXOrigin)
+      TestMethodMacro(std::dec,f,GetYOrigin)
+      TestMethodMacro(std::dec,f,GetZOrigin)
+      TestMethodMacro(std::dec,f,GetBitsStored)
+      TestMethodMacro(std::dec,f,GetBitsAllocated)
+      TestMethodMacro(std::dec,f,GetHighBitPosition)
+      TestMethodMacro(std::dec,f,GetSamplesPerPixel)
+      TestMethodMacro(std::dec,f,GetPlanarConfiguration)
+      TestMethodMacro(std::dec,f,GetPixelSize)
+      TestMethodMacro(std::dec,f,GetPixelType)
+      TestMethodMacro(std::dec,f,GetLUTNbits)
+      TestMethodMacro(std::dec,f,GetRescaleIntercept)
+      TestMethodMacro(std::dec,f,GetRescaleSlope)
+      TestMethodMacro(std::hex,f,GetGrPixel)
+      TestMethodMacro(std::hex,f,GetNumPixel)
+      TestMethodMacro(std::dec,f,GetPixelOffset)
+
+      TestMethodMacro(std::dec,f,GetPixelAreaLength)
+      TestMethodMacro(std::dec,f,GetNumberOfScalarComponents)
+      TestMethodMacro(std::dec,f,GetNumberOfScalarComponentsRaw)
+      TestMethodMacro(std::dec,f,IsSignedPixelData)
+      TestMethodMacro(std::dec,f,IsMonochrome)
+      TestMethodMacro(std::dec,f,IsPaletteColor)
+      TestMethodMacro(std::dec,f,IsYBRFull)
+      TestMethodMacro(std::dec,f,HasLUT)
+      TestMethodMacro(std::dec,f,GetTransferSyntax)
+      TestMethodMacro(std::dec,f,GetTransferSyntaxName)
+      TestMethodMacro(std::dec,f,GetFileType)
+      TestMethodMacro(std::dec,f,GetFileName)
 
       f->GetImageOrientationPatient( iop );
       for (int j=0; j<6; j++)
@@ -109,16 +121,12 @@ int TestFileAccessors(int, char *[])
 
          gdcm::FileHelper *fh= new gdcm::FileHelper( f );   
 
-         // TODO : Newbe user would appreciate any comment !
-         std::cout << "GetImageDataSize()"    << fh->GetImageDataSize()    << std::endl;
-         std::cout << "GetImageDataRawSize()" << fh->GetImageDataRawSize() << std::endl;
-         // User Data
-         std::cout << "GetRGBDataSize()"      << fh->GetRGBDataSize()      << std::endl;
-         std::cout << "GetRawDataSize()"      << fh->GetRawDataSize()      << std::endl;
-         std::cout << "GetUserDataSize()"     << fh->GetUserDataSize()     << std::endl;
-
-         std::cout << "GetWriteType()"        << fh->GetWriteType()        << std::endl;
+         TestMethodMacro(std::dec,fh,GetImageDataSize)
+         TestMethodMacro(std::dec,fh,GetImageDataRawSize)
+         TestMethodMacro(std::dec,fh,GetRGBDataSize)
+         TestMethodMacro(std::dec,fh,GetRawDataSize)
+         TestMethodMacro(std::dec,fh,GetUserDataSize)
+         TestMethodMacro(std::dec,fh,GetWriteType)
  
          delete fh;
       }
@@ -131,6 +139,7 @@ int TestFileAccessors(int, char *[])
       }
 
       delete f;
+      std::cout << "End with " << filename << std::endl;
       i++;
    }
    return 0;
index 7bf62230b57f299a90b28d90f1f760fbd2293bdc..05e6c66f7f95bdfb51635d446d534cfc7036ef16 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestImageSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 13:39:57 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2005/10/18 08:35:46 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -24,7 +24,7 @@
  */
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
-#include "gdcmValEntry.h"
+#include "gdcmDataEntry.h"
 #include "gdcmUtil.h"
 #include "gdcmDebug.h"
 
@@ -42,7 +42,7 @@ int CompareImages(FileList &list, bool sameSerie, bool sameStudy)
    if( sameSerie )
       sameStudy = true;
 
-   gdcm::ValEntry *entry;
+   gdcm::DataEntry *entry;
    std::map<std::string, int> instUID;
    std::map<std::string, int> mediaUID;
    std::map<std::string, int> serieUID;
@@ -52,33 +52,33 @@ int CompareImages(FileList &list, bool sameSerie, bool sameStudy)
    for(it=list.begin();it!=list.end();++it)
    {
       // SOP Instance UID
-      entry=(*it)->GetValEntry(0x0008, 0x0018);
+      entry=(*it)->GetDataEntry(0x0008, 0x0018);
       if( entry )
-         if( instUID.find(entry->GetValue())!=instUID.end() )
-            instUID[entry->GetValue()]++;
+         if( instUID.find(entry->GetString())!=instUID.end() )
+            instUID[entry->GetString()]++;
          else
-            instUID[entry->GetValue()]=1;
+            instUID[entry->GetString()]=1;
       // Media Storage SOP Instance UID
-      entry=(*it)->GetValEntry(0x0002,0x0003);
+      entry=(*it)->GetDataEntry(0x0002,0x0003);
       if( entry )
-         if( mediaUID.find(entry->GetValue())!=mediaUID.end() )
-            mediaUID[entry->GetValue()]++;
+         if( mediaUID.find(entry->GetString())!=mediaUID.end() )
+            mediaUID[entry->GetString()]++;
          else
-            mediaUID[entry->GetValue()]=1;
+            mediaUID[entry->GetString()]=1;
       // Series Instance UID
-      entry=(*it)->GetValEntry(0x0020,0x000e);
+      entry=(*it)->GetDataEntry(0x0020,0x000e);
       if( entry )
-         if( serieUID.find(entry->GetValue())!=serieUID.end() )
-            serieUID[entry->GetValue()]++;
+         if( serieUID.find(entry->GetString())!=serieUID.end() )
+            serieUID[entry->GetString()]++;
          else
-            serieUID[entry->GetValue()]=1;
+            serieUID[entry->GetString()]=1;
       // Study Instance UID
-      entry=(*it)->GetValEntry(0x0020,0x000d);
+      entry=(*it)->GetDataEntry(0x0020,0x000d);
       if( entry )
-         if( studyUID.find(entry->GetValue())!=studyUID.end() )
-            studyUID[entry->GetValue()]++;
+         if( studyUID.find(entry->GetString())!=studyUID.end() )
+            studyUID[entry->GetString()]++;
          else
-            studyUID[entry->GetValue()]=1;
+            studyUID[entry->GetString()]=1;
    }
 
    if( sameSerie )
@@ -152,19 +152,19 @@ gdcm::File *WriteImage(gdcm::File *file, const std::string &fileName)
    std::ostringstream str;
 
    // Set the image size
-   file->InsertValEntry("256",0x0028,0x0011); // Columns
-   file->InsertValEntry("256",0x0028,0x0010); // Rows
+   file->InsertEntryString("256",0x0028,0x0011); // Columns
+   file->InsertEntryString("256",0x0028,0x0010); // Rows
 
    // Set the pixel type
-   file->InsertValEntry("8",0x0028,0x0100); // Bits Allocated
-   file->InsertValEntry("8",0x0028,0x0101); // Bits Stored
-   file->InsertValEntry("7",0x0028,0x0102); // High Bit
+   file->InsertEntryString("8",0x0028,0x0100); // Bits Allocated
+   file->InsertEntryString("8",0x0028,0x0101); // Bits Stored
+   file->InsertEntryString("7",0x0028,0x0102); // High Bit
 
    // Set the pixel representation
-   file->InsertValEntry("0",0x0028,0x0103); // Pixel Representation
+   file->InsertEntryString("0",0x0028,0x0103); // Pixel Representation
 
    // Set the samples per pixel
-   file->InsertValEntry("1",0x0028,0x0002); // Samples per Pixel
+   file->InsertEntryString("1",0x0028,0x0002); // Samples per Pixel
 
    // The so called 'prepared image', built ex nihilo just before,
    // has NO Pixel Element yet.
@@ -252,10 +252,10 @@ int TestImageSet(int argc, char *argv[])
       // It's up to the user to initialize Serie UID and Study UID
       // Study Instance UID
       studyUID = gdcm::Util::CreateUniqueUID();
-      file->InsertValEntry(studyUID, 0x0020, 0x000d);
+      file->InsertEntryString(studyUID, 0x0020, 0x000d);
       // Series Instance UID
       serieUID = gdcm::Util::CreateUniqueUID();
-      file->InsertValEntry(serieUID, 0x0020, 0x000e);
+      file->InsertEntryString(serieUID, 0x0020, 0x000e);
 
       newFile = WriteImage(file, fileName.str());
       if( !newFile )
@@ -287,8 +287,8 @@ int TestImageSet(int argc, char *argv[])
       std::ostringstream fileName;
       fileName << "FileSeq" << i << ".dcm";
       file = new gdcm::File();
-      file->InsertValEntry(studyUID, 0x0020, 0x000d);
-      file->InsertValEntry(serieUID, 0x0020, 0x000e);
+      file->InsertEntryString(studyUID, 0x0020, 0x000d);
+      file->InsertEntryString(serieUID, 0x0020, 0x000e);
 
       newFile = WriteImage(file, fileName.str());
       if( !newFile )
@@ -319,9 +319,9 @@ int TestImageSet(int argc, char *argv[])
       std::ostringstream fileName;
       fileName << "FileSeq" << i << ".dcm";
       file = new gdcm::File();
-      file->InsertValEntry(studyUID, 0x0020, 0x000d);
+      file->InsertEntryString(studyUID, 0x0020, 0x000d);
       serieUID = gdcm::Util::CreateUniqueUID();
-      file->InsertValEntry(serieUID, 0x0020, 0x000e);
+      file->InsertEntryString(serieUID, 0x0020, 0x000e);
       newFile = WriteImage(file, fileName.str());
       if( !newFile )
       {
index b10a018a2b4222be6bbca816819fd05e830237f8..42a337aed7759e383d86b92249474d80b3fa326e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestLoadAllDocumentsNoPrivNoSeq.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/09/22 14:42:37 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2005/10/18 08:35:46 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include "gdcmFile.h"
 #include "gdcmUtil.h"
 #include "gdcmCommon.h"
-#include "gdcmBinEntry.h"  
 #include "gdcmDocEntry.h" 
 #include "gdcmDocEntrySet.h"           
 #include "gdcmDocument.h"          
 #include "gdcmElementSet.h"        
 #include "gdcmSeqEntry.h" 
 #include "gdcmSQItem.h" 
-#include "gdcmValEntry.h" 
 #include "gdcmOrientation.h"
+
 #include <fstream>
 #include <iostream>
 #include <iomanip> // for std::ios::left, ...
index e78c37f158858e8d0f414613d20b4e13a57ff7ef..1ff478a8ee5a2707c05892f4767a8a39afa3c357 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestMakeIcon.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/21 14:05:09 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2005/10/18 08:35:46 $
+  Version:   $Revision: 1.9 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include "gdcmCommon.h"
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
+#include "gdcmDataEntry.h"
 #include "gdcmSeqEntry.h"
 #include "gdcmSQItem.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
 
 // 0088 0200 SQ 1 Icon Image Sequence 
 
@@ -73,16 +72,16 @@ int TestMakeIcon (int argc, char *argv[])
 
    uint16_t binVal[3]={0x52f7,0xf358,0xad9b};
  
-   sqi->InsertValEntry( "MONOCHROME2", 0x0028,0x0004);
-   sqi->InsertValEntry( "128", 0x0028,0x0010);
-   sqi->InsertValEntry( "8",   0x0028,0x0100);
-   sqi->InsertValEntry( "8",   0x0028,0x0101);
-   sqi->InsertValEntry( "7",   0x0028,0x0102);
-   sqi->InsertValEntry( "0",   0x0028,0x0103);
-   sqi->InsertBinEntry(  (uint8_t *)binVal, 3*2, 0x0005,0x0010,"OW");
-   sqi->InsertBinEntry(  pixels, lgth, 0x7fe0,0x0010);
+   sqi->InsertEntryString( "MONOCHROME2", 0x0028,0x0004);
+   sqi->InsertEntryString( "128", 0x0028,0x0010);
+   sqi->InsertEntryString( "8",   0x0028,0x0100);
+   sqi->InsertEntryString( "8",   0x0028,0x0101);
+   sqi->InsertEntryString( "7",   0x0028,0x0102);
+   sqi->InsertEntryString( "0",   0x0028,0x0103);
+   sqi->InsertEntryBinArea(  (uint8_t *)binVal, 3*2, 0x0005,0x0010,"OW");
+   sqi->InsertEntryBinArea(  pixels, lgth, 0x7fe0,0x0010);
    // just to see if it's stored a the right place
-   sqi->InsertValEntry( "128", 0x0028,0x0011);
+   sqi->InsertEntryString( "128", 0x0028,0x0011);
     
    fh->WriteDcmExplVR(output);
 
@@ -119,19 +118,19 @@ int TestMakeIcon (int argc, char *argv[])
    std::cout << "First Item found" << std::endl;
 
    // Test for entry 0028|0010
-   if ( !sqi->GetValEntry(0x0028,0x0010) )
+   if ( !sqi->GetDataEntry(0x0028,0x0010) )
    {
-      std::cout << "ValEntry 0028|0010 not found" << std::endl
+      std::cout << "GetDataEntry 0028|0010 not found" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh;
       delete f;
       return 1;
    }
-   std::cout << "First Item ->ValEntry 0028|0010 found" << std::endl;
-   if ( sqi->GetValEntry(0x0028,0x0010)->GetValue() != "128" )
+   std::cout << "First Item ->DataEntry 0028|0010 found" << std::endl;
+   if ( sqi->GetDataEntry(0x0028,0x0010)->GetString() != "128" )
    {
       std::cout << "Value 0028|0010 don't match" << std::endl
-                << "Read : " << sqi->GetValEntry(0x0028,0x0010)->GetValue()
+                << "Read : " << sqi->GetDataEntry(0x0028,0x0010)->GetString()
                 << " - Expected : 128" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh;
@@ -140,19 +139,19 @@ int TestMakeIcon (int argc, char *argv[])
    }
 
    // Test for entry 0028|0011
-   if ( !sqi->GetValEntry(0x0028,0x0011) )
+   if ( !sqi->GetDataEntry(0x0028,0x0011) )
    {
-      std::cout << "ValEntry 0028|0011 not found" << std::endl
+      std::cout << "GetDataEntry 0028|0011 not found" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh;
       delete f;
       return 1;
    }
-   std::cout << "First Item ->ValEntry 0028|0011 found" << std::endl;
-   if ( sqi->GetValEntry(0x0028,0x0011)->GetValue() != "128" )
+   std::cout << "First Item ->DataEntry 0028|0011 found" << std::endl;
+   if ( sqi->GetDataEntry(0x0028,0x0011)->GetString() != "128" )
    {
       std::cout << "Value 0028|0011 don't match" << std::endl
-                << "Read : " << sqi->GetValEntry(0x0028,0x0011)->GetValue()
+                << "Read : " << sqi->GetDataEntry(0x0028,0x0011)->GetString()
                 << " - Expected : 128" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh;
@@ -161,19 +160,19 @@ int TestMakeIcon (int argc, char *argv[])
    }
 
    // Test for entry 0028|0100
-   if ( !sqi->GetValEntry(0x0028,0x0100) )
+   if ( !sqi->GetDataEntry(0x0028,0x0100) )
    {
-      std::cout << "ValEntry 0028|0100 not found" << std::endl
+      std::cout << "GetDataEntry 0028|0100 not found" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh;
       delete f;
       return 1;
    }
-   std::cout << "First Item ->ValEntry 0028|0100 found" << std::endl;
-   if ( sqi->GetValEntry(0x0028,0x0100)->GetValue() != "8" )
+   std::cout << "First Item ->DataEntry 0028|0100 found" << std::endl;
+   if ( sqi->GetDataEntry(0x0028,0x0100)->GetString() != "8" )
    {
       std::cout << "Value 0028|0100 don't match" << std::endl
-                << "Read : " << sqi->GetValEntry(0x0028,0x0100)->GetValue()
+                << "Read : " << sqi->GetDataEntry(0x0028,0x0100)->GetString()
                 << " - Expected : 8" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh;
@@ -182,19 +181,19 @@ int TestMakeIcon (int argc, char *argv[])
    }
 
    // Test for entry 0028|0101
-   if ( !sqi->GetValEntry(0x0028,0x0101) )
+   if ( !sqi->GetDataEntry(0x0028,0x0101) )
    {
-      std::cout << "ValEntry 0028|0101 not found" << std::endl
+      std::cout << "GetDataEntry 0028|0101 not found" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh;
       delete f;
       return 1;
    }
-   std::cout << "First Item ->ValEntry 0028|0101 found" << std::endl;
-   if ( sqi->GetValEntry(0x0028,0x0101)->GetValue() != "8" )
+   std::cout << "First Item ->DataEntry 0028|0101 found" << std::endl;
+   if ( sqi->GetDataEntry(0x0028,0x0101)->GetString() != "8" )
    {
       std::cout << "Value 0028|0101 don't match" << std::endl
-                << "Read : " << sqi->GetValEntry(0x0028,0x0101)->GetValue()
+                << "Read : " << sqi->GetDataEntry(0x0028,0x0101)->GetString()
                 << " - Expected : 8" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh;
@@ -203,19 +202,19 @@ int TestMakeIcon (int argc, char *argv[])
    }
 
    // Test for entry 0028|0102
-   if ( !sqi->GetValEntry(0x0028,0x0102) )
+   if ( !sqi->GetDataEntry(0x0028,0x0102) )
    {
-      std::cout << "ValEntry 0028|0102 not found" << std::endl
+      std::cout << "DataEntry 0028|0102 not found" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh;
       delete f;
       return 1;
    }
-   std::cout << "First Item ->ValEntry 0028|0102 found" << std::endl;
-   if ( sqi->GetValEntry(0x0028,0x0102)->GetValue() != "7" )
+   std::cout << "First Item ->DataEntry 0028|0102 found" << std::endl;
+   if ( sqi->GetDataEntry(0x0028,0x0102)->GetString() != "7" )
    {
       std::cout << "Value 0028|0102 don't match" << std::endl
-                << "Read : " << sqi->GetValEntry(0x0028,0x0102)->GetValue()
+                << "Read : " << sqi->GetDataEntry(0x0028,0x0102)->GetString()
                 << " - Expected : 7" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh;
@@ -224,19 +223,19 @@ int TestMakeIcon (int argc, char *argv[])
    }
 
    // Test for entry 0028|0103
-   if ( !sqi->GetValEntry(0x0028,0x0103) )
+   if ( !sqi->GetDataEntry(0x0028,0x0103) )
    {
-      std::cout << "ValEntry 0028|0010 not found" << std::endl
+      std::cout << "GetDataEntry 0028|0010 not found" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh;
       delete f;
       return 1;
    }
-   std::cout << "First Item ->ValEntry 0028|0103 found" << std::endl;
-   if ( sqi->GetValEntry(0x0028,0x0103)->GetValue() != "0" )
+   std::cout << "First Item ->DataEntry 0028|0103 found" << std::endl;
+   if ( sqi->GetDataEntry(0x0028,0x0103)->GetString() != "0" )
    {
       std::cout << "Value 0028|0103 don't match" << std::endl
-                << "Read : " << sqi->GetValEntry(0x0028,0x0103)->GetValue()
+                << "Read : " << sqi->GetDataEntry(0x0028,0x0103)->GetString()
                 << " - Expected : 0" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh;
@@ -245,19 +244,19 @@ int TestMakeIcon (int argc, char *argv[])
    }
 
    // Test for entry 0005|0010
-   if ( !sqi->GetBinEntry(0x0005,0x0010) )
+   if ( !sqi->GetDataEntry(0x0005,0x0010) )
    {
-      std::cout << "BinEntry 0005|0010 not found" << std::endl
+      std::cout << "GetDataEntry 0005|0010 not found" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh;
       delete f;
       return 1;
    }
-   std::cout << "First Item ->BinEntry 0005|0010 found" << std::endl;
-   if( sqi->GetBinEntry(0x0005,0x0010)->GetLength() != 6 )
+   std::cout << "First Item ->GetDataEntry 0005|0010 found" << std::endl;
+   if( sqi->GetDataEntry(0x0005,0x0010)->GetLength() != 6 )
    {
-      std::cout << "BinEntry size 0005|0010 don't match" << std::endl
-                << "Read : " << sqi->GetValEntry(0x0005,0x0010)->GetLength()
+      std::cout << "GetDataEntry size 0005|0010 don't match" << std::endl
+                << "Read : " << sqi->GetDataEntry(0x0005,0x0010)->GetLength()
                 << " - Expected : 6" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh;
@@ -265,17 +264,17 @@ int TestMakeIcon (int argc, char *argv[])
       return 1;
    }
 
-   std::cout << "Length BinEntry 0005|0010 OK" << std::endl;
+   std::cout << "Length GetDataEntry 0005|0010 OK" << std::endl;
 
-   if( memcmp(sqi->GetBinEntry(0x0005,0x0010)->GetBinArea(),binVal,6)!=0 )
+   if( memcmp(sqi->GetDataEntry(0x0005,0x0010)->GetBinArea(),binVal,6)!=0 )
    {
-      std::cout << "Value 0005|0010 don't match (BinEntry)" << std::endl
+      std::cout << "Value 0005|0010 don't match (DataEntry)" << std::endl
                 << "   ... Failed" << std::endl;
       delete fh;
       delete f;
       return 1;
    }
-   std::cout << "Value BinEntry 0005|0010 OK" << std::endl;
+   std::cout << "Value DataEntry 0005|0010 OK" << std::endl;
 
    delete fh;
    delete f;
index 26af718ebb4856a4c7e15e47b8ce487afd1215a7..76215a247570bd4b0402b3f650865564a1b44409 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestPrintAllDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/01 19:39:15 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2005/10/18 08:35:46 $
+  Version:   $Revision: 1.9 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include "gdcmFile.h"
 #include "gdcmUtil.h"
 #include "gdcmCommon.h"
-#include "gdcmBinEntry.h"  
 #include "gdcmDocEntry.h" 
 #include "gdcmDocEntrySet.h"           
 #include "gdcmDocument.h"          
 #include "gdcmElementSet.h"        
 #include "gdcmSeqEntry.h" 
 #include "gdcmSQItem.h" 
-#include "gdcmValEntry.h" 
 #include "gdcmOrientation.h"
 #include <fstream>
 #include <iostream>
@@ -84,7 +82,7 @@ int TestPrintAllDocument(int, char *[])
       std::cout << " Smpl.P.Pix.="          << f->GetSamplesPerPixel()
                 << " Plan.Config.="         << f->GetPlanarConfiguration();
  
-      photomInterp =  f->GetEntryValue(0x0028,0x0004);               
+      photomInterp =  f->GetEntryString(0x0028,0x0004);               
       std::cout << " Photom.Interp.="       << photomInterp;
       for (j=0; j<l-photomInterp.length(); j++)
          std::cout << " ";
@@ -100,7 +98,7 @@ int TestPrintAllDocument(int, char *[])
       std::cout << std::endl;
 
       std::string strImageOrientationPatient = 
-                                          f->GetEntryValue(0x0020,0x0037);
+                                          f->GetEntryString(0x0020,0x0037);
       if ( strImageOrientationPatient != gdcm::GDCM_UNFOUND )
       {
          gdcm::Orientation o;
index cadead8a8986d8a576ed40a9ee380f561f5e79a7..f6a2a7eb272ebf17e97cdbd18de5cfc2054edd9d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestReadWriteReadCompare.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/21 04:51:26 $
-  Version:   $Revision: 1.24 $
+  Date:      $Date: 2005/10/18 08:35:46 $
+  Version:   $Revision: 1.25 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -33,7 +33,8 @@ int CompareInternal(std::string const &filename, std::string const &output)
    file->Load ();
    if( !file->IsReadable() )
    {
-      std::cerr << "Test::TestReadWriteReadCompare: Image not gdcm compatible:"
+      std::cout << "Failed" << std::endl
+                << "Test::TestReadWriteReadCompare: Image not gdcm compatible:"
                 << filename << std::endl;
       delete file;
       return 1;
@@ -59,10 +60,10 @@ int CompareInternal(std::string const &filename, std::string const &output)
    fileout->SetFileName( output );
    fileout->Load();
   // gdcm::FileHelper *reread = new gdcm::FileHelper( output ); // deprecated
-  
+
    if( !fileout->IsReadable() )
    {
-     std::cerr << "Failed" << std::endl
+     std::cout << "Failed" << std::endl
                << "Test::TestReadWriteReadCompare: Could not parse the newly "
                << "written image:" << filename << std::endl;
      delete file;
@@ -144,7 +145,7 @@ int TestReadWriteReadCompare(int argc, char *argv[])
    }
    else if( argc > 4 || argc == 2 )
    {
-      std::cerr << "Please read the manual" << std::endl;
+      std::cout << "Please read the manual" << std::endl;
    }
    else
    {
index 6958b8a35830d06b756581be2b31df578ab1c4e2..1b508c76feeab679c9b7155040a60d0129e45ad0 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestWriteSimple.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/11 14:24:29 $
-  Version:   $Revision: 1.38 $
+  Date:      $Date: 2005/10/18 08:35:46 $
+  Version:   $Revision: 1.39 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -99,6 +99,8 @@ Image Images [] = {
    {0,   0,   1,  1, 8, 8,  0, 'i'} // to find the end
 };
 
+const unsigned int MAX_NUMBER_OF_DIFFERENCE = 10;
+
 int WriteSimple(Image &img)
 {
    std::ostringstream fileName;
@@ -114,16 +116,16 @@ int WriteSimple(Image &img)
    // Set the image size
    str.str("");
    str << img.sizeX;
-   fileToBuild->InsertValEntry(str.str(),0x0028,0x0011); // Columns
+   fileToBuild->InsertEntryString(str.str(),0x0028,0x0011); // Columns
    str.str("");
    str << img.sizeY;
-   fileToBuild->InsertValEntry(str.str(),0x0028,0x0010); // Rows
+   fileToBuild->InsertEntryString(str.str(),0x0028,0x0010); // Rows
 
    if(img.sizeZ>1)
    {
       str.str("");
       str << img.sizeZ;
-      fileToBuild->InsertValEntry(str.str(),0x0028,0x0008); // Number of Frames
+      fileToBuild->InsertEntryString(str.str(),0x0028,0x0008); // Number of Frames
    }
 
    fileName << "-" << img.sizeX << "-" << img.sizeY << "-" << img.sizeZ;
@@ -131,20 +133,20 @@ int WriteSimple(Image &img)
    // Set the pixel type
    str.str("");
    str << img.componentSize;
-   fileToBuild->InsertValEntry(str.str(),0x0028,0x0100); // Bits Allocated
+   fileToBuild->InsertEntryString(str.str(),0x0028,0x0100); // Bits Allocated
 
    str.str("");
    str << img.componentUse;
-   fileToBuild->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored
+   fileToBuild->InsertEntryString(str.str(),0x0028,0x0101); // Bits Stored
 
    str.str("");
    str << ( img.componentSize - 1 );
-   fileToBuild->InsertValEntry(str.str(),0x0028,0x0102); // High Bit
+   fileToBuild->InsertEntryString(str.str(),0x0028,0x0102); // High Bit
 
    // Set the pixel representation
    str.str("");
    str << img.sign;
-   fileToBuild->InsertValEntry(str.str(),0x0028,0x0103); // Pixel Representation
+   fileToBuild->InsertEntryString(str.str(),0x0028,0x0103); // Pixel Representation
 
    fileName << "-" << img.componentSize;
    if(img.sign == 0)
@@ -167,7 +169,7 @@ int WriteSimple(Image &img)
    // Set the samples per pixel
    str.str("");
    str << img.components;
-   fileToBuild->InsertValEntry(str.str(),0x0028,0x0002); // Samples per Pixel
+   fileToBuild->InsertEntryString(str.str(),0x0028,0x0002); // Samples per Pixel
 
 // Step 2 : Create the output image
    std::cout << "2...";
@@ -236,7 +238,7 @@ int WriteSimple(Image &img)
    if( !fileH->Write(fileName.str()) )
    {
       std::cout << "Failed for [" << fileName.str() << "]\n"
-                << "           File in unwrittable\n";
+                << "           File is unwrittable\n";
 
       delete fileH;
       delete fileToBuild;
@@ -331,6 +333,23 @@ int WriteSimple(Image &img)
    {
       std::cout << "Failed" << std::endl
                 << "        Pixel differ (as expanded in memory)." << std::endl;
+      std::cout << "        list of the first " << MAX_NUMBER_OF_DIFFERENCE
+                  << " pixels differing (pos : test - ref) :" 
+                  << std::endl;
+      int i;
+      unsigned int j;
+      for(i=0, j=0;i<dataSizeWritten && j<MAX_NUMBER_OF_DIFFERENCE;i++)
+      {
+         if(imageDataWritten[i]!=imageData[i])
+            {
+            std::cout << std::hex << "(" << i << " : " 
+                        << std::hex << (int)(imageDataWritten[i]) << " - "
+                        << std::hex << (int)(imageData[i]) << ") "
+                        << std::dec;
+            ++j;
+            }
+      }
+      std::cout << std::endl;
       delete fileToBuild;
       delete fileH;
       delete reread;
@@ -359,7 +378,7 @@ int TestWriteSimple(int argc, char *argv[])
       return 1;
    }
 
-   // gdcm::Debug::DebugOn();
+   //gdcm::Debug::DebugOn();
        
    int ret=0;
    int i=0;
index 341df43d0cfe802c12136b3ef423d52dabd9d16f..c891650314e1c5122e92665d92808c04c76fa4cb 100644 (file)
@@ -67,7 +67,7 @@ while(patient):
          image=serie.GetFirstImage()
          while(image):
             print "         Image"
-            print "         ---",image.GetValEntry(0x0004,0x1500).GetValue()
+            print "         ---",image.GetDataEntry(0x0004,0x1500).GetValue()
             image=serie.GetNextImage()
          serie=study.GetNextSerie()
       study=patient.GetNextStudy()
index 66af57a44d183ab0442725a33e803341879ff036..84d3df6e89b7229fb7ea4247c5d9e5d9fb14486e 100644 (file)
@@ -22,8 +22,7 @@ INCLUDE_DIRECTORIES(
 SET(libgdcm_la_SOURCES
    gdcmArgMgr.cxx
    gdcmBase.cxx
-   gdcmBinEntry.cxx
-   gdcmContentEntry.cxx
+   gdcmDataEntry.cxx
    gdcmDebug.cxx
    gdcmDicomDir.cxx
    gdcmDicomDirElement.cxx
@@ -65,7 +64,6 @@ SET(libgdcm_la_SOURCES
    gdcmSQItem.cxx
    gdcmTS.cxx
    gdcmUtil.cxx
-   gdcmValEntry.cxx   
    gdcmValidator.cxx
    gdcmVR.cxx
    ${GDCM_BINARY_DIR}/src/gdcmDefaultDicts.cxx
index d68165ebe1ddbeabfc5ec82fdf9ebd3ae1cb6c47..32ed2f3fa8e2c66c8a4cc68d532d46e91665234a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcm.h,v $
   Language:  C++
-  Date:      $Date: 2005/03/09 11:16:11 $
-  Version:   $Revision: 1.54 $
+  Date:      $Date: 2005/10/18 08:35:49 $
+  Version:   $Revision: 1.55 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -33,8 +33,7 @@
 #include "gdcmFileHelper.h"
 #include "gdcmSerieHelper.h"
 
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
 #include "gdcmSeqEntry.h"
 
 #include "gdcmUtil.h"
diff --git a/src/gdcmBinEntry.cxx b/src/gdcmBinEntry.cxx
deleted file mode 100644 (file)
index 33a302b..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-/*=========================================================================
-                                                                                
-  Program:   gdcm
-  Module:    $RCSfile: gdcmBinEntry.cxx,v $
-  Language:  C++
-  Date:      $Date: 2005/10/11 14:48:19 $
-  Version:   $Revision: 1.80 $
-                                                                                
-  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 "gdcmBinEntry.h"
-#include "gdcmContentEntry.h"
-#include "gdcmUtil.h"
-
-#include <fstream>
-#include <sstream>
-#include <iostream> // for std::ios_base, since <ios> does not exist on gcc/Solaris
-
-namespace gdcm 
-{
-//-----------------------------------------------------------------------------
-// Constructor / Destructor
-/**
- * \brief   Constructor from a given BinEntry
- */
-BinEntry::BinEntry(DictEntry *e) 
-         :ContentEntry(e)
-{
-   BinArea = 0;
-   SelfArea = true;
-}
-
-/**
- * \brief   Constructor from a given BinEntry
- * @param   e Pointer to existing Doc entry
- */
-BinEntry::BinEntry(DocEntry *e) 
-        : ContentEntry(e->GetDictEntry())
-{
-   Copy(e);
-
-   BinArea = 0;
-   SelfArea = true;
-}
-
-/**
- * \brief   Canonical destructor.
- */
-BinEntry::~BinEntry()
-{
-   if (BinArea && SelfArea)
-   {
-      delete[] BinArea;
-      BinArea = 0; // let's be carefull !
-   }
-}
-
-//-----------------------------------------------------------------------------
-// Public
-/**
- * \brief   canonical Writer
- * @param fp already open file pointer
- * @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
-*/
-void BinEntry::WriteContent(std::ofstream *fp, FileType filetype)
-{ 
-   DocEntry::WriteContent(fp, filetype);
-   uint8_t *binArea8 = BinArea; //safe notation
-   size_t lgr = GetLength();
-   if (BinArea) // the binArea was *actually* loaded
-   {
-
-   //  The same operation should be done if we wanted 
-   //  to write image with Big Endian Transfer Syntax, 
-   //  while working on Little Endian Processor
-   // --> forget Big Endian Transfer Syntax writting!
-   //     Next DICOM version will give it up ...
-
-   // -->
-   // --> FIXME 
-   // -->
-   // The stuff looks nice, but it's probably bugged,
-   // since troubles occur on big endian processors (SunSparc, Motorola)
-   // while reading the pixels of a 
-   // gdcm-written Little-Endian 16 bits per pixel image
-
-#if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)
-
-      /// \todo FIXME : Right now, we only care of Pixels element
-      ///       we should deal with *all* the BinEntries
-      ///       Well, not really since we are not interpreting values read...
-
-      // 8 Bits Pixels *are* OB, 16 Bits Pixels *are* OW
-      // -value forced while Reading process-
-      
-      //-->
-      // -->
-      // -->  WARNING
-      // -->        the following lines *looked* very clever, 
-      // -->        but they don't work on big endian processors.
-      // -->        since I've no access for the moment to a big endian proc :-(
-      // -->        I comment them out, to see the result on the dash board 
-      // -->     
-      
-      // --> Revert to initial code : TestWriteSimple hangs on Darwin :-(     
-      if (GetGroup() == 0x7fe0 && GetVR() == "OW")
-      {  
-         uint16_t *binArea16 = (uint16_t*)binArea8;
-         binary_write (*fp, binArea16, lgr );
-      }
-      else
-      { 
-         // For any other VR, BinEntry is re-written as-is
-         binary_write (*fp, binArea8, lgr );
-      }
-            
-      //-->
-      // -->
-      // -->  WARNING      
-      // -->         remove the following line, an uncomment the previous ones, 
-      // -->         if it doesn't work better
-      // -->     
-      /*binary_write ( *fp, binArea8, lgr ); // Elem value*/
-      
-#else
-      binary_write ( *fp, binArea8, lgr ); // Elem value
-#endif //GDCM_WORDS_BIGENDIAN
-
-   }
-   else
-   {
-      // nothing was loaded, but we need to skip space on disc
-      
-      //  --> WARNING : nothing is written; 
-      //  --> the initial data (on the the source image) is lost
-      //  --> user is *not* informed !
-      
-      fp->seekp(lgr, std::ios::cur);
-   }
-}
-
-/**
- * \brief Sets the value (non string) of the current Dicom Header Entry
- */
-void BinEntry::SetBinArea( uint8_t *area, bool self )  
-{ 
-   if (BinArea && SelfArea)
-      delete[] BinArea;
-
-   BinArea = area;
-   SelfArea=self;
-}
-
-//-----------------------------------------------------------------------------
-// Protected
-
-//-----------------------------------------------------------------------------
-// Private
-   
-//-----------------------------------------------------------------------------
-// Print
-/**
- * \brief   Prints a BinEntry (Dicom entry)
- * @param   os ostream we want to print in
- * @param indent Indentation string to be prepended during printing
- */
-void BinEntry::Print(std::ostream &os, std::string const & )
-{
-   os << "B ";
-   DocEntry::Print(os);
-   std::ostringstream s;
-   void* binArea = GetBinArea();
-   if (binArea)
-   {
-      if ( GetVR() == "FL" )
-      {
-         int l = GetReadLength()/4 - 1;
-         float *beg = (float *)GetBinArea();
-         s << " [" << *beg;
-         if ( l!= 0)
-            for (int i=0;i<l;i++)
-            {
-               beg++;
-               s << "\\" << *beg;
-            }
-            s << "]";
-      }
-      else if ( GetVR() == "FD" )
-      {
-         int l = GetReadLength()/8 - 1;
-         double *beg = (double *)GetBinArea();
-         s << " [" << *beg;
-         if ( l!= 0)
-            for (int i=0;i<l;i++)
-            {
-               beg++;
-               s << "\\" << *beg;
-            }
-            s << "]";
-      }
-      else
-      { 
-         if ( Util::IsCleanArea( GetBinArea(),GetLength()  ) )
-         {
-            std::string cleanString = 
-                   Util::CreateCleanString( GetBinArea(),GetLength()  );
-            s << " [" << cleanString << "]";
-         }
-         else
-         {
-            //s << " [" << GetValue()
-            s << " [" << GDCM_BINLOADED << ";"
-              << "length = " << GetLength() << "]";
-         } 
-      }
-   }
-   else
-   {
-      if ( GetLength() == 0 )
-      {
-         s << " []";
-      }
-      else 
-      {
-         s << " [" <<GetValue() << "]";
-      }         
-   }
-   os << s.str();
-}
-
-//-----------------------------------------------------------------------------
-} // end namespace gdcm
diff --git a/src/gdcmBinEntry.h b/src/gdcmBinEntry.h
deleted file mode 100644 (file)
index cff1942..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*=========================================================================
-                                                                                
-  Program:   gdcm
-  Module:    $RCSfile: gdcmBinEntry.h,v $
-  Language:  C++
-  Date:      $Date: 2005/09/02 07:10:03 $
-  Version:   $Revision: 1.38 $
-                                                                                
-  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 GDCMBINENTRY_H
-#define GDCMBINENTRY_H
-
-#include "gdcmContentEntry.h"
-#include <iostream>
-
-namespace gdcm 
-{
-
-//-----------------------------------------------------------------------------
-/**
- * \brief   Any Dicom Document (File or DicomDir) contains 
- *           a set of DocEntry - Dicom entries - 
- *          BinEntry is an elementary DocEntry (i.e. a ContentEntry, 
- *           as opposed to SeqEntry) whose content is non std::string
- *          representable
- *          BinEntry is a specialisation of ContentEntry
- */
-class GDCM_EXPORT BinEntry  : public ContentEntry
-{
-public:
-   BinEntry( DictEntry *e );
-   BinEntry( DocEntry *d ); 
-
-   ~BinEntry();
-   
-   void Print( std::ostream &os = std::cout, std::string const &indent = "" );
-
-   void WriteContent( std::ofstream *fp, FileType ft);
-
-   /// \brief Returns the area value of the current Dicom Entry
-   ///  when it's not string-translatable (e.g : LUT table, overlay, icon)         
-   uint8_t *GetBinArea()  { return BinArea; }
-   void  SetBinArea( uint8_t *area, bool self = true );
-
-   /// \brief Sets SelfArea
-   void SetSelfArea(bool area) { SelfArea = area; }
-   /// \brief Returns SelfArea
-   bool IsSelfArea() { return SelfArea; }
-
-private:
-   /// \brief memory area to hold 'non std::string' representable values 
-   ///       (ie : Lookup Tables, overlays, icons)   
-   uint8_t *BinArea;
-   /// \brief Whether BinEntry has its own BinArea or not
-   bool SelfArea;
-};
-
-} // end namespace gdcm
-//-----------------------------------------------------------------------------
-#endif
-
diff --git a/src/gdcmContentEntry.cxx b/src/gdcmContentEntry.cxx
deleted file mode 100644 (file)
index 97c949e..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*=========================================================================
-                                                                                
-  Program:   gdcm
-  Module:    $RCSfile: gdcmContentEntry.cxx,v $
-  Language:  C++
-  Date:      $Date: 2005/06/24 10:55:58 $
-  Version:   $Revision: 1.10 $
-                                                                                
-  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 "gdcmContentEntry.h"
-#include "gdcmVR.h"
-#include "gdcmTS.h"
-#include "gdcmGlobal.h"
-#include "gdcmUtil.h"
-#include "gdcmDebug.h"
-
-#include <fstream>
-
-namespace gdcm 
-{
-
-//-----------------------------------------------------------------------------
-// Constructor / Destructor
-/**
- * \brief   Constructor for a given DictEntry
- * @param   e Pointer to existing dictionary entry
- */
-ContentEntry::ContentEntry(DictEntry *e) 
-            : DocEntry(e)
-{
-   Value = GDCM_UNFOUND;
-}
-
-/**
- * \brief   Constructor for a given DocEntry
- * @param   e Pointer to existing Doc entry
- */
-ContentEntry::ContentEntry(DocEntry *e)
-            : DocEntry(e->GetDictEntry())
-{
-   Copy(e);
-}
-
-/**
- * \brief   Canonical destructor.
- */
-ContentEntry::~ContentEntry ()
-{
-}
-
-//-----------------------------------------------------------------------------
-// Print
-
-//-----------------------------------------------------------------------------
-// Public
-void ContentEntry::Copy(DocEntry *doc)
-{
-   DocEntry::Copy(doc);
-
-   ContentEntry *entry = dynamic_cast<ContentEntry *>(doc);
-   if ( entry )
-      Value = entry->Value;
-}
-
-//-----------------------------------------------------------------------------
-// Protected
-
-//-----------------------------------------------------------------------------
-// Private
-
-//-----------------------------------------------------------------------------
-} // end namespace gdcm
-
diff --git a/src/gdcmContentEntry.h b/src/gdcmContentEntry.h
deleted file mode 100644 (file)
index 0b61d9c..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*=========================================================================
-                                                                                
-  Program:   gdcm
-  Module:    $RCSfile: gdcmContentEntry.h,v $
-  Language:  C++
-  Date:      $Date: 2005/09/02 07:10:03 $
-  Version:   $Revision: 1.6 $
-                                                                                
-  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 GDCMCONTENTENTRY_H
-#define GDCMCONTENTENTRY_H
-
-#include "gdcmDocEntry.h"
-
-#include <iostream>
-
-namespace gdcm 
-{
-//-----------------------------------------------------------------------------
-/**
- * \brief   Any Dicom Document (File or DicomDir) contains 
- *           a set of DocEntry  - Dicom entries -
- *           (when successfuly parsed against a given Dicom dictionary)
- *          ContentEntry is an elementary DocEntry (as opposed to SeqEntry).
- *          Depending on the type of its content,
- *          ContentEntry is specialized as a ValEntry or a BinEntry
- */
-class GDCM_EXPORT ContentEntry  : public DocEntry
-{
-public:
-   virtual void WriteContent(std::ofstream *fp, FileType filetype) = 0;
-
-   /// Sets the value (string) of the current Dicom entry
-   virtual void SetValue(std::string const &val) { Value = val; }
-   /// \brief Returns the 'Value' (e.g. "Dupond^Marcel") converted 
-   /// into a 'string', event if it's physically stored on disk as an integer
-   /// (e.g. : 0x000c returned as "12")
-   std::string const &GetValue() const { return Value; }
-
-   void Copy(DocEntry *doc);
-
-protected:
-   // Contructors are protected, not to be invoked by end user.
-   ContentEntry(DictEntry *e);
-   ContentEntry(DocEntry *d); 
-   // Destructor is protected, not to be invoked by end user.
-   ~ContentEntry();
-
-private:
-// Members :
-   /// \brief Dicom entry value, internaly represented as a std::string.
-   ///        The Value Representation (\ref VR) is independently used
-   ///        in order to interpret (decode) this field.
-   std::string Value;
-};
-
-} // end namespace gdcm
-
-//-----------------------------------------------------------------------------
-#endif
-
diff --git a/src/gdcmDataEntry.cxx b/src/gdcmDataEntry.cxx
new file mode 100644 (file)
index 0000000..a35ef4e
--- /dev/null
@@ -0,0 +1,625 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmDataEntry.cxx,v $
+  Language:  C++
+  Date:      $Date: 2005/10/18 08:35:51 $
+  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 "gdcmDataEntry.h"
+#include "gdcmVR.h"
+#include "gdcmTS.h"
+#include "gdcmGlobal.h"
+#include "gdcmUtil.h"
+#include "gdcmDebug.h"
+
+#include <fstream>
+
+namespace gdcm 
+{
+//-----------------------------------------------------------------------------
+#define MAX_SIZE_PRINT_ELEMENT_VALUE 0x7fffffff
+uint32_t DataEntry::MaxSizePrintEntry = MAX_SIZE_PRINT_ELEMENT_VALUE;
+
+//-----------------------------------------------------------------------------
+// Constructor / Destructor
+/**
+ * \brief   Constructor for a given DictEntry
+ * @param   e Pointer to existing dictionary entry
+ */
+DataEntry::DataEntry(DictEntry *e) 
+            : DocEntry(e)
+{
+   State = STATE_LOADED;
+   Flag = FLAG_NONE;
+
+   BinArea = 0;
+   SelfArea = true;
+}
+
+/**
+ * \brief   Constructor for a given DocEntry
+ * @param   e Pointer to existing Doc entry
+ */
+DataEntry::DataEntry(DocEntry *e)
+            : DocEntry(e->GetDictEntry())
+{
+   Flag = 0;
+   BinArea = 0;
+   SelfArea = true;
+
+   Copy(e);
+}
+
+/**
+ * \brief   Canonical destructor.
+ */
+DataEntry::~DataEntry ()
+{
+   DeleteBinArea();
+}
+
+//-----------------------------------------------------------------------------
+// Print
+
+//-----------------------------------------------------------------------------
+// Public
+/**
+ * \brief Sets the value (non string) of the current Dicom Header Entry
+ */
+void DataEntry::SetBinArea( uint8_t *area, bool self )  
+{ 
+   DeleteBinArea();
+
+   BinArea = area;
+   SelfArea = self;
+
+   State = STATE_LOADED;
+}
+
+void DataEntry::CopyBinArea( uint8_t *area, uint32_t length )
+{
+   DeleteBinArea();
+
+   uint32_t lgh = length + length%2;
+   SetLength(lgh);
+
+   if( area && length > 0 )
+   {
+      NewBinArea();
+      memcpy(BinArea,area,length);
+      if( length!=lgh )
+         BinArea[length]=0;
+
+      State = STATE_LOADED;
+   }
+}
+
+void DataEntry::SetValue(const uint32_t &id,const double &val)
+{
+   if( !BinArea )
+      NewBinArea();
+   State = STATE_LOADED;
+
+   if( id > GetValueCount() )
+   {
+      gdcmErrorMacro("Index (" << id << ")is greater than the data size");
+      return;
+   }
+
+   const VRKey &vr = GetVR();
+   if( vr == "US" || vr == "SS" )
+   {
+      uint16_t *data = (uint16_t *)BinArea;
+      data[id] = (uint16_t)val;
+   }
+   else if( vr == "UL" || vr == "SL" )
+   {
+      uint32_t *data = (uint32_t *)BinArea;
+      data[id] = (uint32_t)val;
+   }
+   else if( vr == "FL" )
+   {
+      float *data = (float *)BinArea;
+      data[id] = (float)val;
+   }
+   else if( vr == "FD" )
+   {
+      double *data = (double *)BinArea;
+      data[id] = (double)val;
+   }
+   else if( Global::GetVR()->IsVROfStringRepresentable(vr) )
+   {
+      gdcmErrorMacro("SetValue on String representable not implemented yet");
+   }
+   else
+   {
+      BinArea[id] = (uint8_t)val;
+   }
+}
+
+double DataEntry::GetValue(const uint32_t &id) const
+{
+   if( !BinArea )
+   {
+      gdcmErrorMacro("BinArea not set. Can't get the value");
+      return 0;
+   }
+
+   uint32_t count = GetValueCount();
+   if( id > count )
+   {
+      gdcmErrorMacro("Index (" << id << ")is greater than the data size");
+      return 0;
+   }
+
+   const VRKey &vr = GetVR();
+   if( vr == "US" || vr == "SS" )
+      return ((uint16_t *)BinArea)[id];
+   else if( vr == "UL" || vr == "SL" )
+      return ((uint32_t *)BinArea)[id];
+   else if( vr == "FL" )
+      return ((float *)BinArea)[id];
+   else if( vr == "FD" )
+      return ((double *)BinArea)[id];
+   else if( Global::GetVR()->IsVROfStringRepresentable(vr) )
+   {
+      if( GetLength() )
+      {
+         // Don't use std::string to accelerate processing
+         double val = 0.0;
+         char *tmp = new char[GetLength()+1];
+         memcpy(tmp,BinArea,GetLength());
+         tmp[GetLength()]=0;
+
+         if( count == 0 )
+         {
+            val = atof(tmp);
+         }
+         else
+         {
+            count = id;
+            char *beg = tmp;
+            for(uint32_t i=0;i<GetLength();i++)
+            {
+               if( tmp[i] == '\\' )
+               {
+                  if( count == 0 )
+                  {
+                     tmp[i] = NULL;
+                     break;
+                  }
+                  else
+                  {
+                     count--;
+                     beg = &(tmp[i+1]);
+                  }
+               }
+            }
+            val = atof(beg);
+         }
+
+         delete[] tmp;
+         return val;
+      }
+      else 
+         return 0.0;
+   }
+   else
+      return BinArea[id];
+}
+
+uint32_t DataEntry::GetValueCount(void) const
+{
+   const VRKey &vr = GetVR();
+   if( vr == "US" || vr == "SS" )
+      return GetLength()/sizeof(uint16_t);
+   else if( vr == "UL" || vr == "SL" )
+      return GetLength()/sizeof(uint32_t);
+   else if( vr == "FL" )
+      return GetLength()/sizeof(float);
+   else if( vr == "FD" )
+      return GetLength()/sizeof(double);
+   else if( Global::GetVR()->IsVROfStringRepresentable(vr) )
+   {
+      // Don't use std::string to accelerate processing
+      uint32_t count = 1;
+      for(uint32_t i=0;i<GetLength();i++)
+      {
+         if( BinArea[i] == '\\')
+            count++;
+      }
+      return count;
+   }
+   else
+      return GetLength();
+}
+
+void DataEntry::SetString(std::string const &value)
+{
+   DeleteBinArea();
+
+   const VRKey &vr = GetVR();
+   if ( vr == "US" || vr == "SS" )
+   {
+      std::vector<std::string> tokens;
+      Util::Tokenize (value, tokens, "\\");
+      SetLength(tokens.size()*sizeof(uint16_t));
+      NewBinArea();
+
+      uint16_t *data = (uint16_t *)BinArea;
+      for (unsigned int i=0; i<tokens.size();i++)
+         data[i] = atoi(tokens[i].c_str());
+      tokens.clear();
+   }
+   else if ( vr == "UL" || vr == "SL" )
+   {
+      std::vector<std::string> tokens;
+      Util::Tokenize (value, tokens, "\\");
+      SetLength(tokens.size()*sizeof(uint32_t));
+      NewBinArea();
+
+      uint32_t *data = (uint32_t *)BinArea;
+      for (unsigned int i=0; i<tokens.size();i++)
+         data[i] = atoi(tokens[i].c_str());
+      tokens.clear();
+   }
+   else if ( vr == "FL" )
+   {
+      std::vector<std::string> tokens;
+      Util::Tokenize (value, tokens, "\\");
+      SetLength(tokens.size()*sizeof(float));
+      NewBinArea();
+
+      float *data = (float *)BinArea;
+      for (unsigned int i=0; i<tokens.size();i++)
+         data[i] = (float)atof(tokens[i].c_str());
+      tokens.clear();
+   }
+   else if ( vr == "FD" )
+   {
+      std::vector<std::string> tokens;
+      Util::Tokenize (value, tokens, "\\");
+      SetLength(tokens.size()*sizeof(double));
+      NewBinArea();
+
+      double *data = (double *)BinArea;
+      for (unsigned int i=0; i<tokens.size();i++)
+         data[i] = atof(tokens[i].c_str());
+      tokens.clear();
+   }
+   else
+   {
+      if( value.size() > 0 )
+      {
+         std::string finalVal = Util::DicomString( value.c_str() );
+         SetLength(finalVal.size());
+         NewBinArea();
+
+         memcpy(BinArea, &(finalVal[0]), finalVal.size());
+      }
+   }
+   State = STATE_LOADED;
+}
+
+std::string const &DataEntry::GetString() const
+{
+   static std::ostringstream s;
+   const VRKey &vr = GetVR();
+
+   s.str("");
+   StrArea="";
+
+   if( !BinArea )
+      return StrArea;
+
+   if( vr == "US" || vr == "SS" )
+   {
+      uint16_t *data=(uint16_t *)BinArea;
+
+      for (int i=0; i < GetValueCount(); i++)
+      {
+         if( i!=0 )
+            s << '\\';
+         s << data[i];
+      }
+      StrArea=s.str();
+   }
+   // See above comment on multiple integers (mutatis mutandis).
+   else if( vr == "UL" || vr == "SL" )
+   {
+      uint32_t *data=(uint32_t *)BinArea;
+
+      for (int i=0; i < GetValueCount(); i++)
+      {
+         if( i!=0 )
+            s << '\\';
+         s << data[i];
+      }
+      StrArea=s.str();
+   }
+   else if( vr == "FL" )
+   {
+      float *data=(float *)BinArea;
+
+      for (int i=0; i < GetValueCount(); i++)
+      {
+         if( i!=0 )
+            s << '\\';
+         s << data[i];
+      }
+      StrArea=s.str();
+   }
+   else if( vr == "FD" )
+   {
+      double *data=(double *)BinArea;
+
+      for (int i=0; i < GetValueCount(); i++)
+      {
+         if( i!=0 )
+            s << '\\';
+         s << data[i];
+      }
+      StrArea=s.str();
+   }
+   else
+      StrArea.append((const char *)BinArea,GetLength());
+
+   return StrArea;
+}
+
+void DataEntry::Copy(DocEntry *doc)
+{
+   DocEntry::Copy(doc);
+
+   DataEntry *entry = dynamic_cast<DataEntry *>(doc);
+   if ( entry )
+   {
+      State = entry->State;
+      Flag = entry->Flag;
+      CopyBinArea(entry->BinArea,entry->GetLength());
+   }
+}
+
+void DataEntry::WriteContent(std::ofstream *fp, FileType filetype)
+{ 
+   DocEntry::WriteContent(fp, filetype);
+
+   if ( GetGroup() == 0xfffe )
+   {
+      return; //delimitors have NO value
+   }
+
+   uint8_t *binArea8 = BinArea; //safe notation
+   size_t lgr = GetLength();
+   if (BinArea) // the binArea was *actually* loaded
+   {
+
+   //  The same operation should be done if we wanted 
+   //  to write image with Big Endian Transfer Syntax, 
+   //  while working on Little Endian Processor
+   // --> forget Big Endian Transfer Syntax writting!
+   //     Next DICOM version will give it up ...
+
+   // --> FIXME 
+   //    The stuff looks nice, but it's probably bugged,
+   //    since troubles occur on big endian processors (SunSparc, Motorola)
+   //    while reading the pixels of a 
+   //    gdcm-written Little-Endian 16 bits per pixel image
+
+#if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)
+
+      /// \todo FIXME : Right now, we only care of Pixels element
+      ///       we should deal with *all* the BinEntries
+      ///       Well, not really since we are not interpreting values read...
+
+      // 8 Bits Pixels *are* OB, 16 Bits Pixels *are* OW
+      // -value forced while Reading process-
+      
+      // -->  WARNING
+      // -->        the following lines *looked* very clever, 
+      // -->        but they don't work on big endian processors.
+      // -->        since I've no access for the moment to a big endian proc :-(
+      // -->        I comment them out, to see the result on the dash board 
+      // -->     
+      
+      // --> Revert to initial code : TestWriteSimple hangs on Darwin :-(     
+      if (GetGroup() == 0x7fe0 && GetVR() == "OW")
+      {  
+         uint16_t *binArea16 = (uint16_t*)binArea8;
+         binary_write (*fp, binArea16, lgr );
+      }
+      else
+      { 
+         // For any other VR, DataEntry is re-written as-is
+         binary_write (*fp, binArea8, lgr );
+      }
+
+      // -->  WARNING      
+      // -->         remove the following line, an uncomment the previous ones, 
+      // -->         if it doesn't work better
+      // -->     
+      /*binary_write ( *fp, binArea8, lgr ); // Elem value*/
+      
+#else
+      binary_write ( *fp, binArea8, lgr ); // Elem value
+#endif //GDCM_WORDS_BIGENDIAN
+   }
+   else
+   {
+      // nothing was loaded, but we need to skip space on disc
+      
+      //  --> WARNING : nothing is written; 
+      //  --> the initial data (on the the source image) is lost
+      //  --> user is *not* informed !
+      
+      fp->seekp(lgr, std::ios::cur);
+   }
+}
+
+//-----------------------------------------------------------------------------
+// Protected
+void DataEntry::NewBinArea(void)
+{
+   DeleteBinArea();
+   if( GetLength() > 0 )
+      BinArea = new uint8_t[GetLength()];
+   SelfArea = true;
+}
+
+void DataEntry::DeleteBinArea(void)
+{
+   if (BinArea && SelfArea)
+   {
+      delete[] BinArea;
+      BinArea = NULL;
+   }
+}
+
+//-----------------------------------------------------------------------------
+// Private
+
+//-----------------------------------------------------------------------------
+// Print
+/**
+ * \brief   Prints a DataEntry (Dicom entry)
+ * @param   os ostream we want to print in
+ * @param indent Indentation string to be prepended during printing
+ */
+void DataEntry::Print(std::ostream &os, std::string const & )
+{
+   os << "D ";
+   DocEntry::Print(os);
+
+   std::ostringstream s;
+   TSAtr v;
+
+   if( BinArea )
+   {
+      v = GetString();
+      const VRKey &vr = GetVR();
+
+      if( vr == "US" || vr == "SS" )
+         s << " [" << GetString() << "]";
+      else if( vr == "UL" || vr == "SL" )
+         s << " [" << GetString() << "]";
+      else if ( vr == "FL" )
+         s << " [" << GetString() << "]";
+      else if ( vr == "FD" )
+         s << " [" << GetString() << "]";
+      else
+      { 
+         if(Global::GetVR()->IsVROfStringRepresentable(vr))
+         {
+            std::string cleanString = Util::CreateCleanString(v);  // replace non printable characters by '.'
+            if ( cleanString.length() <= GetMaxSizePrintEntry()
+            || PrintLevel >= 3
+            || IsNotLoaded() )
+            {
+               s << " [" << cleanString << "]";
+            }
+            else
+            {
+               s << " [gdcm::too long for print (" << cleanString.length() << ") ]";
+            }
+         }
+         else
+         {
+            if ( Util::IsCleanArea( GetBinArea(),GetLength()  ) )
+            {
+               std::string cleanString = 
+                     Util::CreateCleanString( BinArea,GetLength()  );
+               s << " [" << cleanString << "]";
+            }
+            else
+            {
+               s << " [" << GDCM_BINLOADED << ";"
+               << "length = " << GetLength() << "]";
+            }
+         }
+      }
+   }
+   else
+   {
+      if( IsNotLoaded() )
+         s << " [" << GDCM_NOTLOADED << "]";
+      else if( IsUnfound() )
+         s << " [" << GDCM_UNFOUND << "]";
+      else if( IsUnread() )
+         s << " [" << GDCM_UNREAD << "]";
+      else if ( GetLength() == 0 )
+         s << " []";
+   }
+
+   if( IsPixelData() )
+      s << " (" << GDCM_PIXELDATA << ")";
+
+   // Display the UID value (instead of displaying only the rough code)
+   // First 'clean' trailing character (space or zero) 
+   if(BinArea)
+   {
+      const uint16_t &gr = GetGroup();
+      const uint16_t &elt = GetElement();
+      TS *ts = Global::GetTS();
+
+      if (gr == 0x0002)
+      {
+         // Any more to be displayed ?
+         if ( elt == 0x0010 || elt == 0x0002 )
+         {
+            if ( v.length() != 0 )  // for brain damaged headers
+            {
+               if ( ! isdigit((unsigned char)v[v.length()-1]) )
+               {
+                  v.erase(v.length()-1, 1);
+               }
+            }
+            s << "  ==>\t[" << ts->GetValue(v) << "]";
+         }
+      }
+      else if (gr == 0x0008)
+      {
+         if ( elt == 0x0016 || elt == 0x1150 )
+         {
+            if ( v.length() != 0 )  // for brain damaged headers
+            {
+               if ( ! isdigit((unsigned char)v[v.length()-1]) )
+               {
+                  v.erase(v.length()-1, 1);
+               }
+            }
+            s << "  ==>\t[" << ts->GetValue(v) << "]";
+         }
+      }
+      else if (gr == 0x0004)
+      {
+         if ( elt == 0x1510 || elt == 0x1512  )
+         {
+            if ( v.length() != 0 )  // for brain damaged headers  
+            {
+               if ( ! isdigit((unsigned char)v[v.length()-1]) )
+               {
+                  v.erase(v.length()-1, 1);  
+               }
+            }
+            s << "  ==>\t[" << ts->GetValue(v) << "]";
+         }
+      }
+   }
+
+   os << s.str();
+}
+
+//-----------------------------------------------------------------------------
+} // end namespace gdcm
+
diff --git a/src/gdcmDataEntry.h b/src/gdcmDataEntry.h
new file mode 100644 (file)
index 0000000..2407383
--- /dev/null
@@ -0,0 +1,137 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmDataEntry.h,v $
+  Language:  C++
+  Date:      $Date: 2005/10/18 08:35:51 $
+  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 GDCMDATAENTRY_H
+#define GDCMDATAENTRY_H
+
+#include "gdcmDocEntry.h"
+
+#include <iostream>
+
+namespace gdcm 
+{
+//-----------------------------------------------------------------------------
+/**
+ * \brief   Any Dicom Document (File or DicomDir) contains 
+ *           a set of DocEntry  - Dicom entries -
+ *           (when successfuly parsed against a given Dicom dictionary)
+ *          DataEntry is an elementary DocEntry (as opposed to SeqEntry).
+ *          Depending on the type of its content,
+ */
+class GDCM_EXPORT DataEntry  : public DocEntry
+{
+public:
+   DataEntry(DictEntry *e);
+   DataEntry(DocEntry *d); 
+   ~DataEntry();
+
+// Print
+   void Print(std::ostream &os = std::cout, std::string const &indent = "");
+
+// Write
+   virtual void WriteContent(std::ofstream *fp, FileType filetype);
+
+// Set/Get datas
+   /// Sets the value (string) of the current Dicom entry
+   //virtual void SetValue(std::string const &val);
+   /// \brief Returns the 'Value' (e.g. "Dupond^Marcel") converted 
+   /// into a 'string', event if it's physically stored on disk as an integer
+   /// (e.g. : 0x000c returned as "12")
+   //virtual std::string const &GetValue() const { return Value; }
+
+   /// \brief Returns the area value of the current Dicom Entry
+   ///  when it's not string-translatable (e.g : LUT table, overlay, icon)         
+   uint8_t *GetBinArea()  { return BinArea; }
+   void SetBinArea( uint8_t *area, bool self = true );
+   void CopyBinArea( uint8_t *area, uint32_t length );
+
+   void SetValue(const uint32_t &id,const double &val);
+   double GetValue(const uint32_t &id) const;
+   uint32_t GetValueCount(void) const;
+
+   void SetString(std::string const &value);
+   std::string const &GetString() const;
+
+   /// \brief Sets SelfArea
+   void SetSelfArea(bool area) { SelfArea = area; }
+   /// \brief Returns SelfArea
+   bool IsSelfArea() { return SelfArea; }
+
+   // State
+   void SetState(const char &state) { State = state; }
+   const char &GetState() const { return State; }
+   bool IsNotLoaded() { return State == STATE_NOTLOADED; }
+   bool IsUnfound()   { return State == STATE_UNFOUND; }
+   bool IsUnread()    { return State == STATE_UNREAD; }
+   bool IsGoodValue() { return State == 0; }
+
+   // Flags
+   void SetFlag(const char &flag) { Flag = flag; }
+   const char &GetFlag() const { return Flag; }
+   bool IsPixelData() { return (Flag & FLAG_PIXELDATA) != 0; }
+
+   void Copy(DocEntry *doc);
+
+   /// \brief returns the size threshold above which an element value 
+   ///        will NOT be *printed* in order no to polute the screen output
+   static const uint32_t &GetMaxSizePrintEntry() { return MaxSizePrintEntry; }
+   /// \brief Header Elements too long will not be printed
+   static void SetMaxSizePrintEntry(const uint32_t &size) { MaxSizePrintEntry = size; }
+
+   typedef enum
+   {
+      STATE_LOADED    = 0x00,
+      STATE_NOTLOADED = 0x01,
+      STATE_UNFOUND   = 0x02,
+      STATE_UNREAD    = 0x03,
+   } TValueState;
+
+   typedef enum
+   {
+      FLAG_NONE       = 0x00,
+      FLAG_PIXELDATA  = 0x01,
+   } TValueFlag;
+
+protected:
+// Methods :
+   void NewBinArea(void);
+   void DeleteBinArea(void);
+
+// Members :
+   /// \brief memory area to hold 'non std::string' representable values 
+   ///       (ie : Lookup Tables, overlays, icons)   
+   uint8_t *BinArea;
+   /// \brief Whether DataEntry has its own BinArea or not
+   bool SelfArea;
+
+   mutable std::string StrArea;
+
+private:
+   char Flag;
+   char State;
+
+   /// \brief Size threshold above which an element val
+   ///        By default, this upper bound is fixed to 64 bytes.
+   static uint32_t MaxSizePrintEntry;   
+};
+
+} // end namespace gdcm
+
+//-----------------------------------------------------------------------------
+#endif
+
index 123b0fa6495213b6cb214c23a1e879bb55867f5c..67195605e1710b55bd2605fbe2c6191e3fe8568b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/31 16:24:19 $
-  Version:   $Revision: 1.159 $
+  Date:      $Date: 2005/10/18 08:35:49 $
+  Version:   $Revision: 1.160 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -36,7 +36,7 @@
 #include "gdcmFile.h"
 #include "gdcmSeqEntry.h"
 #include "gdcmSQItem.h"
-#include "gdcmValEntry.h"
+#include "gdcmDataEntry.h"
 
 #include <fstream>
 #include <string>
@@ -582,7 +582,7 @@ bool DicomDir::Write(std::string const &fileName)
  
 bool DicomDir::Anonymize() 
 {
-   ValEntry *v;
+   DataEntry *v;
    // Something clever to be found to forge the Patient names
    std::ostringstream s;
    int i = 1;
@@ -591,22 +591,22 @@ bool DicomDir::Anonymize()
                                    ++cc)
    {
       s << i;
-      v = (*cc)->GetValEntry(0x0010, 0x0010) ; // Patient's Name
+      v = (*cc)->GetDataEntry(0x0010, 0x0010) ; // Patient's Name
       if (v)
       {
-         v->SetValue(s.str());
+         v->SetString(s.str());
       }
 
-      v = (*cc)->GetValEntry(0x0010, 0x0020) ; // Patient ID
+      v = (*cc)->GetDataEntry(0x0010, 0x0020) ; // Patient ID
       if (v)
       {
-         v->SetValue(" ");
+         v->SetString(" ");
       }
 
-      v = (*cc)->GetValEntry(0x0010, 0x0030) ; // Patient's BirthDate
+      v = (*cc)->GetDataEntry(0x0010, 0x0030) ; // Patient's BirthDate
       if (v)
       {
-         v->SetValue(" ");
+         v->SetString(" ");
       }
       s << "";
       i++;
@@ -778,13 +778,13 @@ void DicomDir::CreateDicomDir()
    while(tmpSI)
    {
       d = tmpSI->GetDocEntry(0x0004, 0x1430); // Directory Record Type
-      if ( ValEntry* valEntry = dynamic_cast<ValEntry *>(d) )
+      if ( DataEntry *dataEntry = dynamic_cast<DataEntry *>(d) )
       {
-         v = valEntry->GetValue();
+         v = dataEntry->GetString();
       }
       else
       {
-         gdcmWarningMacro( "(0004,1430) not a ValEntry ?!?");
+         gdcmWarningMacro( "(0004,1430) not a DataEntry ?!?");
          continue;
       }
 
@@ -981,12 +981,12 @@ void DicomDir::SetElements(std::string const &path, VectDocument const &list)
                                    ++it )
    {
       // get the current file characteristics
-      patCurName         = (*it)->GetEntryValue(0x0010,0x0010);
-      patCurID           = (*it)->GetEntryValue(0x0010,0x0011);
-      studCurInstanceUID = (*it)->GetEntryValue(0x0020,0x000d);
-      studCurID          = (*it)->GetEntryValue(0x0020,0x0010);
-      serCurInstanceUID  = (*it)->GetEntryValue(0x0020,0x000e);
-      serCurID           = (*it)->GetEntryValue(0x0020,0x0011);
+      patCurName         = (*it)->GetEntryString(0x0010,0x0010);
+      patCurID           = (*it)->GetEntryString(0x0010,0x0011);
+      studCurInstanceUID = (*it)->GetEntryString(0x0020,0x000d);
+      studCurID          = (*it)->GetEntryString(0x0020,0x0010);
+      serCurInstanceUID  = (*it)->GetEntryString(0x0020,0x000e);
+      serCurID           = (*it)->GetEntryString(0x0020,0x0011);
 
       if ( patCurName != patPrevName || patCurID != patPrevID || first )
       {
@@ -1037,7 +1037,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type,
    ListDicomDirElem::const_iterator it;
    uint16_t tmpGr, tmpEl;
    DictEntry *dictEntry;
-   ValEntry *entry;
+   DataEntry *entry;
    std::string val;
    SQItem *si;
 
@@ -1109,7 +1109,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type,
       tmpEl     = it->Elem;
       dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl);
 
-      entry     = new ValEntry( dictEntry ); // Be sure it's never a BinEntry !
+      entry     = new DataEntry( dictEntry ); // Be sure it's never a DataEntry !
 
       entry->SetOffset(0); // just to avoid further missprinting
 
@@ -1117,7 +1117,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type,
       {
          // NULL when we Build Up (ex nihilo) a DICOMDIR
          //   or when we add the META elems
-         val = header->GetEntryValue(tmpGr, tmpEl);
+         val = header->GetEntryString(tmpGr, tmpEl);
       }
       else
       {
@@ -1154,7 +1154,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type,
             val = it->Value;
       }
 
-      entry->SetValue( val ); // troubles expected when vr=SQ ...
+      entry->SetString( val ); // troubles expected when vr=SQ ...
 
       if ( type == GDCM_DICOMDIR_META ) // fusible : should never print !
       {
index 007284287ae8b10d5f8728da57c01011edb1fee7..06dde6d533bbc964dad4e54ce265bcf5afeed882 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirImage.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/06/24 10:55:58 $
-  Version:   $Revision: 1.23 $
+  Date:      $Date: 2005/10/18 08:35:49 $
+  Version:   $Revision: 1.24 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -17,8 +17,8 @@
 =========================================================================*/
 
 #include "gdcmDicomDirImage.h"
-#include "gdcmValEntry.h"
 #include "gdcmGlobal.h"
+#include "gdcmDataEntry.h"
 
 namespace gdcm 
 {
@@ -72,7 +72,8 @@ void DicomDirImage::Print(std::ostream &os, std::string const & )
    {
       if ( (*i)->GetGroup() == 0x0004 && (*i)->GetElement() == 0x1500 )
       {
-         os << (dynamic_cast<ValEntry *>(*i))->GetValue(); //FIXME
+         if( dynamic_cast<DataEntry *>(*i) )
+            os << (dynamic_cast<DataEntry *>(*i))->GetString();
       }
    }
    os << std::endl;
index 84a5387660514f1ae5d53673b75c5277d790036c..e53002695e95d7ada673d7a48a5d0cdaa6d6e435 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirObject.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/12 17:08:12 $
-  Version:   $Revision: 1.20 $
+  Date:      $Date: 2005/10/18 08:35:49 $
+  Version:   $Revision: 1.21 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,8 +19,8 @@
 #include "gdcmDicomDirObject.h"
 #include "gdcmGlobal.h"
 #include "gdcmDebug.h"
-#include "gdcmValEntry.h"
 #include "gdcmDictSet.h"
+#include "gdcmDataEntry.h"
 
 namespace gdcm 
 {
@@ -59,7 +59,7 @@ void DicomDirObject::FillObject(ListDicomDirMetaElem const &elemList)
    ListDicomDirMetaElem::const_iterator it;
    uint16_t tmpGr,tmpEl;
    DictEntry *dictEntry;
-   ValEntry *entry;
+   DataEntry *entry;
       
    // for all the Elements found in they own part of the DicomDir dict.     
    for(it = elemList.begin(); it != elemList.end(); ++it)
@@ -67,9 +67,9 @@ void DicomDirObject::FillObject(ListDicomDirMetaElem const &elemList)
       tmpGr = it->Group;
       tmpEl = it->Elem;
       dictEntry = Global::GetDicts()->GetDefaultPubDict()->GetEntry(tmpGr,tmpEl);
-      entry = new ValEntry(dictEntry);
+      entry = new DataEntry(dictEntry);
       entry->SetOffset(0); // just to avoid further missprinting
-      entry->SetValue(it->Value);
+      entry->SetString(it->Value);
 
       AddEntry(entry);
    }   
index b5c9eaba19a7c2aef0ca53570494dcac4a31df73..98e9226c8f8648a7b0c30e353d9af175e356f467 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirVisit.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 19:07:12 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2005/10/18 08:35:49 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -17,8 +17,8 @@
 =========================================================================*/
 
 #include "gdcmDicomDirVisit.h"
-#include "gdcmValEntry.h"
 #include "gdcmGlobal.h"
+#include "gdcmDataEntry.h"
 
 namespace gdcm 
 {
@@ -72,7 +72,8 @@ void DicomDirVisit::Print(std::ostream &os, std::string const & )
    {
       if ( (*i)->GetGroup() == 0x0004 && (*i)->GetElement() == 0x1500 )
       {
-         os << (dynamic_cast<ValEntry *>(*i))->GetValue(); //FIXME // ????
+         if( dynamic_cast<DataEntry *>(*i) )
+            os << (dynamic_cast<DataEntry *>(*i))->GetString();
       }
    }
    os << std::endl;
index 780c7afd6b2f64977cc800df6124f4b53f176fbe..11425127fc975c1c73f8a164469f152358891d3b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictEntry.h,v $
   Language:  C++
-  Date:      $Date: 2005/07/11 14:40:40 $
-  Version:   $Revision: 1.35 $
+  Date:      $Date: 2005/10/18 08:35:49 $
+  Version:   $Revision: 1.36 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -54,19 +54,19 @@ public:
 
    /// \brief tells if the V(alue) R(epresentation) is known (?!)
    /// @return 
-   bool IsVRUnknown() { return VR == GDCM_UNKNOWN; }
+   bool IsVRUnknown() const { return VR == GDCM_UNKNOWN; }
 
    /// \brief tells if the V(alue) M(ultiplicity) is known (?!)
    /// @return 
-   bool IsVMUnknown() { return VM == GDCM_UNKNOWN; }
+   bool IsVMUnknown() const { return VM == GDCM_UNKNOWN; }
 
    /// \brief  Returns the Dicom Group Number of the current DictEntry
    /// @return the Dicom Group Number
-   uint16_t GetGroup() { return Group; }
+   const uint16_t &GetGroup() const { return Group; }
   
    /// \brief  Returns the Dicom Element Number of the current DictEntry
    /// @return the Dicom Element Number
-   uint16_t GetElement() { return Element; }
+   const uint16_t &GetElement() const { return Element; }
  
    /// \brief  Returns the Dicom Value Representation of the current
    ///         DictEntry
index 2da966c81b10ac832565766456be6e02adfd72b3..729fe8cccece0a618d5ace6c15bb1f5aa54095e1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/09/21 09:44:59 $
-  Version:   $Revision: 1.69 $
+  Date:      $Date: 2005/10/18 08:35:49 $
+  Version:   $Revision: 1.70 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -50,7 +50,7 @@ DocEntry::DocEntry(DictEntry *in)
 //-----------------------------------------------------------------------------
 // Public
 /**
- * \brief   Writes the common part of any ValEntry, BinEntry, SeqEntry
+ * \brief   Writes the common part of any DataEntry, SeqEntry
  * @param fp already open ofstream pointer
  * @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
  */
@@ -223,7 +223,7 @@ void DocEntry::Copy(DocEntry *doc)
 //-----------------------------------------------------------------------------
 // Print
 /**
- * \brief   Prints the common part of ValEntry, BinEntry, SeqEntry
+ * \brief   Prints the common part of DataEntry, SeqEntry
  * @param   os ostream we want to print in
  * @param indent Indentation string to be prepended during printing
  */
index 29a2522eccaebbf9ce8326ae5306412b0cf86b85..d7fecfc3418fcdc6c53b7007893c346b04cbe9e3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.h,v $
   Language:  C++
-  Date:      $Date: 2005/09/02 07:10:03 $
-  Version:   $Revision: 1.49 $
+  Date:      $Date: 2005/10/18 08:35:49 $
+  Version:   $Revision: 1.50 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -28,8 +28,6 @@
 namespace gdcm 
 {
 class File;
-class ValEntry;
-class BinEntry;
 class SeqEntry;
 
 //-----------------------------------------------------------------------------
@@ -52,10 +50,10 @@ public:
    DictEntry * GetDictEntry() { return DicomDict; } 
 
    /// Returns the Dicom Group number of the current Dicom entry
-   uint16_t      GetGroup()     { return DicomDict->GetGroup();  }
+   const uint16_t &GetGroup() const   { return DicomDict->GetGroup();  }
 
    /// Returns the Dicom Element number of the current Dicom entry
-   uint16_t      GetElement()   { return DicomDict->GetElement();}
+   const uint16_t &GetElement() const { return DicomDict->GetElement();}
 
    /// Set the 'key' of the current Dicom entry
    void  SetKey( TagKey const &key ) { Key = key; }
@@ -83,7 +81,7 @@ public:
    /// \brief Returns offset (since the beginning of the file, including
    /// the File Preamble, if any) of the value of the current Dicom entry
    /// \warning offset of the *value*, not of the Dicom entry
-   size_t GetOffset() { return Offset; }
+   const size_t &GetOffset() const { return Offset; }
 
    /// \brief Sets only 'Read Length' (*not* 'Usable Length') of the current
    /// Dicom entry
@@ -92,15 +90,15 @@ public:
    /// \warning this value is the one stored in the Dicom header but not
    ///          mandatoryly the one thats's used (in case on SQ, or delimiters,
    ///          the usable length is set to zero)
-   uint32_t GetReadLength() { return ReadLength; }
+   const uint32_t &GetReadLength() const { return ReadLength; }
 
    /// \brief Sets both 'Read Length' and 'Usable Length' of the current
    /// Dicom entry
-   void SetLength(uint32_t l) { Length = l; }
+   virtual void SetLength(uint32_t l) { Length = l; }
    /// \brief Returns the actual value length of the current Dicom entry
    /// \warning this value is not *always* the one stored in the Dicom header
    ///          in case of well knowned bugs
-   uint32_t GetLength() { return Length; }
+   const uint32_t &GetLength() const { return Length; }
 
    uint32_t GetFullLength();
 
@@ -115,15 +113,15 @@ public:
  
    /// \brief Tells us if the current Dicom entry was checked as ImplicitVr
    /// @return true if the current Dicom entry was checked as ImplicitVr
-   bool IsImplicitVR() { return ImplicitVR; }
+   bool IsImplicitVR() const { return ImplicitVR; }
 
    /// \brief Tells us if the VR of the current Dicom entry is Unknown
    /// @return true if the VR is unknown
-   bool IsVRUnknown() { return DicomDict->IsVRUnknown(); }
+   bool IsVRUnknown() const { return DicomDict->IsVRUnknown(); }
 
    /// \brief Tells us if the VM of the current Dicom entry is Unknown
    /// @return true if the VM is unknown
-   bool IsVMUnknown() { return DicomDict->IsVMUnknown(); }
+   bool IsVMUnknown() const { return DicomDict->IsVMUnknown(); }
 
    bool IsItemDelimitor();
    bool IsItemStarter();
index a054d86e7f990360c22b91aa1d123403f9bdb4fc..8aa7966340a6fc8fb59629814f617f7379f56656 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntrySet.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/09/06 15:28:49 $
-  Version:   $Revision: 1.59 $
+  Date:      $Date: 2005/10/18 08:35:49 $
+  Version:   $Revision: 1.60 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -23,9 +23,9 @@
 #include "gdcmGlobal.h"
 #include "gdcmDocEntry.h"
 #include "gdcmSeqEntry.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
 #include "gdcmUtil.h"
+#include "gdcmDataEntry.h"
+#include "gdcmVR.h"
 
 namespace gdcm 
 {
@@ -44,11 +44,19 @@ DocEntrySet::DocEntrySet()
  * @return  Corresponding element value when it exists,
  *          and the string GDCM_UNFOUND otherwise.
  */
-std::string DocEntrySet::GetEntryValue(uint16_t group, uint16_t elem)
+std::string DocEntrySet::GetEntryString(uint16_t group, uint16_t elem)
 {
-   ContentEntry *entry = dynamic_cast<ContentEntry *>(GetDocEntry(group,elem));
+   DataEntry *entry = dynamic_cast<DataEntry *>(GetDocEntry(group,elem));
    if ( entry )
-      return entry->GetValue();
+   {
+      if( entry->IsNotLoaded() )
+         return GDCM_NOTLOADED;
+      if( entry->IsUnfound() )
+         return GDCM_UNFOUND;
+      if( entry->IsUnread() )
+         return GDCM_UNREAD;
+      return entry->GetString();
+   }
    return GDCM_UNFOUND;
 }
 
@@ -60,14 +68,14 @@ std::string DocEntrySet::GetEntryValue(uint16_t group, uint16_t elem)
  */
 void *DocEntrySet::GetEntryBinArea(uint16_t group, uint16_t elem) 
 {
-   BinEntry *entry = GetBinEntry(group, elem);
+   DataEntry *entry = GetDataEntry(group, elem);
    if ( entry )
       return entry->GetBinArea();
    return 0;
 }
 
 /**
- * \brief   Return the value of the BinEntry if it's "std::string representable"
+ * \brief   Return the value of the DataEntry if it's "std::string representable"
  * @param   group  Group number of the searched tag.
  * @param   elem Element number of the searched tag.
  * @return  Corresponding element value when it's "std::string representable"
@@ -79,17 +87,24 @@ std::string DocEntrySet::GetEntryForcedAsciiValue(uint16_t group, uint16_t elem)
    if ( !d )
       return GDCM_UNFOUND;
 
-   if (ValEntry *v = dynamic_cast<ValEntry *>(d))
-      return v->GetValue();
-
-   if (BinEntry *b = dynamic_cast<BinEntry *>(d))
+   DataEntry *de = dynamic_cast<DataEntry *>(d);
+   if ( de )
    {
-      uint8_t *a = b->GetBinArea();
-      if (!b)
+      if( de->IsNotLoaded() )
          return GDCM_NOTLOADED;
-         // TODO : unify those two methods.
-      if (Util::IsCleanArea(a, b->GetLength()) )
-         return  Util::CreateCleanString(a, b->GetLength());
+      if( de->IsUnfound() )
+         return GDCM_UNFOUND;
+      if( de->IsUnread() )
+         return GDCM_UNREAD;
+   }
+
+   if( Global::GetVR()->IsVROfStringRepresentable( de->GetVR() ) )
+      return de->GetString();
+   else
+   {
+      uint8_t *a = de->GetBinArea();
+      if( Util::IsCleanArea(a, de->GetLength()) )
+         return  Util::CreateCleanString(a, de->GetLength());
    }
    return GDCM_NOTASCII;
 }
@@ -134,39 +149,18 @@ std::string DocEntrySet::GetEntryVR(uint16_t group, uint16_t elem)
 /**
  * \brief  Same as \ref Document::GetDocEntry except it only
  *         returns a result when the corresponding entry is of type
- *         ValEntry.
+ *         DataEntry.
  * @param   group  Group number of the searched Dicom Element 
  * @param   elem Element number of the searched Dicom Element  
- * @return When present, the corresponding ValEntry. 
+ * @return When present, the corresponding DataEntry. 
  */
-ValEntry *DocEntrySet::GetValEntry(uint16_t group, uint16_t elem)
+DataEntry *DocEntrySet::GetDataEntry(uint16_t group, uint16_t elem)
 {
    DocEntry *currentEntry = GetDocEntry(group, elem);
    if ( !currentEntry )
       return NULL;
 
-   return dynamic_cast<ValEntry*>(currentEntry);
-}
-
-/**
- * \brief  Same as \ref Document::GetDocEntry except it only
- *         returns a result when the corresponding entry is of type
- *         BinEntry.
- * @param   group  Group number of the searched Dicom Element
- * @param   elem Element number of the searched Dicom Element
- * @return When present, the corresponding BinEntry. 
- */
-BinEntry *DocEntrySet::GetBinEntry(uint16_t group, uint16_t elem)
-{
-   DocEntry *currentEntry = GetDocEntry(group, elem);
-   if ( !currentEntry )
-   {
-      gdcmWarningMacro( "No corresponding BinEntry " << std::hex << group <<
-                         "," << elem);
-      return NULL;
-   }
-
-   return dynamic_cast<BinEntry*>(currentEntry);
+   return dynamic_cast<DataEntry*>(currentEntry);
 }
 
 /**
@@ -198,17 +192,17 @@ SeqEntry *DocEntrySet::GetSeqEntry(uint16_t group, uint16_t elem)
  * @param   group  group number of the Dicom Element to modify
  * @param   elem element number of the Dicom Element to modify
  */
-bool DocEntrySet::SetValEntry(std::string const &content, 
-                              uint16_t group, uint16_t elem) 
+bool DocEntrySet::SetEntryString(std::string const &content, 
+                                 uint16_t group, uint16_t elem) 
 {
-   ValEntry *entry = GetValEntry(group, elem);
+   DataEntry *entry = GetDataEntry(group, elem);
    if (!entry )
    {
-      gdcmWarningMacro( "No corresponding ValEntry " << std::hex << group <<
+      gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group <<
                          "," << elem << " element (try promotion first).");
       return false;
    }
-   return SetValEntry(content,entry);
+   return SetEntryString(content,entry);
 }
 
 /**
@@ -220,18 +214,18 @@ bool DocEntrySet::SetValEntry(std::string const &content,
  * @param   group  group number of the Dicom Element to modify
  * @param   elem element number of the Dicom Element to modify
  */
-bool DocEntrySet::SetBinEntry(uint8_t *content, int lgth, 
-                              uint16_t group, uint16_t elem) 
+bool DocEntrySet::SetEntryBinArea(uint8_t *content, int lgth, 
+                                  uint16_t group, uint16_t elem) 
 {
-   BinEntry *entry = GetBinEntry(group, elem);
+   DataEntry *entry = GetDataEntry(group, elem);
    if (!entry )
    {
-      gdcmWarningMacro( "No corresponding ValEntry " << std::hex << group <<
+      gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group <<
                         "," << elem << " element (try promotion first).");
       return false;
    }
 
-   return SetBinEntry(content,lgth,entry);
+   return SetEntryBinArea(content,lgth,entry);
 } 
 
 /**
@@ -240,30 +234,29 @@ bool DocEntrySet::SetBinEntry(uint8_t *content, int lgth,
  * @param  content new value (string) to substitute with
  * @param  entry Entry to be modified
  */
-bool DocEntrySet::SetValEntry(std::string const &content, ValEntry *entry)
+bool DocEntrySet::SetEntryString(std::string const &content, DataEntry *entry)
 {
    if (entry)
    {
-      entry->SetValue(content);
+      entry->SetString(content);
       return true;
    }
    return false;
 }
 
 /**
- * \brief   Accesses an existing BinEntry (i.e. a Dicom Element)
+ * \brief   Accesses an existing DataEntry (i.e. a Dicom Element)
  *          and modifies it's content with the given value.
  * @param   content new value (void*  -> uint8_t*) to substitute with
  * @param  entry Entry to be modified 
  * @param  lgth new value length
  */
-bool DocEntrySet::SetBinEntry(uint8_t *content, int lgth, BinEntry *entry)
+bool DocEntrySet::SetEntryBinArea(uint8_t *content, int lgth, DataEntry *entry)
 {
    if (entry)
    {
-      entry->SetBinArea(content);  
       entry->SetLength(lgth);
-      entry->SetValue(GDCM_BINLOADED);
+      entry->SetBinArea(content);  
       return true;
    }
    return false;
@@ -279,51 +272,50 @@ bool DocEntrySet::SetBinEntry(uint8_t *content, int lgth, BinEntry *entry)
  * \return  pointer to the modified/created Header Entry (NULL when creation
  *          failed).
  */ 
-ValEntry *DocEntrySet::InsertValEntry(std::string const &value, 
-                                      uint16_t group, uint16_t elem,
-                                      TagName const &vr )
+DataEntry *DocEntrySet::InsertEntryString(std::string const &value, 
+                                             uint16_t group, uint16_t elem,
+                                             TagName const &vr )
 {
-   ValEntry *valEntry = 0;
+   DataEntry *dataEntry = 0;
    DocEntry *currentEntry = GetDocEntry( group, elem );
    
    if (currentEntry)
    {
-      valEntry = dynamic_cast<ValEntry *>(currentEntry);
+      dataEntry = dynamic_cast<DataEntry *>(currentEntry);
 
       // Verify the VR
-      if ( valEntry )
-         if ( valEntry->GetVR()!=vr )
-            valEntry = NULL;
+      if ( dataEntry )
+         if ( dataEntry->GetVR()!=vr )
+            dataEntry = NULL;
 
-      // if currentEntry doesn't correspond to the requested valEntry
-      if ( !valEntry)
+      // if currentEntry doesn't correspond to the requested dataEntry
+      if ( !dataEntry)
       {
          if ( !RemoveEntry(currentEntry) )
          {
             gdcmWarningMacro( "Removal of previous DocEntry failed.");
-
             return NULL;
          }
       }
    }
 
-   // Create a new valEntry if necessary
-   if ( !valEntry )
+   // Create a new dataEntry if necessary
+   if ( !dataEntry )
    {
-      valEntry = NewValEntry( group, elem, vr );
+      dataEntry = NewDataEntry( group, elem, vr );
 
-      if ( !AddEntry(valEntry) )
+      if ( !AddEntry(dataEntry) )
       {
          gdcmWarningMacro("AddEntry failed although this is a creation.");
 
-         delete valEntry;
+         delete dataEntry;
          return NULL;
       }
    }
 
-   // Set the binEntry value
-   SetValEntry(value, valEntry); // The std::string value
-   return valEntry;
+   // Set the dataEntry value
+   SetEntryString(value, dataEntry); // The std::string value
+   return dataEntry;
 }
 
 /**
@@ -338,50 +330,49 @@ ValEntry *DocEntrySet::InsertValEntry(std::string const &value,
  * \return  pointer to the modified/created Header Entry (NULL when creation
  *          failed).
  */
-BinEntry *DocEntrySet::InsertBinEntry(uint8_t *binArea, int lgth, 
-                                      uint16_t group, uint16_t elem,
-                                      TagName const &vr )
+DataEntry *DocEntrySet::InsertEntryBinArea(uint8_t *binArea, int lgth, 
+                                              uint16_t group, uint16_t elem,
+                                              TagName const &vr )
 {
-   BinEntry *binEntry = 0;
+   DataEntry *dataEntry = 0;
    DocEntry *currentEntry = GetDocEntry( group, elem );
 
    // Verify the currentEntry
    if (currentEntry)
    {
-      binEntry = dynamic_cast<BinEntry *>(currentEntry);
+      dataEntry = dynamic_cast<DataEntry *>(currentEntry);
 
       // Verify the VR
-      if ( binEntry )
-         if ( binEntry->GetVR()!=vr )
-            binEntry = NULL;
+      if ( dataEntry )
+         if ( dataEntry->GetVR()!=vr )
+            dataEntry = NULL;
 
-      // if currentEntry doesn't correspond to the requested valEntry
-      if ( !binEntry)
+      // if currentEntry doesn't correspond to the requested dataEntry
+      if ( !dataEntry)
       {
          if ( !RemoveEntry(currentEntry) )
          {
             gdcmWarningMacro( "Removal of previous DocEntry failed.");
-
             return NULL;
          }
       }
    }
 
-   // Create a new binEntry if necessary
-   if ( !binEntry)
+   // Create a new dataEntry if necessary
+   if ( !dataEntry)
    {
-      binEntry = NewBinEntry(group, elem, vr);
+      dataEntry = NewDataEntry(group, elem, vr);
 
-      if ( !AddEntry(binEntry) )
+      if ( !AddEntry(dataEntry) )
       {
          gdcmWarningMacro( "AddEntry failed although this is a creation.");
 
-         delete binEntry;
+         delete dataEntry;
          return NULL;
       }
    }
 
-   // Set the binEntry value
+   // Set the dataEntry value
    uint8_t *tmpArea;
    if ( lgth>0 && binArea )
    {
@@ -392,7 +383,7 @@ BinEntry *DocEntrySet::InsertBinEntry(uint8_t *binArea, int lgth,
    {
       tmpArea = 0;
    }
-   if ( !SetBinEntry(tmpArea,lgth,binEntry) )
+   if ( !SetEntryBinArea(tmpArea,lgth,dataEntry) )
    {
       if ( tmpArea )
       {
@@ -400,7 +391,7 @@ BinEntry *DocEntrySet::InsertBinEntry(uint8_t *binArea, int lgth,
       }
    }
 
-   return binEntry;
+   return dataEntry;
 }  
 
 /**
@@ -474,40 +465,16 @@ bool DocEntrySet::CheckIfEntryExist(uint16_t group, uint16_t elem )
  * @param   elem  Element number of the new Entry
  * @param   vr    V(alue) R(epresentation) of the new Entry 
  */
-ValEntry *DocEntrySet::NewValEntry(uint16_t group,uint16_t elem,
-                                   TagName const &vr) 
-{
-   DictEntry *dictEntry = GetDictEntry(group, elem, vr);
-   gdcmAssertMacro(dictEntry);
-
-   ValEntry *newEntry = new ValEntry(dictEntry);
-   if (!newEntry) 
-   {
-      gdcmWarningMacro( "Failed to allocate ValEntry");
-      return 0;
-   }
-   return newEntry;
-}
-
-
-/**
- * \brief   Build a new Bin Entry from all the low level arguments. 
- *          Check for existence of dictionary entry, and build
- *          a default one when absent.
- * @param   group Group   number of the new Entry
- * @param   elem  Element number of the new Entry
- * @param   vr    V(alue) R(epresentation) of the new Entry 
- */
-BinEntry *DocEntrySet::NewBinEntry(uint16_t group, uint16_t elem,
+DataEntry *DocEntrySet::NewDataEntry(uint16_t group,uint16_t elem,
                                    TagName const &vr) 
 {
    DictEntry *dictEntry = GetDictEntry(group, elem, vr);
    gdcmAssertMacro(dictEntry);
 
-   BinEntry *newEntry = new BinEntry(dictEntry);
+   DataEntry *newEntry = new DataEntry(dictEntry);
    if (!newEntry) 
    {
-      gdcmWarningMacro( "Failed to allocate BinEntry");
+      gdcmWarningMacro( "Failed to allocate DataEntry");
       return 0;
    }
    return newEntry;
index 81425d0e9f5db6b199088340ba12bf9fb2230800..4502a78aff91d1ca7d353d9753f9de7e314ce6c6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntrySet.h,v $
   Language:  C++
-  Date:      $Date: 2005/09/06 15:28:49 $
-  Version:   $Revision: 1.56 $
+  Date:      $Date: 2005/10/18 08:35:49 $
+  Version:   $Revision: 1.57 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -26,8 +26,7 @@ namespace gdcm
 {
 //-----------------------------------------------------------------------------
 class DocEntry;
-class ValEntry;
-class BinEntry;
+class DataEntry;
 class SeqEntry;
 class DictEntry;
 
@@ -80,32 +79,30 @@ public:
    /// Gets the next entry of any type of set
    virtual DocEntry *GetNextEntry()=0;
 
-   virtual std::string GetEntryValue(uint16_t group, uint16_t elem);
+   virtual std::string GetEntryString(uint16_t group, uint16_t elem);
    virtual void *GetEntryBinArea(uint16_t group, uint16_t elem);
-   
    virtual int GetEntryLength(uint16_t group, uint16_t elem);
    virtual std::string GetEntryVR(uint16_t group, uint16_t elem);
    virtual std::string GetEntryForcedAsciiValue(uint16_t group, uint16_t elem);
+
    /// \brief Gets any type of DocEntry, identified by its (group,elem)
    virtual DocEntry *GetDocEntry(uint16_t group, uint16_t elem) = 0;
-   /// \brief Gets a ValEntry, identified by its (group, elem)
-   ValEntry *GetValEntry(uint16_t group, uint16_t elem);
-   /// \brief Gets a BinEntry, identified by its (group,elem)
-   BinEntry *GetBinEntry(uint16_t group, uint16_t elem);
+   /// \brief Gets a DataEntry, identified by its (group, elem)
+   DataEntry *GetDataEntry(uint16_t group, uint16_t elem);
    /// \brief Gets a SeqEntry, identified by its (group,elem)
    SeqEntry *GetSeqEntry(uint16_t group, uint16_t elem);
 
-   bool SetValEntry(std::string const &content,
-                            uint16_t group, uint16_t elem);
-   bool SetBinEntry(uint8_t *content, int lgth,
-                            uint16_t group, uint16_t elem);
-   bool SetValEntry(std::string const &content, ValEntry *entry);
-   bool SetBinEntry(uint8_t *content, int lgth, BinEntry *entry);
-
-   ValEntry *InsertValEntry(std::string const &value,
-                                    uint16_t group, uint16_t elem,
-                                    TagName const &vr = GDCM_UNKNOWN);
-   BinEntry *InsertBinEntry(uint8_t *binArea, int lgth,
+   bool SetEntryString(std::string const &content,
+                       uint16_t group, uint16_t elem);
+   bool SetEntryBinArea(uint8_t *content, int lgth,
+                        uint16_t group, uint16_t elem);
+   bool SetEntryString(std::string const &content, DataEntry *entry);
+   bool SetEntryBinArea(uint8_t *content, int lgth, DataEntry *entry);
+
+   DataEntry *InsertEntryString(std::string const &value,
+                                   uint16_t group, uint16_t elem,
+                                   TagName const &vr = GDCM_UNKNOWN);
+   DataEntry *InsertEntryBinArea(uint8_t *binArea, int lgth,
                                     uint16_t group, uint16_t elem,
                                     TagName const &vr = GDCM_UNKNOWN);
    SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
@@ -114,9 +111,7 @@ public:
    virtual bool CheckIfEntryExist(uint16_t group, uint16_t elem);
 
 // DocEntry  related utilities 
-   ValEntry *NewValEntry(uint16_t group,uint16_t elem,
-                         TagName const &vr = GDCM_UNKNOWN);
-   BinEntry *NewBinEntry(uint16_t group, uint16_t elem,
+   DataEntry *NewDataEntry(uint16_t group,uint16_t elem,
                          TagName const &vr = GDCM_UNKNOWN);
    SeqEntry *NewSeqEntry(uint16_t group, uint16_t elem);
 
index f5b27b981ae98e85e44962ecd203e8dcca9bd9d7..703d7ef715bda13547e3750c667418a4aae68fd3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/17 14:55:01 $
-  Version:   $Revision: 1.288 $
+  Date:      $Date: 2005/10/18 08:35:49 $
+  Version:   $Revision: 1.289 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -17,8 +17,6 @@
 =========================================================================*/
 
 #include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
 #include "gdcmSeqEntry.h"
 #include "gdcmGlobal.h"
 #include "gdcmUtil.h"
@@ -27,6 +25,7 @@
 #include "gdcmDictSet.h"
 #include "gdcmDocEntrySet.h"
 #include "gdcmSQItem.h"
+#include "gdcmDataEntry.h"
 
 #include <vector>
 #include <iomanip>
@@ -137,21 +136,6 @@ bool Document::DoTheLoadingDocumentJob(  )
    if ( ! IsDocumentModified ) // Nothing to do !
       return true;
 
- //     if ( Filename == fileName )
- //     {
- //        gdcmWarningMacro( "The file was already parsed inside this "
- //                       << "gdcm::Document (its name is: "
- //                       << Filename.c_str() );
- //        return true;
- //     }
-  
-   //gdcmWarningMacro( "A file was already parsed inside this "
-   //                  << "gdcm::Document (previous name was: "
-   //                  << Filename.c_str() << ". New name is :"
-   //                  << fileName );
-     // clean out the Entries, if already parsed
-     // (probabely a mistake from the user)
    ClearEntry();
 
    Fp = 0;
@@ -204,7 +188,7 @@ bool Document::DoTheLoadingDocumentJob(  )
    
    // Load 'non string' values
       
-   std::string PhotometricInterpretation = GetEntryValue(0x0028,0x0004);   
+   std::string PhotometricInterpretation = GetEntryString(0x0028,0x0004);   
    if ( PhotometricInterpretation == "PALETTE COLOR " )
    {
    // FIXME
@@ -217,16 +201,16 @@ bool Document::DoTheLoadingDocumentJob(  )
       /// defined as having an US Value Representation in the public
       /// dictionary. BUT the semantics implied by the three following
       /// lines state that the corresponding tag contents are in fact
-      /// the ones of a BinEntry.
+      /// the ones of a DataEntry.
       /// In order to fix things "Quick and Dirty" the dictionary was
       /// altered on PURPOSE but now contains a WRONG value.
       /// In order to fix things and restore the dictionary to its
       /// correct value, one needs to decided of the semantics by deciding
       /// whether the following tags are either :
-      /// - multivaluated US, and hence loaded as ValEntry, but afterwards
-      ///   also used as BinEntry, which requires the proper conversion,
-      /// - OW, and hence loaded as BinEntry, but afterwards also used
-      ///   as ValEntry, which requires the proper conversion.
+      /// - multivaluated US, and hence loaded as DataEntry, but afterwards
+      ///   also used as DataEntry, which requires the proper conversion,
+      /// - OW, and hence loaded as DataEntry, but afterwards also used
+      ///   as DataEntry, which requires the proper conversion.
       LoadEntryBinArea(0x0028,0x1201);  // R    LUT
       LoadEntryBinArea(0x0028,0x1202);  // G    LUT
       LoadEntryBinArea(0x0028,0x1203);  // B    LUT
@@ -246,12 +230,12 @@ bool Document::DoTheLoadingDocumentJob(  )
       SQItem *sqi= modLutSeq->GetFirstSQItem();
       if ( sqi != 0 )
       {
-         BinEntry *b = sqi->GetBinEntry(0x0028,0x3006);
-         if ( b != 0 )
+         DataEntry *dataEntry = sqi->GetDataEntry(0x0028,0x3006);
+         if ( dataEntry != 0 )
          {
-            if ( b->GetLength() != 0 )
+            if ( dataEntry->GetLength() != 0 )
             {
-               LoadEntryBinArea(b);    //LUT Data (CTX dependent)
+               LoadEntryBinArea(dataEntry);    //LUT Data (CTX dependent)
             }   
         }
      }      
@@ -277,26 +261,7 @@ bool Document::DoTheLoadingDocumentJob(  )
          continue;
       }
 
-      if ( dynamic_cast<ValEntry *>(d) )
-      {
-         LoadDocEntry(d, true);
-         continue;
-      }
-
-      BinEntry *b = dynamic_cast<BinEntry *>(d);
-      if ( b )
-      {
-         LoadEntryBinArea(b);
-         b->SetValue(GDCM_BINLOADED);
-         continue;
-      }
-      if ( dynamic_cast<SeqEntry *>(d) )
-      {
-         gdcmWarningMacro( "You cannot 'ForceLoad' a SeqEntry :" << std::hex
-                           << (*it).Group <<"|"<< (*it).Elem );
-         continue;
-      }
+      LoadDocEntry(d, true);
    }
 
    CloseFile(); 
@@ -312,16 +277,16 @@ bool Document::DoTheLoadingDocumentJob(  )
    // we switch lineNumber and columnNumber
    //
    std::string RecCode;
-   RecCode = GetEntryValue(0x0008, 0x0010); // recognition code (RET)
+   RecCode = GetEntryString(0x0008, 0x0010); // recognition code (RET)
    if (RecCode == "ACRNEMA_LIBIDO_1.1" ||
        RecCode == "CANRME_AILIBOD1_1." )  // for brain-damaged softwares
                                           // with "little-endian strings"
    {
          Filetype = ACR_LIBIDO; 
-         std::string rows    = GetEntryValue(0x0028, 0x0010);
-         std::string columns = GetEntryValue(0x0028, 0x0011);
-         SetValEntry(columns, 0x0028, 0x0010);
-         SetValEntry(rows   , 0x0028, 0x0011);
+         std::string rows    = GetEntryString(0x0028, 0x0010);
+         std::string columns = GetEntryString(0x0028, 0x0011);
+         SetEntryString(columns, 0x0028, 0x0010);
+         SetEntryString(rows   , 0x0028, 0x0011);
    }
    // --- End of ACR-LibIDO kludge --- 
    return true;
@@ -457,9 +422,9 @@ std::string Document::GetTransferSyntax()
    // The entry might be present but not loaded (parsing and loading
    // happen at different stages): try loading and proceed with check...
    LoadDocEntrySafe(entry);
-   if (ValEntry *valEntry = dynamic_cast< ValEntry* >(entry) )
+   if (DataEntry *dataEntry = dynamic_cast<DataEntry *>(entry) )
    {
-      std::string transfer = valEntry->GetValue();
+      std::string transfer = dataEntry->GetString();
       // The actual transfer (as read from disk) might be padded. We
       // first need to remove the potential padding. We can make the
       // weak assumption that padding was not executed with digits...
@@ -471,6 +436,11 @@ std::string Document::GetTransferSyntax()
       while ( !isdigit((unsigned char)transfer[transfer.length()-1]) )
       {
          transfer.erase(transfer.length()-1, 1);
+         if  ( transfer.length() == 0 )
+         {
+            // for brain damaged headers
+            return GDCM_UNKNOWN;
+         }
       }
       return transfer;
    }
@@ -484,7 +454,7 @@ std::string Document::GetTransferSyntax()
 std::string Document::GetTransferSyntaxName()
 {
    // use the TS (TS : Transfer Syntax)
-   std::string transferSyntax = GetEntryValue(0x0002,0x0010);
+   std::string transferSyntax = GetEntryString(0x0002,0x0010);
 
    if ( (transferSyntax.find(GDCM_NOTLOADED) < transferSyntax.length()) )
    {
@@ -692,21 +662,21 @@ void Document::WriteContent(std::ofstream *fp, FileType filetype)
 void Document::LoadEntryBinArea(uint16_t group, uint16_t elem)
 {
    // Search the corresponding DocEntry
-   DocEntry *docElement = GetDocEntry(group, elem);
-   if ( !docElement )
+   DocEntry *docEntry = GetDocEntry(group, elem);
+   if ( !docEntry )
    {
       gdcmWarningMacro(std::hex << group << "|" << elem 
                        <<  "doesn't exist" );
       return;
    }
-   BinEntry *binElement = dynamic_cast<BinEntry *>(docElement);
-   if ( !binElement )
+   DataEntry *dataEntry = dynamic_cast<DataEntry *>(docEntry);
+   if ( !dataEntry )
    {
       gdcmWarningMacro(std::hex << group << "|" << elem 
-                       <<  "is NOT a BinEntry");
+                       <<  "is NOT a DataEntry");
       return;
    }
-   LoadEntryBinArea(binElement);
+   LoadEntryBinArea(dataEntry);
 }
 
 /**
@@ -714,36 +684,70 @@ void Document::LoadEntryBinArea(uint16_t group, uint16_t elem)
  *        when a string is not suitable
  * @param elem  Entry whose binArea is going to be loaded
  */
-void Document::LoadEntryBinArea(BinEntry *elem
+void Document::LoadEntryBinArea(DataEntry *entry
 {
-   if (elem->GetBinArea() )
+   if( entry->GetBinArea() )
       return;
 
    bool openFile = !Fp;
    if ( openFile )
       OpenFile();
 
-   size_t o =(size_t)elem->GetOffset();
+   size_t o =(size_t)entry->GetOffset();
    Fp->seekg(o, std::ios::beg);
 
-   size_t l = elem->GetLength();
-   uint8_t *a = new uint8_t[l];
-   if ( !a )
+   size_t l = entry->GetLength();
+   uint8_t *data = new uint8_t[l];
+   if ( !data )
    {
-      gdcmWarningMacro(  "Cannot allocate BinEntry content for : "
-                       << std::hex << elem->GetGroup() 
-                       << "|" << elem->GetElement() );
+      gdcmWarningMacro(  "Cannot allocate DataEntry content for : "
+                       << std::hex << entry->GetGroup() 
+                       << "|" << entry->GetElement() );
       return;
    }
 
-   Fp->read((char*)a, l);
+   // Read the datas
+   Fp->read((char*)data, l);
    if ( Fp->fail() || Fp->eof() )
    {
-      delete[] a;
+      delete[] data;
+      entry->SetState(DataEntry::STATE_UNREAD);
       return;
    }
 
-   elem->SetBinArea(a);
+   // Swap the data content if necessary
+   uint32_t i;
+   unsigned short vrLgth = Global::GetVR()->GetAtomicElementLength(entry->GetVR());
+   if( entry->GetVR() == "OW" )
+      vrLgth = 1;
+
+   switch(vrLgth)
+   {
+      case 2:
+      {
+         uint16_t *data16 = (uint16_t *)data;
+         for(i=0;i<l/vrLgth;i++)
+            data16[i] = SwapShort(data16[i]);
+         break;
+      }
+      case 4:
+      {
+         uint32_t *data32 = (uint32_t *)data;
+         for(i=0;i<l/vrLgth;i++)
+            data32[i] = SwapLong(data32[i]);
+         break;
+      }
+      case 8:
+      {
+         gdcmWarningMacro("Can't swap 64 bits datas");
+/*         uint64_t *data64 = (uint64_t *)data;
+         for(i=0;i<l/vrLgth;i++)
+            data64[i] = SwapLongLong(data64[i]);*/
+         break;
+      }
+   }
+   
+   entry->SetBinArea(data);
 
    if ( openFile )
       CloseFile();
@@ -775,8 +779,8 @@ void Document::LoadDocEntrySafe(DocEntry *entry)
 bool Document::operator<(Document &document)
 {
    // Patient Name
-   std::string s1 = GetEntryValue(0x0010,0x0010);
-   std::string s2 = document.GetEntryValue(0x0010,0x0010);
+   std::string s1 = GetEntryString(0x0010,0x0010);
+   std::string s2 = document.GetEntryString(0x0010,0x0010);
    if (s1 < s2)
    {
       return true;
@@ -788,8 +792,8 @@ bool Document::operator<(Document &document)
    else
    {
       // Patient ID
-      s1 = GetEntryValue(0x0010,0x0020);
-      s2 = document.GetEntryValue(0x0010,0x0020);
+      s1 = GetEntryString(0x0010,0x0020);
+      s2 = document.GetEntryString(0x0010,0x0020);
       if ( s1 < s2 )
       {
          return true;
@@ -801,8 +805,8 @@ bool Document::operator<(Document &document)
       else
       {
          // Study Instance UID
-         s1 = GetEntryValue(0x0020,0x000d);
-         s2 = document.GetEntryValue(0x0020,0x000d);
+         s1 = GetEntryString(0x0020,0x000d);
+         s2 = document.GetEntryString(0x0020,0x000d);
          if ( s1 < s2 )
          {
             return true;
@@ -814,8 +818,8 @@ bool Document::operator<(Document &document)
          else
          {
             // Serie Instance UID
-            s1 = GetEntryValue(0x0020,0x000e);
-            s2 = document.GetEntryValue(0x0020,0x000e);    
+            s1 = GetEntryString(0x0020,0x000e);
+            s2 = document.GetEntryString(0x0020,0x000e);    
             if ( s1 < s2 )
             {
                return true;
@@ -959,8 +963,7 @@ void Document::ParseDES(DocEntrySet *set, long offset,
                         long l_max, bool delim_mode)
 {
    DocEntry *newDocEntry;
-   ValEntry *newValEntry;
-   BinEntry *newBinEntry;
+   DataEntry *newDataEntry;
    SeqEntry *newSeqEntry;
    VRKey vr;
    bool used; // will be set to false when something wrong happens to an Entry.
@@ -979,12 +982,11 @@ void Document::ParseDES(DocEntrySet *set, long offset,
       newDocEntry = ReadNextDocEntry( );
 
       // FIXME :
-      // Private tag, in IMplicit VR are defaulted as a BinEntry,
+      // Private tag, in IMplicit VR are defaulted as a DataEntry,
       // Very often they are only composed of Printable characters, 
-      // and could be defaulted as a ValEntry.
+      // and could be defaulted as a DataEntry.
       // It's too late to do the Job
       // (we should check the value, but we know it after LoadDocEntry ...)
-      // --> in next gdcm major release let's unify ValEntry and BinEntry !
 
       // Uncoment this printf line to be able to 'follow' the DocEntries
       // when something *very* strange happens
@@ -1012,124 +1014,66 @@ void Document::ParseDES(DocEntrySet *set, long offset,
       }
  
       used = true;
-      newValEntry = dynamic_cast<ValEntry*>(newDocEntry);
-      newBinEntry = dynamic_cast<BinEntry*>(newDocEntry);
+      newDataEntry = dynamic_cast<DataEntry*>(newDocEntry);
 
-      if ( newValEntry || newBinEntry )  
+      if ( newDataEntry )  
       {
-       //////////////////////////// ContentEntry
-         if ( newBinEntry )
-         {
-            vr = newDocEntry->GetVR();
-            if ( Filetype == ExplicitVR && 
-                 !Global::GetVR()->IsVROfBinaryRepresentable(vr) )
-            { 
-                ////// Neither ValEntry NOR BinEntry: should mean UNKOWN VR
-                gdcmWarningMacro( std::hex << newDocEntry->GetGroup() 
-                                  << "|" << newDocEntry->GetElement()
-                                  << " : Neither Valentry, nor BinEntry." 
-                                  "Probably unknown VR.");
-            }
-
-         //////////////////// BinEntry or UNKOWN VR:
-
-            // When "this" is a Document the Key is simply of the
-            // form ( group, elem )...
-            //if ( set == this ) // ( dynamic_cast< Document* > ( set ) )
-            //{
-            //   newBinEntry->SetKey( newBinEntry->GetKey() );
-            //}
-            // but when "this" is a SQItem, we are inserting this new
-            // valEntry in a sequence item, and the key has the
-            // generalized form (refer to \ref BaseTagKey):
+         //////////////////////////// DataEntry
+         vr = newDocEntry->GetVR();
+         if ( Filetype == ExplicitVR && 
+               !Global::GetVR()->IsVROfBinaryRepresentable(vr) )
+         { 
+               ////// No DataEntry: should mean UNKOWN VR
+               gdcmWarningMacro( std::hex << newDocEntry->GetGroup() 
+                                 << "|" << newDocEntry->GetElement()
+                                 << " : No DataEntry." 
+                                 "Probably unknown VR.");
+         }
 
-            // time waste hunting
-            //if (SQItem *parentSQItem = dynamic_cast< SQItem* > ( set ) )
-            //{
-            //   newBinEntry->SetKey(  parentSQItem->GetBaseTagKey()
-            //                       + newBinEntry->GetKey() );
-            //}
-           
-            if ( !set->AddEntry( newBinEntry ) )
-            {
-               gdcmWarningMacro( "in ParseDES : cannot add a BinEntry "
-                                   << newBinEntry->GetKey()  
-                                   << " (at offset : " 
-                                   << newBinEntry->GetOffset() << " )" );
-               used=false;
-            }
-            else
-            {
-               // Load only if we can add (not a duplicate key)
-               LoadDocEntry( newBinEntry );
-            }
-         }  // end BinEntry
+         if ( !set->AddEntry( newDataEntry ) )
+         {
+            gdcmWarningMacro( "in ParseDES : cannot add a DataEntry "
+                                 << newDataEntry->GetKey()  
+                                 << " (at offset : " 
+                                 << newDataEntry->GetOffset() << " )" );
+            used=false;
+         }
          else
          {
-         /////////////////////// ValEntry
-
-            // When "set" is a Document, then we are at the top of the
-            // hierarchy and the Key is simply of the form ( group, elem )...
-            //if ( set == this ) // ( dynamic_cast< Document* > ( set ) )
-            //{
-            //   newValEntry->SetKey( newValEntry->GetKey() );
-            //}
-            // ...but when "set" is a SQItem, we are inserting this new
-            // valEntry in a sequence item. Hence the key has the
-            // generalized form (refer to \ref BaseTagKey):
-
-            // time waste hunting
-            //if (SQItem *parentSQItem = dynamic_cast< SQItem* > ( set ) )
-            //{
-            //   newValEntry->SetKey(  parentSQItem->GetBaseTagKey()
-            //                      + newValEntry->GetKey() );
-            //}
-
-            if ( !set->AddEntry( newValEntry ) )
-            {
-              gdcmWarningMacro( "in ParseDES : cannot add a ValEntry "
-                                  << newValEntry->GetKey()
-                                  << " (at offset : " 
-                                  << newValEntry->GetOffset() << " )" );   
-              used=false;
-            }
-            else
-            {
-               // Load only if we can add (not a duplicate key)
-               LoadDocEntry( newValEntry );
-            }
+            // Load only if we can add (not a duplicate key)
+            LoadDocEntry( newDataEntry );
+         }
 
-            if ( newValEntry->GetElement() == 0x0000 ) // if on group length
+         if ( newDataEntry->GetElement() == 0x0000 ) // if on group length
+         {
+            if ( newDataEntry->GetGroup()%2 != 0 )   // if Shadow Group
             {
-               if ( newValEntry->GetGroup()%2 != 0 )   // if Shadow Group
+               if ( LoadMode & LD_NOSHADOW ) // if user asked to skip shad.gr
                {
-                  if ( LoadMode & LD_NOSHADOW ) // if user asked to skip shad.gr
+                  std::string strLgrGroup = newDataEntry->GetString();
+                  int lgrGroup;
+                  if ( newDataEntry->IsUnfound() )
                   {
-                     std::string strLgrGroup = newValEntry->GetValue();
-                     int lgrGroup;
-                     if ( strLgrGroup != GDCM_UNFOUND)
-                     {
-                        lgrGroup = atoi(strLgrGroup.c_str());
-                        Fp->seekg(lgrGroup, std::ios::cur);
-                        //used = false;  // never used
-                        RemoveEntry( newDocEntry );  // Remove and delete
-                        // bcc 5.5 is right "assigned a value that's never used"
-                        // newDocEntry = 0;
-                        continue;
-                     }
+                     lgrGroup = atoi(strLgrGroup.c_str());
+                     Fp->seekg(lgrGroup, std::ios::cur);
+                     //used = false;  // never used
+                     RemoveEntry( newDocEntry );  // Remove and delete
+                     // bcc 5.5 is right "assigned a value that's never used"
+                     // newDocEntry = 0;
+                     continue;
                   }
                }
             }
+         }
 
-            bool delimitor = newValEntry->IsItemDelimitor();
+         bool delimitor = newDataEntry->IsItemDelimitor();
 
-            if ( (delimitor) || 
-                (!delim_mode && ((long)(Fp->tellg())-offset) >= l_max) )
-            {
-               if ( !used )
-                  delete newDocEntry;
-               break;
-            }
+         if ( (delimitor) || 
+               (!delim_mode && ((long)(Fp->tellg())-offset) >= l_max) )
+         {
+            if ( !used )
+               delete newDocEntry;
+            break;
          }
 
          // Just to make sure we are at the beginning of next entry.
@@ -1277,14 +1221,6 @@ void Document::ParseSQ( SeqEntry *seqEntry,
       }
       // create the current SQItem
       SQItem *itemSQ = new SQItem( seqEntry->GetDepthLevel() );
-/*
-      std::ostringstream newBase;
-      newBase << seqEntry->GetKey()
-              << "/"
-              << SQItemNumber
-              << "#";
-      itemSQ->SetBaseTagKey( newBase.str() );
-*/
       unsigned int l = newDocEntry->GetReadLength();
       
       if ( l == 0xffffffff )
@@ -1348,7 +1284,7 @@ DocEntry *Document::Backtrack(DocEntry *docEntry)
    Fp->seekg( 0, std::ios::beg);
    Fp->seekg(offset, std::ios::cur);
 
-return newEntry;
+   return newEntry;
 }
 
 /**
@@ -1369,16 +1305,22 @@ void Document::LoadDocEntry(DocEntry *entry, bool forceLoad)
    //          (fffe e000) tells us an Element is beginning
    //          (fffe e00d) tells us an Element just ended
    //          (fffe e0dd) tells us the current SeQuence just ended
-   if ( group == 0xfffe )
+   if ( group == 0xfffe || vr == "SQ" )
    {
       // NO more value field for SQ !
       return;
    }
 
+   DataEntry *dataEntryPtr = dynamic_cast< DataEntry* >(entry);
+   if( !dataEntryPtr )
+   {
+      return;
+   }
+
    // When the length is zero things are easy:
    if ( length == 0 )
    {
-      ((ValEntry *)entry)->SetValue("");
+      dataEntryPtr->SetBinArea(NULL,true);
       return;
    }
 
@@ -1392,30 +1334,8 @@ void Document::LoadDocEntry(DocEntry *entry, bool forceLoad)
    {
       if (length > MaxSizeLoadEntry)
       {
-         if (BinEntry *binEntryPtr = dynamic_cast< BinEntry* >(entry) )
-         {  
-            s << GDCM_NOTLOADED;
-            s << " Ad.:" << (long)entry->GetOffset();
-            s << " x(" << std::hex << entry->GetOffset() << ")";
-            s << std::dec;
-            s << " Lgt:"  << entry->GetLength();
-            s << " x(" << std::hex << entry->GetLength() << ")";
-            binEntryPtr->SetValue(s.str());
-         }
-         else if (ValEntry *valEntryPtr = dynamic_cast< ValEntry* >(entry) )
-         {
-            s << GDCM_NOTLOADED;  
-            s << " Address:" << (long)entry->GetOffset();
-            s << " Length:"  << entry->GetLength();
-            s << " x(" << std::hex << entry->GetLength() << ")";
-            valEntryPtr->SetValue(s.str());
-         }
-         else
-         {
-            // fusible
-            gdcmErrorMacro( "MaxSizeLoadEntry exceeded, neither a BinEntry "
-                         << "nor a ValEntry ?! Should never print that !" );
-         }
+         dataEntryPtr->SetBinArea(NULL,true);
+         dataEntryPtr->SetState(DataEntry::STATE_NOTLOADED);
 
          // to be sure we are at the end of the value ...
          Fp->seekg((long)entry->GetOffset()+(long)entry->GetLength(),
@@ -1424,117 +1344,7 @@ void Document::LoadDocEntry(DocEntry *entry, bool forceLoad)
       }
    }
 
-   // When we find a BinEntry not very much can be done :
-   if (BinEntry *binEntryPtr = dynamic_cast< BinEntry* >(entry) )
-   {
-      s << GDCM_BINLOADED;
-      binEntryPtr->SetValue(s.str());
-      LoadEntryBinArea(binEntryPtr); // last one, not to erase length !
-      return;
-   }
-
-   if ( IsDocEntryAnInteger(entry) )
-   {   
-      uint32_t NewInt;
-      int nbInt;
-      // When short integer(s) are expected, read and convert the following 
-      // (n * 2) characters properly i.e. consider them as short integers as
-      // opposed to strings.
-      // Elements with Value Multiplicity > 1
-      // contain a set of integers (not a single one)       
-      if (vr == "US" || vr == "SS")
-      {
-         nbInt = length / 2;
-         NewInt = ReadInt16();
-         s << NewInt;
-         if (nbInt > 1)
-         {
-            for (int i=1; i < nbInt; i++)
-            {
-               s << '\\';
-               NewInt = ReadInt16();
-               s << NewInt;
-            }
-         }
-      }
-      // See above comment on multiple integers (mutatis mutandis).
-      else if (vr == "UL" || vr == "SL")
-      {
-         nbInt = length / 4;
-         NewInt = ReadInt32();
-         s << NewInt;
-         if (nbInt > 1)
-         {
-            for (int i=1; i < nbInt; i++)
-            {
-               s << '\\';
-               NewInt = ReadInt32();
-               s << NewInt;
-            }
-         }
-      }
-#ifdef GDCM_NO_ANSI_STRING_STREAM
-      s << std::ends; // to avoid oddities on Solaris
-#endif //GDCM_NO_ANSI_STRING_STREAM
-
-      ((ValEntry *)entry)->SetValue(s.str());
-      return;
-   }
-   
-  // FIXME: We need an additional byte for storing \0 that is not on disk
-   char *str = new char[length+1];
-   Fp->read(str, (size_t)length);
-   str[length] = '\0'; //this is only useful when length is odd
-   // Special DicomString call to properly handle \0 and even length
-   std::string newValue;
-   if ( length % 2 )
-   {
-      newValue = Util::DicomString(str, length+1);
-      gdcmWarningMacro("Warning: bad length: " << length <<
-                       " For string :" <<  newValue.c_str()); 
-      // Since we change the length of string update it length
-      //entry->SetReadLength(length+1);
-   }
-   else
-   {
-      newValue = Util::DicomString(str, length);
-   }
-   delete[] str;
-
-   if ( ValEntry *valEntry = dynamic_cast<ValEntry* >(entry) )
-   {
-      if ( Fp->fail() || Fp->eof())
-      {
-         if ( Fp->fail() )
-            gdcmWarningMacro("--> fail");
-
-         gdcmWarningMacro("Unread element value " << valEntry->GetKey() 
-                          << " lgt : " << valEntry->GetReadLength() 
-                          << " at " << std::hex << valEntry->GetOffset());
-         valEntry->SetValue(GDCM_UNREAD);
-         return;
-      }
-
-//      if ( vr == "UI" )
-//      {
-//         // Because of correspondance with the VR dic
-//         valEntry->SetValue(newValue);
-//      }
-//      else
-//      {
-//         valEntry->SetValue(newValue);
-//      }
-
-// Anybody remembers the genesis of strange previous (commented out) code?
-      valEntry->SetValue(newValue);
-
-   }
-   else
-   {
-      gdcmWarningMacro("Should have a ValEntry, here ! " << valEntry->GetKey() 
-                          << " lgt : " << valEntry->GetReadLength() 
-                          << " at " << std::hex << valEntry->GetOffset());
-   }
+   LoadEntryBinArea(dataEntryPtr); // last one, not to erase length !
 }
 
 /**
@@ -1727,136 +1537,6 @@ bool Document::CheckDocEntryVR(VRKey vr)
    return true; 
 }
 
-/**
- * \brief   Get the transformed value of the header entry. The VR value 
- *          is used to define the transformation to operate on the value
- * \warning NOT end user intended method !
- * @param   entry entry to tranform
- * @return  Transformed entry value
- */
-std::string Document::GetDocEntryValue(DocEntry *entry)
-{
-   if ( IsDocEntryAnInteger(entry) && entry->IsImplicitVR() )
-   {
-      std::string val = ((ValEntry *)entry)->GetValue();
-      std::string vr  = entry->GetVR();
-      uint32_t length = entry->GetLength();
-      std::ostringstream s;
-      int nbInt;
-
-      // When short integer(s) are expected, read and convert the following 
-      // n * 2 bytes properly i.e. as a multivaluated strings
-      // (each single value is separated fromthe next one by '\'
-      // as usual for standard multivaluated filels
-      // Elements with Value Multiplicity > 1
-      // contain a set of short integers (not a single one) 
-   
-      if ( vr == "US" || vr == "SS" )
-      {
-         uint16_t newInt16;
-
-         nbInt = length / 2;
-         for (int i=0; i < nbInt; i++) 
-         {
-            if ( i != 0 )
-            {
-               s << '\\';
-            }
-            newInt16 = ( val[2*i+0] & 0xFF ) + ( ( val[2*i+1] & 0xFF ) << 8);
-            newInt16 = SwapShort( newInt16 );
-            s << newInt16;
-         }
-      }
-
-      // When integer(s) are expected, read and convert the following 
-      // n * 4 bytes properly i.e. as a multivaluated strings
-      // (each single value is separated fromthe next one by '\'
-      // as usual for standard multivaluated filels
-      // Elements with Value Multiplicity > 1
-      // contain a set of integers (not a single one) 
-      else if ( vr == "UL" || vr == "SL" )
-      {
-         uint32_t newInt32;
-
-         nbInt = length / 4;
-         for (int i=0; i < nbInt; i++) 
-         {
-            if ( i != 0)
-            {
-               s << '\\';
-            }
-            newInt32 = ( val[4*i+0] & 0xFF )
-                    + (( val[4*i+1] & 0xFF ) <<  8 )
-                    + (( val[4*i+2] & 0xFF ) << 16 )
-                    + (( val[4*i+3] & 0xFF ) << 24 );
-            newInt32 = SwapLong( newInt32 );
-            s << newInt32;
-         }
-      }
-#ifdef GDCM_NO_ANSI_STRING_STREAM
-      s << std::ends; // to avoid oddities on Solaris
-#endif //GDCM_NO_ANSI_STRING_STREAM
-      return s.str();
-   }
-   return ((ValEntry *)entry)->GetValue();
-}
-
-/**
- * \brief   Get the reverse transformed value of the header entry. The VR 
- *          value is used to define the reverse transformation to operate on
- *          the value
- * \warning NOT end user intended method !
- * @param   entry Entry to reverse transform
- * @return  Reverse transformed entry value
- */
-std::string Document::GetDocEntryUnvalue(DocEntry *entry)
-{
-   if ( IsDocEntryAnInteger(entry) && entry->IsImplicitVR() )
-   {
-      std::string vr = entry->GetVR();
-      std::vector<std::string> tokens;
-      std::ostringstream s;
-
-      if ( vr == "US" || vr == "SS" ) 
-      {
-         uint16_t newInt16;
-
-         tokens.erase( tokens.begin(), tokens.end()); // clean any previous value
-         Util::Tokenize (((ValEntry *)entry)->GetValue(), tokens, "\\");
-         for (unsigned int i=0; i<tokens.size(); i++) 
-         {
-            newInt16 = atoi(tokens[i].c_str());
-            s << (  newInt16        & 0xFF ) 
-              << (( newInt16 >> 8 ) & 0xFF );
-         }
-         tokens.clear();
-      }
-      if ( vr == "UL" || vr == "SL")
-      {
-         uint32_t newInt32;
-
-         tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
-         Util::Tokenize (((ValEntry *)entry)->GetValue(), tokens, "\\");
-         for (unsigned int i=0; i<tokens.size();i++) 
-         {
-            newInt32 = atoi(tokens[i].c_str());
-            s << (char)(  newInt32         & 0xFF ) 
-              << (char)(( newInt32 >>  8 ) & 0xFF )
-              << (char)(( newInt32 >> 16 ) & 0xFF )
-              << (char)(( newInt32 >> 24 ) & 0xFF );
-         }
-         tokens.clear();
-      }
-
-#ifdef GDCM_NO_ANSI_STRING_STREAM
-      s << std::ends; // to avoid oddities on Solaris
-#endif //GDCM_NO_ANSI_STRING_STREAM
-      return s.str();
-   }
-
-   return ((ValEntry *)entry)->GetValue();
-}
-
 /**
  * \brief   Skip a given Header Entry 
  * \warning NOT end user intended method !
@@ -2311,10 +1991,11 @@ DocEntry *Document::ReadNextDocEntry()
    DocEntry *newEntry;
    if ( Global::GetVR()->IsVROfSequence(realVR) )
       newEntry = NewSeqEntry(group, elem);
-   else if ( Global::GetVR()->IsVROfStringRepresentable(realVR) )
-      newEntry = NewValEntry(group, elem, realVR);
-   else
-      newEntry = NewBinEntry(group, elem, realVR);
+   else 
+   {
+      newEntry = NewDataEntry(group, elem, realVR);
+      static_cast<DataEntry *>(newEntry)->SetState(DataEntry::STATE_NOTLOADED);
+   }
 
    if ( vr == GDCM_UNKNOWN )
    {
index 790291e926b01a026274625b1f7cb76ce42c732d..977124bac4a83ee99f129a7e2caff9fe2457f862 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.h,v $
   Language:  C++
-  Date:      $Date: 2005/09/07 08:55:23 $
-  Version:   $Revision: 1.122 $
+  Date:      $Date: 2005/10/18 08:35:50 $
+  Version:   $Revision: 1.123 $
  
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -30,8 +30,6 @@
 
 namespace gdcm 
 {
-class ValEntry;
-class BinEntry;
 class SeqEntry;
 class Dict;
 
@@ -92,7 +90,7 @@ typedef std::list<Element> ListElements;
 
 // Content entries
    virtual void LoadEntryBinArea(uint16_t group, uint16_t elem);
-   virtual void LoadEntryBinArea(BinEntry *entry);
+   virtual void LoadEntryBinArea(DataEntry *entry);
 
    void LoadDocEntrySafe(DocEntry *entry);
    void AddForceLoadElement(uint16_t group, uint16_t elem);
@@ -196,9 +194,6 @@ private:
    std::string FindDocEntryVR();
    bool CheckDocEntryVR      (VRKey k);
 
-   std::string GetDocEntryValue  (DocEntry *entry);
-   std::string GetDocEntryUnvalue(DocEntry *entry);
-
    void SkipDocEntry          (DocEntry *entry);
    void SkipToNextDocEntry    (DocEntry *entry);
 
index 8dddf32077614fca22fbf8a135e6151aa65855d5..0c662dd070e5ffdb7290754aa60d6dec0691b1bd 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/11 08:24:10 $
-  Version:   $Revision: 1.64 $
+  Date:      $Date: 2005/10/18 08:35:50 $
+  Version:   $Revision: 1.65 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -18,9 +18,8 @@
 
 #include "gdcmElementSet.h"
 #include "gdcmDebug.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
 #include "gdcmSeqEntry.h"
+#include "gdcmDataEntry.h"
 
 namespace gdcm 
 {
@@ -196,11 +195,11 @@ void ElementSet::Print(std::ostream &os, std::string const & )
 {
    // Let's change the 'warning value' for Pixel Data,
    // to avoid human reader to be confused by 'gdcm::NotLoaded'.   
-   gdcm::BinEntry *pixelElement = GetBinEntry(0x7fe0,0x0010);
+   DataEntry *pixelElement = GetDataEntry(0x7fe0,0x0010);
    if ( pixelElement != 0 )
    {
-      pixelElement->SetValue( gdcm::GDCM_PIXELDATA);
-   }      
+      pixelElement->SetFlag( DataEntry::FLAG_PIXELDATA );
+   }
 
    for( TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i)
    {
@@ -209,7 +208,7 @@ void ElementSet::Print(std::ostream &os, std::string const & )
       entry->SetPrintLevel(PrintLevel);
       entry->Print(os);   
 
-      if ( dynamic_cast<SeqEntry*>(entry) )
+      if ( dynamic_cast<SeqEntry *>(entry) )
       {
          // Avoid the newline for a sequence:
          continue;
index fe681ee4311e99d571e120698488c1b381eccbaa..abb272e8ac868d268ad8d9f80b6d018cf350a651 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.h,v $
   Language:  C++
-  Date:      $Date: 2005/09/02 07:10:03 $
-  Version:   $Revision: 1.45 $
+  Date:      $Date: 2005/10/18 08:35:50 $
+  Version:   $Revision: 1.46 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -27,8 +27,6 @@
 
 namespace gdcm 
 {
-class ValEntry;
-class BinEntry;
 class SeqEntry;
 
 typedef std::map<TagKey, DocEntry *> TagDocEntryHT;
@@ -71,8 +69,6 @@ private:
    TagDocEntryHT TagHT;
    /// iterator, used to visit the TagHT variable
    TagDocEntryHT::iterator ItTagHT;
-   /// iterator, used to visit the TagHT variable, seeking only for ValEntries
-   TagDocEntryHT::iterator ItValEntryTagHT;
 };
 } // end namespace gdcm
 //-----------------------------------------------------------------------------
index 688489687a36c4b69f00fd305f276f0ad6ddf474..066959abd581f5ad748d46e22e97106aa52259be 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/17 14:26:44 $
-  Version:   $Revision: 1.275 $
+  Date:      $Date: 2005/10/18 08:35:50 $
+  Version:   $Revision: 1.276 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include "gdcmUtil.h"
 #include "gdcmDebug.h"
 #include "gdcmTS.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
 #include "gdcmSeqEntry.h"
 #include "gdcmRLEFramesInfo.h"
 #include "gdcmJPEGFragmentsInfo.h"
+#include "gdcmDataEntry.h"
 
 #include <vector>
 #include <stdio.h>  //sscanf
@@ -168,7 +167,7 @@ bool File::DoTheLoadingJob( )
    // Note: this IS the right place for the code
  
    // Image Location
-   const std::string &imgLocation = GetEntryValue(0x0028, 0x0200);
+   const std::string &imgLocation = GetEntryString(0x0028, 0x0200);
    if ( imgLocation == GDCM_UNFOUND )
    {
       // default value
@@ -213,11 +212,11 @@ bool File::DoTheLoadingJob( )
          ComputeJPEGFragmentInfo();
       CloseFile();
 
-      // Create a new BinEntry to change the DictEntry
+      // Create a new DataEntry to change the DictEntry
       // The changed DictEntry will have 
       // - a correct PixelVR OB or OW)
       // - the name to "Pixel Data"
-      BinEntry *oldEntry = dynamic_cast<BinEntry *>(entry);
+      DataEntry *oldEntry = dynamic_cast<DataEntry *>(entry);
       if (oldEntry)
       {
          std::string PixelVR;
@@ -234,7 +233,7 @@ bool File::DoTheLoadingJob( )
             DictEntry* newDict = NewVirtualDictEntry(GrPixel,NumPixel,
                                                      PixelVR,"1","Pixel Data");
 
-            BinEntry *newEntry = new BinEntry(newDict);
+            DataEntry *newEntry = new DataEntry(newDict);
             newEntry->Copy(entry);
             newEntry->SetBinArea(oldEntry->GetBinArea(),oldEntry->IsSelfArea());
             oldEntry->SetSelfArea(false);
@@ -261,7 +260,7 @@ bool File::IsReadable()
       return false;
    }
 
-   const std::string &res = GetEntryValue(0x0028, 0x0005);
+   const std::string &res = GetEntryString(0x0028, 0x0005);
    if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 )
    {
       gdcmWarningMacro("Wrong Image Dimensions" << res);
@@ -318,7 +317,7 @@ bool File::IsReadable()
 int File::GetImageNumber()
 {
    //0020 0013 : Image Number
-   std::string strImNumber = GetEntryValue(0x0020,0x0013);
+   std::string strImNumber = GetEntryString(0x0020,0x0013);
    if ( strImNumber != GDCM_UNFOUND )
    {
       return atoi( strImNumber.c_str() );
@@ -333,7 +332,7 @@ int File::GetImageNumber()
 ModalityType File::GetModality()
 {
    // 0008 0060 : Modality
-   std::string strModality = GetEntryValue(0x0008,0x0060);
+   std::string strModality = GetEntryString(0x0008,0x0060);
    if ( strModality != GDCM_UNFOUND )
    {
            if ( strModality.find("AU")  < strModality.length()) return AU;
@@ -398,12 +397,10 @@ ModalityType File::GetModality()
  */
 int File::GetXSize()
 {
-   const std::string &strSize = GetEntryValue(0x0028,0x0011);
-   if ( strSize == GDCM_UNFOUND )
-   {
-      return 0;
-   }
-   return atoi( strSize.c_str() );
+   DataEntry *entry = GetDataEntry(0x0028,0x0011);
+   if( entry )
+      return (int)entry->GetValue(0);
+   return 0;
 }
 
 /**
@@ -414,11 +411,10 @@ int File::GetXSize()
  */
 int File::GetYSize()
 {
-   const std::string &strSize = GetEntryValue(0x0028,0x0010);
-   if ( strSize != GDCM_UNFOUND )
-   {
-      return atoi( strSize.c_str() );
-   }
+   DataEntry *entry = GetDataEntry(0x0028,0x0010);
+   if( entry )
+      return (int)entry->GetValue(0);
+
    if ( IsDicomV3() )
    {
       return 0;
@@ -442,18 +438,14 @@ int File::GetZSize()
 {
    // Both  DicomV3 and ACR/Nema consider the "Number of Frames"
    // as the third dimension.
-   const std::string &strSize = GetEntryValue(0x0028,0x0008);
-   if ( strSize != GDCM_UNFOUND )
-   {
-      return atoi( strSize.c_str() );
-   }
+   DataEntry *entry = GetDataEntry(0x0028,0x0008);
+   if( entry )
+      return (int)entry->GetValue(0);
 
    // We then consider the "Planes" entry as the third dimension 
-   const std::string &strSize2 = GetEntryValue(0x0028,0x0012);
-   if ( strSize2 != GDCM_UNFOUND )
-   {
-      return atoi( strSize2.c_str() );
-   }
+   entry = GetDataEntry(0x0028,0x0012);
+   if( entry )
+      return (int)entry->GetValue(0);
    return 1;
 }
 
@@ -466,12 +458,31 @@ int File::GetZSize()
 float File::GetXSpacing()
 {
    float xspacing = 1.0;
-   float yspacing = 1.0;
-   int nbValues;
+   uint32_t nbValue;
 
    // To follow David Clunie's advice, we first check ImagerPixelSpacing
 
-   const std::string &strImagerPixelSpacing = GetEntryValue(0x0018,0x1164);
+   DataEntry *entry = GetDataEntry(0x0018,0x1164);
+   if( entry )
+   {
+      nbValue = entry->GetValueCount();
+      if( nbValue >= 3 )
+         xspacing = (float)entry->GetValue(2);
+      if( nbValue >= 2 )
+         xspacing = (float)entry->GetValue(1);
+      else
+         xspacing = (float)entry->GetValue(0);
+
+      if ( xspacing == 0.0 )
+         xspacing = 1.0;
+      return xspacing;
+   }
+   else
+   {
+      gdcmWarningMacro( "Unfound Pixel Spacing (0018,1164)" );
+   }
+
+/*   const std::string &strImagerPixelSpacing = GetEntryString(0x0018,0x1164);
    if ( strImagerPixelSpacing != GDCM_UNFOUND )
    {
       if ( ( nbValues = sscanf( strImagerPixelSpacing.c_str(), 
@@ -488,10 +499,29 @@ float File::GetXSpacing()
             xspacing = 1.0;
       }  
       return xspacing;
-   }
+   }*/
+
+   entry = GetDataEntry(0x0028,0x0030);
+   if( entry )
+   {
+      nbValue = entry->GetValueCount();
+      if( nbValue >= 3 )
+         xspacing = (float)entry->GetValue(2);
+      if( nbValue >= 2 )
+         xspacing = (float)entry->GetValue(1);
+      else
+         xspacing = (float)entry->GetValue(0);
 
-   const std::string &strSpacing = GetEntryValue(0x0028,0x0030);
+      if ( xspacing == 0.0 )
+         xspacing = 1.0;
+      return xspacing;
+   }
+   else
+   {
+      gdcmWarningMacro( "Unfound Pixel Spacing (0028,0030)" );
+   }
 
+/*   const std::string &strSpacing = GetEntryString(0x0028,0x0030);
    if ( strSpacing == GDCM_UNFOUND )
    {
       gdcmWarningMacro( "Unfound Pixel Spacing (0028,0030)" );
@@ -510,11 +540,12 @@ float File::GetXSpacing()
 
       if ( xspacing == 0.0 )
          xspacing = 1.0;
-   }
    return xspacing;
 
+   }*/
+
    // to avoid troubles with David Clunie's-like images (at least one)
-   if ( xspacing == 0.0 && yspacing == 0.0)
+/*   if ( xspacing == 0.0 && yspacing == 0.0)
       return 1.0;
 
    if ( xspacing == 0.0)
@@ -524,7 +555,7 @@ float File::GetXSpacing()
       nbValues = sscanf( strSpacing.c_str(), "%f \\0\\%f ", &yspacing, &xspacing);
       gdcmAssertMacro( nbValues == 2 );
    }
-
+*/
    return xspacing;
 }
 
@@ -537,10 +568,22 @@ float File::GetXSpacing()
 float File::GetYSpacing()
 {
    float yspacing = 1.0;
-   int nbValues;
    // To follow David Clunie's advice, we first check ImagerPixelSpacing
 
-   const std::string &strImagerPixelSpacing = GetEntryValue(0x0018,0x1164);
+   DataEntry *entry = GetDataEntry(0x0018,0x1164);
+   if( entry )
+   {
+      yspacing = (float)entry->GetValue(0);
+
+      if ( yspacing == 0.0 )
+         yspacing = 1.0;
+      return yspacing;
+   }
+   else
+   {
+      gdcmWarningMacro( "Unfound Pixel Spacing (0018,1164)" );
+   }
+/*   const std::string &strImagerPixelSpacing = GetEntryString(0x0018,0x1164);
    if ( strImagerPixelSpacing != GDCM_UNFOUND )
    {
       nbValues = sscanf( strImagerPixelSpacing.c_str(), "%f", &yspacing);
@@ -553,9 +596,22 @@ float File::GetYSpacing()
             yspacing = 1.0;
 
       return yspacing;  
-   }
+   }*/
 
-   std::string strSpacing = GetEntryValue(0x0028,0x0030);  
+   entry = GetDataEntry(0x0028,0x0030);
+   if( entry )
+   {
+      yspacing = (float)entry->GetValue(0);
+
+      if ( yspacing == 0.0 )
+         yspacing = 1.0;
+      return yspacing;
+   }
+   else
+   {
+      gdcmWarningMacro( "Unfound Pixel Spacing (0028,0030)" );
+   }
+/*   std::string strSpacing = GetEntryString(0x0028,0x0030);  
    if ( strSpacing == GDCM_UNFOUND )
    {
       gdcmWarningMacro("Unfound Pixel Spacing (0028,0030)");
@@ -570,7 +626,7 @@ float File::GetYSpacing()
       yspacing = 1.0;
 
    if ( yspacing == 0.0 )
-      yspacing = 1.0;
+      yspacing = 1.0;*/
 
    return yspacing;
 } 
@@ -583,6 +639,17 @@ float File::GetYSpacing()
  */
 float File::GetZSpacing()
 {
+   // --->
+   // ---> Warning :
+   // --->
+  // For *Dicom* images, ZSpacing should be calculated using 
+  // XOrigin, YOrigin, ZOrigin (of the top left image corner)
+  // of 2 consecutive images, and the Orientation
+  // 
+  // Computing ZSpacing on a single image is not really meaningfull !
+
+   float zspacing = 1.0f;
+
    // Spacing Between Slices : distance between the middle of 2 slices
    // Slices may be :
    //   jointives     (Spacing between Slices = Slice Thickness)
@@ -592,24 +659,41 @@ float File::GetZSpacing()
    //   It only concerns the MRI guys, not people wanting to visualize volumes
    //   If Spacing Between Slices is missing, 
    //   we suppose slices joint together
+   DataEntry *entry = GetDataEntry(0x0018,0x0088);
+   if( entry )
+   {
+      zspacing = (float)entry->GetValue(0);
 
-   // --->
-   // ---> Warning :
-   // --->
-   
-  //
-  // For *Dicom* images, ZSpacing should be calculated using 
-  // XOrigin, YOrigin, ZOrigin (of the top left image corner)
-  // of 2 consecutive images, and the Orientation
-  // 
-  // Computing ZSpacing on a single image is not really meaningfull !
-  
-   const std::string &strSpacingBSlices = GetEntryValue(0x0018,0x0088);
+      if ( zspacing == 0.0 )
+         zspacing = 1.0;
+      return zspacing;
+   }
+   else
+      gdcmWarningMacro("Unfound Spacing Between Slices (0018,0088)");
 
+   // if no 'Spacing Between Slices' is found, 
+   // we assume slices join together
+   // (no overlapping, no interslice gap)
+   // if they don't, we're fucked up
+   entry = GetDataEntry(0x0018,0x0050);
+   if( entry )
+   {
+      zspacing = (float)entry->GetValue(0);
+
+      if ( zspacing == 0.0 )
+         zspacing = 1.0;
+      return zspacing;
+   }
+   else
+      gdcmWarningMacro("Unfound Slice Thickness (0018,0050)");
+
+   return zspacing;
+
+/*   const std::string &strSpacingBSlices = GetEntryString(0x0018,0x0088);
    if ( strSpacingBSlices == GDCM_UNFOUND )
    {
       gdcmWarningMacro("Unfound Spacing Between Slices (0018,0088)");
-      const std::string &strSliceThickness = GetEntryValue(0x0018,0x0050);       
+      const std::string &strSliceThickness = GetEntryString(0x0018,0x0050);       
       if ( strSliceThickness == GDCM_UNFOUND )
       {
          gdcmWarningMacro("Unfound Slice Thickness (0018,0050)");
@@ -624,12 +708,11 @@ float File::GetZSpacing()
          return (float)atof( strSliceThickness.c_str() );
       }
    }
-   //else
    
    float zsp = (float)atof( strSpacingBSlices.c_str());
    if (zsp == 0.0) // last change not to break further computations ...
       zsp = 1.0;
-   return zsp;
+   return zsp;*/
 }
 
 /**
@@ -640,13 +723,27 @@ float File::GetZSpacing()
  */
 float File::GetXOrigin()
 {
-   float xImPos, yImPos, zImPos;  
-   std::string strImPos = GetEntryValue(0x0020,0x0032);
+   DataEntry *entry = GetDataEntry(0x0020,0x0032);
+   if( !entry )
+   {
+      gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
+      entry = GetDataEntry(0x0020,0x0030);
+      if( !entry )
+      {
+         gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
+         return 0.0f;
+      }
+   }
+
+   if( entry->GetValueCount() == 3 )
+      return (float)entry->GetValue(0);
+   return 0.0f;
 
+/*   std::string strImPos = GetEntryString(0x0020,0x0032);
    if ( strImPos == GDCM_UNFOUND )
    {
       gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
-      strImPos = GetEntryValue(0x0020,0x0030); // For ACR-NEMA images
+      strImPos = GetEntryString(0x0020,0x0030); // For ACR-NEMA images
       if ( strImPos == GDCM_UNFOUND )
       {
          gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
@@ -659,7 +756,7 @@ float File::GetXOrigin()
       return 0.0;
    }
 
-   return xImPos;
+   return xImPos;*/
 }
 
 /**
@@ -670,13 +767,28 @@ float File::GetXOrigin()
  */
 float File::GetYOrigin()
 {
-   float xImPos, yImPos, zImPos;
-   std::string strImPos = GetEntryValue(0x0020,0x0032);
+   DataEntry *entry = GetDataEntry(0x0020,0x0032);
+   if( !entry )
+   {
+      gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
+      entry = GetDataEntry(0x0020,0x0030);
+      if( !entry )
+      {
+         gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
+         return 0.0f;
+      }
+   }
+
+   if( entry->GetValueCount() == 3 )
+      return (float)entry->GetValue(1);
+   return 0.0f;
+/*   float xImPos, yImPos, zImPos;
+   std::string strImPos = GetEntryString(0x0020,0x0032);
 
    if ( strImPos == GDCM_UNFOUND)
    {
       gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
-      strImPos = GetEntryValue(0x0020,0x0030); // For ACR-NEMA images
+      strImPos = GetEntryString(0x0020,0x0030); // For ACR-NEMA images
       if ( strImPos == GDCM_UNFOUND )
       {
          gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
@@ -689,7 +801,7 @@ float File::GetYOrigin()
       return 0.;
    }
 
-   return yImPos;
+   return yImPos;*/
 }
 
 /**
@@ -702,8 +814,16 @@ float File::GetYOrigin()
  */
 float File::GetZOrigin()
 {
-   float xImPos, yImPos, zImPos; 
-   std::string strImPos = GetEntryValue(0x0020,0x0032);
+   DataEntry *entry = GetDataEntry(0x0020,0x0032);
+   if( entry )
+   {
+      if( entry->GetValueCount() == 3 )
+         return (float)entry->GetValue(0);
+      gdcmWarningMacro( "Wrong Image Position Patient (0020,0032)");
+      return 0.0f;
+   }
+/*   float xImPos, yImPos, zImPos; 
+   std::string strImPos = GetEntryString(0x0020,0x0032);
 
    if ( strImPos != GDCM_UNFOUND )
    {
@@ -716,9 +836,17 @@ float File::GetZOrigin()
       {
          return zImPos;
       }
-   }
+   }*/
 
-   strImPos = GetEntryValue(0x0020,0x0030); // For ACR-NEMA images
+   entry = GetDataEntry(0x0020,0x0030);
+   if( entry )
+   {
+      if( entry->GetValueCount() == 3 )
+         return (float)entry->GetValue(0);
+      gdcmWarningMacro( "Wrong Image Position (RET) (0020,0030)");
+      return 0.0f;
+   }
+/*   strImPos = GetEntryString(0x0020,0x0030); // For ACR-NEMA images
    if ( strImPos != GDCM_UNFOUND )
    {
       if ( sscanf( strImPos.c_str(), 
@@ -731,10 +859,18 @@ float File::GetZOrigin()
       {
          return zImPos;
       }
-   }
+   }*/
 
    // for *very* old ACR-NEMA images
-   std::string strSliceLocation = GetEntryValue(0x0020,0x1041);
+   entry = GetDataEntry(0x0020,0x1041);
+   if( entry )
+   {
+      if( entry->GetValueCount() == 1 )
+         return (float)entry->GetValue(0);
+      gdcmWarningMacro( "Wrong Slice Location (0020,1041)");
+      return 0.0f;
+   }
+/*   std::string strSliceLocation = GetEntryString(0x0020,0x1041);
    if ( strSliceLocation != GDCM_UNFOUND )
    {
       if ( sscanf( strSliceLocation.c_str(), "%f ", &zImPos) != 1)
@@ -747,9 +883,18 @@ float File::GetZOrigin()
          return zImPos;
       }
    }
-   gdcmWarningMacro( "Unfound Slice Location (0020,1041)");
+   gdcmWarningMacro( "Unfound Slice Location (0020,1041)");*/
 
-   std::string strLocation = GetEntryValue(0x0020,0x0050);
+   entry = GetDataEntry(0x0020,0x0050);
+   if( entry )
+   {
+      gdcmWarningMacro( "Unfound Location (0020,0050)");
+      if( entry->GetValueCount() == 1 )
+         return (float)entry->GetValue(0);
+      gdcmWarningMacro( "Wrong Location (0020,0050)");
+      return 0.0f;
+   }
+/*   std::string strLocation = GetEntryString(0x0020,0x0050);
    if ( strLocation != GDCM_UNFOUND )
    {
       if ( sscanf( strLocation.c_str(), "%f ", &zImPos) != 1 )
@@ -762,7 +907,7 @@ float File::GetZOrigin()
          return zImPos;
       }
    }
-   gdcmWarningMacro( "Unfound Location (0020,0050)");  
+   gdcmWarningMacro( "Unfound Location (0020,0050)");*/
 
    return 0.; // Hopeless
 }
@@ -782,7 +927,7 @@ bool File::GetImageOrientationPatient( float iop[6] )
    iop[0] = iop[1] = iop[2] = iop[3] = iop[4] = iop[5] = 0.;
 
    // 0020 0037 DS REL Image Orientation (Patient)
-   if ( (strImOriPat = GetEntryValue(0x0020,0x0037)) != GDCM_UNFOUND )
+   if ( (strImOriPat = GetEntryString(0x0020,0x0037)) != GDCM_UNFOUND )
    {
       if ( sscanf( strImOriPat.c_str(), "%f \\ %f \\%f \\%f \\%f \\%f ", 
           &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 )
@@ -794,7 +939,7 @@ bool File::GetImageOrientationPatient( float iop[6] )
    }
    //For ACR-NEMA
    // 0020 0035 DS REL Image Orientation (RET)
-   else if ( (strImOriPat = GetEntryValue(0x0020,0x0035)) != GDCM_UNFOUND )
+   else if ( (strImOriPat = GetEntryString(0x0020,0x0035)) != GDCM_UNFOUND )
    {
       if ( sscanf( strImOriPat.c_str(), "%f \\ %f \\%f \\%f \\%f \\%f ", 
           &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 )
@@ -817,14 +962,22 @@ bool File::GetImageOrientationPatient( float iop[6] )
  */
 int File::GetBitsStored()
 {
-   std::string strSize = GetEntryValue( 0x0028, 0x0101 );
+   DataEntry *entry = GetDataEntry(0x0028,0x0101);
+   if( !entry )
+   {
+      gdcmWarningMacro("(0028,0101) is supposed to be mandatory");
+      return 0;
+   }
+   return (int)entry->GetValue(0);
+
+/*   std::string strSize = GetEntryString( 0x0028, 0x0101 );
    if ( strSize == GDCM_UNFOUND )
    {
       gdcmWarningMacro("(0028,0101) is supposed to be mandatory");
       return 0;  // It's supposed to be mandatory
                  // the caller will have to check
    }
-   return atoi( strSize.c_str() );
+   return atoi( strSize.c_str() );*/
 }
 
 /**
@@ -835,14 +988,22 @@ int File::GetBitsStored()
  */
 int File::GetBitsAllocated()
 {
-   std::string strSize = GetEntryValue(0x0028,0x0100);
+   DataEntry *entry = GetDataEntry(0x0028,0x0100);
+   if( !entry )
+   {
+      gdcmWarningMacro("(0028,0100) is supposed to be mandatory");
+      return 0;
+   }
+   return (int)entry->GetValue(0);
+
+/*   std::string strSize = GetEntryString(0x0028,0x0100);
    if ( strSize == GDCM_UNFOUND  )
    {
       gdcmWarningMacro( "(0028,0100) is supposed to be mandatory");
       return 0; // It's supposed to be mandatory
                 // the caller will have to check
    }
-   return atoi( strSize.c_str() );
+   return atoi( strSize.c_str() );*/
 }
 
 /**
@@ -853,13 +1014,21 @@ int File::GetBitsAllocated()
  */
 int File::GetHighBitPosition()
 {
-   std::string strSize = GetEntryValue( 0x0028, 0x0102 );
+   DataEntry *entry = GetDataEntry(0x0028,0x0102);
+   if( !entry )
+   {
+      gdcmWarningMacro("(0028,0102) is supposed to be mandatory");
+      return 0;
+   }
+   return (int)entry->GetValue(0);
+
+/*   std::string strSize = GetEntryString( 0x0028, 0x0102 );
    if ( strSize == GDCM_UNFOUND )
    {
       gdcmWarningMacro( "(0028,0102) is supposed to be mandatory");
       return 0;
    }
-   return atoi( strSize.c_str() );
+   return atoi( strSize.c_str() );*/
 }
 
 /**
@@ -870,14 +1039,23 @@ int File::GetHighBitPosition()
  */
 int File::GetSamplesPerPixel()
 {
-   const std::string &strSize = GetEntryValue(0x0028,0x0002);
+   DataEntry *entry = GetDataEntry(0x0028,0x0002);
+   if( !entry )
+   {
+      gdcmWarningMacro("(0028,0002) is supposed to be mandatory");
+      return 1; // Well, it's supposed to be mandatory ...
+                // but sometimes it's missing : *we* assume Gray pixels
+   }
+   return (int)entry->GetValue(0);
+
+/*   const std::string &strSize = GetEntryString(0x0028,0x0002);
    if ( strSize == GDCM_UNFOUND )
    {
       gdcmWarningMacro( "(0028,0002) is supposed to be mandatory");
       return 1; // Well, it's supposed to be mandatory ...
                 // but sometimes it's missing : *we* assume Gray pixels
    }
-   return atoi( strSize.c_str() );
+   return atoi( strSize.c_str() );*/
 }
 
 /**
@@ -887,13 +1065,21 @@ int File::GetSamplesPerPixel()
  */
 int File::GetPlanarConfiguration()
 {
-   std::string strSize = GetEntryValue(0x0028,0x0006);
+   DataEntry *entry = GetDataEntry(0x0028,0x0006);
+   if( !entry )
+   {
+      gdcmWarningMacro( "Not found : Planar Configuration (0028,0006)");
+      return 0;
+   }
+   return (int)entry->GetValue(0);
+
+/*   std::string strSize = GetEntryString(0x0028,0x0006);
    if ( strSize == GDCM_UNFOUND )
    {
       gdcmWarningMacro( "Not found : Planar Configuration (0028,0006)");
       return 0;
    }
-   return atoi( strSize.c_str() );
+   return atoi( strSize.c_str() );*/
 }
 
 /**
@@ -905,9 +1091,7 @@ int File::GetPixelSize()
 {
    // 0028 0100 US IMG Bits Allocated
    // (in order no to be messed up by old ACR-NEMA RGB images)
-   //   if (File::GetEntryValue(0x0028,0x0100) == "24")
-   //      return 3;
-   assert( !(GetEntryValue(0x0028,0x0100) == "24") );
+   assert( !(GetEntryString(0x0028,0x0100) == "24") );
 
    std::string pixelType = GetPixelType();
    if ( pixelType ==  "8U" || pixelType == "8S" )
@@ -926,7 +1110,7 @@ int File::GetPixelSize()
    {
       return 8;
    }
-   gdcmWarningMacro( "Unknown pixel type");
+   gdcmWarningMacro( "Unknown pixel type: " << pixelType);
    return 0;
 }
 
@@ -947,7 +1131,7 @@ int File::GetPixelSize()
  */
 std::string File::GetPixelType()
 {
-   std::string bitsAlloc = GetEntryValue(0x0028, 0x0100); // Bits Allocated
+   std::string bitsAlloc = GetEntryString(0x0028, 0x0100); // Bits Allocated
    if ( bitsAlloc == GDCM_UNFOUND )
    {
       gdcmWarningMacro( "Missing  Bits Allocated (0028,0100)");
@@ -969,7 +1153,39 @@ std::string File::GetPixelType()
       bitsAlloc = "8";
    }
 
-   std::string sign = GetEntryValue(0x0028, 0x0103);//"Pixel Representation"
+   std::string sign;
+   if( IsSignedPixelData() )
+   {
+      sign = "S";
+   }
+   else
+   {
+      sign = "U";
+   }
+
+/*   std::string bitsAlloc = GetEntryString(0x0028, 0x0100); // Bits Allocated
+   if ( bitsAlloc == GDCM_UNFOUND )
+   {
+      gdcmWarningMacro( "Missing  Bits Allocated (0028,0100)");
+      bitsAlloc = "16"; // default and arbitrary value, not to polute the output
+   }
+
+   if ( bitsAlloc == "64" )
+   {
+      return "FD";
+   }
+   else if ( bitsAlloc == "12" )
+   {
+      // It will be unpacked
+      bitsAlloc = "16";
+   }
+   else if ( bitsAlloc == "24" )
+   {
+      // (in order no to be messed up by old RGB images)
+      bitsAlloc = "8";
+   }
+
+   std::string sign = GetEntryString(0x0028, 0x0103);//"Pixel Representation"
 
    if (sign == GDCM_UNFOUND )
    {
@@ -983,7 +1199,7 @@ std::string File::GetPixelType()
    else
    {
       sign = "S";
-   }
+   }*/
    return bitsAlloc + sign;
 }
 
@@ -997,7 +1213,14 @@ std::string File::GetPixelType()
  */
 bool File::IsSignedPixelData()
 {
-   std::string strSign = GetEntryValue( 0x0028, 0x0103 );
+   DataEntry *entry = GetDataEntry(0x0028, 0x0103);//"Pixel Representation"
+   if( !entry )
+   {
+      gdcmWarningMacro( "Missing Pixel Representation (0028,0103)");
+      return false;
+   }
+   return entry->GetValue(0) != 0;
+/*   std::string strSign = GetEntryString( 0x0028, 0x0103 );
    if ( strSign == GDCM_UNFOUND )
    {
       gdcmWarningMacro( "(0028,0103) is supposed to be mandatory");
@@ -1008,7 +1231,7 @@ bool File::IsSignedPixelData()
    {
       return false;
    }
-   return true;
+   return true;*/
 }
 
 /**
@@ -1018,7 +1241,7 @@ bool File::IsSignedPixelData()
  */
 bool File::IsMonochrome()
 {
-   const std::string &PhotometricInterp = GetEntryValue( 0x0028, 0x0004 );
+   const std::string &PhotometricInterp = GetEntryString( 0x0028, 0x0004 );
    if (  Util::DicomStringEqual(PhotometricInterp, "MONOCHROME1")
       || Util::DicomStringEqual(PhotometricInterp, "MONOCHROME2") )
    {
@@ -1038,7 +1261,7 @@ bool File::IsMonochrome()
  */
 bool File::IsMonochrome1()
 {
-   const std::string &PhotometricInterp = GetEntryValue( 0x0028, 0x0004 );
+   const std::string &PhotometricInterp = GetEntryString( 0x0028, 0x0004 );
    if (  Util::DicomStringEqual(PhotometricInterp, "MONOCHROME1") )
    {
       return true;
@@ -1057,7 +1280,7 @@ bool File::IsMonochrome1()
  */
 bool File::IsPaletteColor()
 {
-   std::string PhotometricInterp = GetEntryValue( 0x0028, 0x0004 );
+   std::string PhotometricInterp = GetEntryString( 0x0028, 0x0004 );
    if (   PhotometricInterp == "PALETTE COLOR " )
    {
       return true;
@@ -1076,7 +1299,7 @@ bool File::IsPaletteColor()
  */
 bool File::IsYBRFull()
 {
-   std::string PhotometricInterp = GetEntryValue( 0x0028, 0x0004 );
+   std::string PhotometricInterp = GetEntryString( 0x0028, 0x0004 );
    if (   PhotometricInterp == "YBR_FULL" )
    {
       return true;
@@ -1150,7 +1373,7 @@ int File::GetLUTNbits()
    //Just hope Lookup Table Desc-Red = Lookup Table Desc-Red
    //                                = Lookup Table Desc-Blue
    // Consistency already checked in GetLUTLength
-   std::string lutDescription = GetEntryValue(0x0028,0x1101);
+   std::string lutDescription = GetEntryString(0x0028,0x1101);
    if ( lutDescription == GDCM_UNFOUND )
    {
       return 0;
@@ -1173,9 +1396,18 @@ int File::GetLUTNbits()
  */
 float File::GetRescaleIntercept()
 {
-   float resInter = 0.;
+   // 0028 1052 DS IMG Rescale Intercept
+   DataEntry *entry = GetDataEntry(0x0028, 0x1052);
+   if( !entry )
+   {
+      gdcmWarningMacro( "Missing Rescale Intercept (0028,1052)");
+      return 0.0f;
+   }
+   return (float)entry->GetValue(0);
+
+/*   float resInter = 0.;
    /// 0028 1052 DS IMG Rescale Intercept
-   const std::string &strRescInter = GetEntryValue(0x0028,0x1052);
+   const std::string &strRescInter = GetEntryString(0x0028,0x1052);
    if ( strRescInter != GDCM_UNFOUND )
    {
       if ( sscanf( strRescInter.c_str(), "%f ", &resInter) != 1 )
@@ -1185,7 +1417,7 @@ float File::GetRescaleIntercept()
       }
    }
 
-   return resInter;
+   return resInter;*/
 }
 
 /**
@@ -1194,9 +1426,17 @@ float File::GetRescaleIntercept()
  */
 float File::GetRescaleSlope()
 {
-   float resSlope = 1.;
+   // 0028 1053 DS IMG Rescale Slope
+   DataEntry *entry = GetDataEntry(0x0028, 0x1053);
+   if( !entry )
+   {
+      gdcmWarningMacro( "Missing Rescale Slope (0028,1053)");
+      return 1.0f;
+   }
+   return (float)entry->GetValue(0);
+/*   float resSlope = 1.;
    //0028 1053 DS IMG Rescale Slope
-   std::string strRescSlope = GetEntryValue(0x0028,0x1053);
+   std::string strRescSlope = GetEntryString(0x0028,0x1053);
    if ( strRescSlope != GDCM_UNFOUND )
    {
       if ( sscanf( strRescSlope.c_str(), "%f ", &resSlope) != 1 )
@@ -1206,7 +1446,7 @@ float File::GetRescaleSlope()
       }
    }
 
-   return resSlope;
+   return resSlope;*/
 }
 
 /**
@@ -1222,15 +1462,15 @@ int File::GetNumberOfScalarComponents()
    {
       return 3;
    }
-      
+
    // 0028 0100 US IMG Bits Allocated
    // (in order no to be messed up by old RGB images)
-   if ( GetEntryValue(0x0028,0x0100) == "24" )
+   if ( GetEntryString(0x0028,0x0100) == "24" )
    {
       return 3;
    }
-       
-   std::string strPhotometricInterpretation = GetEntryValue(0x0028,0x0004);
+
+   std::string strPhotometricInterpretation = GetEntryString(0x0028,0x0004);
 
    if ( ( strPhotometricInterpretation == "PALETTE COLOR ") )
    {
@@ -1270,7 +1510,7 @@ int File::GetNumberOfScalarComponentsRaw()
 {
    // 0028 0100 US IMG Bits Allocated
    // (in order no to be messed up by old RGB images)
-   if ( File::GetEntryValue(0x0028,0x0100) == "24" )
+   if ( File::GetEntryString(0x0028,0x0100) == "24" )
    {
       return 3;
    }
@@ -1384,7 +1624,7 @@ void File::AnonymizeNoLoad()
 /**
  * \brief anonymize a File (remove Patient's personal info passed with
  *        AddAnonymizeElement()
- * \note You cannot Anonymize a BinEntry (to be fixed)
+ * \note You cannot Anonymize a DataEntry (to be fixed)
  */
 bool File::AnonymizeFile()
 {
@@ -1392,22 +1632,22 @@ bool File::AnonymizeFile()
    if ( UserAnonymizeList.begin() == UserAnonymizeList.end() )
    {
       // If exist, replace by spaces
-      SetValEntry ("  ",0x0010, 0x2154); // Telephone   
-      SetValEntry ("  ",0x0010, 0x1040); // Adress
-      SetValEntry ("  ",0x0010, 0x0020); // Patient ID
+      SetEntryString("  ",0x0010, 0x2154); // Telephone   
+      SetEntryString("  ",0x0010, 0x1040); // Adress
+      SetEntryString("  ",0x0010, 0x0020); // Patient ID
 
-      DocEntrypatientNameHE = GetDocEntry (0x0010, 0x0010);
+      DocEntry *patientNameHE = GetDocEntry (0x0010, 0x0010);
   
       if ( patientNameHE ) // we replace it by Study Instance UID (why not ?)
       {
-         std::string studyInstanceUID =  GetEntryValue (0x0020, 0x000d);
+         std::string studyInstanceUID =  GetEntryString (0x0020, 0x000d);
          if ( studyInstanceUID != GDCM_UNFOUND )
          {
-            SetValEntry(studyInstanceUID, 0x0010, 0x0010);
+            SetEntryString(studyInstanceUID, 0x0010, 0x0010);
          }
          else
          {
-            SetValEntry("anonymized", 0x0010, 0x0010);
+            SetEntryString("anonymized", 0x0010, 0x0010);
          }
       }
    }
@@ -1429,13 +1669,13 @@ bool File::AnonymizeFile()
             continue;
          }
 
-         if ( dynamic_cast<BinEntry *>(d) )
+         if ( dynamic_cast<DataEntry *>(d) )
          {
-            gdcmWarningMacro( "To 'Anonymize' a BinEntry, better use AnonymizeNoLoad (FIXME) ");
+            gdcmWarningMacro( "To 'Anonymize' a DataEntry, better use AnonymizeNoLoad (FIXME) ");
             continue;
          }
          else
-            SetValEntry ((*it).Value, (*it).Group, (*it).Elem);
+            SetEntryString ((*it).Value, (*it).Group, (*it).Elem);
       }
 }
 
@@ -1513,12 +1753,12 @@ bool File::Write(std::string fileName, FileType writetype)
    }
 
    // Entry : 0002|0000 = group length -> recalculated
-   ValEntry*e0000 = GetValEntry(0x0002,0x0000);
+   DataEntry *e0000 = GetDataEntry(0x0002,0x0000);
    if ( e0000 )
    {
       std::ostringstream sLen;
       sLen << ComputeGroup0002Length( );
-      e0000->SetValue(sLen.str());
+      e0000->SetString(sLen.str());
    }
 
    int i_lgPix = GetEntryLength(GrPixel, NumPixel);
@@ -1527,7 +1767,7 @@ bool File::Write(std::string fileName, FileType writetype)
       // no (GrPixel, NumPixel) element
       std::string s_lgPix = Util::Format("%d", i_lgPix+12);
       s_lgPix = Util::DicomString( s_lgPix.c_str() );
-      InsertValEntry(s_lgPix,GrPixel, 0x0000);
+      InsertEntryString(s_lgPix,GrPixel, 0x0000);
    }
 
    Document::WriteContent(fp, writetype);
index 9090bda676dbad24a53bec329325a21042acb199..86405421f43990b80e2253fa00b25c932a14d995 100644 (file)
@@ -4,8 +4,8 @@
   Module:    $RCSfile: gdcmFileHelper.cxx,v $
   Language:  C++
 
-  Date:      $Date: 2005/10/07 09:54:53 $
-  Version:   $Revision: 1.59 $
+  Date:      $Date: 2005/10/18 08:35:50 $
+  Version:   $Revision: 1.60 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include "gdcmDocument.h"
 #include "gdcmDebug.h"
 #include "gdcmUtil.h"
-#include "gdcmBinEntry.h"
-#include "gdcmValEntry.h"
 #include "gdcmSeqEntry.h"
 #include "gdcmSQItem.h"
-#include "gdcmContentEntry.h"
+#include "gdcmDataEntry.h"
 #include "gdcmFile.h"
 #include "gdcmPixelReadConvert.h"
 #include "gdcmPixelWriteConvert.h"
@@ -267,10 +265,10 @@ bool FileHelper::Load()
  * @param   elem element number of the Dicom Element to modify
  * \return  false if DocEntry not found
  */
-bool FileHelper::SetValEntry(std::string const &content,
-                             uint16_t group, uint16_t elem)
+bool FileHelper::SetEntryString(std::string const &content,
+                                    uint16_t group, uint16_t elem)
 { 
-   return FileInternal->SetValEntry(content, group, elem);
+   return FileInternal->SetEntryString(content, group, elem);
 }
 
 
@@ -284,10 +282,10 @@ bool FileHelper::SetValEntry(std::string const &content,
  * @param   elem element number of the Dicom Element to modify
  * \return  false if DocEntry not found
  */
-bool FileHelper::SetBinEntry(uint8_t *content, int lgth,
-                             uint16_t group, uint16_t elem)
+bool FileHelper::SetEntryBinArea(uint8_t *content, int lgth,
+                                     uint16_t group, uint16_t elem)
 {
-   return FileInternal->SetBinEntry(content, lgth, group, elem);
+   return FileInternal->SetEntryBinArea(content, lgth, group, elem);
 }
 
 /**
@@ -299,10 +297,10 @@ bool FileHelper::SetBinEntry(uint8_t *content, int lgth,
  * \return  pointer to the modified/created Dicom entry (NULL when creation
  *          failed).
  */ 
-ValEntry *FileHelper::InsertValEntry(std::string const &content,
-                                     uint16_t group, uint16_t elem)
+DataEntry *FileHelper::InsertEntryString(std::string const &content,
+                                                uint16_t group, uint16_t elem)
 {
-   return FileInternal->InsertValEntry(content, group, elem);
+   return FileInternal->InsertEntryString(content, group, elem);
 }
 
 /**
@@ -316,10 +314,10 @@ ValEntry *FileHelper::InsertValEntry(std::string const &content,
  * \return  pointer to the modified/created Dicom entry (NULL when creation
  *          failed).
  */
-BinEntry *FileHelper::InsertBinEntry(uint8_t *binArea, int lgth,
-                                     uint16_t group, uint16_t elem)
+DataEntry *FileHelper::InsertEntryBinArea(uint8_t *binArea, int lgth,
+                                                 uint16_t group, uint16_t elem)
 {
-   return FileInternal->InsertBinEntry(binArea, lgth, group, elem);
+   return FileInternal->InsertEntryBinArea(binArea, lgth, group, elem);
 }
 
 /**
@@ -705,8 +703,8 @@ bool FileHelper::Write(std::string const &fileName)
       // and forgets to create any Entry belonging to group 0008
       // (shame on him !)
       // We add Recognition Code (RET)
-        if ( ! FileInternal->GetValEntry(0x0008, 0x0010) )
-            FileInternal->InsertValEntry("", 0x0008, 0x0010);
+        if ( ! FileInternal->GetDataEntry(0x0008, 0x0010) )
+            FileInternal->InsertEntryString("", 0x0008, 0x0010);
          SetWriteFileTypeToACR();
         // SetWriteFileTypeToImplicitVR(); // ACR IS implicit VR !
          break;
@@ -816,7 +814,8 @@ bool FileHelper::CheckWriteIntegrity()
             }
             break;
       }
-   }   
+   }
+
    return true;
 }
 
@@ -834,14 +833,14 @@ void FileHelper::SetWriteToRaw()
    } 
    else
    {
-      ValEntry *photInt = CopyValEntry(0x0028,0x0004);
+      DataEntry *photInt = CopyDataEntry(0x0028,0x0004);
       if (FileInternal->HasLUT() )
       {
-         photInt->SetValue("PALETTE COLOR ");
+         photInt->SetString("PALETTE COLOR ");
       }
       else
       {
-         photInt->SetValue("MONOCHROME2 ");
+         photInt->SetString("MONOCHROME2 ");
       }
 
       PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(),
@@ -852,9 +851,9 @@ void FileHelper::SetWriteToRaw()
          vr = "OW";
       if ( FileInternal->GetBitsAllocated()==24 ) // For RGB ACR files 
          vr = "OB";
-      BinEntry *pixel = 
-         CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
-      pixel->SetValue(GDCM_BINLOADED);
+      DataEntry *pixel = 
+         CopyDataEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
+      pixel->SetFlag(DataEntry::FLAG_PIXELDATA);
       pixel->SetBinArea(PixelWriteConverter->GetData(),false);
       pixel->SetLength(PixelWriteConverter->GetDataSize());
 
@@ -876,14 +875,14 @@ void FileHelper::SetWriteToRGB()
    {
       PixelReadConverter->BuildRGBImage();
       
-      ValEntry *spp = CopyValEntry(0x0028,0x0002);
-      spp->SetValue("3 ");
+      DataEntry *spp = CopyDataEntry(0x0028,0x0002);
+      spp->SetString("3 ");
 
-      ValEntry *planConfig = CopyValEntry(0x0028,0x0006);
-      planConfig->SetValue("0 ");
+      DataEntry *planConfig = CopyDataEntry(0x0028,0x0006);
+      planConfig->SetString("0 ");
 
-      ValEntry *photInt = CopyValEntry(0x0028,0x0004);
-      photInt->SetValue("RGB ");
+      DataEntry *photInt = CopyDataEntry(0x0028,0x0004);
+      photInt->SetString("RGB ");
 
       if ( PixelReadConverter->GetRGB() )
       {
@@ -901,9 +900,9 @@ void FileHelper::SetWriteToRGB()
          vr = "OW";
       if ( FileInternal->GetBitsAllocated()==24 ) // For RGB ACR files 
          vr = "OB";
-      BinEntry *pixel = 
-         CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
-      pixel->SetValue(GDCM_BINLOADED);
+      DataEntry *pixel = 
+         CopyDataEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
+      pixel->SetFlag(DataEntry::FLAG_PIXELDATA);
       pixel->SetBinArea(PixelWriteConverter->GetData(),false);
       pixel->SetLength(PixelWriteConverter->GetDataSize());
 
@@ -928,14 +927,14 @@ void FileHelper::SetWriteToRGB()
       // samples per pixels = 1 (in the read file)
       if ( FileInternal->GetBitsAllocated()==24 ) 
       {
-         ValEntry *bitsAlloc = CopyValEntry(0x0028,0x0100);
-         bitsAlloc->SetValue("8 ");
+         DataEntry *bitsAlloc = CopyDataEntry(0x0028,0x0100);
+         bitsAlloc->SetString("8 ");
 
-         ValEntry *bitsStored = CopyValEntry(0x0028,0x0101);
-         bitsStored->SetValue("8 ");
+         DataEntry *bitsStored = CopyDataEntry(0x0028,0x0101);
+         bitsStored->SetString("8 ");
 
-         ValEntry *highBit = CopyValEntry(0x0028,0x0102);
-         highBit->SetValue("7 ");
+         DataEntry *highBit = CopyDataEntry(0x0028,0x0102);
+         highBit->SetString("7 ");
 
          Archive->Push(bitsAlloc);
          Archive->Push(bitsStored);
@@ -1017,8 +1016,8 @@ void FileHelper::SetWriteFileTypeToExplicitVR()
    std::string ts = Util::DicomString( 
       Global::GetTS()->GetSpecialTransferSyntax(TS::ExplicitVRLittleEndian) );
 
-   ValEntry *tss = CopyValEntry(0x0002,0x0010);
-   tss->SetValue(ts);
+   DataEntry *tss = CopyDataEntry(0x0002,0x0010);
+   tss->SetString(ts);
 
    Archive->Push(tss);
 }
@@ -1031,8 +1030,8 @@ void FileHelper::SetWriteFileTypeToImplicitVR()
    std::string ts = Util::DicomString(
       Global::GetTS()->GetSpecialTransferSyntax(TS::ImplicitVRLittleEndian) );
 
-   ValEntry *tss = CopyValEntry(0x0002,0x0010);
-   tss->SetValue(ts);
+   DataEntry *tss = CopyDataEntry(0x0002,0x0010);
+   tss->SetString(ts);
 
    Archive->Push(tss);
 }
@@ -1050,30 +1049,28 @@ void FileHelper::RestoreWriteFileType()
  */ 
 void FileHelper::SetWriteToLibido()
 {
-   ValEntry *oldRow = dynamic_cast<ValEntry *>
-                (FileInternal->GetDocEntry(0x0028, 0x0010));
-   ValEntry *oldCol = dynamic_cast<ValEntry *>
-                (FileInternal->GetDocEntry(0x0028, 0x0011));
+   DataEntry *oldRow = FileInternal->GetDataEntry(0x0028, 0x0010);
+   DataEntry *oldCol = FileInternal->GetDataEntry(0x0028, 0x0011);
    
    if ( oldRow && oldCol )
    {
       std::string rows, columns; 
 
-      ValEntry *newRow=new ValEntry(oldRow->GetDictEntry());
-      ValEntry *newCol=new ValEntry(oldCol->GetDictEntry());
+      DataEntry *newRow=new DataEntry(oldRow->GetDictEntry());
+      DataEntry *newCol=new DataEntry(oldCol->GetDictEntry());
 
       newRow->Copy(oldCol);
       newCol->Copy(oldRow);
 
-      newRow->SetValue(oldCol->GetValue());
-      newCol->SetValue(oldRow->GetValue());
+      newRow->SetString(oldCol->GetString());
+      newCol->SetString(oldRow->GetString());
 
       Archive->Push(newRow);
       Archive->Push(newCol);
    }
 
-   ValEntry *libidoCode = CopyValEntry(0x0008,0x0010);
-   libidoCode->SetValue("ACRNEMA_LIBIDO_1.1");
+   DataEntry *libidoCode = CopyDataEntry(0x0008,0x0010);
+   libidoCode->SetString("ACRNEMA_LIBIDO_1.1");
    Archive->Push(libidoCode);
 }
 
@@ -1082,14 +1079,13 @@ void FileHelper::SetWriteToLibido()
  */ 
 void FileHelper::SetWriteToNoLibido()
 {
-   ValEntry *recCode = dynamic_cast<ValEntry *>
-                (FileInternal->GetDocEntry(0x0008,0x0010));
+   DataEntry *recCode = FileInternal->GetDataEntry(0x0008,0x0010);
    if ( recCode )
    {
-      if ( recCode->GetValue() == "ACRNEMA_LIBIDO_1.1" )
+      if ( recCode->GetString() == "ACRNEMA_LIBIDO_1.1" )
       {
-         ValEntry *libidoCode = CopyValEntry(0x0008,0x0010);
-         libidoCode->SetValue("");
+         DataEntry *libidoCode = CopyDataEntry(0x0008,0x0010);
+         libidoCode->SetString("");
          Archive->Push(libidoCode);
       }
    }
@@ -1112,55 +1108,31 @@ void FileHelper::RestoreWriteOfLibido()
 }
 
 /**
- * \brief Duplicates a ValEntry or creates it.
- * @param   group   Group number of the Entry 
- * @param   elem  Element number of the Entry
- * \return  pointer to the new Val Entry (NULL when creation failed).          
- */ 
-ValEntry *FileHelper::CopyValEntry(uint16_t group, uint16_t elem)
-{
-   DocEntry *oldE = FileInternal->GetDocEntry(group, elem);
-   ValEntry *newE;
-
-   if ( oldE )
-   {
-      newE = new ValEntry(oldE->GetDictEntry());
-      newE->Copy(oldE);
-   }
-   else
-   {
-      newE = GetFile()->NewValEntry(group, elem);
-   }
-
-   return newE;
-}
-
-/**
- * \brief   Duplicates a BinEntry or creates it.
+ * \brief   Duplicates a DataEntry or creates it.
  * @param   group   Group number of the Entry 
  * @param   elem  Element number of the Entry
  * @param   vr  Value Representation of the Entry
  *          FIXME : what is it used for?
  * \return  pointer to the new Bin Entry (NULL when creation failed).
  */ 
-BinEntry *FileHelper::CopyBinEntry(uint16_t group, uint16_t elem,
-                                   const std::string &vr)
+DataEntry *FileHelper::CopyDataEntry(uint16_t group, uint16_t elem,
+                                   const TagName &vr)
 {
    DocEntry *oldE = FileInternal->GetDocEntry(group, elem);
-   BinEntry *newE;
+   DataEntry *newE;
 
-   if ( oldE ) 
+   if ( oldE && vr != GDCM_UNKNOWN 
       if ( oldE->GetVR()!=vr )
          oldE = NULL;
 
    if ( oldE )
    {
-      newE = new BinEntry(oldE->GetDictEntry());
+      newE = new DataEntry(oldE->GetDictEntry());
       newE->Copy(oldE);
    }
    else
    {
-      newE = GetFile()->NewBinEntry(group, elem, vr);
+      newE = GetFile()->NewDataEntry(group, elem, vr);
    }
 
    return newE;
@@ -1213,43 +1185,28 @@ void FileHelper::CheckMandatoryElements()
    // Create them if not found
    // Always modify the value
    // Push the entries to the archive.
-      ValEntry *e_0002_0000 = CopyValEntry(0x0002,0x0000);
-      e_0002_0000->SetValue("0"); // for the moment
-      Archive->Push(e_0002_0000);
+      CopyMandatoryEntry(0x0002,0x0000,"0");
   
-      BinEntry *e_0002_0001 = CopyBinEntry(0x0002,0x0001, "OB");
+      DataEntry *e_0002_0001 = CopyDataEntry(0x0002,0x0001, "OB");
       e_0002_0001->SetBinArea((uint8_t*)Util::GetFileMetaInformationVersion(),
                                false);
       e_0002_0001->SetLength(2);
       Archive->Push(e_0002_0001);
 
    // 'Media Stored SOP Class UID' 
-      ValEntry *e_0002_0002 = CopyValEntry(0x0002,0x0002);
       // [Secondary Capture Image Storage]
-      e_0002_0002->SetValue("1.2.840.10008.5.1.4.1.1.7"); 
-      Archive->Push(e_0002_0002);
+      CopyMandatoryEntry(0x0002,0x0002,"1.2.840.10008.5.1.4.1.1.7");
  
    // 'Media Stored SOP Instance UID'   
-      ValEntry *e_0002_0003 = CopyValEntry(0x0002,0x0003);
-      e_0002_0003->SetValue(Util::CreateUniqueUID());
-      Archive->Push(e_0002_0003); 
+      CopyMandatoryEntry(0x0002,0x0003,Util::CreateUniqueUID());
 
    // 'Implementation Class UID'
-      ValEntry *e_0002_0012 = CopyValEntry(0x0002,0x0012);
-      e_0002_0012->SetValue(Util::CreateUniqueUID());
-      Archive->Push(e_0002_0012); 
+      CopyMandatoryEntry(0x0002,0x0012,Util::CreateUniqueUID());
 
    // 'Implementation Version Name'
-      ValEntry *e_0002_0013 = CopyValEntry(0x0002,0x0013);
       std::string version = "GDCM ";
       version += Util::GetVersion();
-      e_0002_0013->SetValue(version);
-      Archive->Push(e_0002_0013);
-
-   //'Source Application Entity Title' Not Mandatory
-   //ValEntry *e_0002_0016 = CopyValEntry(0x0002,0x0016);
-   //   e_0002_0016->SetValue("1.2.840.10008.5.1.4.1.1.7");
-   //   Archive->Push(e_0002_0016);
+      CopyMandatoryEntry(0x0002,0x0013,version);
    }
 
    // Push out 'LibIDO-special' entries, if any
@@ -1260,11 +1217,9 @@ void FileHelper::CheckMandatoryElements()
 
    // Deal with the pb of (Bits Stored = 12)
    // - we're gonna write the image as Bits Stored = 16
-   if ( FileInternal->GetEntryValue(0x0028,0x0100) ==  "12")
+   if ( FileInternal->GetEntryString(0x0028,0x0100) ==  "12")
    {
-      ValEntry *e_0028_0100 = CopyValEntry(0x0028,0x0100);
-      e_0028_0100->SetValue("16");
-      Archive->Push(e_0028_0100);
+      CopyMandatoryEntry(0x0028,0x0100,"16");
    }
 
    // Check if user wasn't drunk ;-)
@@ -1274,9 +1229,7 @@ void FileHelper::CheckMandatoryElements()
    int nbBitsAllocated = FileInternal->GetBitsAllocated();
    if ( nbBitsAllocated == 0 || nbBitsAllocated > 32)
    {
-      ValEntry *e_0028_0100 = CopyValEntry(0x0028,0x0100);
-      e_0028_0100->SetValue("16");
-      Archive->Push(e_0028_0100); 
+      CopyMandatoryEntry(0x0028,0x0100,"16");
       gdcmWarningMacro("(0028,0100) changed from "
          << nbBitsAllocated << " to 16 for consistency purpose");
       nbBitsAllocated = 16; 
@@ -1285,10 +1238,9 @@ void FileHelper::CheckMandatoryElements()
    int nbBitsStored = FileInternal->GetBitsStored();
    if ( nbBitsStored == 0 || nbBitsStored > nbBitsAllocated )
    {
+      s.str("");
       s << nbBitsAllocated;
-      ValEntry *e_0028_0101 = CopyValEntry(0x0028,0x0101);
-      e_0028_0101->SetValue( s.str() );
-      Archive->Push(e_0028_0101);
+      CopyMandatoryEntry(0x0028,0x0101,s.str());
       gdcmWarningMacro("(0028,0101) changed from "
                        << nbBitsStored << " to " << nbBitsAllocated
                        << " for consistency purpose" );
@@ -1300,11 +1252,9 @@ void FileHelper::CheckMandatoryElements()
         highBitPosition > nbBitsAllocated-1 ||
         highBitPosition < nbBitsStored-1  )
    {
-      ValEntry *e_0028_0102 = CopyValEntry(0x0028,0x0102);
-
+      s.str("");
       s << nbBitsStored - 1; 
-      e_0028_0102->SetValue( s.str() );
-      Archive->Push(e_0028_0102);
+      CopyMandatoryEntry(0x0028,0x0102,s.str());
       gdcmWarningMacro("(0028,0102) changed from "
                        << highBitPosition << " to " << nbBitsAllocated-1
                        << " for consistency purpose");
@@ -1315,8 +1265,8 @@ void FileHelper::CheckMandatoryElements()
    // we create the 'Source Image Sequence' SeqEntry
    // to hold informations about the Source Image
 
-   ValEntry *e_0008_0016 = FileInternal->GetValEntry(0x0008, 0x0016);
-   if ( e_0008_0016 != 0 )
+   DataEntry *e_0008_0016 = FileInternal->GetDataEntry(0x0008, 0x0016);
+   if ( e_0008_0016 )
    {
       // Create 'Source Image Sequence' SeqEntry
       SeqEntry *sis = new SeqEntry (
@@ -1324,16 +1274,16 @@ void FileHelper::CheckMandatoryElements()
       SQItem *sqi = new SQItem(1);
       // (we assume 'SOP Instance UID' exists too) 
       // create 'Referenced SOP Class UID'
-      ValEntry *e_0008_1150 = new ValEntry(
+      DataEntry *e_0008_1150 = new DataEntry(
             Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1150) );
-      e_0008_1150->SetValue( e_0008_0016->GetValue());
+      e_0008_1150->SetString( e_0008_0016->GetString());
       sqi->AddEntry(e_0008_1150);
       
       // create 'Referenced SOP Instance UID'
-      ValEntry *e_0008_0018 = FileInternal->GetValEntry(0x0008, 0x0018);
-      ValEntry *e_0008_1155 = new ValEntry(
+      DataEntry *e_0008_0018 = FileInternal->GetDataEntry(0x0008, 0x0018);
+      DataEntry *e_0008_1155 = new DataEntry(
             Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1155) );
-      e_0008_1155->SetValue( e_0008_0018->GetValue());
+      e_0008_1155->SetString( e_0008_0018->GetString());
       sqi->AddEntry(e_0008_1155);
 
       sis->AddSQItem(sqi,1); 
@@ -1341,9 +1291,7 @@ void FileHelper::CheckMandatoryElements()
       Archive->Push(sis);
  
       // 'Image Type' (The written image is no longer an 'ORIGINAL' one)
-      ValEntry *e_0008_0008 = CopyValEntry(0x0008,0x0008);
-      e_0008_0008->SetValue("DERIVED\\PRIMARY");
-      Archive->Push(e_0008_0008);
+      CopyMandatoryEntry(0x0008,0x0008,"DERIVED\\PRIMARY");
    } 
    else
    {
@@ -1351,35 +1299,21 @@ void FileHelper::CheckMandatoryElements()
       // the source image was NOT a true Dicom one.
       // We consider the image is a 'Secondary Capture' one
       // SOP Class UID
-      e_0008_0016  =  new ValEntry( 
-            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x0016) );
       // [Secondary Capture Image Storage]
-      e_0008_0016 ->SetValue("1.2.840.10008.5.1.4.1.1.7"); 
-      Archive->Push(e_0008_0016); 
+      SetMandatoryEntry(0x0008,0x0016,"1.2.840.10008.5.1.4.1.1.7");
    }
 
 // ---- The user will never have to take any action on the following ----.
-
    // new value for 'SOP Instance UID'
-   ValEntry *e_0008_0018 = new ValEntry(
-         Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x0018) );
-   e_0008_0018->SetValue( Util::CreateUniqueUID() );
-   Archive->Push(e_0008_0018);
+   SetMandatoryEntry(0x0008,0x0018,Util::CreateUniqueUID());
 
    // Instance Creation Date
-   ValEntry *e_0008_0012 = CopyValEntry(0x0008,0x0012);
-   std::string date = Util::GetCurrentDate();
-   e_0008_0012->SetValue(date.c_str());
-   Archive->Push(e_0008_0012);
+   CopyMandatoryEntry(0x0008,0x0012,Util::GetCurrentDate().c_str());
  
    // Instance Creation Time
-   ValEntry *e_0008_0013 = CopyValEntry(0x0008,0x0013);
-   std::string time = Util::GetCurrentTime();
-   e_0008_0013->SetValue(time.c_str());
-   Archive->Push(e_0008_0013);
+   CopyMandatoryEntry(0x0008,0x0013,Util::GetCurrentTime().c_str());
 
 // ----- Add Mandatory Entries if missing ---
-
 // Entries whose type is 1 are mandatory, with a mandatory value
 // Entries whose type is 1c are mandatory-inside-a-Sequence
 // Entries whose type is 2 are mandatory, with a optional value
@@ -1392,14 +1326,7 @@ void FileHelper::CheckMandatoryElements()
    // keeping the same 'Serie Instance UID' for various images
    // The user shouldn't add any image to a 'Manufacturer Serie'
    // but there is no way no to allowed him to do that 
-   ValEntry *e_0020_000e = FileInternal->GetValEntry(0x0020, 0x000e);
-   if ( !e_0020_000e )
-   {
-      e_0020_000e = new ValEntry(
-           Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0020, 0x000e) );
-      e_0020_000e->SetValue(Util::CreateUniqueUID() );
-      Archive->Push(e_0020_000e);
-   } 
+   CheckMandatoryEntry(0x0020,0x000e,Util::CreateUniqueUID());
 
    // 'Study Instance UID'
    // Keep the value if exists
@@ -1407,107 +1334,69 @@ void FileHelper::CheckMandatoryElements()
    //          keeping the same 'Study Instance UID' for various images
    // The user may add images to a 'Manufacturer Study',
    //          adding new series to an already existing Study 
-   ValEntry *e_0020_000d = FileInternal->GetValEntry(0x0020, 0x000d);
-   if ( !e_0020_000d )
-   {
-      e_0020_000d = new ValEntry(
-            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0020, 0x000d) );
-      e_0020_000d->SetValue(Util::CreateUniqueUID() );
-      Archive->Push(e_0020_000d);
-   }
+   CheckMandatoryEntry(0x0020,0x000d,Util::CreateUniqueUID());
 
    // Modality : if missing we set it to 'OTher'
-   ValEntry *e_0008_0060 = FileInternal->GetValEntry(0x0008, 0x0060);
-   if ( !e_0008_0060 )
-   {
-      e_0008_0060 = new ValEntry(
-            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x0060) );
-      e_0008_0060->SetValue("OT");
-      Archive->Push(e_0008_0060);
-   } 
+   CheckMandatoryEntry(0x0008,0x0060,"OT");
 
    // Manufacturer : if missing we set it to 'GDCM Factory'
-   ValEntry *e_0008_0070 = FileInternal->GetValEntry(0x0008, 0x0070);
-   if ( !e_0008_0070 )
-   {
-      e_0008_0070 = new ValEntry(
-            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x0070) );
-      e_0008_0070->SetValue("GDCM Factory");
-      Archive->Push(e_0008_0070);
-   } 
+   CheckMandatoryEntry(0x0008,0x0070,"GDCM Factory");
 
    // Institution Name : if missing we set it to 'GDCM Hospital'
-   ValEntry *e_0008_0080 = FileInternal->GetValEntry(0x0008, 0x0080);
-   if ( !e_0008_0080 )
-   {
-      e_0008_0080 = new ValEntry(
-            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x0080) );
-      e_0008_0080->SetValue("GDCM Hospital");
-      Archive->Push(e_0008_0080);
-   } 
+   CheckMandatoryEntry(0x0008,0x0080,"GDCM Hospital");
 
    // Patient's Name : if missing, we set it to 'GDCM^Patient'
-   ValEntry *e_0010_0010 = FileInternal->GetValEntry(0x0010, 0x0010);
-   if ( !e_0010_0010 )
-   {
-      e_0010_0010 = new ValEntry(
-            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0010, 0x0010) );
-      e_0010_0010->SetValue("GDCM^Patient");
-      Archive->Push(e_0010_0010);
-   } 
+   CheckMandatoryEntry(0x0010,0x0010,"GDCM^Patient");
 
    // Patient's Birth Date : 'type 2' entry -> must exist, value not mandatory
-   ValEntry *e_0010_0030 = FileInternal->GetValEntry(0x0010, 0x0030);
-   if ( !e_0010_0030 )
-   {
-      e_0010_0030 = new ValEntry(
-            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0010, 0x0030) );
-      e_0010_0030->SetValue("");
-      Archive->Push(e_0010_0030);
-   }
+   CheckMandatoryEntry(0x0010,0x0030,"");
 
    // Patient's Sex :'type 2' entry -> must exist, value not mandatory
-   ValEntry *e_0010_0040 = FileInternal->GetValEntry(0x0010, 0x0040);
-   if ( !e_0010_0040 )
-   {
-      e_0010_0040 = new ValEntry(
-            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0010, 0x0040) );
-      e_0010_0040->SetValue("");
-      Archive->Push(e_0010_0040);
-   }
+   CheckMandatoryEntry(0x0010,0x0040,"");
 
    // Referring Physician's Name :'type 2' entry -> must exist, value not mandatory
-   ValEntry *e_0008_0090 = FileInternal->GetValEntry(0x0008, 0x0090);
-   if ( !e_0008_0090 )
-   {
-      e_0008_0090 = new ValEntry(
-            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x0090) );
-      e_0008_0090->SetValue("");
-      Archive->Push(e_0008_0090);
-   }
+   CheckMandatoryEntry(0x0008,0x0090,"");
 
     // Pixel Spacing : defaulted to 1.0\1.0
-   ValEntry *e_0028_0030 = FileInternal->GetValEntry(0x0028, 0x0030);
-   if ( !e_0028_0030 )
-   {
-      e_0028_0030 = new ValEntry(
-            Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0028, 0x0030) );
-      e_0028_0030->SetValue("1.0\\1.0");
-      Archive->Push(e_0028_0030);
-   }  
+   CheckMandatoryEntry(0x0028,0x0030,"1.0\\1.0");
    
    // Remove some inconstencies (probably some more will be added)
 
    // if (0028 0008)Number of Frames exists
    //    Push out (0020 0052),Frame of Reference UID
    //    (only meaningfull within a Serie)
-   ValEntry *e_0028_0008 = FileInternal->GetValEntry(0x0028, 0x0008);
+   DataEntry *e_0028_0008 = FileInternal->GetDataEntry(0x0028, 0x0008);
    if ( !e_0028_0008 )
    {
       Archive->Push(0x0020, 0X0052);
    }
 } 
+
+void FileHelper::CheckMandatoryEntry(uint16_t group,uint16_t elem,std::string value)
+{
+   DataEntry *entry = FileInternal->GetDataEntry(group,elem);
+   if ( !entry )
+   {
+      entry = new DataEntry(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem));
+      entry->SetString(value);
+      Archive->Push(entry);
+   }
+}
+
+void FileHelper::SetMandatoryEntry(uint16_t group,uint16_t elem,std::string value)
+{
+   DataEntry *entry = new DataEntry(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem));
+   entry->SetString(value);
+   Archive->Push(entry);
+}
+
+void FileHelper::CopyMandatoryEntry(uint16_t group,uint16_t elem,std::string value)
+{
+   DataEntry *entry = CopyDataEntry(group,elem);
+   entry->SetString(value);
+   Archive->Push(entry);
+}
+
 /**
  * \brief Restore in the File the initial group 0002
  */
@@ -1592,7 +1481,7 @@ uint8_t *FileHelper::GetRaw()
 
 //-----------------------------------------------------------------------------
 /**
- * \brief   Prints the common part of ValEntry, BinEntry, SeqEntry
+ * \brief   Prints the common part of DataEntry, SeqEntry
  * @param   os ostream we want to print in
  * @param indent (unused)
  */
index ee5e9d776ac572051ea069079970f0943885a398..1c1d0d8d07b4e60aa5b83d840e1668163ee77a2b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFileHelper.h,v $
   Language:  C++
-  Date:      $Date: 2005/09/02 07:10:03 $
-  Version:   $Revision: 1.22 $
+  Date:      $Date: 2005/10/18 08:35:50 $
+  Version:   $Revision: 1.23 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -28,8 +28,7 @@
 namespace gdcm 
 {
 class File;
-class ValEntry;
-class BinEntry;
+class DataEntry;
 class SeqEntry;
 class PixelReadConvert;
 class PixelWriteConvert;
@@ -72,15 +71,15 @@ public:
    void SetUserFunction( VOID_FUNCTION_PUINT8_PFILE_POINTER userFunc ) 
                         { UserFunction = userFunc; }   
    // File methods
-   bool SetValEntry(std::string const &content,
-                    uint16_t group, uint16_t elem);
-   bool SetBinEntry(uint8_t *content, int lgth,
-                    uint16_t group, uint16_t elem);
-
-   ValEntry *InsertValEntry(std::string const &content,
-                            uint16_t group, uint16_t elem);
-   BinEntry *InsertBinEntry(uint8_t *binArea, int lgth,
+   bool SetEntryString(std::string const &content,
+                           uint16_t group, uint16_t elem);
+   bool SetEntryBinArea(uint8_t *content, int lgth,
                             uint16_t group, uint16_t elem);
+
+   DataEntry *InsertEntryString(std::string const &content,
+                                       uint16_t group, uint16_t elem);
+   DataEntry *InsertEntryBinArea(uint8_t *binArea, int lgth,
+                                        uint16_t group, uint16_t elem);
    SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
 
    // File helpers
@@ -165,10 +164,12 @@ protected:
    void SetWriteToNoLibido();
    void RestoreWriteOfLibido();
 
-   ValEntry *CopyValEntry(uint16_t group, uint16_t elem);
-   BinEntry *CopyBinEntry(uint16_t group, uint16_t elem, 
-                          const std::string &vr);
+   DataEntry *CopyDataEntry(uint16_t group, uint16_t elem, 
+                               const TagName &vr = GDCM_UNKNOWN);
    void CheckMandatoryElements();
+   void CheckMandatoryEntry(uint16_t group,uint16_t elem,std::string value);
+   void SetMandatoryEntry(uint16_t group,uint16_t elem,std::string value);
+   void CopyMandatoryEntry(uint16_t group,uint16_t elem,std::string value);
    void RestoreWriteMandatory();
 
 private:
index b6a33bb8e440caf0fe0bc5cf2e140bfa8b2f0cbd..d23402ca091217b2515e3fc69a9738af3618bfe2 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmOrientation.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/03 14:54:16 $
-  Version:   $Revision: 1.16 $
+  Date:      $Date: 2005/10/18 08:35:50 $
+  Version:   $Revision: 1.17 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -336,7 +336,7 @@ try:
       val=image.GetFirstEntry()
       dic={}
       while(val):
-         if isinstance(val,gdcm.ValEntryPtr):
+         if isinstance(val,gdcm.DataEntryPtr):
             dic[val.GetName()]=val.GetValue()
          val=image.GetNextEntry()
       return dic
index 05402379a28fcb91a477ae52f2eb5262112abaf0..689ab46cf157c75fc2c231cb7e940efc5539c72e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmPixelReadConvert.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/13 07:14:45 $
-  Version:   $Revision: 1.78 $
+  Date:      $Date: 2005/10/18 08:35:50 $
+  Version:   $Revision: 1.79 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -148,9 +148,9 @@ void PixelReadConvert::GrabInformationsFromFile( File *file )
    if ( HasLUT )
    {
       // Just in case some access to a File element requires disk access.
-      LutRedDescriptor   = file->GetEntryValue( 0x0028, 0x1101 );
-      LutGreenDescriptor = file->GetEntryValue( 0x0028, 0x1102 );
-      LutBlueDescriptor  = file->GetEntryValue( 0x0028, 0x1103 );
+      LutRedDescriptor   = file->GetEntryString( 0x0028, 0x1101 );
+      LutGreenDescriptor = file->GetEntryString( 0x0028, 0x1102 );
+      LutBlueDescriptor  = file->GetEntryString( 0x0028, 0x1103 );
    
       // The following comment is probabely meaningless, since LUT are *always*
       // loaded at parsing time, whatever their length is.
@@ -164,7 +164,7 @@ void PixelReadConvert::GrabInformationsFromFile( File *file )
       // \TODO Reading a [Bin|Val]Entry directly from disk is a kludge.
       //       We should NOT bypass the [Bin|Val]Entry class. Instead
       //       an access to an UNLOADED content of a [Bin|Val]Entry occurence
-      //       (e.g. BinEntry::GetBinArea()) should force disk access from
+      //       (e.g. DataEntry::GetBinArea()) should force disk access from
       //       within the [Bin|Val]Entry class itself. The only problem
       //       is that the [Bin|Val]Entry is unaware of the FILE* is was
       //       parsed from. Fix that. FIXME.
index 88c93b3ad21c7021b5c4dac7a2201488e63f54b1..0ed62981aeec4deb87fe99b01256ed36350abb12 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/09/06 17:15:25 $
-  Version:   $Revision: 1.75 $
+  Date:      $Date: 2005/10/18 08:35:50 $
+  Version:   $Revision: 1.76 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -18,8 +18,6 @@
 
 #include "gdcmSQItem.h"
 #include "gdcmSeqEntry.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
 #include "gdcmGlobal.h"
 #include "gdcmDictSet.h"
 #include "gdcmUtil.h"
index 8f5e4731c6dc33e6745d1c507fbcd904653812a1..0cfd3643ab4be942ce125f1382c6a07b0938b1ad 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSeqEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/24 03:42:40 $
-  Version:   $Revision: 1.57 $
+  Date:      $Date: 2005/10/18 08:35:50 $
+  Version:   $Revision: 1.58 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -18,7 +18,6 @@
 
 #include "gdcmSeqEntry.h"
 #include "gdcmSQItem.h"
-#include "gdcmValEntry.h"
 #include "gdcmTS.h"
 #include "gdcmGlobal.h"
 #include "gdcmUtil.h"
index 7804b6cfe96f777aef64d863fbf38cb03e084fbf..cae73c898a2b56a68c3760b6aa7fbd3cbc09bce4 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSeqEntry.h,v $
   Language:  C++
-  Date:      $Date: 2005/02/11 15:22:18 $
-  Version:   $Revision: 1.34 $
+  Date:      $Date: 2005/10/18 08:35:50 $
+  Version:   $Revision: 1.35 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -31,7 +31,7 @@ typedef std::list<SQItem *> ListSQItem;
 
 //-----------------------------------------------------------------------------
 /**
- * \brief a SeqEntry (as opposed to a ValEntry) is a non elementary DocEntry.
+ * \brief a SeqEntry (as opposed to a DataEntry) is a non elementary DocEntry.
  *        It is composed by a set of SQItems.
  *        Each SQItem is composed by a set of DocEntry
  *        A DocEntry may be a SeqEntry
index d90e68c5c88190353a3103237d1a5cc1607a7409..f62883e9c08f4f5b6c67428e41bb0222a47c941b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSerieHelper.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/17 15:45:38 $
-  Version:   $Revision: 1.23 $
+  Date:      $Date: 2005/10/18 08:35:50 $
+  Version:   $Revision: 1.24 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -106,7 +106,7 @@ void SerieHelper::AddFileName(std::string const &filename)
           ++it2)
       {
          const ExRule &r = *it2;
-         s = header->GetEntryValue( r.group, r.elem );
+         s = header->GetEntryString( r.group, r.elem );
          if ( !Util::CompareDicomString(s, r.value.c_str(), r.op) )
          {
            // Argh ! This rule is unmatched; let's just quit
@@ -121,7 +121,7 @@ void SerieHelper::AddFileName(std::string const &filename)
          // Let's add it!
 
          // 0020 000e UI REL Series Instance UID
-         const std::string &uid = header->GetEntryValue (0x0020, 0x000e);
+         const std::string &uid = header->GetEntryString(0x0020, 0x000e);
          // if uid == GDCM_UNFOUND then consistently we should find GDCM_UNFOUND
          // no need here to do anything special
 
@@ -486,11 +486,11 @@ XCoherentFileSetmap SerieHelper::SplitOnPosition(FileList *fileSet)
       // 0020,0032 : Image Position Patient
       // 0020,0030 : Image Position (RET)
 
-      strImPos = (*it)->GetEntryValue(0x0020,0x0032);
+      strImPos = (*it)->GetEntryString(0x0020,0x0032);
       if ( strImPos == GDCM_UNFOUND)
       {
          gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
-         strImPos = (*it)->GetEntryValue(0x0020,0x0030); // For ACR-NEMA images
+         strImPos = (*it)->GetEntryString(0x0020,0x0030); // For ACR-NEMA images
          if ( strImPos == GDCM_UNFOUND )
          {
             gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
@@ -559,7 +559,7 @@ XCoherentFileSetmap SerieHelper::SplitOnTagValue(FileList *fileSet,
       // 0020,0032 : Image Position Patient
       // 0020,0030 : Image Position (RET)
 
-      strTagValue = (*it)->GetEntryValue(group,element);
+      strTagValue = (*it)->GetEntryString(group,element);
       
       if ( CoherentFileSet.count(strTagValue) == 0 )
       {
@@ -569,7 +569,7 @@ XCoherentFileSetmap SerieHelper::SplitOnTagValue(FileList *fileSet,
       }
       // Current Tag value and DICOM header match; add the file:
       CoherentFileSet[strTagValue]->push_back( (*it) );
-   }   
+   }
    return CoherentFileSet;
 }
 
index 5c06e5abd03e49c6d0a99c1099d0aba388c77319..b1feafb049e249ddbb5b5969838dcf61dc9231f6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/06 18:49:30 $
-  Version:   $Revision: 1.164 $
+  Date:      $Date: 2005/10/18 08:35:50 $
+  Version:   $Revision: 1.165 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -186,7 +186,7 @@ int Util::CountSubstring (const std::string &str,
  */
 bool Util::IsCleanString(std::string const &s)
 {
-  std::cout<< std::endl << s << std::endl;
+   std::cout<< std::endl << s << std::endl;
    for(unsigned int i=0; i<s.size(); i++)
    {
       //std::cout<< std::endl << i << " : " << (unsigned char)s[i] << std::endl;
@@ -195,7 +195,7 @@ bool Util::IsCleanString(std::string const &s)
          return false;
       }
    }
-return true;   
+   return true;   
 }
 
 /**
index 592f8b025a90b777e45a644fc127b59e3ed746b1..9f9287167eab2f726d548b74c4c56c64e31cfd4b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.h,v $
   Language:  C++
-  Date:      $Date: 2005/08/25 14:55:47 $
-  Version:   $Revision: 1.62 $
+  Date:      $Date: 2005/10/18 08:35:51 $
+  Version:   $Revision: 1.63 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -41,7 +41,7 @@ public:
                                 std::vector<std::string> &tokens,
                                 const std::string &delimiters = " ");
    static int         CountSubstring (const std::string &str,
-                                      const std::string &subStr);       
+                                      const std::string &subStr);
 
    static std::string CreateCleanString(std::string const &s);
    static std::string CreateCleanString(uint8_t *s, int l);
index 57b9301614d4d17d3c013eb8665406f0c4d812de..77bbf2313bea542f05c03e027f7fcb9587f2307e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmVR.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/09/07 14:12:23 $
-  Version:   $Revision: 1.40 $
+  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
@@ -85,7 +85,7 @@ VR::~VR()
 
 /**
  * \brief   Simple predicate that checks whether the given argument
- *          corresponds to the Value Representation of a \ref BinEntry .
+ *          corresponds to the Value Representation of a \ref DataEntry .
  * @param   tested value representation to check for.
  */
 bool VR::IsVROfBinaryRepresentable(VRKey const &tested)
@@ -108,14 +108,12 @@ bool VR::IsVROfBinaryRepresentable(VRKey const &tested)
 
 /**
  * \brief   Simple predicate that checks whether the given argument
- *          corresponds to the Value Representation of a \ref ValEntry
- *          but NOT a \ref BinEntry.
+ *          corresponds to the Value Representation of a representable
+ *          string.
  * @param   tested value representation to be checked.
  */
 bool VR::IsVROfStringRepresentable(VRKey const &tested)
 {
-
-
    return tested == "AE" ||
           tested == "AS" ||
           tested == "CS" ||
@@ -146,6 +144,26 @@ bool VR::IsVROfStringRepresentable(VRKey const &tested)
 */
 }
 
+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;
+}
+
 //-----------------------------------------------------------------------------
 // Protected
 
index 118ad3d8bdec874378ecd5f17424de3007696da9..9b74d4869ea605221433720f428ad99eed445f65 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmVR.h,v $
   Language:  C++
-  Date:      $Date: 2005/09/06 15:36:03 $
-  Version:   $Revision: 1.19 $
+  Date:      $Date: 2005/10/18 08:35:51 $
+  Version:   $Revision: 1.20 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -58,6 +58,8 @@ public:
 
    bool IsValidVR(VRKey const &key) { return vr.find(key) != vr.end(); }
 
+   unsigned short GetAtomicElementLength(VRKey const &vr);
+
 private:
    VRHT vr;
 };
diff --git a/src/gdcmValEntry.cxx b/src/gdcmValEntry.cxx
deleted file mode 100644 (file)
index 671e6bd..0000000
+++ /dev/null
@@ -1,306 +0,0 @@
-/*=========================================================================
-                                                                                
-  Program:   gdcm
-  Module:    $RCSfile: gdcmValEntry.cxx,v $
-  Language:  C++
-  Date:      $Date: 2005/07/05 14:55:24 $
-  Version:   $Revision: 1.63 $
-                                                                                
-  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 "gdcmValEntry.h"
-#include "gdcmVR.h"
-#include "gdcmTS.h"
-#include "gdcmGlobal.h"
-#include "gdcmUtil.h"
-#include "gdcmDebug.h"
-#include "gdcmDocument.h"
-
-#include <fstream>
-#include <ctype.h>  // for isdigit
-#include <stdlib.h> // for atoi
-
-namespace gdcm 
-{
-//-----------------------------------------------------------------------------
-#define MAX_SIZE_PRINT_ELEMENT_VALUE 0x7fffffff
-uint32_t ValEntry::MaxSizePrintEntry = MAX_SIZE_PRINT_ELEMENT_VALUE;
-//-----------------------------------------------------------------------------
-// Constructor / Destructor
-/**
- * \brief   Constructor from a given DictEntry
- * @param   e Pointer to existing dictionary entry
- */
-ValEntry::ValEntry(DictEntry *e) 
-        : ContentEntry(e)
-{
-}
-
-/**
- * \brief   Constructor from a given DocEntry
- * @param   e Pointer to existing Doc entry
- */
-ValEntry::ValEntry(DocEntry *e)
-        : ContentEntry(e->GetDictEntry())
-{
-   Copy(e);
-}
-
-/**
- * \brief   Canonical destructor.
- */
-ValEntry::~ValEntry ()
-{
-}
-
-//-----------------------------------------------------------------------------
-// Public
-/**
- * \brief   Writes the std::string representable' value of a ValEntry
- * @param fp already open ofstream pointer
- * @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
- */
-void ValEntry::WriteContent(std::ofstream *fp, FileType filetype)
-{
-   DocEntry::WriteContent(fp, filetype);
-
-   if ( GetGroup() == 0xfffe )
-   {
-      return; //delimitors have NO value
-   }
-
-   const VRKey &vr = GetVR();
-   unsigned int lgth = GetLength();
-   if (vr == "US" || vr == "SS")
-   {
-      // some 'Short integer' fields may be multivaluated
-      // each single value is separated from the next one by '\'
-      // we split the string and write each value as a short int
-      std::vector<std::string> tokens;
-      tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
-      Util::Tokenize (GetValue(), tokens, "\\");
-      for (unsigned int i=0; i<tokens.size();i++)
-      {
-         uint16_t val_uint16 = atoi(tokens[i].c_str());
-         binary_write( *fp, val_uint16);
-      }
-      tokens.clear();
-      return;
-   }
-   if (vr == "UL" || vr == "SL")
-   {
-      // Some 'Integer' fields may be multivaluated (multiple instances 
-      // of integer). But each single integer value is separated from the
-      // next one by '\' (backslash character). Hence we split the string
-      // along the '\' and write each value as an int:
-      std::vector<std::string> tokens;
-      tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
-      Util::Tokenize (GetValue(), tokens, "\\");
-      for (unsigned int i=0; i<tokens.size();i++)
-      {
-         uint32_t val_uint32 = atoi(tokens[i].c_str());
-         binary_write( *fp, val_uint32);
-      }
-      tokens.clear();
-      return;
-   } 
-
-   gdcmAssertMacro( lgth == GetValue().length() );
-   binary_write(*fp, GetValue());
-} 
-
-
-/**
- * \brief Header Elements too long will not be printed
- * @param newSize new size
- */ 
-void ValEntry::SetMaxSizePrintEntry(long newSize) 
-{
-   if ( newSize < 0 )
-   {
-      return;
-   }
-   if ((uint32_t)newSize >= (uint32_t)0xffffffff )
-   {
-      ValEntry::MaxSizePrintEntry = 0xffffffff;
-      return;
-   }
-   ValEntry::MaxSizePrintEntry = newSize;
-}
-
-
-/**
- * \brief   Sets the std::string representable' value of a ValEntry
- * @param  val value to set 
- */
-void ValEntry::SetValue(std::string const &val)
-{
-   // Integers have a special treatement for their length:
-   int l = val.length();
-   if ( l != 0) // To avoid to be cheated by 'zero length' integers
-   {   
-      const VRKey &vr = GetVR();
-      if ( vr == "US" || vr == "SS" )
-      {
-         // for multivaluated items
-         l = (Util::CountSubstring(val, "\\") + 1) * 2;
-         ContentEntry::SetValue(val);
-      }
-      else if ( vr == "UL" || vr == "SL" )
-      {
-         // for multivaluated items
-         l = (Util::CountSubstring(val, "\\") + 1) * 4;;
-         ContentEntry::SetValue(val);
-      }
-      else
-      {
-         std::string finalVal = Util::DicomString( val.c_str() );
-         gdcmAssertMacro( !(finalVal.size() % 2) );
-
-         l = finalVal.length();
-         ContentEntry::SetValue(finalVal);
-      }
-   }
-   else
-   {
-      std::string finalVal = Util::DicomString( val.c_str() );
-      gdcmAssertMacro( !(finalVal.size() % 2) );
-
-      l = finalVal.length();
-      ContentEntry::SetValue(finalVal);
-   }
-
-   SetLength(l);
-}
-
-//-----------------------------------------------------------------------------
-// Protected
-
-//-----------------------------------------------------------------------------
-// Private
-
-//-----------------------------------------------------------------------------
-// Print
-/**
- * \brief   Prints the 'std::string representable' value of ValEntry
- * @param   os ostream we want to print in
- * @param indent Indentation string to be prepended during printing
- */
-void ValEntry::Print(std::ostream &os, std::string const &)
-{
-   uint16_t g = GetGroup();
-   uint16_t e = GetElement();
-   VRKey vr   = GetVR();
-   std::ostringstream s; 
-   std::string st;
-   std::string d2;
-     
-   os << "V ";
-   DocEntry::Print(os); 
-
-   if (g == 0xfffe) // delimiters have NO value
-   {
-      // just to avoid identing all the remaining code     
-      return;
-   }
-   
-   TS *ts = Global::GetTS();
-    
-   TSAtr v  = GetValue();     
-   d2 = Util::CreateCleanString(v);  // replace non printable characters by '.'            
-   if ( (long)GetLength() <= ValEntry::GetMaxSizePrintEntry()
-    || PrintLevel >= 3
-    || d2.find(GDCM_NOTLOADED) < d2.length() )
-   {
-      s << " [" << d2 << "]";
-   }
-   else
-   {
-      s << " [gdcm::too long for print (" << GetLength() << ") ]";
-   }
-   
-   // Display the UID value (instead of displaying only the rough code)
-   // First 'clean' trailing character (space or zero) 
-   if (g == 0x0002)
-   {
-      // Any more to be displayed ?
-      if ( e == 0x0010 || e == 0x0002 )
-      {
-         if ( v.length() != 0 )  // for brain damaged headers
-         {
-            if ( ! isdigit((unsigned char)v[v.length()-1]) )
-            {
-               v.erase(v.length()-1, 1);
-            }
-         }
-         s << "  ==>\t[" << ts->GetValue(v) << "]";
-      }
-   }
-   else
-   {
-      if (g == 0x0008)
-      {
-         if ( e == 0x0016 || e == 0x1150 )
-         {
-            if ( v.length() != 0 )  // for brain damaged headers
-            {
-               if ( ! isdigit((unsigned char)v[v.length()-1]) )
-               {
-                  v.erase(v.length()-1, 1);
-               }
-            }
-            s << "  ==>\t[" << ts->GetValue(v) << "]";
-         }
-      }
-      else
-      {
-         if (g == 0x0004)
-         {
-            if ( e == 0x1510 || e == 0x1512  )
-            {
-               if ( v.length() != 0 )  // for brain damaged headers  
-               {
-                  if ( ! isdigit((unsigned char)v[v.length()-1]) )
-                  {
-                     v.erase(v.length()-1, 1);  
-                  }
-               }
-              s << "  ==>\t[" << ts->GetValue(v) << "]";
-            }
-         }     
-      }
-   }
-   //if (e == 0x0000) {        // elem 0x0000 --> group length 
-   if ( vr == "UL" || vr == "US" || vr == "SL" || vr == "SS" )
-   {
-      if (v == "4294967295") // to avoid troubles in convertion 
-      {
-         st = "ffffffff";
-      }
-      else
-      {
-         if ( GetLength() != 0 )
-         {
-            st = Util::Format(" x(%x)", atoi(v.c_str()));//FIXME
-         }
-         else
-         {
-            st = " ";
-         }
-      }
-      s << st;
-   }
-   os << s.str();
-}
-
-//-----------------------------------------------------------------------------
-} // end namespace gdcm
-
diff --git a/src/gdcmValEntry.h b/src/gdcmValEntry.h
deleted file mode 100644 (file)
index d5c5203..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*=========================================================================
-                                                                                
-  Program:   gdcm
-  Module:    $RCSfile: gdcmValEntry.h,v $
-  Language:  C++
-  Date:      $Date: 2005/09/02 07:10:03 $
-  Version:   $Revision: 1.42 $
-                                                                                
-  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 GDCMVALENTRY_H
-#define GDCMVALENTRY_H
-
-#include "gdcmDocEntry.h"
-#include "gdcmContentEntry.h"
-
-#include <iostream>
-
-namespace gdcm 
-{
-//-----------------------------------------------------------------------------
-/**
- * \brief   Any Dicom Document (File or DicomDir) contains 
- *           a set of DocEntry  - Dicom entries -
- *          ValEntry is an elementary DocEntry (i.e. a ContentEntry, 
- *           as opposed to SeqEntry)
- *          whose content is 'std::string representable' : characters,
- *          or integers (loaded in memory as a std::string)
- *          ValEntry is a specialisation of ContentEntry
- */
-class GDCM_EXPORT ValEntry  : public ContentEntry
-{
-public:
-
-   // Contructors and Destructor are public.
-   ValEntry(DictEntry *e);
-   ValEntry(DocEntry *d); 
-
-   ~ValEntry();
-
-   // Other accessors are inherited from gdcm::ContentEntry
-
-   void Print(std::ostream &os = std::cout, std::string const &indent = ""); 
-
-   void WriteContent(std::ofstream *fp, FileType filetype); 
-   
-   /// Sets the value (string) of the current Dicom entry.
-   /// The size is updated
-   void SetValue(std::string const &val);
-
-
-   /// \brief returns the size threshold above which an element value 
-   ///        will NOT be *printed* in order no to polute the screen output
-   static long GetMaxSizePrintEntry() { return ValEntry::MaxSizePrintEntry; }
-
-   static void SetMaxSizePrintEntry(long);
-
-protected:
-   
-private:
-
-   /// \brief Size threshold above which an element val
-   ///        By default, this upper bound is fixed to 64 bytes.
-
-   static uint32_t MaxSizePrintEntry;   
-
-};
-
-} // end namespace gdcm
-
-//-----------------------------------------------------------------------------
-#endif
-
index c62079f121911fc4aa85c3d1940f08468068cac9..f4cac4767a216a777d4bd81057a53564541876d8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmValidator.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/06/24 10:55:59 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2005/10/18 08:35:51 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -18,8 +18,7 @@
 
 #include "gdcmValidator.h"
 #include "gdcmElementSet.h"
-#include "gdcmBinEntry.h"
-#include "gdcmValEntry.h"
+#include "gdcmDataEntry.h"
 
 #include <sstream>
 
@@ -34,11 +33,11 @@ Validator::~Validator()
 {
 }
 
-// Function to compare the VM found while parsing d->GetValue()
+// Function to compare the VM found while parsing d->GetString()
 // compare to the one from the dictionary
-bool CheckVM(ValEntry *v)
+bool CheckVM(DataEntry *entry)
 {
-  const std::string &s = v->GetValue();
+  const std::string &s = entry->GetString();
   std::string::size_type n = s.find("\\");
   if ( n == s.npos ) // none found
   {
@@ -48,7 +47,7 @@ bool CheckVM(ValEntry *v)
 
   unsigned int m;
   std::istringstream os;
-  os.str( v->GetVM());
+  os.str( entry->GetVM());
   os >> m;
 
   return n == m;
@@ -57,22 +56,15 @@ bool CheckVM(ValEntry *v)
 void Validator::SetInput(ElementSet *input)
 {
   // berk for now SetInput do two things at the same time
-  gdcm::DocEntry *d=input->GetFirstEntry();
+  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 ( DataEntry *v = dynamic_cast<DataEntry *>(d) )
     {   
       if ( !CheckVM(v) )
       {
         std::cout << "Rah this DICOM contains one wrong tag:" << 
-        v->GetValue() << " " <<
+        v->GetString() << " " <<
         v->GetGroup() << "," << v->GetElement() << "," <<
         v->GetVR() << " " << v->GetVM() << " " << v->GetName() << std::endl;
       }
index 4cf4db2da9252039a05365a1567748ce12c6180d..e5b3b5197109396c6b1db3db5a2be67d0172b542 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcmWriter.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/22 12:23:26 $
-  Version:   $Revision: 1.24 $
+  Date:      $Date: 2005/10/18 08:35:55 $
+  Version:   $Revision: 1.25 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -31,7 +31,7 @@
 #define vtkFloatingPointType float
 #endif
 
-vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.24 $")
+vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.25 $")
 vtkStandardNewMacro(vtkGdcmWriter)
 
 //-----------------------------------------------------------------------------
@@ -137,29 +137,29 @@ void SetImageInformation(gdcm::FileHelper *file, vtkImageData *image)
 
    str.str("");
    str << dim[0];
-   file->InsertValEntry(str.str(),0x0028,0x0011); // Columns
+   file->InsertEntryString(str.str(),0x0028,0x0011); // Columns
 
    str.str("");
    str << dim[1];
-   file->InsertValEntry(str.str(),0x0028,0x0010); // Rows
+   file->InsertEntryString(str.str(),0x0028,0x0010); // Rows
 
    if(dim[2]>1)
    {
       str.str("");
       str << dim[2];
       //file->Insert(str.str(),0x0028,0x0012); // Planes
-      file->InsertValEntry(str.str(),0x0028,0x0008); // Number of Frames
+      file->InsertEntryString(str.str(),0x0028,0x0008); // Number of Frames
    }
 
    // Pixel type
    str.str("");
    str << image->GetScalarSize()*8;
-   file->InsertValEntry(str.str(),0x0028,0x0100); // Bits Allocated
-   file->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored
+   file->InsertEntryString(str.str(),0x0028,0x0100); // Bits Allocated
+   file->InsertEntryString(str.str(),0x0028,0x0101); // Bits Stored
 
    str.str("");
    str << image->GetScalarSize()*8-1;
-   file->InsertValEntry(str.str(),0x0028,0x0102); // High Bit
+   file->InsertEntryString(str.str(),0x0028,0x0102); // High Bit
 
    // Pixel Repr
    // FIXME : what do we do when the ScalarType is 
@@ -176,12 +176,12 @@ void SetImageInformation(gdcm::FileHelper *file, vtkImageData *image)
    {
       str << "1"; // Signed
    }
-   file->InsertValEntry(str.str(),0x0028,0x0103); // Pixel Representation
+   file->InsertEntryString(str.str(),0x0028,0x0103); // Pixel Representation
 
    // Samples per pixel
    str.str("");
    str << image->GetNumberOfScalarComponents();
-   file->InsertValEntry(str.str(),0x0028,0x0002); // Samples per Pixel
+   file->InsertEntryString(str.str(),0x0028,0x0002); // Samples per Pixel
 
    /// \todo : Spacing Between Slices is meaningfull ONLY for CT an MR modality
    ///       We should perform some checkings before forcing the Entry creation
@@ -195,10 +195,10 @@ void SetImageInformation(gdcm::FileHelper *file, vtkImageData *image)
    // thus forcing to fixed point value
    str.setf( std::ios::fixed );
    str << sp[1] << "\\" << sp[0];
-   file->InsertValEntry(str.str(),0x0028,0x0030); // Pixel Spacing
+   file->InsertEntryString(str.str(),0x0028,0x0030); // Pixel Spacing
    str.str("");
    str << sp[2];
-   file->InsertValEntry(str.str(),0x0018,0x0088); // Spacing Between Slices
+   file->InsertEntryString(str.str(),0x0018,0x0088); // Spacing Between Slices
 
    // Origin
    vtkFloatingPointType *org = image->GetOrigin();
@@ -208,7 +208,7 @@ void SetImageInformation(gdcm::FileHelper *file, vtkImageData *image)
 
    str.str("");
    str << org[0] << "\\" << org[1] << "\\" << org[2];
-   file->InsertValEntry(str.str(),0x0020,0x0032); // Image Position Patient
+   file->InsertEntryString(str.str(),0x0020,0x0032); // Image Position Patient
    str.unsetf( std::ios::fixed ); //done with floating point values
 
    // Window / Level
@@ -216,10 +216,10 @@ void SetImageInformation(gdcm::FileHelper *file, vtkImageData *image)
 
    str.str("");
    str << rng[1]-rng[0];
-   file->InsertValEntry(str.str(),0x0028,0x1051); // Window Width
+   file->InsertEntryString(str.str(),0x0028,0x1051); // Window Width
    str.str("");
    str << (rng[1]+rng[0])/2.0;
-   file->InsertValEntry(str.str(),0x0028,0x1050); // Window Center
+   file->InsertEntryString(str.str(),0x0028,0x1050); // Window Center
 
    // Pixels
    unsigned char *data;
index fbf81e162e1adfae99e6c0b577fb667efa8d3a8c..a7b0b1019ac4017b4e2f8fb4abc43f1631acfa85 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkgdcmSerieViewer.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/09/07 08:21:28 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2005/10/18 08:35:55 $
+  Version:   $Revision: 1.12 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -43,7 +43,7 @@
 #include "gdcmDocument.h"  // for NO_SHADOWSEQ
 #include "gdcmSerieHelper.h"
 #include "gdcmDebug.h"
-#include "gdcmValEntry.h"
+#include "gdcmDataEntry.h"
 
 #include "gdcmArgMgr.h" // for Argument Manager functions
 #include <string.h>     // for strcmp
@@ -453,17 +453,17 @@ bool userSuppliedLessThanFunction(gdcm::File *f1, gdcm::File *f2)
    // for *this* user supplied function, I supposed only ValEntries are checked.
 // 
    std::string s1, s2;
-   gdcm::ValEntry *e1,*e2;
+   gdcm::DataEntry *e1,*e2;
    for (int ri=0; ri<orderNb; ri++)
    {
       std::cout << std::hex << elemsToOrderOn[2*ri] << "|" 
                             << elemsToOrderOn[2*ri+1]
                             << std::endl;
  
-      e1= f1->gdcm::Document::GetValEntry( elemsToOrderOn[2*ri],
+      e1= f1->gdcm::Document::GetDataEntry( elemsToOrderOn[2*ri],
                                  elemsToOrderOn[2*ri+1]);
 
-      e2= f2->gdcm::Document::GetValEntry( elemsToOrderOn[2*ri],
+      e2= f2->gdcm::Document::GetDataEntry( elemsToOrderOn[2*ri],
                                  elemsToOrderOn[2*ri+1]);
       if(!e2 || !e2)
       {
@@ -472,8 +472,8 @@ bool userSuppliedLessThanFunction(gdcm::File *f1, gdcm::File *f2)
                               << " not found" << std::endl;
          continue;
       }
-      s1 = e1->gdcm::ValEntry::GetValue();      
-      s2 = e2->gdcm::ValEntry::GetValue();
+      s1 = e1->GetString();      
+      s2 = e2->GetString();
       std::cout << "[" << s1 << "] vs [" << s2 << "]" << std::endl;
       if ( s1 < s2 ) 
          return true;