]> Creatis software - gdcm.git/blobdiff - Example/TestPapyrus.cxx
methods ReplaceOrCreate renamed as Insert
[gdcm.git] / Example / TestPapyrus.cxx
index 9f99e31a26200d1f40d4b50a0e760b8437547544..e0b5dd1330f005cb1db271b15558b6c07ff2406f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestPapyrus.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/20 16:16:58 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2005/01/24 16:44:53 $
+  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
@@ -15,7 +15,7 @@
      PURPOSE.  See the above copyright notices for more information.
                                                                                 
 =========================================================================*/
-#include "gdcmHeader.h"
+#include "gdcmFile.h"
 #include "gdcmFileHelper.h"
 #include "gdcmDocument.h"
 #include "gdcmValEntry.h"
@@ -61,7 +61,7 @@ bool RemoveFile(const char* source)
 }
 
 // ----------------------------------------------------------------------
-// Here we load a supposed to be Papyrus File (gdcm::Header compliant)
+// Here we load a supposed to be Papyrus File (gdcm::File compliant)
 // and then try to get the pixels, using low-level SeqEntry accessors.
 // Since it's not a general purpose Papyrus related program
 // (just a light example) we suppose *everything* is clean
@@ -92,11 +92,11 @@ int main(int argc, char* argv[])
       }
    }
    gdcm::FileHelper *original = new gdcm::FileHelper( filename );
-   gdcm::Header *h = original->GetHeader();
+   gdcm::File *h = original->GetFile();
 
    // Look for private Papyrus Sequence
    gdcm::SeqEntry *seqPapyrus= h->GetSeqEntry(0x0041, 0x1050);
-   if (!h)
+   if (!seqPapyrus)
    {
       std::cout << "NOT a Papyrus File" << std::endl;
       delete h;
@@ -123,12 +123,12 @@ int main(int argc, char* argv[])
 //  Modality, Transfer Syntax, Study Date, Study Time
 // Patient Name, Media Storage SOP Instance UID, etc
 
-   MediaStSOPinstUID   =   h->GetEntry(0x0002,0x0002);
-   TransferSyntax      =   h->GetEntry(0x0002,0x0010);
-   StudyDate           = sqi->GetEntry(0x0008,0x0020);
-   StudyTime           = sqi->GetEntry(0x0008,0x0030);
-   Modality            = sqi->GetEntry(0x0008,0x0060);
-   PatientName         = sqi->GetEntry(0x0010,0x0010);
+   MediaStSOPinstUID   =   h->GetEntryValue(0x0002,0x0002);
+   TransferSyntax      =   h->GetEntryValue(0x0002,0x0010);
+   StudyDate           = sqi->GetEntryValue(0x0008,0x0020);
+   StudyTime           = sqi->GetEntryValue(0x0008,0x0030);
+   Modality            = sqi->GetEntryValue(0x0008,0x0060);
+   PatientName         = sqi->GetEntryValue(0x0010,0x0010);
 
    std::cout << "TransferSyntax " << TransferSyntax << std::endl;
 
@@ -143,18 +143,18 @@ 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 GetEntry
+   // if you're aware they have not, just move the GetEntryValue
    // inside the loop
 
    // Get caracteristics of the first image
 
-   SamplesPerPixel     = sqi->GetEntry(0x0028,0x0002);
-   Rows                = sqi->GetEntry(0x0028,0x0010);
-   Columns             = sqi->GetEntry(0x0028,0x0011);
-   BitsAllocated       = sqi->GetEntry(0x0028,0x0100);
-   BitsStored          = sqi->GetEntry(0x0028,0x0101);
-   HighBit             = sqi->GetEntry(0x0028,0x0102);
-   PixelRepresentation = sqi->GetEntry(0x0028,0x0102);
+   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,0x0102);
 
    // just convert those needed to compute PixelArea length
    int iRows            = (uint32_t) atoi( Rows.c_str() );
@@ -165,12 +165,16 @@ int main(int argc, char* argv[])
    int lgrImage = iRows*iColumns * iSamplesPerPixel * (iBitsAllocated/8);
 
    // compute number of images
+
+   int nbImages = seqPapyrus->GetNumberOfSQItems();
+/*
    int nbImages = 0;
    while (sqi)
    {
       nbImages++;
       sqi =  seqPapyrus->GetNextSQItem();
    }
+*/
    std::cout <<"Number of frames :" << nbImages << std::endl;  
 
    //  allocate enough room to get the pixels of all images.
@@ -199,7 +203,7 @@ int main(int argc, char* argv[])
    while (sqi)
    {
       std::cout << "One more image read. Keep waiting" << std::endl;
-      Rows = sqi->GetEntry(0x0028,0x0010);
+      Rows = sqi->GetEntryValue(0x0028,0x0010);
       // minimum integrity check
       if (Rows != previousRows)
       {
@@ -224,26 +228,26 @@ int main(int argc, char* argv[])
 
    std::string NumberOfFrames = gdcm::Util::Format("%d", nbImages); 
 
-   gdcm::Header *n = new gdcm::Header();
-   n->InitializeDefaultHeader();
+   gdcm::File *n = new gdcm::File();
+   n->InitializeDefaultFile();
 
-   n->ReplaceOrCreate(MediaStSOPinstUID,  0x0002,0x0002);
+   n->Insert(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->ReplaceOrCreate(TransferSyntax,     0x0002,0x0010);
-   n->ReplaceOrCreate(StudyDate,          0x0008,0x0020);
-   n->ReplaceOrCreate(StudyTime,          0x0008,0x0030);
-   n->ReplaceOrCreate(Modality,           0x0008,0x0060);
-   n->ReplaceOrCreate(PatientName,        0x0010,0x0010);
-
-   n->ReplaceOrCreate(SamplesPerPixel,    0x0028,0x0002);
-   n->ReplaceOrCreate(NumberOfFrames,     0x0028,0x0008);
-   n->ReplaceOrCreate(Rows,               0x0028,0x0010);
-   n->ReplaceOrCreate(Columns,            0x0028,0x0011);
-   n->ReplaceOrCreate(BitsAllocated,      0x0028,0x0100);
-   n->ReplaceOrCreate(BitsStored,         0x0028,0x0101);
-   n->ReplaceOrCreate(HighBit,            0x0028,0x0102);
-   n->ReplaceOrCreate(PixelRepresentation,0x0028,0x0102);
+   //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);
 
    // create the file
    gdcm::FileHelper *file = new gdcm::FileHelper(n);