]> Creatis software - gdcm.git/blobdiff - Example/exCurveData.cxx
Coding style + minor modif
[gdcm.git] / Example / exCurveData.cxx
index c92df1516d2a63732da5adbc81b91f9b44ddbf0e..f7244b621db468dc9a16065b32676d0bb2503365 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exCurveData.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/10 20:42:33 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2007/05/23 14:18:05 $
+  Version:   $Revision: 1.6 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -20,7 +20,7 @@
 #include "gdcmCommon.h"
 #include "gdcmDebug.h"
 #include "gdcmDocEntry.h"
-#include "gdcmBinEntry.h"
+#include "gdcmDataEntry.h"
 
 static const char* TypeOfDataArrays[13][2] = {
     { "TAC" , "time activity curve" },
@@ -35,7 +35,7 @@ static const char* TypeOfDataArrays[13][2] = {
     { "FLOW" , "flow data" },
     { "PHYSIO" , "physio data" },
     { "RESP" , "Respiration trace" },
-    NULL
+    { NULL, NULL }
 };
 
 // Part 3, C.10.2.1.1 Type of data
@@ -76,12 +76,12 @@ inline size_t PrintCurveData(DataValueRepresentation* data, unsigned short numPt
  * V 5004|0020 [CS]                  [Type of Data] [PHYSIO]
  * V 5004|0022 [LO]             [Curve Description] []
  * V 5004|0103 [US]     [Data Value Representation] [0] x(0)
- * B 5004|3000 [OW]                    [Curve Data] [gdcm::Binary data loaded;length = 1938]
+ * B 5004|3000 [OW]                    [Curve Data] [GDCM_NAME_SPACE::Binary data loaded;length = 1938]
  */
  
 int main(int argc, char *argv[])
 {  
-   gdcm::File *f;
+   GDCM_NAME_SPACE::File *f;
  
    std::cout << "------------------------------------------------" << std::endl;
    std::cout << "Gets the 'Curve Data' from a full gdcm-readable DICOM " << std::endl;
@@ -101,13 +101,13 @@ int main(int argc, char *argv[])
 //   Read the input image.
 // ============================================================
 
-   f = new gdcm::File( );
+   f = GDCM_NAME_SPACE::File::New( );
 
-   f->SetLoadMode(gdcm::LD_NOSEQ | gdcm::LD_NOSHADOW);
+   f->SetLoadMode(GDCM_NAME_SPACE::LD_NOSEQ | GDCM_NAME_SPACE::LD_NOSHADOW);
    f->SetFileName( fileName );
    bool res = f->Load();  
 
-   if( gdcm::Debug::GetDebugFlag() )
+   if( GDCM_NAME_SPACE::Debug::GetDebugFlag() )
    {
       std::cout << "---------------------------------------------" << std::endl;
       f->Print();
@@ -117,7 +117,7 @@ int main(int argc, char *argv[])
        std::cout << "Sorry, " << fileName <<"  not a gdcm-readable "
            << "DICOM / ACR File"
            <<std::endl;
-      delete f;
+      f->Delete();
       return 1;
    }
    std::cout << " ... is readable " << std::endl;
@@ -126,12 +126,12 @@ int main(int argc, char *argv[])
 //   Check whether image contains Overlays ACR-NEMA style.
 // ============================================================
 
-   //* B 5004|3000 [OW]                    [Curve Data] [gdcm::Binary data loaded;length = 1938]
-   std::string curve_data_str = f->GetEntryValue(0x5004, 0x3000);
-   if (curve_data_str == gdcm::GDCM_UNFOUND)
+   //* B 5004|3000 [OW]                    [Curve Data] [GDCM_NAME_SPACE::Binary data loaded;length = 1938]
+   std::string curve_data_str = f->GetEntryString(0x5004, 0x3000);
+   if (curve_data_str == GDCM_NAME_SPACE::GDCM_UNFOUND)
    {
       std::cout << " Image doesn't contain any Curve Data" << std::endl;
-      delete f;
+      f->Delete();
       return 1;
    }
    std::cout << " File is read! " << std::endl;
@@ -142,61 +142,61 @@ int main(int argc, char *argv[])
 // ============================================================
   std::istringstream convert;
  //* V 5004|0005 [US]              [Curve Dimensions] [1] x(1)
-   std::string curve_dim_str = f->GetEntryValue(0x5004,0x0005);
+   std::string curve_dim_str = f->GetEntryString(0x5004,0x0005);
    unsigned short curve_dim;
    convert.str(curve_dim_str);
    convert >> curve_dim;
    std::cout << "Curve Dimensions: " << curve_dim << std::endl;
  //* V 5004|0010 [US]              [Number of Points] [969] x(3c9)
-   std::string num_points_str = f->GetEntryValue(0x5004,0x0010);
+   std::string num_points_str = f->GetEntryString(0x5004,0x0010);
    unsigned short num_points;
    convert.clear(); //important
    convert.str(num_points_str);
    convert >> num_points;
    std::cout << "Number of Points: " << num_points << std::endl;
  //* V 5004|0020 [CS]                  [Type of Data] [PHYSIO]
-   std::string data_type = f->GetEntryValue(0x5004,0x0020);
+   std::string data_type = f->GetEntryString(0x5004,0x0020);
    std::cout << "Type of Data: " << data_type << std::endl;
    std::cout << " this is thus a : " << ConvertTypeOfData(data_type) << std::endl;
  //* V 5004|0022 [LO]             [Curve Description] []
-   std::string curve_desc = f->GetEntryValue(0x5004,0x0022);
+   std::string curve_desc = f->GetEntryString(0x5004,0x0022);
    std::cout << "Curve Description: " << curve_desc << std::endl;
  //* V 5004|0103 [US]     [Data Value Representation] [0] x(0)
-   std::string data_rep_str = f->GetEntryValue(0x5004,0x0103);
+   std::string data_rep_str = f->GetEntryString(0x5004,0x0103);
    unsigned short data_rep;
    convert.clear(); //important
    convert.str(data_rep_str);
    convert >> data_rep;
 
 
-   gdcm::DocEntry *pCurveDataDoc = f->GetDocEntry(0x5004, 0x3000);
-   gdcm::BinEntry *pCurveData = dynamic_cast<gdcm::BinEntry*>(pCurveDataDoc);
+   GDCM_NAME_SPACE::DocEntry *pCurveDataDoc = f->GetDocEntry(0x5004, 0x3000);
+   GDCM_NAME_SPACE::DataEntry *pCurveData = dynamic_cast<GDCM_NAME_SPACE::DataEntry *>(pCurveDataDoc);
    uint8_t *curve_data = pCurveData->GetBinArea();
    
    // From Part3, C.10.2.1.2 Data value representation (p668)
    size_t sz;
    switch( data_rep)
-     {
-   case 0:
-     sz = PrintCurveData((unsigned short*)(curve_data), num_points);
-     break;
-   case 1:
-     sz = PrintCurveData((signed short*)(curve_data), num_points);
-     break;
-   case 2:
-     sz = PrintCurveData((float*)(curve_data), num_points);
-     break;
-   case 3:
-     sz = PrintCurveData((double*)(curve_data), num_points);
-     break;
-   case 4:
-     sz = PrintCurveData((signed long*)(curve_data), num_points);
-     break;
-   default:
-     std::cerr << "Error don't know the type: " << data_rep_str << std::endl;
-     delete f;
-     return 1;
-     }
+   {
+      case 0:
+         sz = PrintCurveData((unsigned short*)(curve_data), num_points);
+         break;
+      case 1:
+         sz = PrintCurveData((signed short*)(curve_data), num_points);
+         break;
+      case 2:
+         sz = PrintCurveData((float*)(curve_data), num_points);
+         break;
+      case 3:
+         sz = PrintCurveData((double*)(curve_data), num_points);
+         break;
+      case 4:
+         sz = PrintCurveData((signed long*)(curve_data), num_points);
+         break;
+      default:
+         std::cerr << "Error don't know the type: " << data_rep_str << std::endl;
+         f->Delete();
+         return 1;
+   }
    // Just to make sure that values read are consistant and we won't read out of bound data:
    assert( sz*num_points == pCurveData->GetLength());
 
@@ -205,7 +205,7 @@ int main(int argc, char *argv[])
    //o.write((char*)curve_data, num_points*sz);
    //o.close();
 
-   delete f;
+   f->Delete();
    return 0;
 }