]> Creatis software - gdcm.git/commitdiff
* src/ : rename some methods on Entry (SetXxx, InsertXxx) to have a better
authorregrain <regrain>
Tue, 25 Jan 2005 15:44:21 +0000 (15:44 +0000)
committerregrain <regrain>
Tue, 25 Jan 2005 15:44:21 +0000 (15:44 +0000)
     use with python. Some methods ard moved from Document to ElementSet or
     DocEntrySet. The equivalent methods to ElementSet have been added to
     SQItem and are virtual in DocEntrySet. Methods that may have the same code
     in SQItem and ElementSet is directly placed in DocEntrySet
   -- BeNours

28 files changed:
ChangeLog
Example/BuildUpDicomDir.cxx
Example/FindTags.cxx
Example/TestChangeHeader.cxx
Example/TestCopyDicom.cxx
Example/TestFromScratch.cxx
Example/TestPapyrus.cxx
Example/WriteDicom.cxx
Example/WriteDicomSimple.cxx
Testing/TestCopyDicom.cxx
Testing/TestCopyRescaleDicom.cxx
Testing/TestWriteSimple.cxx
src/gdcmDicomDir.cxx
src/gdcmDicomDirPatient.cxx
src/gdcmDicomDirSerie.cxx
src/gdcmDicomDirStudy.cxx
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/gdcmSQItem.cxx
src/gdcmSQItem.h
vtk/vtkGdcmWriter.cxx

index c094101df828645c77cde09e70e4acc587930df2..0c86fcfcc655426d4c4664b1cc51db50aee14e06 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2005-01-25 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
-   * Test/VTKTest*.cxx : remove the show variable in each test method because 
+   * src/ : rename some methods on Entry (SetXxx, InsertXxx) to have a better
+     use with python. Some methods ard moved from Document to ElementSet or
+     DocEntrySet. The equivalent methods to ElementSet have been added to 
+     SQItem and are virtual in DocEntrySet. Methods that may have the same code
+     in SQItem and ElementSet is directly placed in DocEntrySet
+
+2005-01-25 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+   * Test/VTKTest*.cxx : remove the show variable in each test method because
      it's useless (the viewer variable replace this variable)
 
 2005-01-25 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
index a56fa9f8ab66a7ac01fe03f5422336609bf9f044..6de2f2023dc06ae0dca2ace1a647a853d057a206 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: BuildUpDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:10:49 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2005/01/25 15:44:22 $
+  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
@@ -50,25 +50,25 @@ int main(int argc, char* argv[])
    ((gdcm::Document *)dcmdir)->Print();
 
    gdcm::DicomDirPatient *p1=dcmdir->NewPatient();
-   p1->SetEntryValue("patientONE",0x0010, 0x0010);
+   p1->SetValEntry("patientONE",0x0010, 0x0010);
 
      
    gdcm::DicomDirPatient *p2=dcmdir->NewPatient();
-   p2->SetEntryValue("patientTWO",0x0010, 0x0010);     
+   p2->SetValEntry("patientTWO",0x0010, 0x0010);     
    gdcm::DicomDirStudy *s21=p2->NewStudy();  
-       s21->SetEntryValue("StudyDescrTwo.One",0x0008, 0x1030);        
+       s21->SetValEntry("StudyDescrTwo.One",0x0008, 0x1030);        
    gdcm::DicomDirSerie *s211=s21->NewSerie();   
    gdcm::DicomDirImage *s2111=s211->NewImage();
    (void)s2111; //not used
 
    gdcm::DicomDirStudy *s11=p1->NewStudy();  
-   s11->SetEntryValue("StudyDescrOne.One",0x0008, 0x1030);
+   s11->SetValEntry("StudyDescrOne.One",0x0008, 0x1030);
    // Name of the physician reading study
    // Header Entry to be created
-   s11->SetEntryValue("Dr Mabuse",0x0008, 0x1060);
+   s11->SetValEntry("Dr Mabuse",0x0008, 0x1060);
 
    gdcm::DicomDirPatient *p3 = dcmdir->NewPatient();
-   p3->SetEntryValue("patientTHREE",0x0010, 0x0010);
+   p3->SetValEntry("patientTHREE",0x0010, 0x0010);
 
    std::cout << "\n------- BuildUpDicomDir: Test Print of Patient ONE -----\n";
    p1->Print();
index 705a881093a466624053d0473089fbe958226bc1..38d4b2e4ef238fa7f681d76dcb241a3f467e495f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: FindTags.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:10:49 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2005/01/25 15:44:22 $
+  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
@@ -47,14 +47,14 @@ int main(int argc, char* argv[])
    int dataSize = f1->GetImageDataSize();
    std::cout << "---> pourFindTaggs : dataSize " << dataSize << std::endl;
 
-   f1->SetEntryValue(RecCode ,0x0008,0x0010);
-   f1->SetEntryValue(ManufacturerName ,0x0008,0x0070);
+   f1->SetValEntry(RecCode ,0x0008,0x0010);
+   f1->SetValEntry(ManufacturerName ,0x0008,0x0070);
 
 // ImagePositionPatient
    ImagePositionPatient = f1->GetFile()->GetEntryValue(0x0020,0x0032);
 
 // Image Position (RET)
-   f1->SetEntryValue(ImagePositionPatient, 0x0020,0x0030);
+   f1->SetValEntry(ImagePositionPatient, 0x0020,0x0030);
 
    sscanf(ImagePositionPatient.c_str(), "%f%c%f%c%f", &x,&c,&y,&c,&z);
 
@@ -70,7 +70,7 @@ int main(int argc, char* argv[])
 // Location
    std::string zizi = gdcm::Util::Format("%f",l);
    Location = gdcm::Util::DicomString(zizi.c_str());
-   f1->SetEntryValue(Location, 0x0020,0x0050);
+   f1->SetValEntry(Location, 0x0020,0x0050);
 
 // sinon, la longueur du champ est erronĂ©e (?!?) 
 // Probable sac de noeud entre strlen(xxx.c_str()) et xxx.length()
@@ -85,7 +85,7 @@ int main(int argc, char* argv[])
 
    zizi = gdcm::Util::Format("%d",0x7FE0);
    ImageLocation = gdcm::Util::DicomString(zizi.c_str());
-//f1->SetEntryValue(Location, 0x0028,0x0200);
+//f1->SetValEntry(Location, 0x0028,0x0200);
 //f1->GetFile()->SetEntryLength(strlen(ImageLocation.c_str())-1, 0x0020,0x0050); // prudence !
 
 // void* imageData= f1->GetImageData();
index 89073f51e87fcf8228feb3bb07bdfde2bc29b6f2..b8de5e276a62fe60d1ec0f780ac0ab049e0c5bf4 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestChangeHeader.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:44:53 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2005/01/25 15:44:22 $
+  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
@@ -44,7 +44,7 @@ int main(int argc, char* argv[])
     if(matrix != "gdcm::Unfound")
     {
        std::cerr << "Aquisition Matrix:" << matrix << std::endl;
-       f1->GetFile()->Insert( matrix, 0x0018, 0x1310);
+       f1->GetFile()->InsertValEntry( matrix, 0x0018, 0x1310);
     }
 
     f1->GetImageData();
