]> Creatis software - gdcm.git/blobdiff - Example/exExtractDicomTags.cxx
Fix bug on creating E11 + E22 Peak Strain
[gdcm.git] / Example / exExtractDicomTags.cxx
index f94d6ca57125835ed6e8030a33d14fafb528494d..223e4652269d30c5463cfea079e29c2f18709d28 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exExtractDicomTags.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/09/29 08:49:27 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2007/05/23 14:18:05 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -18,8 +18,6 @@
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
 #include "gdcmDocument.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
 #include "gdcmSeqEntry.h"
 #include "gdcmSQItem.h"
 #include "gdcmDebug.h"
@@ -53,7 +51,7 @@ int main(int argc, char *argv[])
 
    // ----- Initialize Arguments Manager ------
    
-   gdcm::ArgMgr *am = new gdcm::ArgMgr(argc, argv);
+   GDCM_NAME_SPACE::ArgMgr *am = new GDCM_NAME_SPACE::ArgMgr(argc, argv);
   
    if (am->ArgMgrDefined("usage")) 
    {
@@ -69,7 +67,7 @@ int main(int argc, char *argv[])
    }
 
    if (am->ArgMgrDefined("debug"))
-      gdcm::Debug::DebugOn();
+      GDCM_NAME_SPACE::Debug::DebugOn();
  
    // if unused Params we give up
    if ( am->ArgMgrPrintUnusedLabels() )
@@ -85,14 +83,14 @@ int main(int argc, char *argv[])
 
 
    int loadMode = 0x0; // load everything
-   gdcm::File *f = new gdcm::File();
+   GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
    f->SetLoadMode( loadMode );
    f->SetFileName( fileName );
    bool res = f->Load();  
 
    if ( !res )
    {
-      delete f;
+      f->Delete();
       return 0;
    }
 
@@ -100,7 +98,7 @@ int main(int argc, char *argv[])
    if (!f->IsReadable())
    {
       std::cout << "NOT a Dicom File : " << fileName <<std::endl;
-      delete f;
+      f->Delete();
       return 1;
    }
 
@@ -125,33 +123,33 @@ int main(int argc, char *argv[])
    std::string ProtocolName;
 
 
-// ------------> Region (Organe) : aucun champ DICOM n'est prĂ©vu 
-//                        pour contenir cette information
+// ------------> Region (Organ) : *no* DICOM field is expected 
+//                        to hold information
 
 // Get informations on the file : 
 //  Modality, Transfer Syntax, Study Date, Study Time
 // Patient Name, Media Storage SOP Instance UID, etc
 
-   MediaStSOPinstUID   = f->GetEntryValue(0x0002,0x0002);
-   TransferSyntax      = f->GetEntryValue(0x0002,0x0010);
-   StudyDate           = f->GetEntryValue(0x0008,0x0020);
-   StudyTime           = f->GetEntryValue(0x0008,0x0030);
-   PatientName         = f->GetEntryValue(0x0010,0x0010);
-   PatientID           = f->GetEntryValue(0x0010,0x0020);  //patientid
-   PatientSex          = f->GetEntryValue(0x0010,0x0040);  //sexe
-   SOPInstanceUID      = f->GetEntryValue(0x0008,0x0018);  //imageid = SOPinsUID
-   StudyInstanceUID    = f->GetEntryValue(0x0020,0x000d);  //STUInsUID                                              [Study Instance UID] [1.2.840.113680.1.103.56887.1017329008.714317]
-   SeriesInstanceUID   = f->GetEntryValue(0x0020,0x000e);  //SerInsUID
-   AcquistionDate      = f->GetEntryValue(0x0008,0x0022);
-   AcquisitionTime     = f->GetEntryValue(0x0008,0x0032);
-   AcquisitionDateTime = f->GetEntryValue(0x0008,0x002a);
-
-
-   Modality            = f->GetEntryValue(0x0008,0x0060);  //modality
-   InstitutionName     = f->GetEntryValue(0x0008,0x0080);  //hospital
+   MediaStSOPinstUID   = f->GetEntryString(0x0002,0x0002);
+   TransferSyntax      = f->GetEntryString(0x0002,0x0010);
+   StudyDate           = f->GetEntryString(0x0008,0x0020);
+   StudyTime           = f->GetEntryString(0x0008,0x0030);
+   PatientName         = f->GetEntryString(0x0010,0x0010);
+   PatientID           = f->GetEntryString(0x0010,0x0020);  //patientid
+   PatientSex          = f->GetEntryString(0x0010,0x0040);  //sex
+   SOPInstanceUID      = f->GetEntryString(0x0008,0x0018);  //imageid = SOPinsUID
+   StudyInstanceUID    = f->GetEntryString(0x0020,0x000d);  //STUInsUID                                              [Study Instance UID] [1.2.840.113680.1.103.56887.1017329008.714317]
+   SeriesInstanceUID   = f->GetEntryString(0x0020,0x000e);  //SerInsUID
+   AcquistionDate      = f->GetEntryString(0x0008,0x0022);
+   AcquisitionTime     = f->GetEntryString(0x0008,0x0032);
+   AcquisitionDateTime = f->GetEntryString(0x0008,0x002a);
+
+
+   Modality            = f->GetEntryString(0x0008,0x0060);  //modality
+   InstitutionName     = f->GetEntryString(0x0008,0x0080);  //hospital
    // always empty :-(
    InstitutionalDepartmentName     
