]> Creatis software - gdcm.git/blobdiff - Example/exExtractCSATag.cxx
Make it compile again.
[gdcm.git] / Example / exExtractCSATag.cxx
index 9cca05809b8adc8d7b0971ca5f4de2780d9974c0..74b9c750d3697b55bf3c0d95961a1291c33959f5 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exExtractCSATag.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/09/11 12:54:49 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2010/08/30 15:23:23 $
+  Version:   $Revision: 1.4 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -26,8 +26,8 @@
 
 #include <iomanip>
 
-namespace gdcm
-{
+//namespace gdcm
+//{
 
    static const char *lookupTable1[] = {
       "UsedPatientWeight",
@@ -233,8 +233,8 @@ static equ mapping[] = {
    {     4 , "FD" },
    {     5 , "FL" },
    {     6 , "IS" },
-  {   7 , "SL" },
-  {   8 , "SS" },
+   {     7 , "SL" },
+   {     8 , "SS" },
    {     9 , "UL" },
    {    10 , "US" },
    {    16 , "CS" },
@@ -243,7 +243,7 @@ static equ mapping[] = {
    {    22 , "SH" },
    {    23 , "ST" },
    {    25 , "UI" },
-  {  27 , "UT" },
+   {    27 , "UT" }
 };
 
 bool check_mapping(uint32_t syngodt, const char *vr)
@@ -293,7 +293,7 @@ uint32_t readCSAHeader(std::istream &is)
   return n;
 }
 
-DataEntry *readCSAElement(std::istream &is)
+GDCM_NAME_SPACE::DataEntry *readCSAElement(std::istream &is)
 {
       char name[64+1];
       name[64] = 0; // security
@@ -309,7 +309,7 @@ DataEntry *readCSAElement(std::istream &is)
     assert( vr[2] == vr[3] && vr[2] == 0 );
       std::cout << "vr=" << vr << std::endl;
 
-      DataEntry *de = DataEntry::New(0x0029, element, vr);
+      GDCM_NAME_SPACE::DataEntry *de = GDCM_NAME_SPACE::DataEntry::New(0x0029, element, vr);
 
       uint32_t syngodt;
       is.read((char*)&syngodt, sizeof(syngodt));
@@ -358,18 +358,18 @@ DataEntry *readCSAElement(std::istream &is)
   return de;
 }
 
-int convertCSA(std::istream &is, File *f)
+int convertCSA(std::istream &is, GDCM_NAME_SPACE::File *f)
 {
    f->RemoveEntry( f->GetDataEntry(0X0029,0x1010) );
 
-    SeqEntry *sq = SeqEntry::New(0x0029,0x1010);
-    SQItem *sqi = SQItem::New(1);
-//    DataEntry *e_0008_1150 = DataEntry::New(0x0008, 0x1150, "UI");
+    GDCM_NAME_SPACE::SeqEntry *sq = GDCM_NAME_SPACE::SeqEntry::New(0x0029,0x1010);
+    GDCM_NAME_SPACE::SQItem *sqi = GDCM_NAME_SPACE::SQItem::New(1);
+//    GDCM_NAME_SPACE::DataEntry *e_0008_1150 = DataEntry::New(0x0008, 0x1150, "UI");
 //    e_0008_1150->SetString( "coucou" );
 //    sqi->AddEntry(e_0008_1150);
 //    e_0008_1150->Delete();
 //
-//    DataEntry *e_0008_1155 = DataEntry::New(0x0008, 0x1155, "UI");
+//    GDCM_NAME_SPACE::DataEntry *e_0008_1155 = DataEntry::New(0x0008, 0x1155, "UI");
 //    e_0008_1155->SetString( "mathieu" );
 //    sqi->AddEntry(e_0008_1155);
 //    e_0008_1155->Delete();
@@ -380,7 +380,7 @@ int convertCSA(std::istream &is, File *f)
 
    for(uint32_t i = 0; i < n; ++i)
       {
-    DataEntry *de = readCSAElement(is);
+    GDCM_NAME_SPACE::DataEntry *de = readCSAElement(is);
     sqi->AddEntry(de);
     de->Delete();
       }
@@ -392,17 +392,17 @@ int convertCSA(std::istream &is, File *f)
     sq->Delete();
    f->Print( std::cout );
 
-   gdcm::FileHelper *fh = gdcm::FileHelper::New(f);
+   GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(f);
          fh->SetWriteTypeToDcmExplVR();
          fh->Write("/tmp/csa2.dcm");
 
    return 0;
 }
-} // end namespace gdcm
+//} // end namespace gdcm
 
 int main(int argc, char *argv[])
 {  
-   gdcm::File *f;
+   GDCM_NAME_SPACE::File *f;
  
    if( argc < 5 )
    {
@@ -417,14 +417,14 @@ int main(int argc, char *argv[])
 //   Read the input image.
 // ============================================================
 
-   f = gdcm::File::New( );
+   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 );
    f->SetMaxSizeLoadEntry(0xffff);
    bool res = f->Load();  
 
-   if( gdcm::Debug::GetDebugFlag())
+   if( GDCM_NAME_SPACE::Debug::GetDebugFlag())
    {
       std::cout << "---------------------------------------------" << std::endl;
       f->Print();
@@ -450,16 +450,16 @@ int main(int argc, char *argv[])
    std::cout << "Extracting tag: (0x" << std::hex << std::setw(4) << std::setfill('0')
      << group << ",0x" << std::setw(4) << std::setfill('0') << elem << ")" << std::endl;
    std::string dicom_tag_value = f->GetEntryString(group, elem);
-   if (dicom_tag_value == gdcm::GDCM_UNFOUND)
+   if (dicom_tag_value == GDCM_NAME_SPACE::GDCM_UNFOUND)
    {
-     gdcm::DictEntry *dictEntry = f->GetPubDict()->GetEntry( group, elem);
+     GDCM_NAME_SPACE::DictEntry *dictEntry = f->GetPubDict()->GetEntry( group, elem);
      std::cerr << "Image doesn't contain any tag: " << dictEntry->GetName() << std::endl;
      f->Delete();
      return 1;
    }
 
-   gdcm::DocEntry *dicom_tag_doc = f->GetDocEntry(group, elem);
-   gdcm::DataEntry *dicom_tag = dynamic_cast<gdcm::DataEntry *>(dicom_tag_doc);
+   GDCM_NAME_SPACE::DocEntry *dicom_tag_doc = f->GetDocEntry(group, elem);
+   GDCM_NAME_SPACE::DataEntry *dicom_tag = dynamic_cast<GDCM_NAME_SPACE::DataEntry *>(dicom_tag_doc);
    if( !dicom_tag )
    {
       std::cerr << "Sorry DataEntry only please" << std::endl;
@@ -481,7 +481,7 @@ int main(int argc, char *argv[])
    std::istringstream is;
    is.str( std::string( (char*)dicom_tag->GetBinArea(), dicom_tag->GetLength()) );
 
-   gdcm::convertCSA(is, f);
+   convertCSA(is, f);
 
    f->Delete();