index 37005844279a0d24147f1e743704dfce9b822667..8e7a43b2cb00f00ed4ba5fadff92979329385c97 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestCopyDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:44:53 $
-  Version:   $Revision: 1.21 $
+  Date:      $Date: 2005/01/25 15:44:22 $
+  Version:   $Revision: 1.22 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -104,20 +104,15 @@ int main(int argc, char* argv[])
       {
          if ( gdcm::BinEntry* b = dynamic_cast<gdcm::BinEntry*>(d) )
          {              
-            copy->GetFile()->Insert( 
-                                 b->GetBinArea(),
-                                 b->GetLength(),
-                                 b->GetGroup(), 
-                                 b->GetElement(),
-                                 b->GetVR() );
+            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()->Insert( 
-                                 v->GetValue(),
-                                 v->GetGroup(), 
-                                 v->GetElement(),
-                                 v->GetVR() ); 
+            copy->GetFile()->InsertValEntry( v->GetValue(),
+                                             v->GetGroup(),v->GetElement(),
+                                             v->GetVR() ); 
          }
          else
          {
index 29099d77772e0f072eaa176283fad74cf8dc314f..d47f638d216bed4aa21288f9338a91507a96846f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestFromScratch.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:44:53 $
-  Version:   $Revision: 1.13 $
+  Date:      $Date: 2005/01/25 15:44:22 $
+  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
@@ -62,10 +62,9 @@ int main(int argc, char *argv[])
          // Do not bother with field from private dict
          if( v->GetName() != "gdcm::Unknown" )
          {  
-            h2->Insert( v->GetValue(),
-                        v->GetGroup(), 
-                        v->GetElement(),
-                        v->GetVR() ); 
+            h2->InsertValEntry( v->GetValue(),
+                                v->GetGroup(),v->GetElement(),
+                                v->GetVR() ); 
          }
       }
       //else
index e0b5dd1330f005cb1db271b15558b6c07ff2406f..d82083b02e805cc7293fe178f7a269ed5451b29d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestPapyrus.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:44:53 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2005/01/25 15:44:22 $
+  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
@@ -231,23 +231,23 @@ int main(int argc, char* argv[])
    gdcm::File *n = new gdcm::File();
    n->InitializeDefaultFile();
 
-   n->Insert(MediaStSOPinstUID,  0x0002,0x0002);
+   n->InsertValEntry(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->Insert(TransferSyntax,     0x0002,0x0010);
-   n->Insert(StudyDate,          0x0008,0x0020);
-   n->Insert(StudyTime,          0x0008,0x0030);
-   n->Insert(Modality,           0x0008,0x0060);
-   n->Insert(PatientName,        0x0010,0x0010);
-
-   n->Insert(SamplesPerPixel,    0x0028,0x0002);
-   n->Insert(NumberOfFrames,     0x0028,0x0008);
-   n->Insert(Rows,               0x0028,0x0010);
-   n->Insert(Columns,            0x0028,0x0011);
-   n->Insert(BitsAllocated,      0x0028,0x0100);
-   n->Insert(BitsStored,         0x0028,0x0101);
-   n->Insert(HighBit,            0x0028,0x0102);
-   n->Insert(PixelRepresentation,0x0028,0x0102);
+   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,0x0102);
 
    // create the file
    gdcm::FileHelper *file = new gdcm::FileHelper(n);
index 50ee73574ecbf2298e18e4a2d31166e73f75a3b9..e450f33f0689307afbc75561dc2353682d72af40 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: WriteDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:44:53 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2005/01/25 15:44:22 $
+  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
@@ -41,12 +41,12 @@ int main(int argc, char* argv[])
  
    std::string nbFrames = f2->GetFile()->GetEntryValue(0x0028, 0x0008);
    if(nbFrames != "gdcm::Unfound") {
-       f1->GetFile()->Insert( nbFrames, 0x0028, 0x0008);
+       f1->GetFile()->InsertValEntry( nbFrames, 0x0028, 0x0008);
    }
           
-   f1->GetFile()->Insert(
+   f1->GetFile()->InsertValEntry(
      f2->GetFile()->GetEntryValue(0x0028, 0x0010), 0x0028, 0x0010); // nbLig
-   f1->GetFile()->Insert( 
+   f1->GetFile()->InsertValEntry
      f2->GetFile()->GetEntryValue(0x0028, 0x0011), 0x0028, 0x0011); // nbCol
  
    // Some other tags should be updated:
index 78b94565943deae0d043f992f0f9d5b2da8c4c3c..f5b4e273d29058f53daa67f706be7d19c4634459 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: WriteDicomSimple.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:44:53 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2005/01/25 15:44:22 $
+  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
@@ -63,39 +63,39 @@ int main(int argc, char* argv[])
    // Set the image size
    str.str("");
    str << SIZE_X;
-   header->Insert(str.str(),0x0028,0x0011); // Columns
+   header->InsertValEntry(str.str(),0x0028,0x0011); // Columns
 
    str.str("");
    str << SIZE_Y;
-   header->Insert(str.str(),0x0028,0x0010); // Rows
+   header->InsertValEntry(str.str(),0x0028,0x0010); // Rows
 
    // Set the pixel type
    str.str("");
    str << COMPONENT_SIZE * 8;
-   header->Insert(str.str(),0x0028,0x0100); // Bits Allocated
-   header->Insert(str.str(),0x0028,0x0101); // Bits Stored
+   header->InsertValEntry(str.str(),0x0028,0x0100); // Bits Allocated
+   header->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored
 
    str.str("");
    str << COMPONENT_SIZE * 8 - 1;
-   header->Insert(str.str(),0x0028,0x0102); // High Bit
+   header->InsertValEntry(str.str(),0x0028,0x0102); // High Bit
 
    // Set the pixel representation
    str.str("");
    str << "0"; // Unsigned
-   header->Insert(str.str(),0x0028,0x0103); // Pixel Representation
+   header->InsertValEntry(str.str(),0x0028,0x0103); // Pixel Representation
 
    // Set the samples per pixel
    str.str("");
    str << COMPONENT;
-   header->Insert(str.str(),0x0028,0x0002); // Samples per Pixel
+   header->InsertValEntry(str.str(),0x0028,0x0002); // Samples per Pixel
 
    // Set the Window / Level
    str.str("");
    str << COLOR_WINDOW;
-   header->Insert(str.str(),0x0028,0x1051); // Window Width
+   header->InsertValEntry(str.str(),0x0028,0x1051); // Window Width
    str.str("");
    str << COLOR_LEVEL;
-   header->Insert(str.str(),0x0028,0x1050); // Window Center
+   header->InsertValEntry(str.str(),0x0028,0x1050); // Window Center
 
    if( !header->IsReadable() )
    {
index 7d0b74b969051afa34a873be5665ef237a3326e0..1dfd328ead71784d6260dd3eca6435664edfd1cf 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestCopyDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:44:54 $
-  Version:   $Revision: 1.35 $
+  Date:      $Date: 2005/01/25 15:44:22 $
+  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
@@ -83,18 +83,15 @@ int CopyDicom(std::string const & filename,
       {
          if ( gdcm::BinEntry* b = dynamic_cast<gdcm::BinEntry*>(d) )
          {
-            copyH->Insert( b->GetBinArea(),
-                           b->GetLength(),
-                           b->GetGroup(), 
-                           b->GetElement(),
-                           b->GetVR() );
+            copyH->InsertBinEntry( b->GetBinArea(),b->GetLength(),
+                                   b->GetGroup(),b->GetElement(),
+                                   b->GetVR() );
          }
          else if ( gdcm::ValEntry* v = dynamic_cast<gdcm::ValEntry*>(d) )
          {   
-             copyH->Insert( v->GetValue(),
-                            v->GetGroup(), 
-                            v->GetElement(),
-                            v->GetVR() ); 
+             copyH->InsertValEntry( v->GetValue(),
+                                    v->GetGroup(),v->GetElement(),
+                                    v->GetVR() ); 
          }
          else
          {
index eaff8b4c891e5678c8118a40243e90d0d98758df..3400ec8668760ded239002150cd7ded6e3d748df 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestCopyRescaleDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:44:54 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2005/01/25 15:44:22 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -56,20 +56,15 @@ int CopyRescaleDicom(std::string const & filename,
    {
       if ( gdcm::BinEntry* b = dynamic_cast<gdcm::BinEntry*>(d) )
       {
-         copyH->Insert( 
-                              b->GetBinArea(),
-                              b->GetLength(),
-                              b->GetGroup(), 
-                              b->GetElement(),
-                              b->GetVR() );
+         copyH->InsertBinEntry( b->GetBinArea(),b->GetLength(),
+                                b->GetGroup(),b->GetElement(),
+                                b->GetVR() );
       }
       else if ( gdcm::ValEntry* v = dynamic_cast<gdcm::ValEntry*>(d) )
       {   
-          copyH->Insert( 
-                              v->GetValue(),
-                              v->GetGroup(), 
-                              v->GetElement(),
-                              v->GetVR() ); 
+          copyH->InsertValEntry( v->GetValue(),
+                                 v->GetGroup(),v->GetElement(),
+                                 v->GetVR() ); 
       }
       else
       {
@@ -91,10 +86,10 @@ int CopyRescaleDicom(std::string const & filename,
    if( bitsStored == "16" )
    {
       std::cout << "Rescale...";
-      copyH->Insert( "8", 0x0028, 0x0100); // BitsAllocated
-      copyH->Insert( "8", 0x0028, 0x0101); // BitsStored
-      copyH->Insert( "7", 0x0028, 0x0102); // HighBit
-      copyH->Insert( "0", 0x0028, 0x0103); //Pixel Representation
+      copyH->InsertValEntry( "8", 0x0028, 0x0100); // BitsAllocated
+      copyH->InsertValEntry( "8", 0x0028, 0x0101); // BitsStored
+      copyH->InsertValEntry( "7", 0x0028, 0x0102); // HighBit
+      copyH->InsertValEntry( "0", 0x0028, 0x0103); //Pixel Representation
  
       // We assume the value were from 0 to uint16_t max
       rescaleSize = dataSize / 2;
index 23076f16af32452a70e5fe805eac59eaf6284747..af00b7c57af0f8804cbb3daa4322bd20a6a596ff 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestWriteSimple.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 15:29:33 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2005/01/25 15:44:23 $
+  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
@@ -78,41 +78,41 @@ int WriteSimple(Image &img)
    // Set the image size
    str.str("");
    str << img.sizeX;
-   header->Insert(str.str(),0x0028,0x0011); // Columns
+   header->InsertValEntry(str.str(),0x0028,0x0011); // Columns
 
    str.str("");
    str << img.sizeY;
-   header->Insert(str.str(),0x0028,0x0010); // Rows
+   header->InsertValEntry(str.str(),0x0028,0x0010); // Rows
 
    if(img.sizeZ>1)
    {
       str.str("");
       str << img.sizeZ;
-      header->Insert(str.str(),0x0028,0x0008); // Number of Frames
+      header->InsertValEntry(str.str(),0x0028,0x0008); // Number of Frames
    }
 
    // Set the pixel type
    str.str("");
    str << img.componentSize;
-   header->Insert(str.str(),0x0028,0x0100); // Bits Allocated
+   header->InsertValEntry(str.str(),0x0028,0x0100); // Bits Allocated
 
    str.str("");
    str << img.componentUse;
-   header->Insert(str.str(),0x0028,0x0101); // Bits Stored
+   header->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored
 
    str.str("");
    str << img.componentSize - 1;
-   header->Insert(str.str(),0x0028,0x0102); // High Bit
+   header->InsertValEntry(str.str(),0x0028,0x0102); // High Bit
 
    // Set the pixel representation
    str.str("");
    str << img.sign;
-   header->Insert(str.str(),0x0028,0x0103); // Pixel Representation
+   header->InsertValEntry(str.str(),0x0028,0x0103); // Pixel Representation
 
    // Set the samples per pixel
    str.str("");
    str << img.components;
-   header->Insert(str.str(),0x0028,0x0002); // Samples per Pixel
+   header->InsertValEntry(str.str(),0x0028,0x0002); // Samples per Pixel
 
    if( !header->IsReadable() )
    {
index 01fb17ce6fa768436f8cd2f2ba75037f424f6459..97d1f3dec03d6e7b2a80e8b695b216e62da6c81e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 11:11:58 $
-  Version:   $Revision: 1.117 $
+  Date:      $Date: 2005/01/25 15:44:23 $
+  Version:   $Revision: 1.118 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -331,11 +331,10 @@ DicomDirPatient *DicomDir::GetFirstPatient()
 DicomDirPatient *DicomDir::GetNextPatient()
 {
    gdcmAssertMacro (ItPatient != Patients.end());
-   {
-      ++ItPatient;
-      if ( ItPatient != Patients.end() )
-         return *ItPatient;
-   }
+
+   ++ItPatient;
+   if ( ItPatient != Patients.end() )
+      return *ItPatient;
    return NULL;
 }
 
index 9a339e21f4ed7b59afea54045f30e40a638d4e44..72081cf3a763f166569d9caa664ba97d9eb039fe 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirPatient.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 11:11:58 $
-  Version:   $Revision: 1.32 $
+  Date:      $Date: 2005/01/25 15:44:23 $
+  Version:   $Revision: 1.33 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -135,11 +135,10 @@ DicomDirStudy *DicomDirPatient::GetFirstStudy()
 DicomDirStudy *DicomDirPatient::GetNextStudy()
 {
    gdcmAssertMacro (ItStudy != Studies.end())
-   {
-      ++ItStudy;
-      if (ItStudy != Studies.end())
-         return *ItStudy;
-   }
+
+   ++ItStudy;
+   if (ItStudy != Studies.end())
+      return *ItStudy;
    return NULL;
 }
 
index a03c64800f76bcff2b74821fc417933e0c82ff8e..3678c9a1b2b266aeca1e18640ae2bc634b4bfc30 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirSerie.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 11:11:58 $
-  Version:   $Revision: 1.34 $
+  Date:      $Date: 2005/01/25 15:44:23 $
+  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
@@ -134,11 +134,10 @@ DicomDirImage *DicomDirSerie::GetFirstImage()
 DicomDirImage *DicomDirSerie::GetNextImage()
 {
    gdcmAssertMacro (ItImage != Images.end());
-   {
-      ++ItImage;
-      if (ItImage != Images.end())      
-         return *ItImage;
-   }
+
+   ++ItImage;
+   if (ItImage != Images.end())      
+      return *ItImage;
    return NULL;
 }
  
index 058879eec7b5786f32e60c76a0c5d5536a62c9df..8975dabdb0d4b825e69296f6aa358bba45aa75d4 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirStudy.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 11:11:58 $
-  Version:   $Revision: 1.31 $
+  Date:      $Date: 2005/01/25 15:44:23 $
+  Version:   $Revision: 1.32 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -135,11 +135,10 @@ DicomDirSerie *DicomDirStudy::GetFirstSerie()
 DicomDirSerie *DicomDirStudy::GetNextSerie()
 {
    gdcmAssertMacro (ItSerie != Series.end());
-   {
-      ++ItSerie;
-      if (ItSerie != Series.end())
-         return *ItSerie;
-   }
+
+   ++ItSerie;
+   if (ItSerie != Series.end())
+      return *ItSerie;
    return NULL;
 }  
 
index f9c74ec0270d886100ee43ef3d66b21e9bd19bcf..3ff3e607828479f313df832dad81e3381f1cbb8a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntrySet.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 14:14:11 $
-  Version:   $Revision: 1.44 $
+  Date:      $Date: 2005/01/25 15:44:23 $
+  Version:   $Revision: 1.45 $
                                                                                 
   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,394 @@ namespace gdcm
 
 //-----------------------------------------------------------------------------
 // Public
+/**
+ * \brief   Get the (std::string representable) value of the Dicom entry
+ * @param   group  Group number of the searched tag.
+ * @param   elem Element number of the searched tag.
+ * @return  Corresponding element value when it exists,
+ *          and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
+ */
+std::string DocEntrySet::GetEntryValue(uint16_t group, uint16_t elem)
+{
+   ValEntry *entry = GetValEntry(group,elem);
+   if( entry )
+      return entry->GetValue();
+   return GDCM_UNFOUND;
+}
+
+/**
+ * \brief   Gets (from Header) a 'non string' element value 
+ *          (LoadElementValues has already be executed)  
+ * @param group   group number of the Entry 
+ * @param elem  element number of the Entry
+ * @return Pointer to the 'non string' area
+ */
+void *DocEntrySet::GetEntryBinArea(uint16_t group, uint16_t elem) 
+{
+   BinEntry *entry = GetBinEntry(group,elem);
+   if( entry )
+      return entry->GetBinArea();
+   return 0;
+}
+
+/**
+ * \brief   Searches within Header Entries (Dicom Elements) parsed with 
+ *          the public and private dictionaries 
+ *          for the value length of a given tag..
+ * @param   group  Group number of the searched tag.
+ * @param   elem Element number of the searched tag.
+ * @return  Corresponding element length; -2 if not found
+ */
+int DocEntrySet::GetEntryLength(uint16_t group, uint16_t elem)
+{
+   DocEntry *entry = GetDocEntry(group,elem);
+   if( entry )
+      return entry->GetLength();
+   return -1;
+}
+
+/**
+ * \brief   Searches within Header Entries (Dicom Elements) parsed with 
+ *          the public and private dictionaries 
+ *          for the element value representation of a given tag..
+ *          Obtaining the VR (Value Representation) might be needed by caller
+ *          to convert the string typed content to caller's native type 
+ *          (think of C++ vs Python). The VR is actually of a higher level
+ *          of semantics than just the native C++ type.
+ * @param   group  Group number of the searched tag.
+ * @param   elem Element number of the searched tag.
+ * @return  Corresponding element value representation when it exists,
+ *          and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
+ */
+std::string DocEntrySet::GetEntryVR(uint16_t group, uint16_t elem)
+{
+   DocEntry *entry = GetDocEntry(group,elem);
+   if( entry )
+      return entry->GetVR();
+   return GDCM_UNFOUND;
+}
+
+/**
+ * \brief  Same as \ref Document::GetDocEntry except it only
+ *         returns a result when the corresponding entry is of type
+ *         ValEntry.
+ * @param   group  Group number of the searched Dicom Element 
+ * @param   elem Element number of the searched Dicom Element  
+ * @return When present, the corresponding ValEntry. 
+ */
+ValEntry *DocEntrySet::GetValEntry(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 )
+      return NULL;
+
+   return dynamic_cast<BinEntry*>(currentEntry);
+}
+
+/**
+ * \brief  Same as \ref Document::GetDocEntry except it only
+ *         returns a result when the corresponding entry is of type
+ *         SeqEntry.
+ * @param   group  Group number of the searched Dicom Element 
+ * @param   elem Element number of the searched Dicom Element  
+ * @return When present, the corresponding SeqEntry. 
+ */
+SeqEntry *DocEntrySet::GetSeqEntry(uint16_t group, uint16_t elem)
+{
+   DocEntry *currentEntry = GetDocEntry(group, elem);
+   if ( !currentEntry )
+      return NULL;
+
+   return dynamic_cast<SeqEntry*>(currentEntry);
+}
+
+/**
+ * \brief   Accesses an existing DocEntry (i.e. a Dicom Element)
+ *          through it's (group, element) and modifies it's content with
+ *          the given value.
+ * @param   content new value (string) to substitute with
+ * @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) 
+{
+   ValEntry *entry = GetValEntry(group, elem);
+   if (!entry )
+   {
+      gdcmVerboseMacro( "No corresponding ValEntry (try promotion first).");
+      return false;
+   }
+   return SetValEntry(content,entry);
+}
+
+/**
+ * \brief   Accesses an existing DocEntry (i.e. a Dicom Element)
+ *          through it's (group, element) and modifies it's content with
+ *          the given value.
+ * @param   content new value (void*  -> uint8_t*) to substitute with
+ * @param   lgth new value length
+ * @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) 
+{
+   BinEntry *entry = GetBinEntry(group, elem);
+   if (!entry )
+   {
+      gdcmVerboseMacro( "No corresponding ValEntry (try promotion first).");
+      return false;
+   }
+
+   return SetBinEntry(content,lgth,entry);
+} 
+
+/**
+ * \brief   Accesses an existing DocEntry (i.e. a Dicom Element)
+ *          and modifies it's content with the given value.
+ * @param  content new value (string) to substitute with
+ * @param  entry Entry to be modified
+ */
+bool DocEntrySet::SetValEntry(std::string const &content, ValEntry *entry)
+{
+   if(entry)
+   {
+      entry->SetValue(content);
+      return true;
+   }
+   return false;
+}
+
+/**
+ * \brief   Accesses an existing BinEntry (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)
+{
+   if(entry)
+   {
+      entry->SetBinArea(content);  
+      entry->SetLength(lgth);
+      entry->SetValue(GDCM_BINLOADED);
+      return true;
+   }
+   return false;
+}
+
+/**
+ * \brief   Modifies the value of a given Doc Entry (Dicom Element)
+ *          when it exists. Create it with the given value when unexistant.
+ * @param   value (string) Value to be set
+ * @param   group   Group number of the Entry 
+ * @param   elem  Element number of the Entry
+ * @param   vr  V(alue) R(epresentation) of the Entry -if private 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 )
+{
+   ValEntry *valEntry = 0;
+   DocEntry *currentEntry = GetDocEntry( group, elem);
+   
+   if (currentEntry)
+   {
+      valEntry = dynamic_cast<ValEntry *>(currentEntry);
 
+      // Verify the VR
+      if( valEntry )
+         if( valEntry->GetVR()!=vr )
+            valEntry = NULL;
+
+      // if currentEntry doesn't correspond to the requested valEntry
+      if( !valEntry)
+      {
+         if( !RemoveEntry(currentEntry) )
+         {
+            gdcmVerboseMacro( "Removal of previous DocEntry failed.");
+
+            return NULL;
+         }
+      }
+   }
+
+   // Create a new valEntry if necessary
+   if( !valEntry )
+   {
+      valEntry = NewValEntry(group, elem, vr);
+
+      if ( !AddEntry(valEntry) )
+      {
+         gdcmVerboseMacro("AddEntry failed although this is a creation.");
+
+         delete valEntry;
+         return NULL;
+      }
+   }
+
+   // Set the binEntry value
+   SetValEntry(value, valEntry); // The std::string value
+   return valEntry;
+}
+
+/*
+ * \brief   Modifies the value of a given Header Entry (Dicom Element)
+ *          when it exists. Create it with the given value when unexistant.
+ *          A copy of the binArea is made to be kept in the Document.
+ * @param   binArea (binary) value to be set
+ * @param   group   Group number of the Entry 
+ * @param   elem  Element number of the Entry
+ * @param   vr  V(alue) R(epresentation) of the Entry -if private Entry-
+ * \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 )
+{
+   BinEntry *binEntry = 0;
+   DocEntry *currentEntry = GetDocEntry( group, elem);
+
+   // Verify the currentEntry
+   if (currentEntry)
+   {
+      binEntry = dynamic_cast<BinEntry *>(currentEntry);
+
+      // Verify the VR
+      if( binEntry )
+         if( binEntry->GetVR()!=vr )
+            binEntry = NULL;
+
+      // if currentEntry doesn't correspond to the requested valEntry
+      if( !binEntry)
+      {
+         if( !RemoveEntry(currentEntry) )
+         {
+            gdcmVerboseMacro( "Removal of previous DocEntry failed.");
+
+            return NULL;
+         }
+      }
+   }
+
+   // Create a new binEntry if necessary
+   if( !binEntry)
+   {
+      binEntry = NewBinEntry(group, elem, vr);
+
+      if ( !AddEntry(binEntry) )
+      {
+         gdcmVerboseMacro( "AddEntry failed allthough this is a creation.");
+
+         delete binEntry;
+         return NULL;
+      }
+   }
+
+   // Set the binEntry value
+   uint8_t *tmpArea;
+   if( lgth>0 && binArea )
+   {
+      tmpArea = new uint8_t[lgth];
+      memcpy(tmpArea,binArea,lgth);
+   }
+   else
+   {
+      tmpArea = 0;
+   }
+   if( !SetBinEntry(tmpArea,lgth,binEntry) )
+   {
+      if( tmpArea )
+      {
+         delete[] tmpArea;
+      }
+   }
+
+   return binEntry;
+}  
+
+/*
+ * \brief   Modifies the value of a given Header Entry (Dicom Element)
+ *          when it exists. Creates it when unexistant.
+ * @param   group   Group number of the Entry 
+ * @param   elem  Element number of the Entry
+ * \return  pointer to the modified/created SeqEntry (NULL when creation
+ *          failed).
+ */
+SeqEntry *DocEntrySet::InsertSeqEntry(uint16_t group, uint16_t elem)
+{
+   SeqEntry *seqEntry = 0;
+   DocEntry *currentEntry = GetDocEntry( group, elem);
+
+   // Verify the currentEntry
+   if( currentEntry )
+   {
+      seqEntry = dynamic_cast<SeqEntry *>(currentEntry);
+
+      // Verify the VR
+      if( seqEntry )
+         if( seqEntry->GetVR()!="SQ" )
+            seqEntry = NULL;
+
+      // if currentEntry doesn't correspond to the requested valEntry
+      if( !seqEntry )
+      {
+         if (!RemoveEntry(currentEntry))
+         {
+            gdcmVerboseMacro( "Removal of previous DocEntry failed.");
+
+            return NULL;
+         }
+      }
+   }
+   // Create a new seqEntry if necessary
+   if( !seqEntry )
+   {
+      seqEntry = NewSeqEntry(group, elem);
+
+      if( !AddEntry(seqEntry) )
+      {
+         gdcmVerboseMacro( "AddEntry failed allthough this is a creation.");
+
+         delete seqEntry;
+         return NULL;
+      }
+   }
+   return seqEntry;
+} 
+/**
+ * \brief   Checks if a given Dicom Element exists within the H table
+ * @param   group   Group number of the searched Dicom Element 
+ * @param   elem  Element number of the searched Dicom Element 
+ * @return true is found
+ */
+bool DocEntrySet::CheckIfEntryExist(uint16_t group, uint16_t elem )
+{
+   return GetDocEntry(group,elem)!=NULL;
+}
 
 /**
  * \brief   Request a new virtual dict entry to the dict set
@@ -187,11 +574,8 @@ DictEntry *DocEntrySet::GetDictEntry(uint16_t group, uint16_t elem,
    return goodEntry;
 }
 
-
-
 //-----------------------------------------------------------------------------
 // Private
 
-} // end namespace gdcm
-
 //-----------------------------------------------------------------------------
+} // end namespace gdcm
index e1b94f2a483fbd06f13429615131d819f31335bb..df5c2fd4a0ec0aed45ca9f8047c6df0a394dab72 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntrySet.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 11:11:58 $
-  Version:   $Revision: 1.43 $
+  Date:      $Date: 2005/01/25 15:44:23 $
+  Version:   $Revision: 1.44 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -62,55 +62,60 @@ public:
    DocEntrySet() {};
    virtual ~DocEntrySet() {};
 
-   // ------- '... =0;' stands for 'Pure Virtual'
+   /// \brief write any type of entry to the entry set
+   virtual void WriteContent (std::ofstream *fp, FileType filetype) = 0;
 
    /// \brief Remove all Entry in the entry set
    virtual void ClearEntry() = 0;
-
    /// \brief adds any type of entry to the entry set
    virtual bool AddEntry(DocEntry *Entry) = 0;
-
    /// \brief Removes any type of entry out of the entry set, and destroys it
    virtual bool RemoveEntry(DocEntry *EntryToRemove)=0;
-
    /// \brief Removes any type of entry out of the entry set, DOESN'T destroy it
    virtual bool RemoveEntryNoDestroy(DocEntry *EntryToRemove)= 0;
 
-   /// \brief write any type of entry to the entry set
-   virtual void WriteContent (std::ofstream *fp, 
-                              FileType filetype) = 0;
+   virtual DocEntry *GetFirstEntry()=0;
+   virtual DocEntry *GetNextEntry()=0;
 
-   /// \brief Gets any type of DocEntry, identified by its (group,elem)
-   virtual DocEntry *GetDocEntry(uint16_t group,
-                                 uint16_t elem) = 0;
+   virtual std::string GetEntryValue(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);
 
+   /// \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)
-   virtual ValEntry *GetValEntry(uint16_t group,
-                                 uint16_t elem) = 0;
+   virtual ValEntry *GetValEntry(uint16_t group,uint16_t elem);
    /// \brief Gets a BinEntry, identified by its (group,elem)
-   virtual BinEntry *GetBinEntry(uint16_t group,
-                                 uint16_t elem) = 0;
-
+   virtual BinEntry *GetBinEntry(uint16_t group,uint16_t elem);
    /// \brief Gets a SeqEntry, identified by its (group,elem)
-   virtual SeqEntry *GetSeqEntry(uint16_t group,
-                                 uint16_t elem) = 0;
-
-   /// \brief Gets the 'string value' of a ValEntry
-   ///        identified by its (group,elem) - Sorry for the name !...-
-   virtual std::string GetEntryValue(uint16_t group, uint16_t elem) = 0;
-
-   virtual DocEntry *GetFirstEntry()=0;
-   virtual DocEntry *GetNextEntry()=0;
-
-   DictEntry *NewVirtualDictEntry(uint16_t group, 
-                                  uint16_t elem,
+   virtual SeqEntry *GetSeqEntry(uint16_t group,uint16_t elem);
+
+   virtual bool SetValEntry(std::string const &content,
+                            uint16_t group, uint16_t elem);
+   virtual bool SetBinEntry(uint8_t *content, int lgth,
+                            uint16_t group, uint16_t elem);
+   virtual bool SetValEntry(std::string const &content, ValEntry *entry);
+   virtual bool SetBinEntry(uint8_t *content, int lgth, BinEntry *entry);
+
+   virtual ValEntry *InsertValEntry(std::string const &value,
+                                    uint16_t group, uint16_t elem,
+                                    TagName const &vr = GDCM_UNKNOWN);
+   virtual BinEntry *InsertBinEntry(uint8_t *binArea, int lgth,
+                                    uint16_t group, uint16_t elem,
+                                    TagName const &vr = GDCM_UNKNOWN);
+   virtual SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
+
+   virtual bool IsEmpty() = 0;
+   virtual bool CheckIfEntryExist(uint16_t group, uint16_t elem);
+
+   DictEntry *NewVirtualDictEntry(uint16_t group,uint16_t elem,
                                   TagName const &vr     = GDCM_UNKNOWN,
                                   TagName const &vm     = GDCM_UNKNOWN,
                                   TagName const &name   = GDCM_UNKNOWN );
 
 protected:
 // DocEntry  related utilities 
-
    ValEntry *NewValEntry(uint16_t group,uint16_t elem,
                          TagName const &vr = GDCM_UNKNOWN);
    BinEntry *NewBinEntry(uint16_t group,uint16_t elem,
index ca217bb74dc53e982e816c67172fdcfd572156f3..fcf5c2907f8eea675782437ac0bca88153ac2b7c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 11:25:33 $
-  Version:   $Revision: 1.209 $
+  Date:      $Date: 2005/01/25 15:44:23 $
+  Version:   $Revision: 1.210 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -149,8 +149,8 @@ Document::Document( std::string const &filename ) : ElementSet(-1)
          Filetype = ACR_LIBIDO; 
          std::string rows    = GetEntryValue(0x0028, 0x0010);
          std::string columns = GetEntryValue(0x0028, 0x0011);
-         SetEntryValue(columns, 0x0028, 0x0010);
-         SetEntryValue(rows   , 0x0028, 0x0011);
+         SetValEntry(columns, 0x0028, 0x0010);
+         SetValEntry(rows   , 0x0028, 0x0011);
    }
    // ----------------- End of ACR-LibIDO kludge ------------------ 
 }
@@ -264,7 +264,6 @@ bool Document::IsReadable()
       return false;
    }
 
-   //if( TagHT.empty() )
    if ( IsEmpty() )
    { 
       gdcmVerboseMacro( "No tag in internal hash table.");
@@ -475,358 +474,8 @@ void Document::WriteContent(std::ofstream *fp, FileType filetype)
    ElementSet::WriteContent(fp, filetype); // This one is recursive
 }
 
-/**
- * \brief   Modifies the value of a given Doc Entry (Dicom Element)
- *          when it exists. Create it with the given value when unexistant.
- * @param   value (string) Value to be set
- * @param   group   Group number of the Entry 
- * @param   elem  Element number of the Entry
- * @param   vr  V(alue) R(epresentation) of the Entry -if private Entry-
- * \return  pointer to the modified/created Header Entry (NULL when creation
- *          failed).
- */ 
-ValEntry *Document::Insert(std::string const &value, 
-                                    uint16_t group, 
-                                    uint16_t elem,
-                                    TagName const &vr )
-{
-   ValEntry *valEntry = 0;
-   DocEntry *currentEntry = GetDocEntry( group, elem);
-   
-   if (currentEntry)
-   {
-      valEntry = dynamic_cast< ValEntry* >(currentEntry);
-
-      // Verify the VR
-      if( valEntry )
-         if( valEntry->GetVR()!=vr )
-            valEntry=NULL;
-
-      // if currentEntry doesn't correspond to the requested valEntry
-      if( !valEntry)
-      {
-         if (!RemoveEntry(currentEntry))
-         {
-            gdcmVerboseMacro( "Removal of previous DocEntry failed.");
-
-            return NULL;
-         }
-      }
-   }
-
-   // Create a new valEntry if necessary
-   if (!valEntry)
-   {
-      valEntry = NewValEntry(group, elem, vr);
-
-      if ( !AddEntry(valEntry))
-      {
-         gdcmVerboseMacro("AddEntry failed although this is a creation.");
-
-         delete valEntry;
-         return NULL;
-      }
-   }
-
-   // Set the binEntry value
-   SetEntryValue(value, valEntry); // The std::string value
-   return valEntry;
-}   
-
-/*
- * \brief   Modifies the value of a given Header Entry (Dicom Element)
- *          when it exists. Create it with the given value when unexistant.
- *          A copy of the binArea is made to be kept in the Document.
- * @param   binArea (binary) value to be set
- * @param   group   Group number of the Entry 
- * @param   elem  Element number of the Entry
- * @param   vr  V(alue) R(epresentation) of the Entry -if private Entry-
- * \return  pointer to the modified/created Header Entry (NULL when creation
- *          failed).
- */
-BinEntry *Document::Insert(uint8_t *binArea,
-                                    int lgth, 
-                                    uint16_t group, 
-                                    uint16_t elem,
-                                    TagName const &vr )
-{
-   BinEntry *binEntry = 0;
-   DocEntry *currentEntry = GetDocEntry( group, elem);
-
-   // Verify the currentEntry
-   if (currentEntry)
-   {
-      binEntry = dynamic_cast< BinEntry* >(currentEntry);
-
-      // Verify the VR
-      if( binEntry )
-         if( binEntry->GetVR()!=vr )
-            binEntry=NULL;
-
-      // if currentEntry doesn't correspond to the requested valEntry
-      if( !binEntry)
-      {
-         if (!RemoveEntry(currentEntry))
-         {
-            gdcmVerboseMacro( "Removal of previous DocEntry failed.");
-
-            return NULL;
-         }
-      }
-   }
-
-   // Create a new binEntry if necessary
-   if (!binEntry)
-   {
-      binEntry = NewBinEntry(group, elem, vr);
-
-      if ( !AddEntry(binEntry))
-      {
-         gdcmVerboseMacro( "AddEntry failed allthough this is a creation.");
-
-         delete binEntry;
-         return NULL;
-      }
-   }
-
-   // Set the binEntry value
-   uint8_t *tmpArea;
-   if (lgth>0 && binArea)
-   {
-      tmpArea = new uint8_t[lgth];
-      memcpy(tmpArea,binArea,lgth);
-   }
-   else
-   {
-      tmpArea = 0;
-   }
-   if (!SetEntryBinArea(tmpArea,lgth,binEntry))
-   {
-      if (tmpArea)
-      {
-         delete[] tmpArea;
-      }
-   }
-
-   return binEntry;
-}  
-
-/*
- * \brief   Modifies the value of a given Header Entry (Dicom Element)
- *          when it exists. Creates it when unexistant.
- * @param   group   Group number of the Entry 
- * @param   elem  Element number of the Entry
- * \return  pointer to the modified/created SeqEntry (NULL when creation
- *          failed).
- */
-SeqEntry *Document::Insert( uint16_t group, uint16_t elem)
-{
-   SeqEntry *seqEntry = 0;
-   DocEntry *currentEntry = GetDocEntry( group, elem);
-
-   // Verify the currentEntry
-   if (currentEntry)
-   {
-      seqEntry = dynamic_cast< SeqEntry* >(currentEntry);
-
-      // Verify the VR
-      if( seqEntry )
-         if( seqEntry->GetVR()!="SQ" )
-            seqEntry=NULL;
-
-      // if currentEntry doesn't correspond to the requested valEntry
-      if( !seqEntry)
-      {
-         if (!RemoveEntry(currentEntry))
-         {
-            gdcmVerboseMacro( "Removal of previous DocEntry failed.");
-
-            return NULL;
-         }
-      }
-   }
-   // Create a new seqEntry if necessary
-   if (!seqEntry)
-   {
-      seqEntry = NewSeqEntry(group, elem);
-
-      if ( !AddEntry(seqEntry))
-      {
-         gdcmVerboseMacro( "AddEntry failed allthough this is a creation.");
-
-         delete seqEntry;
-         return NULL;
-      }
-   }
-   return seqEntry;
-} 
-/**
- * \brief Set a new value if the invoked element exists
- *        Seems to be useless !!!
- * @param value new element value
- * @param group  group number of the Entry 
- * @param elem element number of the Entry
- * \return  boolean 
- */
-bool Document::ReplaceIfExist(std::string const &value, 
-                              uint16_t group, uint16_t elem ) 
-{
-   SetEntryValue(value, group, elem);
-
-   return true;
-} 
-
 //-----------------------------------------------------------------------------
 // Protected
-
-/**
- * \brief   Searches within Header Entries (Dicom Elements) parsed with 
- *          the public and private dictionaries 
- *          for the element value representation of a given tag..
- *          Obtaining the VR (Value Representation) might be needed by caller
- *          to convert the string typed content to caller's native type 
- *          (think of C++ vs Python). The VR is actually of a higher level
- *          of semantics than just the native C++ type.
- * @param   group  Group number of the searched tag.
- * @param   elem Element number of the searched tag.
- * @return  Corresponding element value representation when it exists,
- *          and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string Document::GetEntryVR(uint16_t group, uint16_t elem)
-{
-   DocEntry *element = GetDocEntry(group, elem);
-   if ( !element )
-   {
-      return GDCM_UNFOUND;
-   }
-   return element->GetVR();
-}
-
-/**
- * \brief   Searches within Header Entries (Dicom Elements) parsed with 
- *          the public and private dictionaries 
- *          for the value length of a given tag..
- * @param   group  Group number of the searched tag.
- * @param   elem Element number of the searched tag.
- * @return  Corresponding element length; -2 if not found
- */
-int Document::GetEntryLength(uint16_t group, uint16_t elem)
-{
-   DocEntry *element =  GetDocEntry(group, elem);
-   if ( !element )
-   {
-      return -2;  //magic number
-   }
-   return element->GetLength();
-}
-
-/**
- * \brief   Accesses an existing DocEntry (i.e. a Dicom Element)
- *          through it's (group, element) and modifies it's content with
- *          the given value.
- * @param   content new value (string) to substitute with
- * @param   group  group number of the Dicom Element to modify
- * @param   elem element number of the Dicom Element to modify
- */
-bool Document::SetEntryValue(std::string const& content, 
-                        uint16_t group, uint16_t elem) 
-{
-   ValEntry *entry = GetValEntry(group, elem);
-   if (!entry )
-   {
-      gdcmVerboseMacro( "No corresponding ValEntry (try promotion first).");
-      return false;
-   }
-   return SetEntryValue(content,entry);
-} 
-/**
- * \brief   Accesses an existing DocEntry (i.e. a Dicom Element)
- *          through it's (group, element) and modifies it's content with
- *          the given value.
- * @param   content new value (void*  -> uint8_t*) to substitute with
- * @param   lgth new value length
- * @param   group  group number of the Dicom Element to modify
- * @param   elem element number of the Dicom Element to modify
- */
-bool Document::SetEntryBinArea(uint8_t*content, int lgth, 
-                        uint16_t group, uint16_t elem) 
-{
-   BinEntry *entry = GetBinEntry(group, elem);
-   if (!entry )
-   {
-      gdcmVerboseMacro( "No corresponding ValEntry (try promotion first).");
-      return false;
-   }
-
-   return SetEntryBinArea(content,lgth,entry);
-} 
-
-/**
- * \brief   Accesses an existing DocEntry (i.e. a Dicom Element)
- *          and modifies it's content with the given value.
- * @param  content new value (string) to substitute with
- * @param  entry Entry to be modified
- */
-bool Document::SetEntryValue(std::string const &content, ValEntry *entry)
-{
-   if(entry)
-   {
-      entry->SetValue(content);
-      return true;
-   }
-   return false;
-}
-
-/**
- * \brief   Accesses an existing BinEntry (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 Document::SetEntryBinArea(uint8_t *content, int lgth, BinEntry *entry)
-{
-   if(entry)
-   {
-      // Hope Binary field length is *never* wrong    
-      /*if(lgth%2) // Non even length are padded with a space (020H).
-      {  
-         lgth++;
-         //content = content + '\0'; // fing a trick to enlarge a binary field?
-      }*/
-      
-      entry->SetBinArea(content);  
-      entry->SetLength(lgth);
-      entry->SetValue(GDCM_BINLOADED);
-      return true;
-   }
-   return false;
-}
-
-/**
- * \brief   Gets (from Header) a 'non string' element value 
- *          (LoadElementValues has already be executed)  
- * @param group   group number of the Entry 
- * @param elem  element number of the Entry
- * @return Pointer to the 'non string' area
- */
-void *Document::GetEntryBinArea(uint16_t group, uint16_t elem) 
-{
-   DocEntry *entry = GetDocEntry(group, elem);
-   if (!entry) 
-   {
-      gdcmVerboseMacro( "No entry");
-      return 0;
-   }
-   if ( BinEntry *binEntry = dynamic_cast<BinEntry*>(entry) )
-   {
-      return binEntry->GetBinArea();
-   }
-
-   return 0;
-}
-
 /**
  * \brief Loads (from disk) the element content 
  *        when a string is not suitable
index 7082c7554a28f0c5a3b93f244c71831c0bea37bb..4166b318315212890507a498e458598a19f81144 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:44:54 $
-  Version:   $Revision: 1.100 $
+  Date:      $Date: 2005/01/25 15:44:24 $
+  Version:   $Revision: 1.101 $
  
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -88,38 +88,10 @@ public:
 
 // Content entries
 
-// Oops ! Python is gonna cry : 
-// 4 methods with same name and different parameters ...
-// Only C++ is aware!
-
-   virtual bool SetEntryValue(std::string const &content,
-                         uint16_t group, uint16_t elem);
-   virtual bool SetEntryBinArea(uint8_t *content, int lgth,
-                         uint16_t group, uint16_t elem);
-   virtual bool SetEntryValue(std::string const &content, ValEntry *entry);
-   virtual bool SetEntryBinArea(uint8_t *content, int lgth, BinEntry *entry);
-
-   virtual void *GetEntryBinArea(uint16_t group, uint16_t elem);   
-
-   virtual std::string GetEntryVR(uint16_t group, uint16_t elem);
-   virtual int GetEntryLength(uint16_t group, uint16_t elem);
-
-   ValEntry *Insert(std::string const &value,
-                    uint16_t group, uint16_t elem,
-                    TagName const &vr = GDCM_UNKNOWN);
-   BinEntry *Insert(uint8_t *binArea, int lgth,
-                    uint16_t group, uint16_t elem,
-                    TagName const &vr = GDCM_UNKNOWN);
-   SeqEntry *Insert(uint16_t group, uint16_t elem);
-
-   bool ReplaceIfExist(std::string const &value,
-                       uint16_t group, uint16_t elem );
-   
    virtual void LoadEntryBinArea(uint16_t group, uint16_t elem);
    virtual void LoadEntryBinArea(BinEntry *entry);
 
    void LoadDocEntrySafe(DocEntry *entry);
-   /*TagDocEntryHT *BuildFlatHashTable();*/
 
    /// Return the Transfer Syntax as a string
    std::string GetTransferSyntaxName();
index 0b634fa7073d1563a13aa957228d70667ef44671..dbf05c6065215f64dcf39c1dadd5bc4f271ede86 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 11:11:59 $
-  Version:   $Revision: 1.50 $
+  Date:      $Date: 2005/01/25 15:44:24 $
+  Version:   $Revision: 1.51 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -88,124 +88,6 @@ void ElementSet::WriteContent(std::ofstream *fp, FileType filetype)
    } 
 }
 
-/**
- * \brief  retrieves a Dicom Element using (group, element)
- * @param   group  Group number of the searched Dicom Element 
- * @param   elem Element number of the searched Dicom Element 
- * @return  
- */
-DocEntry *ElementSet::GetDocEntry(uint16_t group, uint16_t elem) 
-{
-   TagKey key = DictEntry::TranslateToKey(group, elem);
-   if ( !TagHT.count(key))
-   {
-      return NULL;
-   }
-   return TagHT.find(key)->second;
-}
-
-/**
- * \brief  Same as \ref Document::GetDocEntry except it only
- *         returns a result when the corresponding entry is of type
- *         ValEntry.
- * @param   group  Group number of the searched Dicom Element 
- * @param   elem Element number of the searched Dicom Element  
- * @return When present, the corresponding ValEntry. 
- */
-ValEntry *ElementSet::GetValEntry(uint16_t group, uint16_t elem)
-{
-   DocEntry *currentEntry = GetDocEntry(group, elem);
-   if ( !currentEntry )
-   {
-      return 0;
-   }
-   if ( ValEntry *entry = dynamic_cast<ValEntry*>(currentEntry) )
-   {
-      return entry;
-   }
-   gdcmVerboseMacro( "Unfound ValEntry.");
-
-   return 0;
-}
-
-/**
- * \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 *ElementSet::GetBinEntry(uint16_t group, uint16_t elem)
-{
-   DocEntry *currentEntry = GetDocEntry(group, elem);
-   if ( !currentEntry )
-   {
-      return 0;
-   }
-   if ( BinEntry *entry = dynamic_cast<BinEntry*>(currentEntry) )
-   {
-      return entry;
-   }
-   gdcmVerboseMacro( "Unfound BinEntry.");
-
-   return 0;
-}
-
-/**
- * \brief  Same as \ref Document::GetDocEntry except it only
- *         returns a result when the corresponding entry is of type
- *         SeqEntry.
- * @param   group  Group number of the searched Dicom Element 
- * @param   elem Element number of the searched Dicom Element  
- * @return When present, the corresponding SeqEntry. 
- */
-SeqEntry *ElementSet::GetSeqEntry(uint16_t group, uint16_t elem)
-{
-   DocEntry *currentEntry = GetDocEntry(group, elem);
-   if ( !currentEntry )
-   {
-      return 0;
-   }
-   if ( SeqEntry *entry = dynamic_cast<SeqEntry*>(currentEntry) )
-   {
-      return entry;
-   }
-   gdcmVerboseMacro( "Unfound SeqEntry.");
-
-   return 0;
-}
-
-/**
- * \brief   Checks if a given Dicom Element exists within the H table
- * @param   group   Group number of the searched Dicom Element 
- * @param   elem  Element number of the searched Dicom Element 
- * @return true is found
- */
-bool ElementSet::CheckIfEntryExist(uint16_t group, uint16_t elem )
-{
-   const std::string &key = DictEntry::TranslateToKey(group, elem );
-   return TagHT.count(key) != 0;
-}
-
-/**
- * \brief   Get the (std::string representable) value of the Dicom entry
- * @param   group  Group number of the searched tag.
- * @param   elem Element number of the searched tag.
- * @return  Corresponding element value when it exists,
- *          and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string ElementSet::GetEntryValue(uint16_t group, uint16_t elem)
-{
-   TagKey key = DictEntry::TranslateToKey(group, elem);
-   if ( !TagHT.count(key))
-   {
-      return GDCM_UNFOUND;
-   }
-
-   return ((ValEntry *)TagHT.find(key)->second)->GetValue();
-}
-
 /**
  * \brief   delete all entries in the ElementSet
  */
@@ -306,29 +188,18 @@ DocEntry *ElementSet::GetNextEntry()
 }
 
 /**
- * \brief   Get the larst entry while visiting the DocEntrySet
- * \return  The last DocEntry if found, otherwhise NULL
- */
-DocEntry *ElementSet::GetLastEntry()
-{
-   ItTagHT = TagHT.end();
-   if ( ItTagHT != TagHT.begin() )
-      return  ItTagHT->second;
-   return NULL;
-}
-
-/**
- * \brief   Get the previous entry while visiting the Hash table (TagHT)
- * \note : meaningfull only if GetFirstEntry already called 
- * \return  The previous DocEntry if found, otherwhise NULL
+ * \brief  retrieves a Dicom Element using (group, element)
+ * @param   group  Group number of the searched Dicom Element 
+ * @param   elem Element number of the searched Dicom Element 
+ * @return  
  */
-DocEntry *ElementSet::GetPreviousEntry()
+DocEntry *ElementSet::GetDocEntry(uint16_t group, uint16_t elem) 
 {
-   gdcmAssertMacro (ItTagHT != TagHT.begin());
+   TagKey key = DictEntry::TranslateToKey(group, elem);
+   TagDocEntryHT::iterator it = TagHT.find(key);
 
-   --ItTagHT;
-   if (ItTagHT != TagHT.begin())
-      return  ItTagHT->second;
+   if ( it!=TagHT.end() )
+      return it->second;
    return NULL;
 }
 
index 0f6e5d500bdf656aa5d382a287373cb826f0b658..20b56c53578290a9f5543c1aa791d4ba1cdd7557 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 11:11:59 $
-  Version:   $Revision: 1.37 $
+  Date:      $Date: 2005/01/25 15:44:24 $
+  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
@@ -49,32 +49,19 @@ public:
 
    virtual void Print(std::ostream &os = std::cout, std::string const &indent = "" ); 
 
+   void WriteContent(std::ofstream *fp, FileType filetype); 
+
    void ClearEntry();
    bool AddEntry(DocEntry *Entry);
    bool RemoveEntry(DocEntry *EntryToRemove);
    bool RemoveEntryNoDestroy(DocEntry *EntryToRemove);
    
-   void WriteContent(std::ofstream *fp, FileType filetype); 
-
    DocEntry *GetFirstEntry();
    DocEntry *GetNextEntry();
-   DocEntry *GetLastEntry();
-   DocEntry *GetPreviousEntry();
 
    DocEntry *GetDocEntry(uint16_t group, uint16_t elem);
-   ValEntry *GetValEntry(uint16_t group, uint16_t elem);
-   BinEntry *GetBinEntry(uint16_t group, uint16_t elem);
-   SeqEntry *GetSeqEntry(uint16_t group, uint16_t elem);
 
    bool IsEmpty() { return TagHT.empty(); };
-   bool CheckIfEntryExist(uint16_t group, uint16_t elem);
-
-   std::string GetEntryValue(uint16_t group, uint16_t elem);
-   int GetEntryLength(uint16_t group, uint16_t elem);
-   std::string GetEntryVR(uint16_t group, uint16_t elem);
-
-   bool SetEntryValue(std::string const& content, 
-                      uint16_t group, uint16_t elem);
 
 protected:
 
index 9e6788e6dc945d4df6e31f1448831cd955cd3e1d..17e4a80acc2099687a9720bf6555b3c09e1f61c1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:44:54 $
-  Version:   $Revision: 1.199 $
+  Date:      $Date: 2005/01/25 15:44:24 $
+  Version:   $Revision: 1.200 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -140,7 +140,7 @@ bool File::Write(std::string fileName, FileType filetype)
    // Bits Allocated
    if ( GetEntryValue(0x0028,0x0100) ==  "12")
    {
-      SetEntryValue("16", 0x0028,0x0100);
+      SetValEntry("16", 0x0028,0x0100);
    }
 
   /// \todo correct 'Pixel group' Length if necessary
@@ -151,7 +151,7 @@ bool File::Write(std::string fileName, FileType filetype)
       // no (GrPixel, NumPixel) element
       std::string s_lgPix = Util::Format("%d", i_lgPix+12);
       s_lgPix = Util::DicomString( s_lgPix.c_str() );
-      Insert(s_lgPix,GrPixel, 0x0000);
+      InsertValEntry(s_lgPix,GrPixel, 0x0000);
    }
 
    // FIXME : should be nice if we could move it to File
@@ -1209,9 +1209,9 @@ int File::GetLUTNbits()
 bool File::AnonymizeFile()
 {
    // If exist, replace by spaces
-   SetEntryValue ("  ",0x0010, 0x2154); // Telephone   
-   SetEntryValue ("  ",0x0010, 0x1040); // Adress
-   SetEntryValue ("  ",0x0010, 0x0020); // Patient ID
+   SetValEntry ("  ",0x0010, 0x2154); // Telephone   
+   SetValEntry ("  ",0x0010, 0x1040); // Adress
+   SetValEntry ("  ",0x0010, 0x0020); // Patient ID
 
    DocEntry* patientNameHE = GetDocEntry (0x0010, 0x0010);
   
@@ -1220,11 +1220,11 @@ bool File::AnonymizeFile()
       std::string studyInstanceUID =  GetEntryValue (0x0020, 0x000d);
       if ( studyInstanceUID != GDCM_UNFOUND )
       {
-         Insert(studyInstanceUID, 0x0010, 0x0010);
+         InsertValEntry(studyInstanceUID, 0x0010, 0x0010);
       }
       else
       {
-         Insert("anonymised", 0x0010, 0x0010);
+         InsertValEntry("anonymised", 0x0010, 0x0010);
       }
    }
 
@@ -1380,14 +1380,14 @@ void File::InitializeDefaultFile()
    // Special case this is the image (not a string)
    GrPixel = 0x7fe0;
    NumPixel = 0x0010;
-   Insert(0, 0, GrPixel, NumPixel);
+   InsertBinEntry(0, 0, GrPixel, NumPixel);
 
    // All remaining strings:
    unsigned int i = 0;
    DICOM_DEFAULT_VALUE current = defaultvalue[i];
    while( current.value )
    {
-      Insert(current.value, current.group, current.elem);
+      InsertValEntry(current.value, current.group, current.elem);
       current = defaultvalue[++i];
    }
 }
index 9d30a55d4bdeeedad3fde43672b22f05fba8325b..9d8e8f440499036f1e16f7e360de94c91641962a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFileHelper.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 15:21:20 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2005/01/25 15:44:24 $
+  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
@@ -532,10 +532,10 @@ bool FileHelper::Write(std::string const &fileName)
  * @param   group  group number of the Dicom Element to modify
  * @param   elem element number of the Dicom Element to modify
  */
-bool FileHelper::SetEntryValue(std::string const &content,
+bool FileHelper::SetValEntry(std::string const &content,
                     uint16_t group, uint16_t elem)
 { 
-   return FileInternal->SetEntryValue(content,group,elem);
+   return FileInternal->SetValEntry(content,group,elem);
 }
 
 
@@ -548,10 +548,10 @@ bool FileHelper::SetEntryValue(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 FileHelper::SetEntryBinArea(uint8_t *content, int lgth,
+bool FileHelper::SetBinEntry(uint8_t *content, int lgth,
                                  uint16_t group, uint16_t elem)
 {
-   return FileInternal->SetEntryBinArea(content,lgth,group,elem);
+   return FileInternal->SetBinEntry(content,lgth,group,elem);
 }
 
 /**
@@ -563,10 +563,10 @@ bool FileHelper::SetEntryBinArea(uint8_t *content, int lgth,
  * \return  pointer to the modified/created Dicom entry (NULL when creation
  *          failed).
  */ 
-bool FileHelper::Insert(std::string const &content,
-                        uint16_t group, uint16_t elem)
+ValEntry *FileHelper::InsertValEntry(std::string const &content,
+                                uint16_t group, uint16_t elem)
 {
-   return FileInternal->Insert(content,group,elem) != NULL;
+   return FileInternal->InsertValEntry(content,group,elem);
 }
 
 /*
@@ -579,10 +579,24 @@ bool FileHelper::Insert(std::string const &content,
  * \return  pointer to the modified/created Dicom entry (NULL when creation
  *          failed).
  */
-bool FileHelper::Insert(uint8_t *binArea, int lgth,
-                        uint16_t group, uint16_t elem)
+BinEntry *FileHelper::InsertBinEntry(uint8_t *binArea, int lgth,
+                                uint16_t group, uint16_t elem)
 {
-   return FileInternal->Insert(binArea,lgth,group,elem) != NULL;
+   return FileInternal->InsertBinEntry(binArea,lgth,group,elem);
+}
+
+/*
+ * \brief   Modifies the value of a given DocEntry (Dicom entry)
+ *          when it exists. Create it with the given value when unexistant.
+ *          A copy of the binArea is made to be kept in the Document.
+ * @param   group   Group number of the Entry 
+ * @param   elem  Element number of the Entry
+ * \return  pointer to the modified/created Dicom entry (NULL when creation
+ *          failed).
+ */
+SeqEntry *FileHelper::InsertSeqEntry(uint16_t group, uint16_t elem)
+{
+   return FileInternal->InsertSeqEntry(group,elem);
 }
 
 /**
index 7752d395b137839dc256bf0a90976436415482d6..4848a946b4faa6393daa61250dad16a457e3e503 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFileHelper.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:44:54 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2005/01/25 15:44:24 $
+  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
@@ -27,6 +27,7 @@ namespace gdcm
 class File;
 class ValEntry;
 class BinEntry;
+class SeqEntry;
 class PixelReadConvert;
 class PixelWriteConvert;
 class DocEntryArchive;
@@ -54,6 +55,18 @@ public:
 
    void Print(std::ostream &os = std::cout, std::string const & indent = ""); 
 
+   // 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,
+                            uint16_t group, uint16_t elem);
+   SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
+
    /// Accessor to \ref File
    File *GetFile() { return FileInternal; }
 
@@ -86,15 +99,6 @@ public:
    bool WriteAcr      (std::string const &fileName);
    bool Write         (std::string const &fileName);
 
-   bool SetEntryValue(std::string const &content,
-                      uint16_t group, uint16_t elem);
-   bool SetEntryBinArea(uint8_t *content, int lgth,
-                        uint16_t group, uint16_t elem);
-   bool Insert(std::string const &content,
-               uint16_t group, uint16_t elem);
-   bool Insert(uint8_t *binArea, int lgth,
-               uint16_t group, uint16_t elem);
-
    uint8_t* GetLutRGBA();
 
    // Write mode
index 0c1cb641eb58b267eb649b2dce72734c809eb74f..0431202ca3bbf3c16c1f69236af1d0baa5c45fb6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 11:11:59 $
-  Version:   $Revision: 1.59 $
+  Date:      $Date: 2005/01/25 15:44:24 $
+  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
@@ -165,72 +165,6 @@ bool SQItem::AddEntry(DocEntry *entry)
    return true;
 }   
 
-/**
- * \brief   Sets Entry (Dicom Element) value of an element,
- *          specified by it's tag (Group, Number) 
- *          and the length, too ...  inside a SQ Item
- *          If the Element is not found, it's just created !
- * \warning we suppose, right now, the element belongs to a Public Group
- *          (NOT a shadow one)       
- * @param   val string value to set
- * @param   group  Group number of the searched tag.
- * @param   elem Element number of the searched tag.
- * @return  true if element was found or created successfully
- */
-
-bool SQItem::SetEntryValue(std::string const &val, uint16_t group, 
-                      uint16_t elem)
-{
-   for(ListDocEntry::iterator i = DocEntries.begin(); 
-                              i != DocEntries.end(); 
-                            ++i)
-   { 
-      if ( (*i)->GetGroup() == 0xfffe && (*i)->GetElement() == 0xe000 ) 
-      {
-         continue;
-      }
-
-      if (  ( group  < (*i)->GetGroup() )
-          ||( group == (*i)->GetGroup() && elem < (*i)->GetElement()) )
-      {
-         // instead of Insert, that is a method of Document :-( 
-         ValEntry* entry = 0;
-         TagKey key = DictEntry::TranslateToKey(group, elem);
-
-         // we assume a Public Dictionary *is* loaded
-         Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
-         // if the invoked (group,elem) doesn't exist inside the Dictionary
-         // we create a VirtualDictEntry
-         DictEntry *dictEntry = pubDict->GetEntry(group, elem);
-         if (dictEntry == NULL)
-         {
-            dictEntry = 
-               Global::GetDicts()->NewVirtualDictEntry(group, elem,
-                                                       "UN", GDCM_UNKNOWN, 
-                                                        GDCM_UNKNOWN);
-         } 
-         // we assume the constructor didn't fail
-         entry = new ValEntry(dictEntry);
-         if (entry)
-         {
-            entry->SetValue(val); 
-         }
-         DocEntries.insert(i,entry);
-
-         return true;
-      }   
-      if (group == (*i)->GetGroup() && elem == (*i)->GetElement() )
-      {
-         if ( ValEntry *entry = dynamic_cast<ValEntry*>(*i) )
-         {
-            entry->SetValue(val);
-         }
-         return true;    
-      }
-   }
-   return false;
-}
-
 /**
  * \brief   Clear the std::list from given entry AND delete the entry.
  * @param   entryToRemove Entry to remove AND delete.
@@ -305,8 +239,6 @@ DocEntry *SQItem::GetNextEntry()
    }
 }
 
-//-----------------------------------------------------------------------------
-// Protected
 /**
  * \brief   Gets a Dicom Element inside a SQ Item Entry
  * @param   group Group number of the Entry
@@ -318,94 +250,15 @@ DocEntry *SQItem::GetDocEntry(uint16_t group, uint16_t elem)
    for(ListDocEntry::iterator i = DocEntries.begin();
                               i != DocEntries.end(); ++i)
    {
-      if ( (*i)->GetGroup() == group && (*i)->GetElement() == elem )
-      {
+      if ( (*i)->GetGroup()==group && (*i)->GetElement()==elem )
          return *i;
-      }
    }
-   return 0;
-}
-
-/**
- * \brief   Gets a Dicom Element inside a SQ Item Entry
- * @param   group Group number of the Entry
- * @param   elem  Element number of the Entry
- * @return Entry whose (group,elem) was passed. 0 if not found
- */
-ValEntry* SQItem::GetValEntry(uint16_t group, uint16_t elem)
-{
-   DocEntry *d = GetDocEntry(group, elem);
-   if ( ValEntry *e = dynamic_cast<ValEntry*>(d) )
-      return e;
-   return 0;
-}
-
-/**
- * \brief   Gets a Dicom Element inside a SQ Item Entry
- * @param   group   Group number of the Entry
- * @param   elem  Element number of the Entry
- * @return Entry whose (group,elem) was passed. 0 if not found
- */
-BinEntry* SQItem::GetBinEntry(uint16_t group, uint16_t elem)
-{
-   DocEntry *d = GetDocEntry(group, elem);
-   if ( BinEntry *e = dynamic_cast<BinEntry*>(d) )
-      return e;
-   return 0;
-}
-
-/**
- * \brief   Gets a Dicom Element inside a SQ Item Entry
- * @param   group   Group number of the Entry
- * @param   elem  Element number of the Entry
- * @return Entry whose (group,elem) was passed. 0 if not found
- */
-SeqEntry* SQItem::GetSeqEntry(uint16_t group, uint16_t elem)
-{
-   DocEntry *d = GetDocEntry(group, elem);
-   if ( SeqEntry *e = dynamic_cast<SeqEntry*>(d) )
-      return e;
-   return 0;
+   return NULL;
 }
 
+//-----------------------------------------------------------------------------
+// Protected
 
-/**
- * \brief   Get the value of a Dicom Element inside a SQ Item Entry
- * \note : meaningfull only if the required entry is NEITHER a SeqEntry 
- *                                                   NOR a BinEntry
- * @param   group   Group number of the Entry
- * @param   elem  Element number of the Entry 
- * @return  'string value' of the entry whose (group,elem) was passed.
- *           GDCM_UNFOUND if not found
- */ 
-
-std::string SQItem::GetEntryValue(uint16_t group, uint16_t elem)
-{
-
-/*
-   DocEntry *e = GetFirstEntry();
-   while (e)
-   {
-      if ( e->GetGroup() == group && e->GetElement() == elem)
-      {
-
-         if (ValEntry *ve = dynamic_cast<ValEntry*>(e))
-            return ve->GetValue();
-      }
-      e = GetNextEntry();
-   }   
-*/
-   for(ListDocEntry::iterator i = DocEntries.begin();
-                              i != DocEntries.end(); ++i)
-   {
-      if ( (*i)->GetGroup() == group && (*i)->GetElement() == elem)
-      {
-         if (ValEntry *ve = dynamic_cast<ValEntry*>(*i))
-           return ve->GetValue();
-      }
-   }
-   return GDCM_UNFOUND;
-}
 //-----------------------------------------------------------------------------
 // Private
 
index de9fa1f0133d6ae537fbc4511320e5ed290c3d61..23c5586f60adc40b1c1ecddbb90b9a7883e5cc52 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/25 11:11:59 $
-  Version:   $Revision: 1.36 $
+  Date:      $Date: 2005/01/25 15:44:24 $
+  Version:   $Revision: 1.37 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -46,33 +46,25 @@ public:
    virtual void Print(std::ostream &os = std::cout, std::string const & indent = "" ); 
    void WriteContent(std::ofstream *fp, FileType filetype);
 
-   /// \brief   returns the DocEntry chained List for this SQ Item.
-   ListDocEntry const &GetDocEntries() const { return DocEntries; };
-   
    void ClearEntry();
    bool AddEntry(DocEntry *Entry); // add to the List
    bool RemoveEntry(DocEntry *EntryToRemove);
    bool RemoveEntryNoDestroy(DocEntry *EntryToRemove);
   
+   DocEntry *GetFirstEntry();
+   DocEntry *GetNextEntry();
+
    DocEntry *GetDocEntry(uint16_t group, uint16_t elem);
-   ValEntry *GetValEntry(uint16_t group, uint16_t elem); 
-   BinEntry *GetBinEntry(uint16_t group, uint16_t elem); 
-   SeqEntry *GetSeqEntry(uint16_t group, uint16_t elem); 
-   
-   bool SetEntryValue(std::string const &val, uint16_t group, 
-                                         uint16_t elem);
-    
-   std::string GetEntryValue(uint16_t group, uint16_t elem);
+
+   bool IsEmpty() { return DocEntries.empty(); };
 
    /// \brief   returns the ordinal position of a given SQItem
    int GetSQItemNumber() { return SQItemNumber; };
-
    /// \brief   Sets the ordinal position of a given SQItem
    void SetSQItemNumber(int itemNumber) { SQItemNumber = itemNumber; };
 
    ///  \brief Accessor on \ref SQDepthLevel.
-   int GetDepthLevel() { return SQDepthLevel; }
-                                                                                
+   int GetDepthLevel() { return SQDepthLevel; }                                                                             
    ///  \brief Accessor on \ref SQDepthLevel.
    void SetDepthLevel(int depth) { SQDepthLevel = depth; }
 
@@ -82,23 +74,14 @@ public:
    ///  \brief Accessor on \ref BaseTagKey.
    BaseTagKey const &GetBaseTagKey() const { return BaseTagKeyNested; }
 
-   DocEntry *GetFirstEntry();
-   DocEntry *GetNextEntry();
-
 protected:
 // Variables that need to be access in subclasses
-
    /// \brief Chained list of (Elementary) Doc Entries
    ListDocEntry DocEntries;
    /// Chained list iterator, used to visit the TagHT variable
    ListDocEntry::iterator ItDocEntries;
    
-   /// \brief pointer to the HTable of the Document,
-   ///       (because we don't know it within any DicomDirObject nor any SQItem)
-   // TagDocEntryHT *PtagHT;
-
 private:
-
    /// \brief Sequences can be nested. This \ref SQDepthLevel represents
    ///        the level of the nesting of instances of this class.
    ///        \ref SQDepthLevel and its \ref SeqEntry::SQDepthLevel
index 822a7132d05fa3c4fe65e95bbff592d4770e4a21..1652c3c6c28801edd1f0f2f16f56d2fd5b29713c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcmWriter.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:51:01 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2005/01/25 15:44:25 $
+  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
@@ -26,7 +26,7 @@
 #include <vtkPointData.h>
 #include <vtkLookupTable.h>
 
-vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.14 $");
+vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.15 $");
 vtkStandardNewMacro(vtkGdcmWriter);
 
 //-----------------------------------------------------------------------------
@@ -132,29 +132,29 @@ void SetImageInformation(gdcm::FileHelper *file,vtkImageData *image)
 
    str.str("");
    str << dim[0];
-   file->Insert(str.str(),0x0028,0x0011); // Columns
+   file->InsertValEntry(str.str(),0x0028,0x0011); // Columns
 
    str.str("");
    str << dim[1];
-   file->Insert(str.str(),0x0028,0x0010); // Rows
+   file->InsertValEntry(str.str(),0x0028,0x0010); // Rows
 
    if(dim[2]>1)
    {
       str.str("");
       str << dim[2];
       //file->Insert(str.str(),0x0028,0x0012); // Planes
-      file->Insert(str.str(),0x0028,0x0008); // Number of Frames
+      file->InsertValEntry(str.str(),0x0028,0x0008); // Number of Frames
    }
 
    // Pixel type
    str.str("");
    str << image->GetScalarSize()*8;
-   file->Insert(str.str(),0x0028,0x0100); // Bits Allocated
-   file->Insert(str.str(),0x0028,0x0101); // Bits Stored
+   file->InsertValEntry(str.str(),0x0028,0x0100); // Bits Allocated
+   file->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored
 
    str.str("");
    str << image->GetScalarSize()*8-1;
-   file->Insert(str.str(),0x0028,0x0102); // High Bit
+   file->InsertValEntry(str.str(),0x0028,0x0102); // High Bit
 
    // Pixel Repr
    // FIXME : what do we do when the ScalarType is 
@@ -171,39 +171,39 @@ void SetImageInformation(gdcm::FileHelper *file,vtkImageData *image)
    {
       str << "1"; // Signed
    }
-   file->Insert(str.str(),0x0028,0x0103); // Pixel Representation
+   file->InsertValEntry(str.str(),0x0028,0x0103); // Pixel Representation
 
    // Samples per pixel
    str.str("");
    str << image->GetNumberOfScalarComponents();
-   file->Insert(str.str(),0x0028,0x0002); // Samples per Pixel
+   file->InsertValEntry(str.str(),0x0028,0x0002); // Samples per Pixel
 
    // Spacing
    double *sp = image->GetSpacing();
 
    str.str("");
    str << sp[0] << "\\" << sp[1];
-   file->Insert(str.str(),0x0028,0x0030); // Pixel Spacing
+   file->InsertValEntry(str.str(),0x0028,0x0030); // Pixel Spacing
    str.str("");
    str << sp[2];
-   file->Insert(str.str(),0x0018,0x0088); // Spacing Between Slices
+   file->InsertValEntry(str.str(),0x0018,0x0088); // Spacing Between Slices
 
    // Origin
    double *org = image->GetOrigin();
 
    str.str("");
    str << org[0] << "\\" << org[1] << "\\" << org[2];
-   file->Insert(str.str(),0x0020,0x0032); // Image Position Patient
+   file->InsertValEntry(str.str(),0x0020,0x0032); // Image Position Patient
 
    // Window / Level
    double *rng=image->GetScalarRange();
 
    str.str("");
    str << rng[1]-rng[0];
-   file->Insert(str.str(),0x0028,0x1051); // Window Width
+   file->InsertValEntry(str.str(),0x0028,0x1051); // Window Width
    str.str("");
    str << (rng[1]+rng[0])/2.0;
-   file->Insert(str.str(),0x0028,0x1050); // Window Center
+   file->InsertValEntry(str.str(),0x0028,0x1050); // Window Center
 
    // Pixels
    unsigned char *data;