-                     = f->GetEntryValue(0x0008,0x1040);  //departement
+                     = f->GetEntryString(0x0008,0x1040);  //departement
 
    // Radiologist :
    // 0008|0090  [Referring Physician's Name]
@@ -162,14 +160,14 @@ int main(int argc, char *argv[])
 
    // --> I'll have to ask people working on PACS which one they use. JPRx
 
-   ProtocolName = f->GetEntryValue(0x0018,0x1030); 
+   ProtocolName = f->GetEntryString(0x0018,0x1030); 
   
-   // --> Big trouble with nz (mb of planes) and nt (number of 'times')
+   // --> Big trouble with nz (number of planes) and nt (number of 'times')
    // --> that belong to LibIDO, not to DICOM.
    // --> DICOM has 'Number of Frames' (0028|0008), 
    //     that's more or less number of 'times'
    // Volumes are generaly stored in a 'Serie' 
-   //  (hope so ... a single Serie be xti-slice xti-times)
+   //  (hope so ... a single Serie may be xti-slice xti-times)
 
 
    std::string Rows;
@@ -183,15 +181,15 @@ int main(int argc, char *argv[])
    std::string PixelRepresentation;
    std::string PixelType;
    
-   SamplesPerPixel     = f->GetEntryValue(0x0028,0x0002);  // 3 -> RGB
-   Rows                = f->GetEntryValue(0x0028,0x0010);  //ny
-   Columns             = f->GetEntryValue(0x0028,0x0011);  //nx
-   Planes              = f->GetEntryValue(0x0028,0x0012);  //nz
+   SamplesPerPixel     = f->GetEntryString(0x0028,0x0002);  // 3 -> RGB
+   Rows                = f->GetEntryString(0x0028,0x0010);  //ny
+   Columns             = f->GetEntryString(0x0028,0x0011);  //nx
+   Planes              = f->GetEntryString(0x0028,0x0012);  //nz
 
-   BitsAllocated       = f->GetEntryValue(0x0028,0x0100);
-   BitsStored          = f->GetEntryValue(0x0028,0x0101);
-   HighBit             = f->GetEntryValue(0x0028,0x0102);
-   PixelRepresentation = f->GetEntryValue(0x0028,0x0103);
+   BitsAllocated       = f->GetEntryString(0x0028,0x0100);
+   BitsStored          = f->GetEntryString(0x0028,0x0101);
+   HighBit             = f->GetEntryString(0x0028,0x0102);
+   PixelRepresentation = f->GetEntryString(0x0028,0x0103);
 
    PixelType           = f->GetPixelType();                //type 
 /*
@@ -249,5 +247,6 @@ int main(int argc, char *argv[])
    std::cout << "GetYSpacing = ["            << sy << "]" << std::endl;
    std::cout << "GetZSpacing = ["            << sz << "]" << std::endl;
 
+   f->Delete();
    return 0;
 }