]> Creatis software - gdcm.git/commitdiff
* Some classes inherit now from gdcm::RefCounter
authorregrain <regrain>
Tue, 25 Oct 2005 14:52:26 +0000 (14:52 +0000)
committerregrain <regrain>
Tue, 25 Oct 2005 14:52:26 +0000 (14:52 +0000)
   -- BeNours

75 files changed:
Example/Anonymize.cxx
Example/AnonymizeDicomDir.cxx
Example/AnonymizeNoLoad.cxx
Example/FindTags.cxx
Example/MakeDicomDir.cxx
Example/PatchHeader.cxx
Example/PrintDicomDir.cxx
Example/PrintFile.cxx
Example/ReWrite.cxx
Example/TestChangeHeader.cxx
Example/TestCopyDicom.cxx
Example/Volume2Dicom.cxx
Example/WriteDicomSimple.cxx
Example/WriteRead.cxx
Example/exColorToRGB.cxx
Example/exCurveData.cxx
Example/exExtractDicomTags.cxx
Example/exExtractTag.cxx
Example/exGC.cxx
Example/exGrey2RGB.cxx
Example/exImageLighten.cxx
Example/exOverlaysACR.cxx
Example/exReadPapyrus.cxx
Example/exReadWriteFile.cxx
Testing/TestAllReadCompareDicom.cxx
Testing/TestAllVM.cxx
Testing/TestBug.cxx
Testing/TestBuildUpDicomDir.cxx
Testing/TestDicomDir.cxx
Testing/TestDicomDirElement.cxx
Testing/TestDict.cxx
Testing/TestDictGroupName.cxx
Testing/TestFileAccessors.cxx
Testing/TestImageSet.cxx
Testing/TestLoadAllDocumentsNoPrivNoSeq.cxx
Testing/TestMakeDicomDir.cxx
Testing/TestMakeIcon.cxx
Testing/TestPrintAllDocument.cxx
Testing/TestReadWriteReadCompare.cxx
Testing/TestTS.cxx
Testing/TestVR.cxx
Testing/TestWriteSimple.cxx
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h
src/gdcmDicomDirElement.h
src/gdcmDicomDirImage.h
src/gdcmDicomDirMeta.h
src/gdcmDicomDirObject.h
src/gdcmDicomDirPatient.cxx
src/gdcmDicomDirPatient.h
src/gdcmDicomDirSerie.cxx
src/gdcmDicomDirSerie.h
src/gdcmDicomDirStudy.cxx
src/gdcmDicomDirStudy.h
src/gdcmDicomDirVisit.h
src/gdcmDict.h
src/gdcmDictGroupName.h
src/gdcmDictSet.cxx
src/gdcmDictSet.h
src/gdcmDocEntrySet.h
src/gdcmDocument.cxx
src/gdcmDocument.h
src/gdcmElementSet.h
src/gdcmFile.cxx
src/gdcmFile.h
src/gdcmFileHelper.cxx
src/gdcmFileHelper.h
src/gdcmGlobal.cxx
src/gdcmSQItem.h
src/gdcmSeqEntry.cxx
src/gdcmSerieHelper.cxx
src/gdcmTS.h
src/gdcmVR.h
vtk/vtkGdcmReader.cxx
vtk/vtkGdcmWriter.cxx

index 16983535180204d0a58e446c8abe02a7f1a360bd..7e33bfa6fc58ef5fb93ad7d41620f00e58d0c3f9 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: Anonymize.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/30 15:13:05 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2005/10/25 14:52:26 $
+  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
@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
 
    gdcm::File *f;
 
-   f = new gdcm::File(  );
+   f = gdcm::File::New(  );
    f->SetLoadMode( gdcm::LD_ALL );
    f->SetFileName( fileName );
    int res = f->Load();
@@ -85,7 +85,7 @@ int main(int argc, char *argv[])
    {
        std::cerr << "Sorry, " << fileName <<"  not a gdcm-readable "
                  << "DICOM / ACR File" <<std::endl;
-       delete f;  
+       f->Delete();
        return 0;
    }
    std::cout << " ... is readable " << std::endl;
@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
    // ============================================================
 
    // We need a gdcm::FileHelper, since we want to load the pixels        
-   gdcm::FileHelper *fh = new gdcm::FileHelper(f);
+   gdcm::FileHelper *fh = gdcm::FileHelper::New(f);
 
    // (unit8_t DOESN'T mean it's mandatory for the image to be a 8 bits one) 
 
@@ -106,8 +106,8 @@ int main(int argc, char *argv[])
        std::cerr << "Sorry, Pixels of" << fileName <<"  are not "
            << " gdcm-readable."       << std::endl
                  << "Use exAnonymizeNoLoad" << std::endl;
-       delete f;  
-       delete fh;    
+       f->Delete();
+       fh->Delete();
        return 0;
    } 
 
@@ -143,8 +143,8 @@ int main(int argc, char *argv[])
    // ============================================================  
    f->ClearAnonymizeList();
     
-   delete f;
-   delete fh; 
+   f->Delete();
+   fh->Delete();
    return 0;
 }
 
index 02190c34f61bd63ab2c715f2d5e1533b1a2a6291..747714b538ff476dd775f5c4c4d9f03e06177204 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: AnonymizeDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:43 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2005/10/25 14:52:26 $
+  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
@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
 
    //   Read the input DICOMDIR
    gdcm::File *f;
-   f = new gdcm::File( );
+   f = gdcm::File::New( );
    f->SetLoadMode(0);
    f->SetFileName( fileName );
    bool res = f->Load();  
@@ -123,7 +123,7 @@ int main(int argc, char *argv[])
    if ( !e )
    {
       std::cout << "No Directory Record Sequence (0004,1220) found" <<std::endl;;
-      delete f;
+      f->Delete();
       return 0;
    }
    
@@ -131,7 +131,7 @@ int main(int argc, char *argv[])
    if ( !s )
    {
       std::cout << "Element (0004,1220) is not a Sequence ?!?" <<std::endl;
-      delete f;
+      f->Delete();
       return 0;
    }
 
@@ -188,7 +188,8 @@ int main(int argc, char *argv[])
 
    fp->close();
 
-   delete f;
+   delete fp;
+   f->Delete();
    return 0;
 }
 
index 3fa8500583f2e5cbf000660614440308e99440c9..0eb1da3fb4823b163ed5cecfaf9bc8d38c6a3f38 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: AnonymizeNoLoad.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/30 15:13:05 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2005/10/25 14:52:26 $
+  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
@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
    // 
    //   Parse the input file.
    // 
-      f = new gdcm::File( );
+      f = gdcm::File::New( );
       f->SetLoadMode(loadMode);
       f->SetFileName( fileName );
 
@@ -119,7 +119,7 @@ int main(int argc, char *argv[])
               << "Sorry, " << fileName <<"  not a gdcm-readable "
               << "DICOM / ACR Document"
               << std::endl;
-           delete f;
+           f->Delete();
            return 1;
       }
       std::cout << fileName << " is readable " << std::endl;
@@ -179,7 +179,7 @@ int main(int argc, char *argv[])
       //   
       f->ClearAnonymizeList();
  
-      delete f;
+      f->Delete();
       return 0;
 
    }
@@ -192,13 +192,13 @@ int main(int argc, char *argv[])
                                  it != fileList.end();
                                  ++it )
       {
-         f = new gdcm::File( );
+         f = gdcm::File::New( );
          f->SetLoadMode(loadMode);
          f->SetFileName( it->c_str() );
 
          if ( !f->Load() )
          {
-            delete f; 
+            f->Delete();
             continue;
          }
          // 
@@ -243,10 +243,9 @@ int main(int argc, char *argv[])
 
          f->ClearAnonymizeList();
     
-         delete f;         
-        }
-
-     }
+         f->Delete();
+      }
+   }
    return 0;
 }
 
index a1b9e4f7c5f213f5dd2d725d79131a5ae7ae71c3..a56ddb4a3db1f199c770727b7744e7afe353c46b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: FindTags.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:43 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2005/10/25 14:52:26 $
+  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
@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
    std::string fileName;
 
    gdcm::FileHelper *h;
-   gdcm::File *f = new gdcm::File();
+   gdcm::File *f = gdcm::File::New();
    
    
    if(argc > 1 ) 
@@ -42,7 +42,7 @@ int main(int argc, char *argv[])
    f->Load();
    // Should test if it worked !
    
-   h = new gdcm::FileHelper(f);
+   h = gdcm::FileHelper::New(f);
    
    std::string ManufacturerName="SIEMENS ";
    std::string RecCode="ACR-NEMA 2.0";
@@ -113,6 +113,9 @@ int main(int argc, char *argv[])
 
    std::cout << "----------------apres Write---------------------" << std::endl;
 
+   h->Delete();
+   f->Delete();
+
    return 0;
 }
 
index e8ebe98394f3057f880fbdbb2fc6bebe0eba24e5..bb97ae6b2a66609fcaaf2e15a40d0174c430e892 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: MakeDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/31 09:29:10 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2005/10/25 14:52:26 $
+  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
@@ -103,7 +103,7 @@ int main(int argc, char *argv[])
 
    // we ask for Directory parsing
 
-   dcmdir = new gdcm::DicomDir( );
+   dcmdir = gdcm::DicomDir::New( );
 
    dcmdir->SetStartMethod(StartMethod);
    dcmdir->SetEndMethod(EndMethod);
@@ -119,17 +119,17 @@ int main(int argc, char *argv[])
    {
       std::cout << "makeDicomDir: no patient found. Exiting."
                 << std::endl;
-      delete dcmdir;
+      dcmdir->Delete();
       return 1;
    }
     
    // ----- Create the corresponding DicomDir
 
    dcmdir->Write("NewDICOMDIR");
-   delete dcmdir;
+   dcmdir->Delete();
 
    // Read from disc the just written DicomDir
-   gdcm::DicomDir *newDicomDir = new gdcm::DicomDir();
+   gdcm::DicomDir *newDicomDir = gdcm::DicomDir::New();
    newDicomDir->SetFileName( "NewDICOMDIR" );
    newDicomDir->Load();
    if( !newDicomDir->IsReadable() )
@@ -138,7 +138,7 @@ int main(int argc, char *argv[])
                <<" is not readable"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete newDicomDir;
+      newDicomDir->Delete();
       return 1;
    }
 
@@ -148,12 +148,12 @@ int main(int argc, char *argv[])
                <<" has no patient"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete newDicomDir;
+      newDicomDir->Delete();
       return(1);
    }
 
    std::cout<<std::flush;
 
-   delete newDicomDir;
+   newDicomDir->Delete();
    return 0;
 }
index 27654339ab8d9965dfd21ee63171c00e3cfd94b6..e88de9161a81fa8211ccae3619e37539b92da934 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: PatchHeader.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/30 15:13:05 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2005/10/25 14:52:27 $
+  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
@@ -269,7 +269,7 @@ int main(int argc, char *argv[])
       loadMode |= gdcm::LD_NOSHADOWSEQ;
    else 
    {
-   if ( am->ArgMgrDefined("noshadow") )
+      if ( am->ArgMgrDefined("noshadow") )
          loadMode |= gdcm::LD_NOSHADOW;
       if ( am->ArgMgrDefined("noseq") )
          loadMode |= gdcm::LD_NOSEQ;
@@ -288,12 +288,10 @@ int main(int argc, char *argv[])
 
    if ( fileName != 0 ) // ====== Deal with a single file ======
    {
-
-   // 
-   //   Parse the input file.
-   // 
-      
-      f = new gdcm::File( );
+      // 
+      //   Parse the input file.
+      // 
+      f = gdcm::File::New( );
       f->SetLoadMode(loadMode);
       f->SetFileName( fileName );
       bool res = f->Load();
@@ -303,12 +301,12 @@ int main(int argc, char *argv[])
       // not only gdcm::File (as opposed to gdcm::DicomDir)
       if ( !res ) 
       {
-          std::cout <<std::endl
-              << "Sorry, " << fileName <<"  not a gdcm-readable "
-              << "DICOM / ACR Document"
-              << std::endl;
-           delete f;
-           return 1;
+         std::cout <<std::endl
+            << "Sorry, " << fileName <<"  not a gdcm-readable "
+            << "DICOM / ACR Document"
+            << std::endl;
+         f->Delete();
+         return 1;
       }
       std::cout << fileName << " is readable " << std::endl;
 
@@ -325,7 +323,7 @@ int main(int argc, char *argv[])
 
       fp->close();
       delete fp; 
-      delete f;
+      f->Delete();
       return 0;
 
    }
@@ -338,14 +336,14 @@ int main(int argc, char *argv[])
                                  it != fileList.end();
                                  ++it )
       {
-         f = new gdcm::File( );
+         f = gdcm::File::New( );
          f->SetLoadMode(loadMode);
          f->SetFileName( it->c_str() );
          bool res = f->Load();
 
          if ( !res )
          {
-            delete f
+            f->Delete()
             continue;
          }
 
@@ -357,8 +355,8 @@ int main(int argc, char *argv[])
 
          fp->close();
          delete fp; 
-         delete f;
-     }
+         f->Delete();
+      }
    }
    return 0;
 }
index 2d40b7df35723832e6570febd2800222daa78eea..29dfdc800a0655b8535bb22a16877cf967f972bf 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: PrintDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:43 $
-  Version:   $Revision: 1.29 $
+  Date:      $Date: 2005/10/25 14:52:27 $
+  Version:   $Revision: 1.30 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -81,7 +81,7 @@ int main(int argc, char* argv[])
 
    // new gdcm2 style 
 
-   f = new gdcm::DicomDir();
+   f = gdcm::DicomDir::New();
    f->SetFileName ( fileName );
    f->Load( );
 
@@ -92,7 +92,7 @@ int main(int argc, char* argv[])
                <<"' is not readable"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete f;
+      f->Delete();
       return 1;
    }
 
@@ -106,152 +106,161 @@ int main(int argc, char* argv[])
                <<" has no patient"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete f;
+      f->Delete();
       return 1;
    }
 
 // Structure use Examples 
 
    switch (detailLevel)
-  { 
-  case 1:
-     std::cout << std::endl << std::endl  
-       << " =  PATIENT List ==========================================" 
-       << std::endl<< std::endl;
-
-      pa = f->GetFirstPatient();
-      while (pa) 
-      {
-         std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
-         std::cout << " Pat.ID:[";
-         std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
-         pa = f->GetNextPatient();    
-      }
-      break;
-
-   case 2:    
-      std::cout << std::endl << std::endl  
-        << " = PATIENT/STUDY List =======================================" 
-        << std::endl<< std::endl;
-
-      pa = f->GetFirstPatient();
-      while ( pa ) // on degouline les PATIENT de ce DICOMDIR
-      {  
-         std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
-         std::cout << " Pat.ID:[";
-         std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
-         st = pa->GetFirstStudy();
-         while ( st ) { // on degouline les STUDY de ce patient
-            std::cout << "--- Stud.descr:["    << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description 
-            std::cout << " Stud.ID:["          << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID
-            std::cout << std::endl; 
-            st = pa->GetNextStudy();
+   { 
+      case 1:
+         std::cout << std::endl << std::endl  
+         << " =  PATIENT List ==========================================" 
+         << std::endl<< std::endl;
+
+         pa = f->GetFirstPatient();
+         while (pa) 
+         {
+            std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
+            std::cout << " Pat.ID:[";
+            std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
+            pa = f->GetNextPatient();    
          }
-         pa = f->GetNextPatient();    
-      }   
-      break;
+         break;
+
+      case 2:    
+         std::cout << std::endl << std::endl  
+         << " = PATIENT/STUDY List =======================================" 
+         << std::endl<< std::endl;
+
+         pa = f->GetFirstPatient();
+         while ( pa ) // on degouline les PATIENT de ce DICOMDIR
+         {  
+            std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
+            std::cout << " Pat.ID:[";
+            std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
+            st = pa->GetFirstStudy();
+            while ( st ) 
+            { // on degouline les STUDY de ce patient
+               std::cout << "--- Stud.descr:["    << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description 
+               std::cout << " Stud.ID:["          << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID
+               std::cout << std::endl; 
+               st = pa->GetNextStudy();
+            }
+            pa = f->GetNextPatient();    
+         }   
+         break;
+
+      case 3: 
+         std::cout << std::endl << std::endl  
+         << " =  PATIENT/STUDY/SERIE List ==================================" 
+         << std::endl<< std::endl;
+
+         pa = f->GetFirstPatient(); 
+         while ( pa )   // on degouline les PATIENT de ce DICOMDIR
+         {
+            // Patient's Name, Patient ID 
+            std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
+            std::cout << " Pat.ID:[";
+            std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
+
+            st = pa->GetFirstStudy();
+            while ( st ) 
+            { // on degouline les STUDY de ce patient
+               std::cout << "--- Stud.descr:["    << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description 
+               std::cout << " Stud.ID:["          << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID
+               std::cout << std::endl;
+
+               se = st->GetFirstSerie();
+               while ( se ) 
+               { // on degouline les SERIES de cette study
+                  std::cout << "--- --- Ser.Descr:["<< se->GetEntryString(0x0008, 0x103e)<< "]";  // Series Description
+                  std::cout << " Ser.nb:["          << se->GetEntryString(0x0020, 0x0011);        // Series number
+                  std::cout << "] Mod.:["           << se->GetEntryString(0x0008, 0x0060) << "]"; // Modality
+                  std::cout << std::endl;    
+                  se = st->GetNextSerie();   
+               }
 
-   case 3: 
-      std::cout << std::endl << std::endl  
-        << " =  PATIENT/STUDY/SERIE List ==================================" 
-        << std::endl<< std::endl;
+               vs = st->GetFirstVisit();
+               while ( vs ) 
+               { // on degouline les VISIT de cette study
+                  std::cout << "--- --- VISIT: ";
+                  std::cout << " Ref. File ID :[" << vs->GetEntryString(0x0004, 0x1500) << "]"; // Referenced File ID
+                  std::cout << " Inst.Name:["    << vs->GetEntryString(0x0008,0x0080)   << "]"; // Institution Name
+                  std::cout << " Adm.ID:["      << vs->GetEntryString(0x0038, 0x0010)   << "]"; // Admission ID
+                  std::cout << " Adm. date:["   << vs->GetEntryString(0x0038, 0x0020)   << "]"; // Admitting Date
+                  std::cout << std::endl;    
+                  vs = st->GetNextVisit();    
+               }
 
-      pa = f->GetFirstPatient(); 
-      while ( pa )   // on degouline les PATIENT de ce DICOMDIR
-      {
-       // Patient's Name, Patient ID 
-         std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
-         std::cout << " Pat.ID:[";
-         std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
-
-         st = pa->GetFirstStudy();
-         while ( st ) { // on degouline les STUDY de ce patient
-            std::cout << "--- Stud.descr:["    << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description 
-            std::cout << " Stud.ID:["          << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID
-            std::cout << std::endl;
-
-            se = st->GetFirstSerie();
-            while ( se ) { // on degouline les SERIES de cette study
-               std::cout << "--- --- Ser.Descr:["<< se->GetEntryString(0x0008, 0x103e)<< "]";  // Series Description
-               std::cout << " Ser.nb:["          << se->GetEntryString(0x0020, 0x0011);        // Series number
-               std::cout << "] Mod.:["           << se->GetEntryString(0x0008, 0x0060) << "]"; // Modality
-               std::cout << std::endl;    
-               se = st->GetNextSerie();   
-            }
-  
-            vs = st->GetFirstVisit();
-            while ( vs ) { // on degouline les VISIT de cette study
-               std::cout << "--- --- VISIT: ";
-               std::cout << " Ref. File ID :[" << vs->GetEntryString(0x0004, 0x1500) << "]"; // Referenced File ID
-               std::cout << " Inst.Name:["    << vs->GetEntryString(0x0008,0x0080)   << "]"; // Institution Name
-               std::cout << " Adm.ID:["      << vs->GetEntryString(0x0038, 0x0010)   << "]"; // Admission ID
-               std::cout << " Adm. date:["   << vs->GetEntryString(0x0038, 0x0020)   << "]"; // Admitting Date
-               std::cout << std::endl;    
-               vs = st->GetNextVisit();    
+               st = pa->GetNextStudy();
             }
+            pa = f->GetNextPatient();    
+         } 
+         break;
+
+      case 4:  
+         std::cout << std::endl << std::endl  
+         << " = PATIENT/STUDY/SERIE/IMAGE List ============================" 
+         << std::endl<< std::endl;
+
+         pa = f->GetFirstPatient(); 
+         while ( pa )
+         {  // les PATIENT de ce DICOMDIR
+            // Patient's Name, Patient ID 
+            std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
+            std::cout << " Pat.ID:[";
+            std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
+
+            st = pa->GetFirstStudy();
+            while ( st ) 
+            { // on degouline les STUDY de ce patient
+               std::cout << "--- Stud.descr:["    << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description 
+               std::cout << " Stud.ID:["          << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID
+               std::cout << std::endl;
+
+               vs = st->GetFirstVisit();
+               while ( vs ) 
+               { // on degouline les VISIT de cette study
+                  std::cout << "--- --- VISIT: ";
+                  std::cout << " Ref. File ID :[" << vs->GetEntryString(0x0004, 0x1500) << "]"; // Referenced File ID
+                  std::cout << " Inst.Name:["    << vs->GetEntryString(0x0008,0x0080)   << "]"; // Institution Name
+                  std::cout << " Adm.ID:["      << vs->GetEntryString(0x0038, 0x0010)   << "]"; // Admission ID
+                  std::cout << " Adm. date:["   << vs->GetEntryString(0x0038, 0x0020)   << "]"; // Admitting Date
+                  std::cout << std::endl;    
+                  vs = st->GetNextVisit();    
+               }
 
-            st = pa->GetNextStudy();
+               se = st->GetFirstSerie();
+               while ( se ) 
+               { // on degouline les SERIES de cette study
+                  std::cout << "--- --- Ser.Descr:["<< se->GetEntryString(0x0008, 0x103e)<< "]";  // Series Description
+                  std::cout << " Ser.nb:["         <<  se->GetEntryString(0x0020, 0x0011);        // Series number
+                  std::cout << "] Mod.:["          <<  se->GetEntryString(0x0008, 0x0060) << "]"; // Modality
+                  std::cout << std::endl;    
+
+                  im = se->GetFirstImage();
+                  while ( im ) 
+                  { // on degouline les Images de cette serie
+                     std::cout << "--- --- --- "<< " IMAGE Ref. File ID :[" << im->GetEntryString(0x0004, 0x1500) 
+                               << "]" << std::endl; // File name (Referenced File ID)
+                     im = se->GetNextImage();   
+                  }
+                  se = st->GetNextSerie();   
+               }
+               st = pa->GetNextStudy();
+            }     
+            pa = f->GetNextPatient();    
          }
-         pa = f->GetNextPatient();    
-      } 
-      break;
-
-   case 4:  
-      std::cout << std::endl << std::endl  
-           << " = PATIENT/STUDY/SERIE/IMAGE List ============================" 
-           << std::endl<< std::endl;
-      pa = f->GetFirstPatient(); 
-      while ( pa ) {  // les PATIENT de ce DICOMDIR
-       // Patient's Name, Patient ID 
-         std::cout << "Pat.Name:[" << pa->GetEntryString(0x0010, 0x0010) <<"]"; // Patient's Name
-         std::cout << " Pat.ID:[";
-         std::cout << pa->GetEntryString(0x0010, 0x0020) << "]" << std::endl; // Patient ID
-
-         st = pa->GetFirstStudy();
-         while ( st ) { // on degouline les STUDY de ce patient
-            std::cout << "--- Stud.descr:["    << st->GetEntryString(0x0008, 0x1030) << "]"; // Study Description 
-            std::cout << " Stud.ID:["          << st->GetEntryString(0x0020, 0x0010) << "]"; // Study ID
-            std::cout << std::endl;
-  
-            vs = st->GetFirstVisit();
-            while ( vs ) { // on degouline les VISIT de cette study
-               std::cout << "--- --- VISIT: ";
-               std::cout << " Ref. File ID :[" << vs->GetEntryString(0x0004, 0x1500) << "]"; // Referenced File ID
-               std::cout << " Inst.Name:["    << vs->GetEntryString(0x0008,0x0080)   << "]"; // Institution Name
-               std::cout << " Adm.ID:["      << vs->GetEntryString(0x0038, 0x0010)   << "]"; // Admission ID
-               std::cout << " Adm. date:["   << vs->GetEntryString(0x0038, 0x0020)   << "]"; // Admitting Date
-               std::cout << std::endl;    
-               vs = st->GetNextVisit();    
-            }
+         break;
 
-            se = st->GetFirstSerie();
-            while ( se ) { // on degouline les SERIES de cette study
-               std::cout << "--- --- Ser.Descr:["<< se->GetEntryString(0x0008, 0x103e)<< "]";  // Series Description
-               std::cout << " Ser.nb:["         <<  se->GetEntryString(0x0020, 0x0011);        // Series number
-               std::cout << "] Mod.:["          <<  se->GetEntryString(0x0008, 0x0060) << "]"; // Modality
-               std::cout << std::endl;    
-
-               im = se->GetFirstImage();
-               while ( im ) { // on degouline les Images de cette serie
-                  std::cout << "--- --- --- "<< " IMAGE Ref. File ID :[" << im->GetEntryString(0x0004, 0x1500) 
-                            << "]" << std::endl; // File name (Referenced File ID)
-                  im = se->GetNextImage();   
-               }
-               se = st->GetNextSerie();   
-           }
-            st = pa->GetNextStudy();
-        }     
-        pa = f->GetNextPatient();    
-      }
-      break;
-
-   case 5:
-      std::cout << std::endl << std::endl  
-           << " = DICOMDIR full content ==========================================" 
-           << std::endl<< std::endl;
-      f->Print();
-      break;
+      case 5:
+         std::cout << std::endl << std::endl  
+         << " = DICOMDIR full content ==========================================" 
+         << std::endl<< std::endl;
+         f->Print();
+         break;
 
    }  // end switch
 
@@ -296,7 +305,7 @@ int main(int argc, char* argv[])
    else
       std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
    std::cout<<std::flush;
-   delete f;
+   f->Delete();
 
    return(0);
 }
index 6a01b9041faab88f618a916b8b98e268ae82d95e..d2291f7aa1269f1d6491d01b34103d933cad21d8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: PrintFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/20 08:53:21 $
-  Version:   $Revision: 1.65 $
+  Date:      $Date: 2005/10/25 14:52:27 $
+  Version:   $Revision: 1.66 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -219,7 +219,7 @@ int main(int argc, char *argv[])
       // any kind of gdcm-Parsable *document* 
       // not only gdcm::File (as opposed to gdcm::DicomDir)
 
-      gdcm::File *f = new gdcm::File();
+      gdcm::File *f = gdcm::File::New();
       f->SetLoadMode(loadMode);
       f->SetFileName( fileName );
 
@@ -239,11 +239,11 @@ int main(int argc, char *argv[])
                    << std::endl;
          std::cout << "use 'PrintFile filein=... debug' to try to guess the pb"
                    << std::endl;
-         delete f;
+         f->Delete();
          return 0;
       }
 
-      gdcm::FileHelper *fh = new gdcm::FileHelper(f);
+      gdcm::FileHelper *fh = gdcm::FileHelper::New(f);
       fh->SetPrintLevel( level );
 
       fh->Print();
@@ -286,6 +286,7 @@ int main(int argc, char *argv[])
             std::cout << "Transfer Syntax not loaded. " << std::endl
                      << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
                   << std::endl;
+            f->Delete();
             return 0;
          }
   
@@ -378,7 +379,7 @@ int main(int argc, char *argv[])
                gdcm::SQItem *sqi= modLutSeq->GetFirstSQItem();
                if ( !sqi )
                {
-               std::string lutDescriptor = sqi->GetEntryString(0x0028,0x3002);
+                  std::string lutDescriptor = sqi->GetEntryString(0x0028,0x3002);
                   int length;   // LUT length in Bytes
                   int deb;      // Subscript of the first Lut Value
                   int nbits;    // Lut item size (in Bits)
@@ -463,7 +464,7 @@ int main(int argc, char *argv[])
       }
  
       std::cout<<std::flush;
-      delete f;
+      f->Delete();
       delete fh;
    }
    else  // ====== Deal with a Directory ======
@@ -473,13 +474,14 @@ int main(int argc, char *argv[])
       gdcm::DirListType fileList = dirList.GetFilenames();
       gdcm::File *f;
       bool res;
+
       for( gdcm::DirListType::iterator it  = fileList.begin();
                                  it != fileList.end();
                                  ++it )
       {
          std::cout << std::endl<<" Start processing :[" << it->c_str() << "]"
                    << std::endl;
-         f = new gdcm::File();
+         f = gdcm::File::New();
          f->SetLoadMode(loadMode);
          f->SetFileName( it->c_str() );
 
@@ -503,11 +505,11 @@ int main(int argc, char *argv[])
             std::cout << "use 'PrintFile filein=... debug' "
                       << "to try to guess the pb"
                       << std::endl;
-            delete f;
+            f->Delete();
             continue;
          }
 
-         gdcm::FileHelper *fh = new gdcm::FileHelper(f);
+         gdcm::FileHelper *fh = gdcm::FileHelper::New(f);
          fh->SetPrintLevel( level );
          fh->Print();
 
@@ -580,8 +582,8 @@ int main(int argc, char *argv[])
          else
             std::cout <<std::endl<<it->c_str()<<" is NOT Readable"<<std::endl;
          std::cout << "\n\n" << std::endl;
-         delete f;
-         delete fh;
+         f->Delete();
+         fh->Delete();
       }
       std::cout<<std::flush;
    }
index bde09d1e0afedd0610737ff3a09ff00956f0bee4..e049bec852269f2c8b1a77c259640f2b370c28da 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: ReWrite.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/21 08:39:31 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2005/10/25 14:52:27 $
+  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
@@ -96,24 +96,24 @@ int main(int argc, char *argv[])
 
    // ----------- End Arguments Manager ---------
 
-   gdcm::File *f = new gdcm::File();
+   gdcm::File *f = gdcm::File::New();
    f->SetLoadMode( loadMode );
    f->SetFileName( fileName );
    bool res = f->Load();  
    if ( !res )
    {
-      delete f;
+      f->Delete();
       return 0;
    }
   
    if (!f->IsReadable())
    {
        std::cerr << "Sorry, not a Readable DICOM / ACR File"  <<std::endl;
-       delete f;
+       f->Delete();
        return 0;
    }
    
-   gdcm::FileHelper *fh = new gdcm::FileHelper(f);
+   gdcm::FileHelper *fh = gdcm::FileHelper::New(f);
    void *imageData; 
    int dataSize;
   
@@ -162,74 +162,68 @@ int main(int argc, char *argv[])
 
    switch (mode[0])
    {
-   case 'A' :
-   case 'a' :
-            // Writting an ACR file
-            // from a full gdcm readable File
-
-      std::cout << "WriteACR" << std::endl;
-      fh->WriteAcr(outputFileName);
-      break;
-
-   case 'D' : // Not documented in the 'usage', because the method 
-   case 'd' : //                             is known to be bugged. 
-              // Writting a DICOM Implicit VR file
-              // from a full gdcm readable File
-
-      std::cout << "WriteDCM Implicit VR" << std::endl;
-      fh->WriteDcmImplVR(outputFileName);
-      break;
-
-   case 'X' :
-   case 'x' :
-              // writting a DICOM Explicit VR 
-              // from a full gdcm readable File
-
-      std::cout << "WriteDCM Explicit VR" << std::endl;
-      // fh->WriteDcmExplVR(outputFileName);
-      // Try this one :
-      fh->SetWriteTypeToDcmExplVR();
-      fh->Write(outputFileName);
-      break;
-
-   case 'R' :
-   case 'r' :
-             //  Writting a Raw File, 
-
-      std::cout << "WriteRaw" << std::endl;
-      fh->WriteRawData(outputFileName);
-      break;
+      case 'A' :
+      case 'a' :
+      // Writting an ACR file
+      // from a full gdcm readable File
+         std::cout << "WriteACR" << std::endl;
+         fh->WriteAcr(outputFileName);
+         break;
+
+      case 'D' : // Not documented in the 'usage', because the method 
+      case 'd' : //                             is known to be bugged. 
+      // Writting a DICOM Implicit VR file
+      // from a full gdcm readable File
+         std::cout << "WriteDCM Implicit VR" << std::endl;
+         fh->WriteDcmImplVR(outputFileName);
+         break;
+
+      case 'X' :
+      case 'x' :
+      // writting a DICOM Explicit VR 
+      // from a full gdcm readable File
+         std::cout << "WriteDCM Explicit VR" << std::endl;
+         // fh->WriteDcmExplVR(outputFileName);
+         // Try this one :
+         fh->SetWriteTypeToDcmExplVR();
+         fh->Write(outputFileName);
+         break;
+
+      case 'R' :
+      case 'r' :
+      //  Writting a Raw File, 
+         std::cout << "WriteRaw" << std::endl;
+         fh->WriteRawData(outputFileName);
+         break;
  
  // Just for fun :
  // Write a 'Video inverse' version of the file.
  // *Not* described, on purpose,  in the USAGE  
-   
-  case 'V' :
-  case 'v' :
-
-     if ( fh->GetFile()->GetBitsAllocated() == 8)
-     {
-        std::cout << "videoinv for 8 bits" << std::endl;
-        for (int i=0; i<dataSize; i++) 
-        {
-           ((uint8_t*)imageData)[i] = 255 - ((uint8_t*)imageData)[i];
-        }
-     }
-     else
-     {
-        std::cout << "videoinv for 16 bits" << std::endl;    
-        for (int i=0; i<dataSize/2; i++) 
-        {
-           ((uint16_t*)imageData)[i] =  65535 - ((uint16_t*)imageData)[i];
-        }
-     }
-     std::cout << "WriteDCM Explicit VR + VideoInv" << std::endl;
-     fh->WriteDcmExplVR(outputFileName);
-     break;      
-
+      case 'V' :
+      case 'v' :
+         if ( fh->GetFile()->GetBitsAllocated() == 8)
+         {
+            std::cout << "videoinv for 8 bits" << std::endl;
+            for (int i=0; i<dataSize; i++) 
+            {
+               ((uint8_t*)imageData)[i] = 255 - ((uint8_t*)imageData)[i];
+            }
+         }
+         else
+         {
+            std::cout << "videoinv for 16 bits" << std::endl;    
+            for (int i=0; i<dataSize/2; i++) 
+            {
+               ((uint16_t*)imageData)[i] =  65535 - ((uint16_t*)imageData)[i];
+            }
+         }
+         std::cout << "WriteDCM Explicit VR + VideoInv" << std::endl;
+         fh->WriteDcmExplVR(outputFileName);
+         break;
    }
-   delete f;
-   delete fh;
+
+   f->Delete();
+   fh->Delete();
    return 0;
 }
 
index eac9c7269501c6bc9c9534b360cbe9ec76084faa..c6c19cd3d13c3a7cb1bde55058df93eb58ff52aa 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestChangeHeader.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/21 08:37:44 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2005/10/25 14:52:27 $
+  Version:   $Revision: 1.18 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 
 int main(int argc, char *argv[])
 {
-    if (argc < 3)
-    {
-       std::cerr << "usage :" << std::endl <<
-         argv[0] << " fileNameForHeader fileNameForData" << 
-         std::endl;
-       return 1;
-    }
+   if (argc < 3)
+   {
+      std::cerr << "usage :" << std::endl <<
+      argv[0] << " fileNameForHeader fileNameForData" << 
+      std::endl;
+      return 1;
+   }
 
-    gdcm::File *h1 = new gdcm::File( );
-    h1->SetFileName ( argv[1] );
-    h1->Load( );
-    gdcm::FileHelper  *f1 = new gdcm::FileHelper( h1 );
-    
-    gdcm::File *h2 = new gdcm::File( );
-    h2->SetFileName ( argv[2] );
-    h2->Load( );
-    gdcm::FileHelper  *f2 = new gdcm::FileHelper( h2 );   
-    
+   gdcm::File *h1 = gdcm::File::New( );
+   h1->SetFileName ( argv[1] );
+   h1->Load( );
+   gdcm::FileHelper  *f1 = gdcm::FileHelper::New( h1 );
+   
+   gdcm::File *h2 = gdcm::File::New( );
+   h2->SetFileName ( argv[2] );
+   h2->Load( );
+   gdcm::FileHelper  *f2 = gdcm::FileHelper::New( h2 );   
+   
 
-    // 0018 1310 US ACQ Acquisition Matrix
-    gdcm::DictEntry *dictEntry =
-                          f2->GetFile()->GetPubDict()->GetEntry( 0x0018, 1310 );
-    std::cerr << std::hex << dictEntry->GetGroup() << "," 
-              << dictEntry->GetElement() << std::endl;
+   // 0018 1310 US ACQ Acquisition Matrix
+   gdcm::DictEntry *dictEntry =
+                        f2->GetFile()->GetPubDict()->GetEntry( 0x0018, 1310 );
+   std::cerr << std::hex << dictEntry->GetGroup() << "," 
+            << dictEntry->GetElement() << std::endl;
 
-    std::string matrix = f2->GetFile()->GetEntryString(0x0018, 0x1310);
-    if(matrix != "gdcm::Unfound")
-    {
-       std::cerr << "Aquisition Matrix:" << matrix << std::endl;
-       f1->GetFile()->InsertEntryString( matrix, 0x0018, 0x1310);
-    }
+   std::string matrix = f2->GetFile()->GetEntryString(0x0018, 0x1310);
+   if(matrix != "gdcm::Unfound")
+   {
+      std::cerr << "Aquisition Matrix:" << matrix << std::endl;
+      f1->GetFile()->InsertEntryString( matrix, 0x0018, 0x1310);
+   }
 
-    f1->GetImageData();
-    
-    h1->Print();
-    
-    f1->WriteDcmExplVR("output-matrix.dcm");
-    
-    delete f1;
-    delete f2;
-    delete h1;
-    delete h2;
+   f1->GetImageData();
+   
+   h1->Print();
+   
+   f1->WriteDcmExplVR("output-matrix.dcm");
+   
+   f1->Delete();
+   f2->Delete();
+   h1->Delete();
+   h2->Delete();
 
-    return 0;
+   return 0;
 }
index 081c58c1ee7da1ddd4c7394830048f009661ace7..77be5b59cf1283ebb14c3bf5397bcc180441e034 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestCopyDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:43 $
-  Version:   $Revision: 1.31 $
+  Date:      $Date: 2005/10/25 14:52:27 $
+  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
@@ -66,7 +66,6 @@ int main(int argc, char *argv[])
    }
 
 // don't modify identation in order to let this source xdiffable with ../Test
-
       std::string filename = argv[1];
       std::string output = argv[2];
 
@@ -81,26 +80,21 @@ int main(int argc, char *argv[])
             return 1;
          }
       }
-      gdcm::File *fileOr = new gdcm::File();
+      gdcm::File *fileOr = gdcm::File::New();
       fileOr->SetFileName( filename );
       fileOr->Load();
-      gdcm::FileHelper *original = new gdcm::FileHelper( fileOr );
+      gdcm::FileHelper *original = gdcm::FileHelper::New( fileOr );
    
       std::cout << "--- Original ----------------------" << std::endl;
-      //original->GetFile()->Print();
    
-      gdcm::FileHelper *copy = new gdcm::FileHelper( );
+      gdcm::FileHelper *copy = gdcm::FileHelper::New( );
       copy->SetFileName( output );
       copy->Load();
 
-      //size_t dataSize;
       uint8_t *imageData;
-      //dataSize = original->GetImageDataSize();// just an accesor :useless here
       
       imageData = original->GetImageData(); // VERY important : 
                                       // brings pixels into memory !
-      //(void)imageData; // not enough to avoid warning with icc compiler
-      //(void)dataSize; //  not enough to avoid warning on 'Golgot'
   
       std::cout << imageData << std::endl; // to avoid warning ?
 
@@ -117,19 +111,16 @@ int main(int argc, char *argv[])
          }
          else
          {
-          // We skip pb of SQ recursive exploration
-          std::cout << "Skipped Sequence " 
-                    << "------------- " << d->GetVR() << " "<< std::hex
-                    << d->GetGroup() << "," << d->GetElement()
-                    << std::endl;    
+            // We skip pb of SQ recursive exploration
+            std::cout << "Skipped Sequence " 
+                      << "------------- " << d->GetVR() << " "<< std::hex
+                      << d->GetGroup() << "," << d->GetElement()
+                      << std::endl;    
          }
 
          d=original->GetFile()->GetNextEntry();
       }
 
-      //copy->GetImageData();
-      //copy->SetImageData(imageData, dataSize);
-
       std::cout << "--- Copy ----------------------" << std::endl;
       std::cout <<std::endl << "DO NOT care about Offset"  
                 <<std::endl << std::endl;; 
@@ -138,10 +129,9 @@ int main(int argc, char *argv[])
    
       copy->WriteDcmExplVR( output );
       
-
-      delete fileOr;   // File
-      delete original; // FileHelper
-      delete copy;     // FileHelper
+      fileOr->Delete();    // File
+      original->Delete();  // FileHelper
+      copy->Delete();      // FileHelper
       return 0;
 }
 
index 8d18a440b81fd7d75749fb605a9a19d8b3203dd1..e8b97936b89e424488bdd739138c3fc3755445c2 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: Volume2Dicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:43 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2005/10/25 14:52:27 $
+  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
@@ -53,107 +53,89 @@ int main( int argc, char *argv[] )
 
    //const char *inputfile = argv[1];
    std::string directory = argv[1];
-//   itksys::SystemTools::ConvertToUnixSlashes( directory );
+   //   itksys::SystemTools::ConvertToUnixSlashes( directory );
    if (directory[directory.size()-1] != '/') 
-      directory += '/';
+   directory += '/';
 
    std::cout << "Converting image into dicom in " << directory << std::endl;
 
-    ////////////////////////////////////////////////////////////
-    // Reading input image and getting some information       //
-    ////////////////////////////////////////////////////////////
-    //std::cout << "Loading image " << inputfile << std::endl;
-    //PixelType* imageData = input->GetPixelContainer()->GetImportPointer();
-    uint8_t *imageData = new uint8_t[256*256*10];
-    memset( imageData, 0, 256*256*10);
-    std::cout << "Image Loaded." << std::endl;
-
-    int   sizex      = 256;
-    int   sizey      = 256;
-    int   sizez      = 10;
-    //float spacing[3] = { 1.0, 1.0, 1.5 };
-    //float orig[3]    = { 0.0, 0.0, 0.0 };
-    int   sliceSize  = sizex*sizey*sizeof(uint8_t);
-
-    ////////////////////////////////////////////////////////////
-    // compute window center and window width                 //
-    ////////////////////////////////////////////////////////////
-    uint8_t min, max; min = max = imageData[0];
-    for (int i=1; i<sizex*sizey*sizez; i++) 
-    {
-       uint8_t val = imageData[i];
-       if (val > max) 
-          max = val;
-       if (val < min) 
-          min = val;
-    }
-    //float wcenter = (max+min) / 2.;
-    //float wwidth  = (max-min)>0 ? (max-min) : 1.;
-
-    ////////////////////////////////////////////////////////////
-    // Get file date and time                                 //
-    ////////////////////////////////////////////////////////////
-    std::string filedate, filetime;    
-    //GetFileDateAndTime(inputfile, filedate, filetime);
-
-    ////////////////////////////////////////////////////////////
-    // Create a new dicom header and fill in some info        //
-    ////////////////////////////////////////////////////////////
-    gdcm::File *f = new gdcm::File();
-
-    //f->SetDateAndTime(filedate, filetime);
-    //f->SetModality("CT");
-    //f->SetPatientName( "TestPatient");
-    //f->SetPatientID( "TestID");
-    //f->SetStudyID( "1");
-    //f->SetSeriesNumber( "1");
-    //f->SetSliceThickness(spacing[2]);
-    //f->SetSpaceBetweenSlices(spacing[2]);
-    //f->SetXYSpacing( spacing[0], spacing[1]);
-    //f->SetXSize(sizex);
-    //f->SetYSize(sizey);
-    //f->SetNbBitsAllocated(16);
-    //f->SetNbBitsStored(12);
-    //f->SetNbBitsStored(12);
-    //f->SetPixelSigned(true);
-    //f->SetCenter( wcenter);
-    //f->SetWindow( wwidth);
-
-    ////////////////////////////////////////////////////////////
-    // Create a new dicom file object from the header         //
-    ////////////////////////////////////////////////////////////
-    gdcm::FileHelper  *fh = new gdcm::FileHelper(f);
-    uint8_t *myData = fh->GetImageData(); // Get an Image pointer
-    fh->SetImageData( myData, sliceSize); // This callback ensures that the internal
-                                          // Pixel_Data of fh is set correctly
-
-    
-    ////////////////////////////////////////////////////////////
-    // Iterate through the slices and save them to file       //
-    ////////////////////////////////////////////////////////////
-    for (int z=0; z<sizez; z++) 
-    {
-       // Set dicom relevant information for that slice
-       //f->SetImageUIDFromSliceNumber(z);
-       //f->SetImageLocation(orig[0],orig[1],orig[2]+z*spacing[2]);
-
-       // copy image slice content
-       memcpy(myData,imageData+z*sizex*sizey,sliceSize);
-
-       // write the image
-       std::string filename = directory + gdcm::Util::Format("%Image_%05d.dcm", z);
-       std::cout << "Writing file " << filename;
-       fh->WriteDcmExplVR(filename);
-       std::cout << " OK" << std::endl;
-    }
-
-    ////////////////////////////////////////////////////////////
-    // Free the allocated objects                             //
-    ////////////////////////////////////////////////////////////
-    // delete fh; // FIXME: these calls sometimes crashes under .NET ????
-    // delete f;
-
-    return 0;
+   ////////////////////////////////////////////////////////////
+   // Reading input image and getting some information       //
+   ////////////////////////////////////////////////////////////
+   //std::cout << "Loading image " << inputfile << std::endl;
+   //PixelType* imageData = input->GetPixelContainer()->GetImportPointer();
+   uint8_t *imageData = new uint8_t[256*256*10];
+   memset( imageData, 0, 256*256*10);
+   std::cout << "Image Loaded." << std::endl;
+
+   int   sizex      = 256;
+   int   sizey      = 256;
+   int   sizez      = 10;
+   //float spacing[3] = { 1.0, 1.0, 1.5 };
+   //float orig[3]    = { 0.0, 0.0, 0.0 };
+   int   sliceSize  = sizex*sizey*sizeof(uint8_t);
+
+   ////////////////////////////////////////////////////////////
+   // compute window center and window width                 //
+   ////////////////////////////////////////////////////////////
+   uint8_t min, max; min = max = imageData[0];
+   for (int i=1; i<sizex*sizey*sizez; i++) 
+   {
+      uint8_t val = imageData[i];
+      if (val > max) 
+         max = val;
+      if (val < min) 
+         min = val;
+   }
+   //float wcenter = (max+min) / 2.;
+   //float wwidth  = (max-min)>0 ? (max-min) : 1.;
+
+   ////////////////////////////////////////////////////////////
+   // Get file date and time                                 //
+   ////////////////////////////////////////////////////////////
+   std::string filedate, filetime;    
+   //GetFileDateAndTime(inputfile, filedate, filetime);
+
+   ////////////////////////////////////////////////////////////
+   // Create a new dicom header and fill in some info        //
+   ////////////////////////////////////////////////////////////
+   gdcm::File *f = gdcm::File::New();
+
+   ////////////////////////////////////////////////////////////
+   // Create a new dicom file object from the header         //
+   ////////////////////////////////////////////////////////////
+   gdcm::FileHelper  *fh = gdcm::FileHelper::New(f);
+   uint8_t *myData = fh->GetImageData(); // Get an Image pointer
+   fh->SetImageData( myData, sliceSize); // This callback ensures that the internal
+                                        // Pixel_Data of fh is set correctly
+
+
+   ////////////////////////////////////////////////////////////
+   // Iterate through the slices and save them to file       //
+   ////////////////////////////////////////////////////////////
+   for (int z=0; z<sizez; z++) 
+   {
+      // Set dicom relevant information for that slice
+      //f->SetImageUIDFromSliceNumber(z);
+      //f->SetImageLocation(orig[0],orig[1],orig[2]+z*spacing[2]);
+
+      // copy image slice content
+      memcpy(myData,imageData+z*sizex*sizey,sliceSize);
+
+      // write the image
+      std::string filename = directory + gdcm::Util::Format("%Image_%05d.dcm", z);
+      std::cout << "Writing file " << filename;
+      fh->WriteDcmExplVR(filename);
+      std::cout << " OK" << std::endl;
+   }
+
+   ////////////////////////////////////////////////////////////
+   // Free the allocated objects                             //
+   ////////////////////////////////////////////////////////////
+   fh->Delete();
+   f->Delete();
+
+   return 0;
 }
 
 
index 455b9063f9c0761406facdbd77f4b92baa538ca1..ab83ac19fdb65e12d13cf32aed1f2387e3396b2a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: WriteDicomSimple.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:43 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2005/10/25 14:52:27 $
+  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
@@ -57,7 +57,7 @@ int main(int argc, char *argv[])
 
 
 // Step 1 : Create the header of the image
-   gdcm::File *header = new gdcm::File();
+   gdcm::File *header = gdcm::File::New();
    std::ostringstream str;
 
    // Set the image size
@@ -102,7 +102,7 @@ int main(int argc, char *argv[])
       std::cerr << "-------------------------------\n"
                 << "Error while creating the file\n"
                 << "This file is considered to be not readable\n";
-
+      header->Delete();
       return 1;
    }
 
@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
    }
 
 // Step 3 : Create the file of the image
-   gdcm::FileHelper *file = new gdcm::FileHelper(header);
+   gdcm::FileHelper *file = gdcm::FileHelper::New(header);
    file->SetImageData(imageData,size);
 
 // Step 4 : Set the writting mode and write the image
@@ -162,18 +162,17 @@ int main(int argc, char *argv[])
                    << "File :" << fileName << std::endl;
 
          delete[] imageData;
-         delete file;
-         delete header;
+         file->Delete();
+         header->Delete();
          return 0;
 
       default :
          std::cout << "-------------------------------\n"
                    << "Write mode undefined...\n"
                    << "No file written\n";
-
          delete[] imageData;
-         delete file;
-         delete header;
+         file->Delete();
+         header->Delete();
          return 1;
    }
 
@@ -185,8 +184,8 @@ int main(int argc, char *argv[])
    }
 
    delete[] imageData;
-   delete file;
-   delete header;
+   file->Delete();
+   header->Delete();
 
    return 0;
 }
index 2f247d923074903fca4ace5e748f82a564d187d2..46634fde8cc98fb6c19d2395ee3e80fab6db8172 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: WriteRead.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 12:02:02 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2005/10/25 14:52:27 $
+  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
@@ -32,67 +32,86 @@ int main(int argc, char *argv[])
    int dataSize, dataSize2;
      
    if( argc < 2 )
-    {
-    std::cerr << "Usage " << argv[0] << " image.dcm" << std::endl;
-    return 1;
-    }
+   {
+      std::cerr << "Usage " << argv[0] << " image.dcm" << std::endl;
+      return 1;
+   }
 
    std::string fileName = argv[1];
 
 // --------------------- we read the input image
 
    std::cout << argv[1] << std::endl;
-   e1 = new gdcm::File( );
+   e1 = gdcm::File::New( );
    e1->SetFileName( fileName );
    e1->Load();
-   if (!e1->IsReadable()) {
-       std::cerr << "Sorry, " << fileName <<"  not a Readable DICOM / ACR File"
-                 <<std::endl;
-       return 0;
+   if (!e1->IsReadable()) 
+   {
+      std::cerr << "Sorry, " << fileName <<"  not a Readable DICOM / ACR File"
+                <<std::endl;
+      e1->Delete();
+      return 1;
    }
    
-   f1 = new gdcm::FileHelper(e1);
+   f1 = gdcm::FileHelper::New(e1);
    imageData= f1->GetImageData();
    dataSize = f1->GetImageDataSize();
 
 // --------------------- we write it as an Explicit VR DICOM file
 
-      fileNameToWrite = "temp.XDCM";
-      std::cout << "WriteDCM Explicit VR" << std::endl;
-      f1->WriteDcmExplVR(fileNameToWrite);
+   fileNameToWrite = "temp.XDCM";
+   std::cout << "WriteDCM Explicit VR" << std::endl;
+   f1->WriteDcmExplVR(fileNameToWrite);
 
 // --------------------- we read the written image
-   e2 = new gdcm::File( );
+   e2 = gdcm::File::New( );
    e2->SetFileName( fileNameToWrite );
    e2->Load();
-   if (!e2->IsReadable()) {
-       std::cerr << "Sorry, " << fileNameToWrite << " not a Readable DICOM / ACR File"  
-                 <<std::endl;
-       return 0;
+   if (!e2->IsReadable()) 
+   {
+      std::cerr << "Sorry, " << fileNameToWrite << " not a Readable DICOM / ACR File"  
+               <<std::endl;
+      e1->Delete();
+      e2->Delete();
+      f1->Delete();
+      return 1;
    }
-   f2 = new gdcm::FileHelper(e2);
+   f2 = gdcm::FileHelper::New(e2);
    imageData2= f2->GetImageData();
    dataSize2 = f2->GetImageDataSize();
 
 // --------------------- we compare the pixel areas
 
-  if (dataSize != dataSize2) {
-     std::cout << " ----------------------------------------- " 
-          << "Bad shot! Lengthes are different : " 
-          << dataSize << " # " << dataSize2
-          << " for file : " << fileName << std::endl;
+   if (dataSize != dataSize2) 
+   {
+      std::cout << " ----------------------------------------- " 
+                << "Bad shot! Lengthes are different : " 
+                << dataSize << " # " << dataSize2
+                << " for file : " << fileName << std::endl;
 
-     return 0;
-  }
-  if (int res=memcmp(imageData,imageData2,dataSize) !=0) {
-     std::cout << " ----------------------------------------- " 
-          << "Bad shot! Pixels are different : " 
-          << " for file : " << fileName << std::endl;
-     std::cout << "memcmp(imageData,imageData2,dataSize) = " << res << std::endl;
-     return 1;
-  }
+      e1->Delete();
+      e2->Delete();
+      f1->Delete();
+      f2->Delete();
+      return 1;
+   }
+   if (int res=memcmp(imageData,imageData2,dataSize) !=0) 
+   {
+      std::cout << " ----------------------------------------- " 
+                << "Bad shot! Pixels are different : " 
+                << " for file : " << fileName << std::endl;
+      std::cout << "memcmp(imageData,imageData2,dataSize) = " << res << std::endl;
+      e1->Delete();
+      e2->Delete();
+      f1->Delete();
+      f2->Delete();
+      return 1;
+   }
   
-  //If we reach here everything is fine, return 0 then:
-  return 0;
+   e1->Delete();
+   e2->Delete();
+   f1->Delete();
+   f2->Delete();
+   return 0;
 }
 
index 12964570530162b71ebace9b7d27f840179257ba..6d547945963f4d9a09b5e37f2b46b89dcc8916fc 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exColorToRGB.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:43 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2005/10/25 14:52:27 $
+  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
@@ -51,24 +51,28 @@ int main(int argc, char *argv[])
 
    std::cout << argv[1] << std::endl;
 
-   gdcm::File *f = new gdcm::File();
+   gdcm::File *f = gdcm::File::New();
    f->SetLoadMode( gdcm::LD_ALL);
    f->SetFileName( fileName );
    bool res = f->Load();        
 
-   if (!res) {
+   if (!res) 
+   {
        std::cerr << "Sorry, " << fileName <<"  not a gdcm-readable "
                  << "DICOM / ACR File"
                  <<std::endl;
+       f->Delete();
        return 0;
    }
    std::cout << " ... is readable " << std::endl;
 
 /*
-   if (!f->IsMonochrome()) {
+   if (!f->IsMonochrome()) 
+   {
        std::cerr << "Sorry, " << fileName <<"  not a 'color' File "
                  << " "
                  <<std::endl;
+       f->Delete();
        return 0;
    }
 */
@@ -78,7 +82,7 @@ int main(int argc, char *argv[])
 // ============================================================
 
    // We need a gdcm::FileHelper, since we want to load the pixels        
-   gdcm::FileHelper *fh = new gdcm::FileHelper(f);
+   gdcm::FileHelper *fh = gdcm::FileHelper::New(f);
 
    // uint8_t DOESN'T mean it's mandatory for the image to be a 8 bits one !
    // It's just for prototyping.
@@ -90,6 +94,7 @@ int main(int argc, char *argv[])
    {
        std::cerr << "Sorry, Pixels of" << fileName <<"  are not "
                  << " gdcm-readable."       << std::endl;
+       f->Delete();
        return 0;
    }
  
@@ -98,7 +103,7 @@ int main(int argc, char *argv[])
    // ------                              without Sequences     -------------
 
  
-   gdcm::FileHelper *copy = new gdcm::FileHelper( );
+   gdcm::FileHelper *copy = gdcm::FileHelper::New( );
    copy->SetFileName( output );
    copy->Load();
  
@@ -132,10 +137,9 @@ int main(int argc, char *argv[])
 
    copy->WriteDcmExplVR( output );
 
-
-   delete f;
-   delete fh;
-   delete copy;
+   f->Delete();
+   fh->Delete();
+   copy->Delete();
 
    exit (0);
 }
index 47ec1b3cdb88380f93e4d0a2bbb6ad3cefc32241..ce1c5293d0f7cc93ee5b45436deb2167a15a94be 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exCurveData.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:43 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2005/10/25 14:52:27 $
+  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
@@ -101,7 +101,7 @@ int main(int argc, char *argv[])
 //   Read the input image.
 // ============================================================
 
-   f = new gdcm::File( );
+   f = gdcm::File::New( );
 
    f->SetLoadMode(gdcm::LD_NOSEQ | gdcm::LD_NOSHADOW);
    f->SetFileName( fileName );
@@ -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;
@@ -131,7 +131,7 @@ int main(int argc, char *argv[])
    if (curve_data_str == gdcm::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;
@@ -194,7 +194,7 @@ int main(int argc, char *argv[])
          break;
       default:
          std::cerr << "Error don't know the type: " << data_rep_str << std::endl;
-         delete f;
+         f->Delete();
          return 1;
    }
    // Just to make sure that values read are consistant and we won't read out of bound data:
@@ -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;
 }
 
index c799f927acf3132ec8342688594bd17cd14274ff..85f24ea36337b3405f973bc4b1c53f1043db6f27 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exExtractDicomTags.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:44 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2005/10/25 14:52:27 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -83,14 +83,14 @@ int main(int argc, char *argv[])
 
 
    int loadMode = 0x0; // load everything
-   gdcm::File *f = new gdcm::File();
+   gdcm::File *f = gdcm::File::New();
    f->SetLoadMode( loadMode );
    f->SetFileName( fileName );
    bool res = f->Load();  
 
    if ( !res )
    {
-      delete f;
+      f->Delete();
       return 0;
    }
 
@@ -98,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;
    }
 
@@ -247,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;
 }
index b1097a8e71b95a4a50d53d7a29d31c83f898cd5d..07843925e4faf3c9c7df4a195dffc5accb520512 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exExtractTag.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:44 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2005/10/25 14:52:27 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -41,7 +41,7 @@ int main(int argc, char *argv[])
 //   Read the input image.
 // ============================================================
 
-   f = new gdcm::File( );
+   f = gdcm::File::New( );
 
    //f->SetLoadMode(gdcm::LD_NOSEQ | gdcm::LD_NOSHADOW);
    f->SetFileName( fileName );
@@ -57,7 +57,7 @@ int main(int argc, char *argv[])
        std::cerr << "Sorry, " << fileName << " not a gdcm-readable "
            << "DICOM / ACR File"
            << std::endl;
-      delete f;
+      f->Delete();
       return 1;
    }
    std::cout << " ... is readable " << std::endl;
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
    {
      gdcm::DictEntry *dictEntry = f->GetPubDict()->GetEntry( group, elem);
      std::cerr << "Image doesn't contain any tag: " << dictEntry->GetName() << std::endl;
-     delete f;
+     f->Delete();
      return 1;
    }
 
@@ -86,7 +86,7 @@ int main(int argc, char *argv[])
    if( !dicom_tag )
    {
       std::cerr << "Sorry DataEntry only please" << std::endl;
-      delete f;
+      f->Delete();
       return 1;
    }
 
@@ -95,13 +95,13 @@ int main(int argc, char *argv[])
    if( !o )
    {
       std::cerr << "Problem opening file: " << argv[4] << std::endl;
-      delete f;
+      f->Delete();
       return 1;
    }
    o.write((char*)dicom_tag->GetBinArea(), dicom_tag->GetLength());
    o.close();
 
-   delete f;
+   f->Delete();
    return 0;
 }
 
index 68f8adff80f712850b6aa75a0266e1167e35324b..8a55ded29cf6604e52d8ccac5e114b6e4d58b714 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exGC.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:44 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2005/10/25 14:52:27 $
+  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
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
 
    std::cout << argv[1] << std::endl;
 
-   gdcm::File *f = new gdcm::File();
+   gdcm::File *f = gdcm::File::New();
    f->SetLoadMode( gdcm::LD_ALL);
    f->SetFileName( fileName );
    bool res = f->Load();        
@@ -83,6 +83,7 @@ int main(int argc, char *argv[])
        std::cerr << "Sorry, " << fileName <<"  not a gdcm-readable "
                  << "DICOM / ACR File"
                  <<std::endl;
+       f->Delete();
        return 0;
    }
    std::cout << " ... is readable " << std::endl;
@@ -101,7 +102,7 @@ int main(int argc, char *argv[])
 // ============================================================
 
    // We need a gdcm::FileHelper, since we want to load the pixels        
-   gdcm::FileHelper *fh = new gdcm::FileHelper(f);
+   gdcm::FileHelper *fh = gdcm::FileHelper::New(f);
 
    // (unit8_t DOESN'T mean it's mandatory for the image to be a 8 bits one) 
 
@@ -111,6 +112,8 @@ int main(int argc, char *argv[])
    {
        std::cerr << "Sorry, Pixels of" << fileName <<"  are not "
                  << " gdcm-readable."  << std::endl;
+       f->Delete();
+       fh->Delete();
        return 0;
    }
 
@@ -118,7 +121,7 @@ int main(int argc, char *argv[])
    // ------                              without Sequences     -------------
 
  
-   gdcm::FileHelper *copy = new gdcm::FileHelper( );
+   gdcm::FileHelper *copy = gdcm::FileHelper::New( );
    copy->SetFileName( output );
    copy->Load();
  
@@ -162,17 +165,17 @@ int main(int argc, char *argv[])
       }
    }
    
-    std::cout << n << " points put to black (within " 
-              << imageSize/3 << ")" << std::endl;
+   std::cout << n << " points put to black (within " 
+             << imageSize/3 << ")" << std::endl;
 
    n = 0;
    for (i = 0; i<imageSize/3; i++)
    {
-   if ( ((rgb8_t *)imageData)[i].r < threshold
-     &&
-        ((rgb8_t *)imageData)[i].g < threshold
-     &&
-        ((rgb8_t *)imageData)[i].b < threshold )
+      if ( ((rgb8_t *)imageData)[i].r < threshold
+         &&
+         ((rgb8_t *)imageData)[i].g < threshold
+         &&
+         ((rgb8_t *)imageData)[i].b < threshold )
       {
          n++;
         ((rgb8_t *)imageData)[i].r = (unsigned char)background;
@@ -190,9 +193,9 @@ int main(int argc, char *argv[])
 
    copy->WriteDcmExplVR( output );
 
-   delete f;
-   delete fh;
-   delete copy;
+   f->Delete();
+   fh->Delete();
+   copy->Delete();
 
    exit (0);
 }
index 768228bb42cd6b9478e0cd85c3c3812428963bde..2fba62d49b35077e058312dd16d0525c8f695a58 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exGrey2RGB.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:44 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2005/10/25 14:52:28 $
+  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
@@ -79,7 +79,7 @@ int main(int argc, char *argv[])
       }
    }
  
-   gdcm::FileHelper *fh = new gdcm::FileHelper( );
+   gdcm::FileHelper *fh = gdcm::FileHelper::New( );
    fh->SetFileName( filename );
    fh->Load();
       
@@ -119,6 +119,8 @@ int main(int argc, char *argv[])
    fh->SetImageData(imageDataRGB, dataSize*3);   
    fh->WriteDcmExplVR( output );
 
+   fh->Delete();
+
    return 0;
 }
 
index fe3ff4214c18fde9097978e391043a3ce0da20ab..7ee9e264875e33a5b232724ea78b46c1047ece93 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exImageLighten.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:44 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2005/10/25 14:52:28 $
+  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
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])
 
    std::cout << argv[1] << std::endl;
 
-   gdcm::File *f = new gdcm::File();
+   gdcm::File *f = gdcm::File::New();
    f->SetLoadMode( gdcm::LD_ALL);
    f->SetFileName( fileName );
    bool res = f->Load();        
@@ -64,6 +64,7 @@ int main(int argc, char *argv[])
        std::cerr << "Sorry, " << fileName <<"  not a gdcm-readable "
                  << "DICOM / ACR File"
                  <<std::endl;
+       f->Delete();
        return 0;
    }
    std::cout << " ... is readable " << std::endl;
@@ -77,7 +78,7 @@ int main(int argc, char *argv[])
    // to load the Palettes Color (if any)
 
    // First, create a gdcm::FileHelper
-   gdcm::FileHelper *fh = new gdcm::FileHelper(f);
+   gdcm::FileHelper *fh = gdcm::FileHelper::New(f);
 
    // Load the pixels, DO NOT transform LUT (if any) into RGB Pixels 
    uint8_t *imageDataRaw = fh->GetImageDataRaw();
@@ -88,7 +89,7 @@ int main(int argc, char *argv[])
 //   Create a new gdcm::Filehelper, to hold new image.
 // ============================================================
 
-   gdcm::FileHelper *copy = new gdcm::FileHelper( );
+   gdcm::FileHelper *copy = gdcm::FileHelper::New( );
    copy->SetFileName( output );
    copy->Load();
 
@@ -128,9 +129,10 @@ int main(int argc, char *argv[])
    std::cout << std::endl
              << "------------------------------------------------------------"
              << std::endl;
-   delete f;
-   delete fh;
-   delete copy;
+
+   f->Delete();
+   fh->Delete();
+   copy->Delete();
 
    exit (0);
 }
index f5eb508e0a3818b94e1b844ef8c84e425054f437..61590cf985d4b4ce071676cd841450f07b03c4da 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exOverlaysACR.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:44 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2005/10/25 14:52:28 $
+  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
@@ -86,7 +86,7 @@ int main(int argc, char *argv[])
 
    //std::cout << argv[1] << std::endl;
 
-   f = new gdcm::File( );
+   f = gdcm::File::New( );
 
    f->SetLoadMode(gdcm::LD_NOSEQ | gdcm::LD_NOSHADOW);
    f->SetFileName( fileName );
@@ -102,7 +102,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 0;
    }
    std::cout << " ... is readable " << std::endl;
@@ -115,14 +115,14 @@ int main(int argc, char *argv[])
    if ( bitsAllocated <= 8 )
    {
       std::cout << " 8 bits pixel image cannot contain Overlays " << std::endl;
-      delete f;
+      f->Delete();
       return 0;
    }
    std::string s1 = f->GetEntryString(0x6000, 0x0102);
    if (s1 == gdcm::GDCM_UNFOUND)
    {
       std::cout << " Image doesn't contain any Overlay " << std::endl;
-      delete f;
+      f->Delete();
       return 0;
    }
    std::cout << " File is read! " << std::endl;
@@ -155,7 +155,7 @@ int main(int argc, char *argv[])
    if (fp == 0)
    {
       std::cout << "Unable to open File" << std::endl;
-      delete f;
+      f->Delete();
       return 0;
    }
    else
@@ -171,7 +171,7 @@ int main(int argc, char *argv[])
                  << "readable. expected length :" << nx*ny 
                  << "  " << "read length : " << lgt
                  << std::endl;
-       delete f;
+       f->Delete();
        delete pixels;  
        return 0;
    }
@@ -199,9 +199,9 @@ int main(int argc, char *argv[])
    gdcm::FileHelper *fh = 0;
 
       
-while ( (strOvlBitPosition = f->GetEntryString(currentOvlGroup, 0x0102)) 
-          != gdcm::GDCM_UNFOUND )
-{
+   while ( (strOvlBitPosition = f->GetEntryString(currentOvlGroup, 0x0102)) 
+            != gdcm::GDCM_UNFOUND )
+   {
 
       strOverlayLocation = f->GetEntryString(currentOvlGroup, 0x0200);
       if ( strOverlayLocation != gdcm::GDCM_UNFOUND )
@@ -234,7 +234,7 @@ while ( (strOvlBitPosition = f->GetEntryString(currentOvlGroup, 0x0102))
       if( gdcm::Debug::GetDebugFlag() )
          std::cout << "About to built empty file"  << std::endl;
 
-      fileToBuild = new gdcm::File();
+      fileToBuild = gdcm::File::New();
 
       if( gdcm::Debug::GetDebugFlag() )
          std::cout << "Finish to built empty file"  << std::endl;
@@ -259,7 +259,7 @@ while ( (strOvlBitPosition = f->GetEntryString(currentOvlGroup, 0x0102))
       if( gdcm::Debug::GetDebugFlag() )
          std::cout << "-------------About to built FileHelper"  << std::endl;
 
-      fh = new gdcm::FileHelper(fileToBuild);
+      fh = gdcm::FileHelper::New(fileToBuild);
 
       if( gdcm::Debug::GetDebugFlag() )
          std::cout << "-------------Finish to built FileHelper"  << std::endl;
@@ -275,9 +275,9 @@ while ( (strOvlBitPosition = f->GetEntryString(currentOvlGroup, 0x0102))
       {
          std::cout << "Failed\n"
                    << "File in unwrittable\n";
-         delete fh;
+         fh->Delete();
          if (fileToBuild)
-            delete fileToBuild;
+            fileToBuild->Delete();
          delete pixels;
          delete tabPixels;
          return 0;
@@ -290,13 +290,14 @@ while ( (strOvlBitPosition = f->GetEntryString(currentOvlGroup, 0x0102))
       i++;
    }
     
-   delete f;
    if (f)
-      delete fh;
+      fh->Delete();
    if (fileToBuild)
-      delete fileToBuild;
+      fileToBuild->Delete();
+   f->Delete();
    delete pixels;
    delete tabPixels;
+
    return 0;
 }
 
index 185c84ae20d06e3b4af4d4c2fb361476b0b0ea65..eed4ddb3a843571d76f5d7953887b93276959753 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exReadPapyrus.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:44 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2005/10/25 14:52:28 $
+  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
@@ -133,14 +133,14 @@ int main(int argc, char *argv[])
    }
 
    int loadMode = 0x0; // load everything
-   gdcm::File *f = new gdcm::File();
+   gdcm::File *f = gdcm::File::New();
    f->SetLoadMode( loadMode );
    f->SetFileName( fileName );
    bool res = f->Load();  
 
    if ( !res )
    {
-      delete f;
+      f->Delete();
       return 0;
    }
 
@@ -149,7 +149,7 @@ int main(int argc, char *argv[])
    if (!seqPapyrus)
    {
       std::cout << "NOT a Papyrus File : " << fileName <<std::endl;
-      delete f;
+      f->Delete();
       return 1;
    }
 
@@ -162,7 +162,7 @@ int main(int argc, char *argv[])
    {
       std::cout << "NO SQItem found within private Papyrus Sequence"
           << std::endl;
-      delete f;
+      f->Delete();
       return 1;
    }
       
@@ -271,7 +271,7 @@ int main(int argc, char *argv[])
 
    std::string NumberOfFrames = gdcm::Util::Format("%d", nbImages); 
 
-   gdcm::File *n = new gdcm::File();
+   gdcm::File *n = gdcm::File::New();
 
    n->InsertEntryString(MediaStSOPinstUID,  0x0002,0x0002);
   // Whe keep default gdcm Transfer Syntax (Explicit VR Little Endian)
@@ -292,7 +292,7 @@ int main(int argc, char *argv[])
    n->InsertEntryString(PixelRepresentation,0x0028,0x0103);
 
    // create the file
-   gdcm::FileHelper *file = new gdcm::FileHelper(n);
+   gdcm::FileHelper *file = gdcm::FileHelper::New(n);
 
    file->SetImageData(PixelArea,lgrImage*nbImages);
    file->SetWriteTypeToDcmExplVR();
@@ -305,7 +305,11 @@ int main(int argc, char *argv[])
    if (!file)
    {
       std::cout <<"Fail to open (write) file:[" << outputFileName << "]" << std::endl;;
+      n->Delete();
+      file->Delete();
       return 1;  
    }
+   n->Delete();
+   file->Delete();
    return 0;
 }
index 37f5b6e2f94e057fa4b0f7b2464168f7cf1547ac..7599959c0b7a2d03a79dd05cb881ffd5b2941446 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exReadWriteFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 12:58:24 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2005/10/25 14:52:28 $
+  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
@@ -59,7 +59,7 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
    // First, let's create a gdcm::File
    // that will contain all the Dicom fields but the Pixels Element
 
-   gdcm::File *f1= new gdcm::File( );
+   gdcm::File *f1= gdcm::File::New( );
    f1->SetFileName( filename );
    f1->Load();
 
@@ -218,7 +218,7 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
    // Hope now he knows enought about the image ;-)
 
    // First, create a gdcm::FileHelper
-   gdcm::FileHelper *fh1 = new gdcm::FileHelper(f1);
+   gdcm::FileHelper *fh1 = gdcm::FileHelper::New(f1);
 
    // Load the pixels, transforms LUT (if any) into RGB Pixels 
    uint8_t *imageData = fh1->GetImageData();
@@ -253,7 +253,7 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
  
    // ------ User wants write a new image without shadow groups -------------
 
-   gdcm::FileHelper *copy = new gdcm::FileHelper( );
+   gdcm::FileHelper *copy = gdcm::FileHelper::New( );
    copy->SetFileName( output );
    copy->Load();
  
@@ -323,9 +323,9 @@ std::cout << " --- WARNING --- WARNING --- WARNING --- WARNING ---" <<std::endl;
    std::cout << std::endl
              << "------------------------------------------------------------"
              << std::endl;
-   delete f1;
-   delete fh1;
-   delete copy;
+   f1->Delete();
+   fh1->Delete();
+   copy->Delete();
 
    exit (0);
 }
index bb428fd0903b006f0668f019cf88ece83c7c53fe..53afc93357638381ad9a636c14e2099b4f86488b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestAllReadCompareDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:46 $
-  Version:   $Revision: 1.48 $
+  Date:      $Date: 2005/10/25 14:52:30 $
+  Version:   $Revision: 1.49 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -398,7 +398,7 @@ int InternalTest(std::string const &filename,
       std::cout << "1...";
 
        // new style 
-      gdcm::File *f = new gdcm::File();
+      gdcm::File *f = gdcm::File::New();
       f->SetLoadMode ( gdcm::LD_ALL ); // Load everything
       f->SetFileName( filename );
       f->Load();
@@ -408,10 +408,10 @@ int InternalTest(std::string const &filename,
         std::cout << " Failed" << std::endl
                    << "      Image not gdcm compatible:"
                   << filename << std::endl;
-        delete f;
+        f->Delete();
         return 1;
       }
-     gdcm::FileHelper *tested = new gdcm::FileHelper( f );
+      gdcm::FileHelper *tested = gdcm::FileHelper::New( f );
      
       ////// Step 2:
       ////// Check for existence of reference baseline dicom file:
@@ -443,8 +443,8 @@ int InternalTest(std::string const &filename,
                    << "      Image not Testing compatible:"
                   << filename << std::endl;
          delete reference;
-         delete tested;
-         delete f;
+         tested->Delete();
+         f->Delete();
          return 1;
       }
 
@@ -471,8 +471,8 @@ int InternalTest(std::string const &filename,
                    << "Z: " << tested->GetFile()->GetZSize() << " # " 
                    << reference->GetZSize() << std::endl;
          delete reference;
-         delete tested;
-         delete f;
+         tested->Delete();
+         f->Delete();
          return 1;
       }
 
@@ -488,8 +488,8 @@ int InternalTest(std::string const &filename,
                    << reference->GetNumberOfComponents() << std::endl
                    << "        Pixel type: " << tested->GetFile()->GetPixelType() << std::endl;
          delete reference;
-         delete tested;
-         delete f;
+         tested->Delete();
+         f->Delete();
          return 1;
       }
 
@@ -507,9 +507,9 @@ int InternalTest(std::string const &filename,
                    << tested->GetFile()->GetYSize() << ","
                    << tested->GetFile()->GetZSize() << ")"
                    << std::endl;
-         delete tested;
+         tested->Delete();
          delete reference;
-         delete f;
+         f->Delete();
          return 1;
       }
 
@@ -546,16 +546,16 @@ int InternalTest(std::string const &filename,
          }
          std::cout << std::endl;
 
-         delete tested;
+         tested->Delete();
          delete reference;
-         delete f;
+         f->Delete();
          return 1;
       }
 
       //////////////// Clean up:
-      delete tested;
+      tested->Delete();
       delete reference;
-      delete f;
+      f->Delete();
 
       std::cout << "OK." << std::endl;
       
index 1dce8206204ea1a16d8749ad6ea56ba45a726ab6..3dc460c395514430c33a499e3e796cbefe9c081a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestAllVM.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/23 14:53:51 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2005/10/25 14:52:30 $
+  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
 
 int DoTheVMTest(std::string const &filename)
 {
-   gdcm::File file;
+   gdcm::File *file = gdcm::File::New();
    // - Do not test unknow VM in shadow groups (if element 0x0000 is present)
    // - Skip Sequences (if they are 'True Length'); loading will be quicker
    //                  (anyway, Sequences are skipped at processing time ...)
-   file.SetLoadMode( gdcm::LD_NOSHADOW | gdcm::LD_NOSEQ );
+   file->SetLoadMode( gdcm::LD_NOSHADOW | gdcm::LD_NOSEQ );
 
-   file.SetFileName( filename );
-   if( !file.Load() ) //would be really bad...
+   file->SetFileName( filename );
+   if( !file->Load() ) //would be really bad...
       return 1;
 
-   gdcm::DocEntry *d = file.GetFirstEntry();
+   gdcm::DocEntry *d = file->GetFirstEntry();
    std::cerr << "Testing file : " << filename << std::endl;
    while(d)
    {
@@ -56,9 +56,11 @@ int DoTheVMTest(std::string const &filename)
       {
           // We skip pb of SQ recursive exploration
       }
-      d = file.GetNextEntry();
+      d = file->GetNextEntry();
    }
-      return 0;
+   file->Delete();
+
+   return 0;
 }
 
 int TestAllVM(int argc, char *argv[])
index 2ff730c6dbf0e1f81377da243275558b7bbd5541..976756089daa31447b4fd92db363d384846edb73 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestBug.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 13:39:57 $
-  Version:   $Revision: 1.20 $
+  Date:      $Date: 2005/10/25 14:52:30 $
+  Version:   $Revision: 1.21 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -24,7 +24,7 @@
 int TestBug(int argc, char *argv[])
 {  
   gdcm::File *f;
-  f = new gdcm::File();
+  f = gdcm::File::New();
   
    if (argc > 1)
       f->SetFileName( argv[1] );
@@ -36,7 +36,7 @@ int TestBug(int argc, char *argv[])
    f->Load( );
    
    f->GetPubDict()->Print();
-   delete f;
+   f->Delete();
 
    return 0;
 }
index 0c4813c30efdf67f77bfb41e94580128704bccf0..64efd4b0e89217b6f6856c06d88911ab061cd81e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestBuildUpDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/25 09:22:13 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2005/10/25 14:52:30 $
+  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
@@ -44,7 +44,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
    gdcm::DicomDir *dcmdir;
    std::string dirName;  
 
-   dcmdir = new gdcm::DicomDir();
+   dcmdir = gdcm::DicomDir::New();
 
    gdcm::DicomDirPatient *p1;
    // --- Forget these 4 lines :
@@ -171,7 +171,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
                <<" is not readable"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete dcmdir;
+      dcmdir->Delete();
       return 1;
    }
 
@@ -184,10 +184,10 @@ int TestBuildUpDicomDir(int argc, char *argv[])
    // Write it on disc
    dcmdir->Write("NewDICOMDIR");
 
-   delete dcmdir;
+   dcmdir->Delete();
 
    // Read the newly written DicomDir
-   gdcm::DicomDir *newDicomDir = new gdcm::DicomDir();
+   gdcm::DicomDir *newDicomDir = gdcm::DicomDir::New();
    newDicomDir->SetFileName("NewDICOMDIR");
    newDicomDir->Load( );
    if( !newDicomDir->IsReadable() )
@@ -196,7 +196,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
                <<" is not readable"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete newDicomDir;
+      newDicomDir->Delete();
       return 1;
    }
    // Check some value we are sure
@@ -208,7 +208,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
    {
       std::cout << "A patient is missing in written DicomDir"
           << std::endl;
-      delete newDicomDir;
+      newDicomDir->Delete();
       return 1;
    }
 
@@ -363,7 +363,7 @@ int TestBuildUpDicomDir(int argc, char *argv[])
    }
 
    std::cout<<std::flush;
-   delete newDicomDir;
+   newDicomDir->Delete();
 
    return errorFound;
 }
index 886120b3b6076f19fa162ad3a4d6b3c98e7d538c..384fa293b88065e26e86b3995a9d887f9811b292 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:46 $
-  Version:   $Revision: 1.41 $
+  Date:      $Date: 2005/10/25 14:52:30 $
+  Version:   $Revision: 1.42 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -100,9 +100,9 @@ int TestDicomDir(int argc, char *argv[])
       file += "/DICOMDIR";
    }
 
-   dicomdir = new gdcm::DicomDir( );
+   dicomdir = gdcm::DicomDir::New();
    dicomdir->SetFileName(file);
-   dicomdir->Load( );
+   dicomdir->Load();
    if (argc > 2) 
    {
       int level = atoi(argv[2]);   
@@ -116,7 +116,7 @@ int TestDicomDir(int argc, char *argv[])
                <<"' is not readable"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete dicomdir;
+      dicomdir->Delete();
       return 1;
    }
    else
@@ -132,7 +132,7 @@ int TestDicomDir(int argc, char *argv[])
                <<" has no patient"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete dicomdir;
+      dicomdir->Delete();
       return 1;
    }
 
@@ -187,10 +187,10 @@ int TestDicomDir(int argc, char *argv[])
              << "NewDICOMDIR written on disc =================================" 
              << std::endl<< std::endl;
   // Read what we wrote  
-   gdcm::DicomDir *d2 = new gdcm::DicomDir( );
+   gdcm::DicomDir *d2 = gdcm::DicomDir::New();
    d2->SetFileName("NewDICOMDIR");
-   d2->Load( );
-   if (!d2->IsReadable( ))
+   d2->Load();
+   if (!d2->IsReadable())
    {
       std::cout << std::endl << std::endl  
                 << "Read NewDicomDir from disc failed ========================" 
@@ -212,8 +212,8 @@ int TestDicomDir(int argc, char *argv[])
    if (!d2)
    {
       std::cout << "NewDICOMDIR contains no Patient ?!?" << std::endl;
-      delete dicomdir;
-      delete d2;
+      dicomdir->Delete();
+      d2->Delete();
       return 1;
    }
    
@@ -222,8 +222,8 @@ int TestDicomDir(int argc, char *argv[])
 
       if ( CompareSQItem(pa2,pa1) == 1 )
       {
-         delete dicomdir;
-         delete d2;
+         dicomdir->Delete();
+         d2->Delete();
          return 1;
       }
   
@@ -238,8 +238,8 @@ int TestDicomDir(int argc, char *argv[])
       {
          if ( CompareSQItem(st2,st1) == 1 )
          {
-            delete dicomdir;
-            delete d2;
+            dicomdir->Delete();
+            d2->Delete();
             return 1;
          }
 
@@ -256,7 +256,8 @@ int TestDicomDir(int argc, char *argv[])
          while ( se1 && se2 ) 
          { // we process all the SERIE of this study
             if ( CompareSQItem(se2,se1) == 1 )
-              return 1; 
+              return 1;
+
             std::cout << "--- --- " << se2->GetEntryString(0x0008, 0x103e);      // Serie Description
             std::cout << " Ser.nb:["<< se2->GetEntryString(0x0020, 0x0011);        // Series number
             std::cout << "] Mod.:[" << se2->GetEntryString(0x0008, 0x0060) << "]" << std::endl; // Modality
@@ -267,8 +268,8 @@ int TestDicomDir(int argc, char *argv[])
             {
                if ( CompareSQItem(im2,im1) == 1 )
                {
-                  delete dicomdir;
-                  delete d2;
+                  dicomdir->Delete();
+                  d2->Delete();
                   return 1; 
                }
 
@@ -286,8 +287,8 @@ int TestDicomDir(int argc, char *argv[])
    }
    
    std::cout << std::flush;
-   delete dicomdir;
-   delete d2;
+   dicomdir->Delete();
+   d2->Delete();
 
    return 0;
 }
index 41171ded9c3a304d9bb539cac3b51188a9624921..7eb6a17ffc6b04a8daee99af329c76f046f901a8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestDicomDirElement.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 13:39:57 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2005/10/25 14:52:30 $
+  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
 
 int TestDicomDirElement(int , char *[])
 {
-   gdcm::DicomDirElement *ddElt = new gdcm::DicomDirElement();
+   gdcm::DicomDirElement *ddElt = gdcm::DicomDirElement::New();
    if (ddElt == 0)
    {
-   std::cout << "new DicomDirElement failed" << std::endl;
-   return 1;
+      std::cout << "new DicomDirElement failed" << std::endl;
+      return 1;
    }  
    ddElt->Print( std::cout );
 
@@ -48,6 +48,6 @@ int TestDicomDirElement(int , char *[])
    std::cout << " -------- DicomDirElement After modif --------" <<std::endl;
    ddElt->Print( std::cout );
 
-   delete ddElt;
+   ddElt->Delete();
    return 0;
 }
index 232bbb01d5a9b62051fb7d5304efbe9bc012eada..4dd71b144d06d74fa6e2964f006f7986211a972b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestDict.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/20 15:24:05 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2005/10/25 14:52:30 $
+  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
@@ -28,13 +28,13 @@ int TestDict(int , char *[])
 
    std::cout << "----- Test Default Dicom Dictionary : ----------" << std::endl;
    // Just to improve test coverage:
-   gdcm::Dict *tempDict = new gdcm::Dict("dummyFileNameThatDoesntExist");
+   gdcm::Dict *tempDict = gdcm::Dict::New("dummyFileNameThatDoesntExist");
    // Default dict is supposed to be used.
    tempDict->Print();
    std::cout << "---- end Test Default Dicom Dictionary : -------" << std::endl;
 
    // Lets delete it.
-   delete tempDict;
+   tempDict->Delete();
 
  
    // Print the DictSet
index cc74a79f864efabbdebcce1ec22e620f95a8b2bf..47add5e4d81a36103500af421a1fd29f7dba1cb4 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestDictGroupName.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 13:39:57 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2005/10/25 14:52:30 $
+  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
 
 #include <iomanip>
 
-int CompareDictGroupName(gdcm::DictGroupName &groupName,
+int CompareDictGroupName(gdcm::DictGroupName *groupName,
                          uint16_t group,std::string ref)
 {
-   std::string val = groupName.GetName(group);
+   std::string val = groupName->GetName(group);
    std::cout << "Group : 0x" << std::hex << std::setw(4) << group 
              << std::dec << " : " << val << " - "
              << (bool)(val==ref) << std::endl;
@@ -34,8 +34,8 @@ int CompareDictGroupName(gdcm::DictGroupName &groupName,
 
 int TestDictGroupName(int , char *[])
 {
-   gdcm::DictGroupName groupName;
-   groupName.Print( std::cout );
+   gdcm::DictGroupName *groupName = gdcm::DictGroupName::New();
+   groupName->Print( std::cout );
 
    int ret = 0;
 
@@ -44,5 +44,7 @@ int TestDictGroupName(int , char *[])
    ret += CompareDictGroupName(groupName,0x7fe0,"Pixels");
    ret += CompareDictGroupName(groupName,0x0007,gdcm::GDCM_UNFOUND);
 
+   groupName->Delete();
+
    return ret;
 }
index ff1ea02b56c25caff1782a85139d8b313976e619..3ace1920d4b89f6ddb3adcaf8d7feef3b6e60629 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestFileAccessors.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/20 08:58:15 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2005/10/25 14:52:31 $
+  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
@@ -45,7 +45,7 @@
    catch(...) \
    { \
       std::cout << "   --> Can't access to the '" << #name << "' method !" << std::endl; \
-      delete f; \
+      f->Delete(); \
       return 1; \
    }
 
@@ -63,7 +63,7 @@ int TestFileAccessors(int, char *[])
       filename += gdcmDataImages[i];
       
       std::cout << "Begin with " << filename << std::endl;
-      gdcm::File *f= new gdcm::File( );
+      gdcm::File *f= gdcm::File::New( );
       f->SetFileName( filename );
       f->Load( );
 
@@ -119,7 +119,7 @@ int TestFileAccessors(int, char *[])
       {
          std::cout << "   " << filename << " is Readable" << std::endl;
 
-         gdcm::FileHelper *fh= new gdcm::FileHelper( f );   
+         gdcm::FileHelper *fh= gdcm::FileHelper::New( f );   
 
          TestMethodMacro(std::dec,fh,GetImageDataSize)
          TestMethodMacro(std::dec,fh,GetImageDataRawSize)
@@ -128,17 +128,17 @@ int TestFileAccessors(int, char *[])
          TestMethodMacro(std::dec,fh,GetUserDataSize)
          TestMethodMacro(std::dec,fh,GetWriteType)
  
-         delete fh;
+         fh->Delete();
       }
       else
       {
          std::cout << filename << " is NOT Readable" 
                    << std::endl << std::endl;
-         delete f;
+         f->Delete();
          return 1;
       }
 
-      delete f;
+      f->Delete();
       std::cout << "End with " << filename << std::endl;
       i++;
    }
index 05e6c66f7f95bdfb51635d446d534cfc7036ef16..4caf0ade80e4a8ddea67ff4e32ec4a0a7af58385 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestImageSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:46 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2005/10/25 14:52:31 $
+  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
@@ -141,7 +141,7 @@ void ClearList(FileList &list)
    FileList::iterator it;
    for(it=list.begin();it!=list.end();++it)
    {
-      delete (*it);
+      (*it)->Delete();
    }
    list.clear();
 }
@@ -182,7 +182,7 @@ gdcm::File *WriteImage(gdcm::File *file, const std::string &fileName)
    memset(imageData,0,size);
 
 // Write the image
-   gdcm::FileHelper *hlp = new gdcm::FileHelper(file);
+   gdcm::FileHelper *hlp = gdcm::FileHelper::New(file);
    hlp->SetImageData(imageData,size);
    hlp->SetWriteTypeToDcmExplVR();
    if( !hlp->Write(fileName) )
@@ -190,22 +190,22 @@ gdcm::File *WriteImage(gdcm::File *file, const std::string &fileName)
       std::cout << "Failed\n"
                 << "        File in unwrittable\n";
 
-      delete hlp;
+      hlp->Delete();
       delete[] imageData;
       return NULL;
    }
    delete[] imageData;
-   delete hlp;
+   hlp->Delete();
 
 // Read the written image
-   gdcm::File *reread = new gdcm::File(  );
+   gdcm::File *reread = gdcm::File::New(  );
    reread->SetFileName( fileName );
    reread->Load();
    if( !reread->IsReadable() )
    {
      std::cerr << "Failed" << std::endl
                << "        Could not reread written image :" << fileName << std::endl;
-     delete reread;
+     reread->Delete();
      return NULL;
    }
 
@@ -248,7 +248,7 @@ int TestImageSet(int argc, char *argv[])
    {
       std::ostringstream fileName;
       fileName << "FileSeq" << i << ".dcm";
-      file = new gdcm::File();
+      file = gdcm::File::New();
       // It's up to the user to initialize Serie UID and Study UID
       // Study Instance UID
       studyUID = gdcm::Util::CreateUniqueUID();
@@ -260,13 +260,13 @@ int TestImageSet(int argc, char *argv[])
       newFile = WriteImage(file, fileName.str());
       if( !newFile )
       {
-         delete file;
+         file->Delete();
          return 1;
       }
       else
          fileList.push_back(newFile);
 
-      delete file;
+      file->Delete();
    }
 
    if( CompareImages(fileList, false, false) )
@@ -286,20 +286,20 @@ int TestImageSet(int argc, char *argv[])
    {
       std::ostringstream fileName;
       fileName << "FileSeq" << i << ".dcm";
-      file = new gdcm::File();
+      file = gdcm::File::New();
       file->InsertEntryString(studyUID, 0x0020, 0x000d);
       file->InsertEntryString(serieUID, 0x0020, 0x000e);
 
       newFile = WriteImage(file, fileName.str());
       if( !newFile )
       {
-         delete file;
+         file->Delete();
          return(1);
       }
       else
          fileList.push_back(newFile);
 
-      delete file;
+      file->Delete();
    }
 
    if( CompareImages(fileList, true, true) )
@@ -318,20 +318,20 @@ int TestImageSet(int argc, char *argv[])
    {
       std::ostringstream fileName;
       fileName << "FileSeq" << i << ".dcm";
-      file = new gdcm::File();
+      file = gdcm::File::New();
       file->InsertEntryString(studyUID, 0x0020, 0x000d);
       serieUID = gdcm::Util::CreateUniqueUID();
       file->InsertEntryString(serieUID, 0x0020, 0x000e);
       newFile = WriteImage(file, fileName.str());
       if( !newFile )
       {
-         delete file;
+         file->Delete();
          return(1);
       }
       else
          fileList.push_back(newFile);
 
-      delete file;
+      file->Delete();
    }
 
    if( CompareImages(fileList, false, true) )
index 42a337aed7759e383d86b92249474d80b3fa326e..b6491ca0fbd01c0510b7a9ef78b972655f6d5caa 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestLoadAllDocumentsNoPrivNoSeq.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:46 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2005/10/25 14:52:31 $
+  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
@@ -54,7 +54,7 @@ int TestLoadAllDocumentsNoPrivNoSeq(int, char *[])
       filename += "/";  //doh!
       filename += gdcmDataImages[i];
 
-      gdcm::File *f= new gdcm::File( );
+      gdcm::File *f= gdcm::File::New( );
       f->SetFileName( filename );
       // just to improve coverage
       f->SetLoadMode (gdcm::LD_NOSEQ|gdcm::LD_NOSHADOW);
@@ -120,11 +120,11 @@ int TestLoadAllDocumentsNoPrivNoSeq(int, char *[])
       {
          std::cout << filename << " is NOT Readable" 
                    << std::endl << std::endl;
-         delete f;
+         f->Delete();
          return 1;
       }
  */
-      delete f;
+      f->Delete();
       i++;
    }
    return 0;
index c560f1b0fe3293990608d961bd89c6c214b4896d..0aa1ecc91b126aeecf313d12bb64841d06bcf97e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestMakeDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/08/31 09:29:11 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2005/10/25 14:52:31 $
+  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
@@ -62,7 +62,7 @@ int TestMakeDicomDir(int argc, char *argv[])
    gdcm::DicomDir *dcmdir;
 
    // new style (user is allowed no to load Sequences an/or Shadow Groups)
-   dcmdir = new gdcm::DicomDir( );
+   dcmdir = gdcm::DicomDir::New( );
  
    // dcmdir->SetLoadMode(gdcm::LD_NOSEQ | gdcm::LD_NOSHADOW);
    // some images have a wrong length for element 0x0000 of private groups
@@ -78,16 +78,16 @@ int TestMakeDicomDir(int argc, char *argv[])
       std::cout << "makeDicomDir: no patient found. Exiting."
                 << std::endl;
 
-      delete dcmdir;
+      dcmdir->Delete();
       return 1;
    }
     
    // Create the corresponding DicomDir
    dcmdir->Write("NewDICOMDIR");
-   delete dcmdir;
+   dcmdir->Delete();
 
    // Read from disc the just written DicomDir
-   gdcm::DicomDir *newDicomDir = new gdcm::DicomDir();
+   gdcm::DicomDir *newDicomDir = gdcm::DicomDir::New();
    newDicomDir->SetFileName("NewDICOMDIR");
    newDicomDir->Load();
 
@@ -97,7 +97,7 @@ int TestMakeDicomDir(int argc, char *argv[])
                <<" is not readable"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete newDicomDir;
+      newDicomDir->Delete();
       return 1;
    }
 
@@ -107,11 +107,11 @@ int TestMakeDicomDir(int argc, char *argv[])
                <<" has no patient"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete newDicomDir;
+      newDicomDir->Delete();
       return(1);
    }
 
    std::cout<<std::flush;
-   delete newDicomDir;
+   newDicomDir->Delete();
    return 0;
 }
index 1ff478a8ee5a2707c05892f4767a8a39afa3c357..678f8930118639a3d7b53af3c47a316ed8ff7797 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestMakeIcon.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:46 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2005/10/25 14:52:31 $
+  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
@@ -48,23 +48,24 @@ int TestMakeIcon (int argc, char *argv[])
                 << " input filename.dcm output Filename.dcm" << std::endl;
    }
 
-   gdcm::File *f = new gdcm::File( );
+   gdcm::File *f = gdcm::File::New( );
    f->SetFileName( input );
    f->Load( );
 
    if ( ! f->IsReadable() )
    {
       std::cout << " Failed to Open/Parse file" << input << std::endl;
-      delete f;
+      f->Delete();
       return 1;
    }  
-   gdcm::FileHelper *fh = new gdcm::FileHelper(f); 
+   gdcm::FileHelper *fh = gdcm::FileHelper::New(f); 
    uint8_t *pixels = fh->GetImageData();
    uint32_t lgth   = fh->GetImageDataSize();
 
    gdcm::SeqEntry *icon = f->InsertSeqEntry(0x0088, 0x0200);
-   gdcm::SQItem *sqi = new gdcm::SQItem(1);
+   gdcm::SQItem *sqi = gdcm::SQItem::New(1);
    icon->AddSQItem(sqi, 1);
+   sqi->Delete();
 
    // icone is just define like the image
    // The purpose is NOT to imagine an icon, 
@@ -85,9 +86,10 @@ int TestMakeIcon (int argc, char *argv[])
     
    fh->WriteDcmExplVR(output);
 
-   delete f;
+   f->Delete();
+   fh->Delete();
 
-   f = new gdcm::File();
+   f = gdcm::File::New();
    f->SetFileName(output);
    f->Load();
    f->Print();
@@ -98,8 +100,7 @@ int TestMakeIcon (int argc, char *argv[])
    {
       std::cout << "Sequence 0088|0200 not found" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
    std::cout << "Sequence 0088|0200 found" << std::endl;
@@ -110,8 +111,7 @@ int TestMakeIcon (int argc, char *argv[])
    {
       std::cout << "Sequence 0088|0200 has no SQItem" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
 
@@ -122,8 +122,7 @@ int TestMakeIcon (int argc, char *argv[])
    {
       std::cout << "GetDataEntry 0028|0010 not found" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
    std::cout << "First Item ->DataEntry 0028|0010 found" << std::endl;
@@ -133,8 +132,7 @@ int TestMakeIcon (int argc, char *argv[])
                 << "Read : " << sqi->GetDataEntry(0x0028,0x0010)->GetString()
                 << " - Expected : 128" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
 
@@ -143,8 +141,7 @@ int TestMakeIcon (int argc, char *argv[])
    {
       std::cout << "GetDataEntry 0028|0011 not found" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
    std::cout << "First Item ->DataEntry 0028|0011 found" << std::endl;
@@ -154,8 +151,7 @@ int TestMakeIcon (int argc, char *argv[])
                 << "Read : " << sqi->GetDataEntry(0x0028,0x0011)->GetString()
                 << " - Expected : 128" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
 
@@ -164,8 +160,7 @@ int TestMakeIcon (int argc, char *argv[])
    {
       std::cout << "GetDataEntry 0028|0100 not found" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
    std::cout << "First Item ->DataEntry 0028|0100 found" << std::endl;
@@ -175,8 +170,7 @@ int TestMakeIcon (int argc, char *argv[])
                 << "Read : " << sqi->GetDataEntry(0x0028,0x0100)->GetString()
                 << " - Expected : 8" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
 
@@ -185,8 +179,7 @@ int TestMakeIcon (int argc, char *argv[])
    {
       std::cout << "GetDataEntry 0028|0101 not found" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
    std::cout << "First Item ->DataEntry 0028|0101 found" << std::endl;
@@ -196,8 +189,7 @@ int TestMakeIcon (int argc, char *argv[])
                 << "Read : " << sqi->GetDataEntry(0x0028,0x0101)->GetString()
                 << " - Expected : 8" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
 
@@ -206,8 +198,7 @@ int TestMakeIcon (int argc, char *argv[])
    {
       std::cout << "DataEntry 0028|0102 not found" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
    std::cout << "First Item ->DataEntry 0028|0102 found" << std::endl;
@@ -217,8 +208,7 @@ int TestMakeIcon (int argc, char *argv[])
                 << "Read : " << sqi->GetDataEntry(0x0028,0x0102)->GetString()
                 << " - Expected : 7" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
 
@@ -227,8 +217,7 @@ int TestMakeIcon (int argc, char *argv[])
    {
       std::cout << "GetDataEntry 0028|0010 not found" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
    std::cout << "First Item ->DataEntry 0028|0103 found" << std::endl;
@@ -238,8 +227,7 @@ int TestMakeIcon (int argc, char *argv[])
                 << "Read : " << sqi->GetDataEntry(0x0028,0x0103)->GetString()
                 << " - Expected : 0" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
 
@@ -248,8 +236,7 @@ int TestMakeIcon (int argc, char *argv[])
    {
       std::cout << "GetDataEntry 0005|0010 not found" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
    std::cout << "First Item ->GetDataEntry 0005|0010 found" << std::endl;
@@ -259,8 +246,7 @@ int TestMakeIcon (int argc, char *argv[])
                 << "Read : " << sqi->GetDataEntry(0x0005,0x0010)->GetLength()
                 << " - Expected : 6" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
 
@@ -270,14 +256,12 @@ int TestMakeIcon (int argc, char *argv[])
    {
       std::cout << "Value 0005|0010 don't match (DataEntry)" << std::endl
                 << "   ... Failed" << std::endl;
-      delete fh;
-      delete f;
+      f->Delete();
       return 1;
    }
    std::cout << "Value DataEntry 0005|0010 OK" << std::endl;
 
-   delete fh;
-   delete f;
+   f->Delete();
    std::cout << "   ... OK" << std::endl;
 
    return 0;
index 76215a247570bd4b0402b3f650865564a1b44409..d083bf07b087277587fab69aada44f211c87d26d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestPrintAllDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:46 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2005/10/25 14:52:31 $
+  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
@@ -53,7 +53,7 @@ int TestPrintAllDocument(int, char *[])
       filename += "/";  //doh!
       filename += gdcmDataImages[i];
 
-      gdcm::File *f= new gdcm::File( );
+      gdcm::File *f= gdcm::File::New( );
       f->SetFileName( filename );
       f->Load();
 
@@ -116,10 +116,10 @@ int TestPrintAllDocument(int, char *[])
       {
          std::cout << filename << " is NOT Readable" 
                    << std::endl << std::endl;
-         delete f;
+         f->Delete();
          return 1;
       }
-      delete f;
+      f->Delete();
       i++;
    }
    return 0;
index 2fe46dee09ae2c02199e417fac110c0f83f1e645..7f62c0b7019c9cfccc6a98998d0596b77baa74de 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestReadWriteReadCompare.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/19 13:15:37 $
-  Version:   $Revision: 1.26 $
+  Date:      $Date: 2005/10/25 14:52:31 $
+  Version:   $Revision: 1.27 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -28,7 +28,7 @@ int CompareInternal(std::string const &filename, std::string const &output)
 
    //////////////// Step 1 (see above description):
 
-   gdcm::File *file = new gdcm::File( );
+   gdcm::File *file = gdcm::File::New( );
    file->SetFileName( filename );
    file->Load ();
    if( !file->IsReadable() )
@@ -36,13 +36,13 @@ int CompareInternal(std::string const &filename, std::string const &output)
       std::cout << "Failed" << std::endl
                 << "Test::TestReadWriteReadCompare: Image not gdcm compatible:"
                 << filename << std::endl;
-      delete file;
+      file->Delete();
       return 1;
    }
    std::cout << "           step 1...";
 
    //////////////// Step 2:
-   gdcm::FileHelper *filehelper = new gdcm::FileHelper( file );
+   gdcm::FileHelper *filehelper = gdcm::FileHelper::New( file );
    int dataSize    = filehelper->GetImageDataSize();
    uint8_t *imageData = filehelper->GetImageData(); //EXTREMELY IMPORTANT
           // Sure, it is : It's up to the user to decide if he wants to
@@ -56,7 +56,7 @@ int CompareInternal(std::string const &filename, std::string const &output)
    std::cout << "2...";
  
    //////////////// Step 3:
-   gdcm::File *fileout = new gdcm::File();
+   gdcm::File *fileout = gdcm::File::New();
    fileout->SetFileName( output );
    fileout->Load();
   // gdcm::FileHelper *reread = new gdcm::FileHelper( output ); // deprecated
@@ -66,13 +66,13 @@ int CompareInternal(std::string const &filename, std::string const &output)
       std::cout << "Failed" << std::endl
                 << "Test::TestReadWriteReadCompare: Could not parse the newly "
                 << "written image:" << filename << std::endl;
-      delete file;
-      delete filehelper;
-      delete fileout;
+      file->Delete();
+      filehelper->Delete();
+      fileout->Delete();
       return 1;
    }
 
-   gdcm::FileHelper *reread = new gdcm::FileHelper( fileout );
+   gdcm::FileHelper *reread = gdcm::FileHelper::New( fileout );
 
    std::cout << "3...";
    // For the next step:
@@ -93,10 +93,10 @@ int CompareInternal(std::string const &filename, std::string const &output)
                   << reread->GetFile()->GetYSize() << " | "
          << "Z: " << file->GetZSize() << " # " 
                   << reread->GetFile()->GetZSize() << std::endl;
-      delete file;
-      delete filehelper;
-      delete fileout;
-      delete reread;
+      file->Delete();
+      filehelper->Delete();
+      fileout->Delete();
+      reread->Delete();
       return 1;
    }
 
@@ -106,10 +106,10 @@ int CompareInternal(std::string const &filename, std::string const &output)
       std::cout << "Failed" << std::endl
          << "        Pixel areas lengths differ: "
          << dataSize << " # " << dataSizeWritten << std::endl;
-      delete file;
-      delete filehelper;
-      delete fileout;
-      delete reread;
+      file->Delete();
+      filehelper->Delete();
+      fileout->Delete();
+      reread->Delete();
       return 1;
    }
 
@@ -118,19 +118,19 @@ int CompareInternal(std::string const &filename, std::string const &output)
    {
       std::cout << "Failed" << std::endl
          << "        Pixel differ (as expanded in memory)." << std::endl;
-      delete file;
-      delete filehelper;
-      delete fileout;
-      delete reread;
+      file->Delete();
+      filehelper->Delete();
+      fileout->Delete();
+      reread->Delete();
       return 1;
    }
    std::cout << "4...OK." << std::endl ;
 
    //////////////// Clean up:
-   delete file;
-   delete filehelper;
-   delete fileout;
-   delete reread;
+   file->Delete();
+   filehelper->Delete();
+   fileout->Delete();
+   reread->Delete();
 
    return 0;
 }
index 7b3c457c5a253236dd3e61ba52f9905095bcebee..b757561ef0ee61203ae01157715a2296a686e25c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestTS.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/02 10:05:26 $
-  Version:   $Revision: 1.9 $
+  Date:      $Date: 2005/10/25 14:52:31 $
+  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
 
 int TestTS(int , char *[])
 {
-   gdcm::TS ts;
+   gdcm::TS *ts = gdcm::TS::New();
    // There should be ~150 entries
-   ts.Print( std::cout );
+   ts->Print( std::cout );
 
    // Implicit VR Little Endian
-   std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2" ) << std::endl;
    // Implicit VR Big Endian DLX (G.E Private)
-   std::cout << ts.IsTransferSyntax( "1.2.840.113619.5.2" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "1.2.840.113619.5.2" ) << std::endl;
    // Explicit VR Little Endian
-   std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.1" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.1" ) << std::endl;
    // Deflated Explicit VR Little Endian
-   std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.1.99" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.1.99" ) << std::endl;
    // Explicit VR Big Endian
-   std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.2" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.2" ) << std::endl;
    // JPEG Baseline (Process 1)
-   std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.50" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.50" ) << std::endl;
    // JPEG Extended (Process 2 & 4)
-   std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.51" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.51" ) << std::endl;
    // JPEG Extended (Process 3 & 5)
-   std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.52" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.52" ) << std::endl;
    // JPEG Spectral Selection, Non-Hierarchical (Process 6 & 8)
-   std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.53" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.53" ) << std::endl;
    // JPEG Full Progression, Non-Hierarchical (Process 10 & 12)
-   std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.55" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.55" ) << std::endl;
    // JPEG Lossless, Non-Hierarchical (Process 14)
-   std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.57" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.57" ) << std::endl;
    // JPEG Lossless, Hierarchical, First-Order Prediction (Process 14, 
    //               [Selection Value 1])
-   std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.70" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.70" ) << std::endl;
    // JPEG 2000 Lossless
-   std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.90" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.90" ) << std::endl;
    // JPEG 2000
-   std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.4.91" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.4.91" ) << std::endl;
    // RLE Lossless
-   std::cout << ts.IsTransferSyntax( "1.2.840.10008.1.2.5" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "1.2.840.10008.1.2.5" ) << std::endl;
    // Unknown
-   std::cout << ts.IsTransferSyntax( "Unknown Transfer Syntax" ) << std::endl;
+   std::cout << ts->IsTransferSyntax( "Unknown Transfer Syntax" ) << std::endl;
 
    // Test JPEG test:
    std::cout << "Test TS:" << std::endl;
-   std::cout << ts.IsJPEGLossless( "1.2.840.10008.1.2.4.55") << std::endl;
+   std::cout << ts->IsJPEGLossless( "1.2.840.10008.1.2.4.55") << std::endl;
 //if ( key == "1.2.840.10008.1.2.4.55"
 //  || key == "1.2.840.10008.1.2.4.57"
 //  || key == "1.2.840.10008.1.2.4.70" )
-   std::cout << ts.IsRLELossless( "1.2.840.10008.1.2.5") << std::endl;
-   std::cout << ts.IsJPEGLossless( "1.2.840.10008.1.2.5") << std::endl;
-   std::cout << ts.IsJPEG2000( "1.2.840.10008.1.2.5") << std::endl;
-   std::cout << ts.IsJPEG( "1.2.840.10008.1.2.5") << std::endl;
-   std::cout << ts.GetSpecialTransferSyntax( 
-                ts.GetSpecialTransferSyntax( "1.2.840.10008.1.2.5")) << std::endl;
+   std::cout << ts->IsRLELossless( "1.2.840.10008.1.2.5") << std::endl;
+   std::cout << ts->IsJPEGLossless( "1.2.840.10008.1.2.5") << std::endl;
+   std::cout << ts->IsJPEG2000( "1.2.840.10008.1.2.5") << std::endl;
+   std::cout << ts->IsJPEG( "1.2.840.10008.1.2.5") << std::endl;
+   std::cout << ts->GetSpecialTransferSyntax( 
+                ts->GetSpecialTransferSyntax( "1.2.840.10008.1.2.5")) << std::endl;
    std::cout << gdcm::Global::GetTS()->IsRLELossless( "1.2.840.10008.1.2.5" )  
              << std::endl;
 
-   return ts.GetValue( "" ) != gdcm::GDCM_UNFOUND;
+   bool ret = ts->GetValue( "" ) != gdcm::GDCM_UNFOUND;
+
+   ts->Delete();
+
+   return ret;
 }
index 303ec22dfaa1f422bc38d3e20df6cd44c982ffef..26e8144f0cff02c8c4a15fbb54b88b501761d242 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestVR.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/21 08:28:02 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2005/10/25 14:52:31 $
+  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
@@ -21,7 +21,7 @@
 int TestVR(int , char *[])
 {
    int error = 0;
-   gdcm::VR *vr = new gdcm::VR();
+   gdcm::VR *vr = gdcm::VR::New();
  
    gdcm::Debug::DebugOn();
 
@@ -96,6 +96,6 @@ int TestVR(int , char *[])
       error++;
    }
 
-   delete vr;
+   vr->Delete();
    return error;
 }
index 62ce69271b29ad32df462b4c0af218d9af9b30ad..c5f4c39353e88dc27876fe15844f5d526d014d47 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestWriteSimple.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/21 08:34:26 $
-  Version:   $Revision: 1.41 $
+  Date:      $Date: 2005/10/25 14:52:31 $
+  Version:   $Revision: 1.42 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -110,7 +110,7 @@ int WriteSimple(Image &img)
 // Step 1 : Create the header of the image
 
    std::cout << "        1...";
-   gdcm::File *fileToBuild = new gdcm::File();
+   gdcm::File *fileToBuild = gdcm::File::New();
    std::ostringstream str;
 
    // Set the image size
@@ -204,7 +204,7 @@ int WriteSimple(Image &img)
 
 // Step 3 : Create the file of the image
    std::cout << "3...";
-   gdcm::FileHelper *fileH = new gdcm::FileHelper(fileToBuild);
+   gdcm::FileHelper *fileH = gdcm::FileHelper::New(fileToBuild);
    fileH->SetImageData(imageData,size);
 
 // Step 4 : Set the writting mode and write the image
@@ -229,8 +229,8 @@ int WriteSimple(Image &img)
          std::cout << "Failed for [" << fileName.str() << "]\n"
                    << "        Write mode '"<<img.writeMode<<"' is undefined\n";
 
-         delete fileH;
-         delete fileToBuild;
+         fileH->Delete();
+         fileToBuild->Delete();
          delete[] imageData;
          return 1;
    }
@@ -240,8 +240,8 @@ int WriteSimple(Image &img)
       std::cout << "Failed for [" << fileName.str() << "]\n"
                 << "           File is unwrittable\n";
 
-      delete fileH;
-      delete fileToBuild;
+      fileH->Delete();
+      fileToBuild->Delete();
       delete[] imageData;
       return 1;
    }
@@ -251,7 +251,7 @@ int WriteSimple(Image &img)
    // old form.
    //gdcm::FileHelper *reread = new gdcm::FileHelper( fileName.str() );
    // Better use :
-   gdcm::FileHelper *reread = new gdcm::FileHelper( );
+   gdcm::FileHelper *reread = gdcm::FileHelper::New( );
    reread->SetFileName( fileName.str() );
    reread->SetLoadMode(gdcm::LD_ALL); // Load everything
                            // Possible values are 
@@ -266,9 +266,9 @@ int WriteSimple(Image &img)
    {
       std::cerr << "Failed" << std::endl
                 << "Could not read written image : " << fileName.str() << std::endl;
-      delete fileToBuild;
-      delete fileH;
-      delete reread;
+      fileToBuild->Delete();
+      fileH->Delete();
+      reread->Delete();
       delete[] imageData;
       return 1;
    }
@@ -285,9 +285,9 @@ int WriteSimple(Image &img)
          << "        File type differ: "
          << fileH->GetWriteType() << " # " 
          << reread->GetFile()->GetFileType() << std::endl;
-      delete fileToBuild;
-      delete fileH;
-      delete reread;
+      fileToBuild->Delete();
+      fileH->Delete();
+      reread->Delete();
       delete[] imageData;
 
       return 1;
@@ -306,9 +306,9 @@ int WriteSimple(Image &img)
                   << reread->GetFile()->GetYSize() << " | "
          << "Z: " << fileToBuild->GetZSize() << " # " 
                   << reread->GetFile()->GetZSize() << std::endl;
-      delete fileToBuild;
-      delete fileH;
-      delete reread;
+      fileToBuild->Delete();
+      fileH->Delete();
+      reread->Delete();
       delete[] imageData;
 
       return 1;
@@ -320,9 +320,9 @@ int WriteSimple(Image &img)
       std::cout << "Failed" << std::endl
          << "        Pixel areas lengths differ: "
          << size << " # " << dataSizeWritten << std::endl;
-      delete fileToBuild;
-      delete fileH;
-      delete reread;
+      fileToBuild->Delete();
+      fileH->Delete();
+      reread->Delete();
       delete[] imageData;
 
       return 1;
@@ -350,9 +350,9 @@ int WriteSimple(Image &img)
             }
       }
       std::cout << std::endl;
-      delete fileToBuild;
-      delete fileH;
-      delete reread;
+      fileToBuild->Delete();
+      fileH->Delete();
+      reread->Delete();
       delete[] imageData;
 
       return 1;
@@ -360,9 +360,9 @@ int WriteSimple(Image &img)
 
    std::cout << "OK" << std::endl;
 
-   delete fileToBuild;
-   delete fileH;
-   delete reread;
+   fileToBuild->Delete();
+   fileH->Delete();
+   reread->Delete();
    delete[] imageData;
 
    return 0;
index 17da13ee9e5aebf45bb5bc7c44590a3e3c163607..2f19e2432703aae4b464030cb15b5e6736a5ed26 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/25 09:22:15 $
-  Version:   $Revision: 1.166 $
+  Date:      $Date: 2005/10/25 14:52:33 $
+  Version:   $Revision: 1.167 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -124,36 +124,6 @@ DicomDir::DicomDir()
    NewMeta();
 }
 
-#ifndef GDCM_LEGACY_REMOVE
-/* *
- * \ brief Constructor Parses recursively the directory and creates the DicomDir
- *        or uses an already built DICOMDIR, depending on 'parseDir' value.
- * @ param fileName  name 
- *                      - of the root directory (parseDir = true)
- *                      - of the DICOMDIR       (parseDir = false)
- * @ param parseDir boolean
- *                      - true if user passed an entry point 
- *                        and wants to explore recursively the directories
- *                      - false if user passed an already built DICOMDIR file
- *                        and wants to use it 
- * @ deprecated use : new DicomDir() + [ SetLoadMode(lm) + ] SetDirectoryName(name)
- *              or : new DicomDir() + SetFileName(name)
- */
-DicomDir::DicomDir(std::string const &fileName, bool parseDir ):
-   Document( )
-{
-   // At this step, Document constructor is already executed,
-   // whatever user passed (either a root directory or a DICOMDIR)
-   // and whatever the value of parseDir was.
-   // (nothing is cheked in Document constructor, to avoid overhead)
-
-   ParseDir = parseDir;
-   SetLoadMode (LD_ALL); // concerns only dicom files
-   SetFileName( fileName );
-   Load( );
-}
-#endif
-
 /**
  * \brief  Canonical destructor 
  */
@@ -166,7 +136,7 @@ DicomDir::~DicomDir()
    ClearPatient();
    if ( MetaElems )
    {
-      delete MetaElems;
+      MetaElems->Delete();
    }
 }
 
@@ -306,12 +276,12 @@ bool DicomDir::IsReadable()
 DicomDirMeta *DicomDir::NewMeta()
 {
    if ( MetaElems )
-      delete MetaElems;
+      MetaElems->Delete();
 
    DocEntry *entry = GetFirstEntry();
    if ( entry )
    { 
-      MetaElems = new DicomDirMeta(true); // true = empty
+      MetaElems = DicomDirMeta::New(true); // true = empty
 
       entry = GetFirstEntry();
       while( entry )
@@ -327,7 +297,7 @@ DicomDirMeta *DicomDir::NewMeta()
    }
    else  // after root directory parsing
    {
-      MetaElems = new DicomDirMeta(false); // false = not empty
+      MetaElems = DicomDirMeta::New(false); // false = not empty
    }
    MetaElems->SetSQItemNumber(0); // To avoid further missprinting
    return MetaElems;  
@@ -339,9 +309,9 @@ DicomDirMeta *DicomDir::NewMeta()
  */
 DicomDirPatient *DicomDir::NewPatient()
 {
-   DicomDirPatient *p = new DicomDirPatient();
-   AddPatientToEnd( p );
-   return p;
+   DicomDirPatient *dd = DicomDirPatient::New();
+   AddPatientToEnd( dd );
+   return dd;
 }
 
 /**
@@ -353,7 +323,7 @@ void DicomDir::ClearPatient()
                                      cc!= Patients.end();
                                    ++cc)
    {
-      delete *cc;
+      (*cc)->Unregister();
    }
    Patients.clear();
 }
@@ -626,18 +596,12 @@ void DicomDir::CreateDicomDirChainedList(std::string const &path)
          break;
       }
 
-      f = new File( );
+      f = File::New( );
       f->SetLoadMode(LoadMode); // we allow user not to load Sequences, or Shadow
                               //             groups, or ......
       f->SetFileName( it->c_str() );
-   /*int res = */f->Load( );
+      f->Load( );
 
-//     if ( !f )
-//     {
-//         gdcmWarningMacro( "Failure in new gdcm::File " << it->c_str() );
-//         continue;
-//      }
-      
       if ( f->IsReadable() )
       {
          // Add the file to the chained list:
@@ -646,7 +610,7 @@ void DicomDir::CreateDicomDirChainedList(std::string const &path)
        }
        else
        {
-          delete f;
+          f->Delete();
        }
        count++;
    }
@@ -662,7 +626,7 @@ void DicomDir::CreateDicomDirChainedList(std::string const &path)
        itDoc!=list.end();
        ++itDoc)
    {
-      delete dynamic_cast<File *>(*itDoc);
+      dynamic_cast<File *>(*itDoc)->Delete();
    }
 }
 
@@ -780,50 +744,50 @@ void DicomDir::CreateDicomDir()
 
       if ( v == "IMAGE " ) 
       {
-         si = new DicomDirImage(true);
+         si = DicomDirImage::New(true);
          if ( !AddImageToEnd( static_cast<DicomDirImage *>(si)) )
          {
-            delete si;
+            si->Delete();
             si = NULL;
             gdcmErrorMacro( "Add AddImageToEnd failed");
          }
       }
       else if ( v == "SERIES" )
       {
-         si = new DicomDirSerie(true);
+         si = DicomDirSerie::New(true);
          if ( !AddSerieToEnd( static_cast<DicomDirSerie *>(si)) )
          {
-            delete si;
+            si->Delete();
             si = NULL;
             gdcmErrorMacro( "Add AddSerieToEnd failed");
          }
       }
       else if ( v == "VISIT " )
       {
-         si = new DicomDirVisit(true);
+         si = DicomDirVisit::New(true);
          if ( !AddVisitToEnd( static_cast<DicomDirVisit *>(si)) )
          {
-            delete si;
+            si->Delete();
             si = NULL;
             gdcmErrorMacro( "Add AddVisitToEnd failed");
          }
       }
       else if ( v == "STUDY " )
       {
-         si = new DicomDirStudy(true);
+         si = DicomDirStudy::New(true);
          if ( !AddStudyToEnd( static_cast<DicomDirStudy *>(si)) )
          {
-            delete si;
+            si->Delete();
             si = NULL;
             gdcmErrorMacro( "Add AddStudyToEnd failed");
          }
       }
       else if ( v == "PATIENT " )
       {
-         si = new DicomDirPatient(true);
+         si = DicomDirPatient::New(true);
          if ( !AddPatientToEnd( static_cast<DicomDirPatient *>(si)) )
          {
-            delete si;
+            si->Delete();
             si = NULL;
             gdcmErrorMacro( "Add PatientToEnd failed");
          }
@@ -1029,48 +993,48 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type,
    {
       case GDCM_DICOMDIR_IMAGE:
          elemList = Global::GetDicomDirElements()->GetDicomDirImageElements();
-         si = new DicomDirImage(true);
+         si = DicomDirImage::New(true);
          if ( !AddImageToEnd(static_cast<DicomDirImage *>(si)) )
          {
-            delete si;
+            si->Delete();
             gdcmErrorMacro( "Add ImageToEnd failed");
          }
          break;
       case GDCM_DICOMDIR_SERIE:
          elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements();
-         si = new DicomDirSerie(true);
+         si = DicomDirSerie::New(true);
          if ( !AddSerieToEnd(static_cast<DicomDirSerie *>(si)) )
          {
-            delete si;
+            si->Delete();
             gdcmErrorMacro( "Add SerieToEnd failed");
          }
          break;
       case GDCM_DICOMDIR_STUDY:
          elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements();
-         si = new DicomDirStudy(true);
+         si = DicomDirStudy::New(true);
          if ( !AddStudyToEnd(static_cast<DicomDirStudy *>(si)) )
          {
-            delete si;
+            si->Delete();
             gdcmErrorMacro( "Add StudyToEnd failed");
          }
          break;
       case GDCM_DICOMDIR_PATIENT:
          elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements();
-         si = new DicomDirPatient(true);
+         si = DicomDirPatient::New(true);
          if ( !AddPatientToEnd(static_cast<DicomDirPatient *>(si)) )
          {
-            delete si;
+            si->Delete();
             gdcmErrorMacro( "Add PatientToEnd failed");
          }
          break;
       case GDCM_DICOMDIR_META:
          if ( MetaElems )
          {
-            delete MetaElems;
+            MetaElems->Delete();
             gdcmErrorMacro( "MetaElements already exist, they will be destroyed");
          }
          elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements();
-         MetaElems = new DicomDirMeta(true);
+         MetaElems = DicomDirMeta::New(true);
          si = MetaElems;
          break;
       default:
index 2a524f3e13a1b24c55e6d0246f818ac5d1e5ca0c..7a698763d2ea978b29def667c903e04d767582ea 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.h,v $
   Language:  C++
-  Date:      $Date: 2005/08/31 09:29:12 $
-  Version:   $Revision: 1.68 $
+  Date:      $Date: 2005/10/25 14:52:33 $
+  Version:   $Revision: 1.69 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -50,12 +50,12 @@ typedef std::vector<Document *> VectDocument;
  */
 class GDCM_EXPORT DicomDir: public Document
 {
+   gdcmTypeMacro(DicomDir);
+
 public:
-   typedef void Method(void*);
+   static DicomDir *New() {return new DicomDir();}
 
-   DicomDir(); 
-   GDCM_LEGACY( DicomDir(std::string const &filename, bool parseDir = false) ); 
-   ~DicomDir();
+   typedef void Method(void*);
 
    GDCM_LEGACY( bool Load(std::string const &filename) );
    bool Load( );
@@ -140,6 +140,9 @@ public:
    } DicomDirType;
    
 protected:
+   DicomDir(); 
+   ~DicomDir();
+
    void CreateDicomDirChainedList(std::string const &path);
    void CallStartMethod();
    void CallProgressMethod();
index 74b18e0331128a7ea60cfab4388f97d0038b3bdb..37c605ec09ddf71e7b8277734254b12a18351d0c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirElement.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/19 12:01:50 $
-  Version:   $Revision: 1.32 $
+  Date:      $Date: 2005/10/25 14:52:33 $
+  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
@@ -19,7 +19,7 @@
 #ifndef GDCMDICOMDIRELEMENT_H
 #define GDCMDICOMDIRELEMENT_H
 
-#include "gdcmCommon.h"
+#include "gdcmRefCounter.h"
 
 #include <list>
 
@@ -65,13 +65,14 @@ typedef std::list<DicomElement> ListDicomDirFiducialElem;
  * \brief   Represents elements contained in a DicomDir class
  *          for the chained lists from the file 'Dicts/DicomDir.dic'
  */
-class GDCM_EXPORT DicomDirElement
+class GDCM_EXPORT DicomDirElement : public RefCounter
 {
+   gdcmTypeMacro(DicomDirElement);
+
 public:
-   DicomDirElement();
-   ~DicomDirElement();
+   static DicomDirElement *New() {return new DicomDirElement();}
 
-  /**
+   /**
     * \brief   canonical Printer 
     */ 
    void Print(std::ostream &os);
@@ -124,6 +125,10 @@ public:
    void AddDicomDirElement(DicomDirType type,
                            uint16_t group, uint16_t elem);
 
+protected:
+   DicomDirElement();
+   ~DicomDirElement();
+
 private:
    /// Elements chained list, related to the MetaElements of DICOMDIR
    ListDicomDirMetaElem    DicomDirMetaList;
index 2fc5738c847a7092386249e141b8b375a6f8109e..573cc64fee4b56622469dc11051355e576c32e7c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirImage.h,v $
   Language:  C++
-  Date:      $Date: 2005/02/01 13:11:49 $
-  Version:   $Revision: 1.16 $
+  Date:      $Date: 2005/10/25 14:52:33 $
+  Version:   $Revision: 1.17 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -30,11 +30,16 @@ namespace gdcm
  */
  class GDCM_EXPORT DicomDirImage : public DicomDirObject
 {
+   gdcmTypeMacro(DicomDirImage);
+
 public:
-   DicomDirImage(bool empty=false); 
-   ~DicomDirImage();
+   static DicomDirImage *New(bool empty=false) {return new DicomDirImage(empty);}
 
    void Print(std::ostream &os = std::cout, std::string const &indent = "" );
+
+protected:
+   DicomDirImage(bool empty=false); 
+   ~DicomDirImage();
 };
 } // end namespace gdcm
 //-----------------------------------------------------------------------------
index ddeca2534c18372011e97033a96170caa6000609..96403f23c0ecb8c15ab61ce017bd8352a540ff93 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirMeta.h,v $
   Language:  C++
-  Date:      $Date: 2005/02/01 13:11:49 $
-  Version:   $Revision: 1.18 $
+  Date:      $Date: 2005/10/25 14:52:33 $
+  Version:   $Revision: 1.19 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -30,12 +30,17 @@ namespace gdcm
  */
 class GDCM_EXPORT DicomDirMeta : public DicomDirObject 
 {
+   gdcmTypeMacro(DicomDirMeta);
+
 public:
-   DicomDirMeta(bool empty=false); 
-   ~DicomDirMeta();
+   static DicomDirMeta *New(bool empty=false) {return new DicomDirMeta(empty);}
 
    virtual void Print(std::ostream &os = std::cout, std::string const &indent = "" );
    virtual void WriteContent(std::ofstream *fp, FileType t);
+
+protected:
+   DicomDirMeta(bool empty=false); 
+   ~DicomDirMeta();
 };
 } // end namespace gdcm
 //-----------------------------------------------------------------------------
index 5e6dc85335f0601eaa49f8ebd8e930522e411f84..39e4e9964b76d663c3ecd093d4d3941aa1e1886c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirObject.h,v $
   Language:  C++
-  Date:      $Date: 2005/07/12 17:08:12 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2005/10/25 14:52:33 $
+  Version:   $Revision: 1.18 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -39,6 +39,8 @@ typedef std::list<DicomDirObject *> ListContent;
  */
 class GDCM_EXPORT DicomDirObject : public SQItem
 {
+   gdcmTypeMacro(DicomDirObject);
+
 public:
 
 protected:
index 7c2b598de7dd780f5c52932c5630005cad4b7197..73680f8051df592defd78eac10bae7c8e14198f7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirPatient.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/06/24 10:55:58 $
-  Version:   $Revision: 1.38 $
+  Date:      $Date: 2005/10/25 14:52:33 $
+  Version:   $Revision: 1.39 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -75,9 +75,9 @@ void DicomDirPatient::WriteContent(std::ofstream *fp, FileType t)
  */
 DicomDirStudy* DicomDirPatient::NewStudy()
 {
-   DicomDirStudy *st = new DicomDirStudy();
-   Studies.push_back(st);
-   return st
+   DicomDirStudy *dd = DicomDirStudy::New();
+   Studies.push_back(dd);
+   return dd
 }   
 
 /**
@@ -89,7 +89,7 @@ void DicomDirPatient::ClearStudy()
                                          cc != Studies.end(); 
                                        ++cc )
    {
-      delete *cc;
+      (*cc)->Delete();
    }
    Studies.clear();
 }
index 737acd7cccf36aa95306dcd8c806969115041d57..4f989ca48cb997fc66d40ec269bc1562ab5b7ca7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirPatient.h,v $
   Language:  C++
-  Date:      $Date: 2005/09/02 07:10:03 $
-  Version:   $Revision: 1.27 $
+  Date:      $Date: 2005/10/25 14:52:33 $
+  Version:   $Revision: 1.28 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -35,9 +35,10 @@ typedef std::list<DicomDirStudy*> ListDicomDirStudy;
 
 class GDCM_EXPORT DicomDirPatient : public DicomDirObject 
 {
+   gdcmTypeMacro(DicomDirPatient);
+
 public:
-   DicomDirPatient(bool empty=false); 
-   ~DicomDirPatient();
+   static DicomDirPatient *New(bool empty=false) {return new DicomDirPatient(empty);}
 
    void Print(std::ostream &os = std::cout, std::string const &indent = "" );
    void WriteContent(std::ofstream *fp, FileType t);
@@ -52,8 +53,11 @@ public:
    DicomDirStudy *GetNextStudy();
    DicomDirStudy *GetLastStudy();
 
-private:
+protected:
+   DicomDirPatient(bool empty=false); 
+   ~DicomDirPatient();
 
+private:
    /// chained list of DicomDirStudy  (to be exploited hierarchicaly)
    ListDicomDirStudy Studies;
    /// iterator on the DicomDirStudies of the current DicomDirPatient
index db93cc01be4ca3e76a5d2cfc060a843c26543f6a..090dac646c530056d5274e317a7289760e887254 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirSerie.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/06/24 10:55:58 $
-  Version:   $Revision: 1.38 $
+  Date:      $Date: 2005/10/25 14:52:33 $
+  Version:   $Revision: 1.39 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -74,9 +74,9 @@ void DicomDirSerie::WriteContent(std::ofstream *fp, FileType t)
  */
 DicomDirImage *DicomDirSerie::NewImage()
 {
-   DicomDirImage *st = new DicomDirImage();
-   Images.push_back(st);
-   return st;   
+   DicomDirImage *dd = DicomDirImage::New();
+   Images.push_back(dd);
+   return dd;   
 }
 
 /**
@@ -88,7 +88,7 @@ void DicomDirSerie::ClearImage()
                                    cc != Images.end();
                                    ++cc)
    {
-      delete *cc;
+      (*cc)->Delete();
    }
    Images.clear();
 }
index 27c5adc9cc778de2a78585ed4373d4463e3fba41..dfcf896860b27bc3068b2df5de6e0836578bf715 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirSerie.h,v $
   Language:  C++
-  Date:      $Date: 2005/09/02 07:10:03 $
-  Version:   $Revision: 1.29 $
+  Date:      $Date: 2005/10/25 14:52:33 $
+  Version:   $Revision: 1.30 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -34,9 +34,10 @@ typedef std::list<DicomDirImage *> ListDicomDirImage;
  */
 class GDCM_EXPORT DicomDirSerie : public DicomDirObject 
 {
+   gdcmTypeMacro(DicomDirSerie);
+
 public:
-   DicomDirSerie(bool empty=false); 
-   ~DicomDirSerie();
+   static DicomDirSerie *New(bool empty=false) {return new DicomDirSerie(empty);}
 
    void Print( std::ostream &os = std::cout, std::string const &indent = "" );
    void WriteContent( std::ofstream *fp, FileType t );
@@ -50,8 +51,11 @@ public:
    DicomDirImage *GetFirstImage();
    DicomDirImage *GetNextImage();
 
-private:
+protected:
+   DicomDirSerie(bool empty=false); 
+   ~DicomDirSerie();
 
+private:
    ///chained list of DicomDirImages (to be exploited recursively)
    ListDicomDirImage Images;
    /// iterator on the DicomDirImages of the current DicomDirSerie
index 9a5dd26551e40cf08bc9d9014681e7621c178592..b907e6983291b013b170765d75ebbe942ac62186 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirStudy.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/11 08:20:25 $
-  Version:   $Revision: 1.40 $
+  Date:      $Date: 2005/10/25 14:52:33 $
+  Version:   $Revision: 1.41 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -83,9 +83,9 @@ void DicomDirStudy::WriteContent(std::ofstream *fp, FileType t)
  */
 DicomDirSerie *DicomDirStudy::NewSerie()
 {
-   DicomDirSerie *st = new DicomDirSerie();
-   Series.push_back(st);
-   return st;
+   DicomDirSerie *dd = DicomDirSerie::New();
+   Series.push_back(dd);
+   return dd;
 } 
 
 /**
@@ -97,7 +97,7 @@ void DicomDirStudy::ClearSerie()
                                    cc != Series.end();
                                  ++cc )
    {
-      delete *cc;
+      (*cc)->Delete();
    }
    Series.clear();
 }
@@ -151,9 +151,10 @@ DicomDirSerie *DicomDirStudy::GetLastSerie()
  */
 DicomDirVisit *DicomDirStudy::NewVisit()
 {
-   DicomDirVisit *st = new DicomDirVisit();
-   Visits.push_back(st);
-   return st;
+   DicomDirVisit *dd = DicomDirVisit::New();
+   Visits.push_back(dd);
+   dd->Delete();
+   return dd;
 } 
 
 /**
@@ -165,7 +166,7 @@ void DicomDirStudy::ClearVisit()
                                    cc != Visits.end();
                                  ++cc )
    {
-      delete *cc;
+      (*cc)->Delete();
    }
    Visits.clear();
 }
index bc8245abc1002ad9bd211b154c87ceb27bcece56..ba277d51cb5586e34a98d4fe3cb662c70466465c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirStudy.h,v $
   Language:  C++
-  Date:      $Date: 2005/09/02 07:10:03 $
-  Version:   $Revision: 1.29 $
+  Date:      $Date: 2005/10/25 14:52:33 $
+  Version:   $Revision: 1.30 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -42,9 +42,10 @@ typedef std::list<DicomDirStudyComponent *> ListDicomDirStudyComponent;
  */
 class GDCM_EXPORT DicomDirStudy : public DicomDirObject
 {
+   gdcmTypeMacro(DicomDirStudy);
+
 public:
-   DicomDirStudy(bool empty=false); 
-   ~DicomDirStudy();
+   static DicomDirStudy *New(bool empty=false) {return new DicomDirStudy(empty);}
 
    void Print(std::ostream &os = std::cout, std::string const &indent = "" );
    void WriteContent(std::ofstream *fp, FileType t);
@@ -77,8 +78,12 @@ public:
    DicomDirStudyComponent *GetNextStudyComponent();
    DicomDirStudyComponent *GetLastStudyComponent();
 */    
-private:
 
+protected:
+   DicomDirStudy(bool empty=false); 
+   ~DicomDirStudy();
+
+private:
    /// chained list of DicomDirSeries (to be exploited hierarchicaly)
    ListDicomDirSerie Series;
    /// iterator on the DicomDirSeries of the current DicomDirStudy
index 18337fba6bef6df16db79ad0614d5a15493f54c6..27f03b6dc1bda639a6a1fca88d3fe12b01562d44 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirVisit.h,v $
   Language:  C++
-  Date:      $Date: 2005/07/08 19:07:12 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2005/10/25 14:52:34 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -30,13 +30,17 @@ namespace gdcm
  */
 class GDCM_EXPORT DicomDirVisit : public DicomDirObject 
 {
+   gdcmTypeMacro(DicomDirVisit);
+
 public:
-   DicomDirVisit(bool empty=false); 
-   ~DicomDirVisit();
+   static DicomDirVisit *New(bool empty=false) {return new DicomDirVisit(empty);}
 
    void Print( std::ostream &os = std::cout, std::string const &indent = "" );
   // void WriteContent( std::ofstream *fp, FileType t );
 
+protected:
+   DicomDirVisit(bool empty=false); 
+   ~DicomDirVisit();
 };
 } // end namespace gdcm
 //-----------------------------------------------------------------------------
index d48b96944fc028167744cba3d0afb14ab643fe99..168f794e25d23507e04f76db136fbcd258f63458 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDict.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/23 15:32:30 $
-  Version:   $Revision: 1.44 $
+  Date:      $Date: 2005/10/25 14:52:34 $
+  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
@@ -19,7 +19,7 @@
 #ifndef GDCMDICT_H
 #define GDCMDICT_H
 
-#include "gdcmBase.h"
+#include "gdcmRefCounter.h"
 #include "gdcmDictEntry.h"
 
 #include <iostream>
@@ -44,12 +44,13 @@ typedef std::map<TagKey, DictEntry *>  TagKeyHT;
  *           combined with all software versions...
  * \see DictSet
  */
-class GDCM_EXPORT Dict : public Base
+class GDCM_EXPORT Dict : public RefCounter
 {
+   gdcmTypeMacro(Dict);
+
 public:
-   Dict();
-   Dict(std::string const &filename);
-   ~Dict();
+   static Dict *New() {return new Dict();}
+   static Dict *New(std::string const &filename) {return new Dict(filename);}
 
    bool AddDict(std::string const &filename);
    bool RemoveDict(std::string const &filename);
@@ -70,6 +71,11 @@ public:
    DictEntry *GetFirstEntry();
    DictEntry *GetNextEntry();
 
+protected:
+   Dict();
+   Dict(std::string const &filename);
+   ~Dict();
+
 private:
    void DoTheLoadingJob(std::ifstream &ifs);
 
index b03c5c61ed3304fa896017d56f09187b3e2c7a01..c31266d6cd52211a12f22f2f239267a666b35a80 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictGroupName.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/23 15:32:31 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2005/10/25 14:52:34 $
+  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
@@ -19,7 +19,8 @@
 #ifndef GDCMDICTGROUPNAME_H
 #define GDCMDICTGROUPNAME_H
 
-#include "gdcmCommon.h"
+#include "gdcmRefCounter.h"
+
 #include <map>
 #include <string>
 #include <iostream>
@@ -36,16 +37,21 @@ typedef std::map<uint16_t, TagName> DictGroupNameHT;
  * \brief Container for dicom 'Value Representation' Hash Table.
  * \note   This is a singleton.
  */
-class GDCM_EXPORT DictGroupName 
+class GDCM_EXPORT DictGroupName : public RefCounter
 {
+   gdcmTypeMacro(DictGroupName);
+
 public:
-   DictGroupName(void);
-   ~DictGroupName();
+   static DictGroupName *New() {return new DictGroupName();}
 
    void Print(std::ostream &os = std::cout);
 
    const TagName &GetName(uint16_t group);
 
+protected:
+   DictGroupName();
+   ~DictGroupName();
+
 private:
    DictGroupNameHT groupName;
 };
index 32a5023a73c2f85391bc159403fe899d852da4c1..524f0f98e76db7330d05815aa8bf882070327d97 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/20 15:24:08 $
-  Version:   $Revision: 1.71 $
+  Date:      $Date: 2005/10/25 14:52:34 $
+  Version:   $Revision: 1.72 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -36,7 +36,7 @@ DictSet::DictSet()
    DictPath = BuildDictPath();
    std::string pubDictFile(DictPath);
    pubDictFile += PUB_DICT_FILENAME;
-   Dicts[PUB_DICT_NAME] = new Dict(pubDictFile);
+   Dicts[PUB_DICT_NAME] = Dict::New(pubDictFile);
 }
 
 /**
@@ -47,12 +47,8 @@ DictSet::~DictSet()
    // Remove dictionaries
    for (DictSetHT::iterator tag = Dicts.begin(); tag != Dicts.end(); ++tag) 
    {
-      Dict *entryToDelete = tag->second;
-      if ( entryToDelete )
-      {
-         delete entryToDelete;
-      }
-      tag->second = NULL;
+      if ( tag->second )
+         tag->second->Delete();
    }
    Dicts.clear();
 }
@@ -70,8 +66,8 @@ DictSet::~DictSet()
 Dict *DictSet::LoadDictFromFile(std::string const &filename, 
                                 DictKey const &name) 
 {
-   Dict *newDict = new Dict(filename);
-   AppendDict(newDict, name);
+   Dict *newDict = Dict::New(filename);
+   Dicts[name] = newDict;
 
    return newDict;
 }
@@ -151,16 +147,6 @@ std::string DictSet::BuildDictPath()
 
 //-----------------------------------------------------------------------------
 // Protected
-/**
- * \brief   Adds a Dictionary to a DictSet
- * \return  always true
- */
-bool DictSet::AppendDict(Dict *newDict, DictKey const &name)
-{
-   Dicts[name] = newDict;
-
-   return true;
-}
 
 //-----------------------------------------------------------------------------
 // Private
index 4ae5d721589c0ef5be5dfcf754e4068e3ef3a7ba..e49e859eb35924669fe10eb9c8fe37269fa9c38e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDictSet.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/23 15:32:31 $
-  Version:   $Revision: 1.48 $
+  Date:      $Date: 2005/10/25 14:52:34 $
+  Version:   $Revision: 1.49 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,7 +19,7 @@
 #ifndef GDCMDICTSET_H
 #define GDCMDICTSET_H
 
-#include "gdcmBase.h"
+#include "gdcmRefCounter.h"
 #include "gdcmDict.h"
 
 #include <map>
@@ -38,11 +38,12 @@ typedef std::map<DictKey, Dict*> DictSetHT;
  * \par    having many in memory representations of the same dictionary
  *        (saving memory).
  */
-class GDCM_EXPORT DictSet : public Base
+class GDCM_EXPORT DictSet : public RefCounter
 {
+   gdcmTypeMacro(DictSet);
+
 public:
-   DictSet();
-   ~DictSet();
+   static DictSet *New() {return new DictSet();}
 
    void Print(std::ostream &os = std::cout, std::string const &indent = "" );
 
@@ -68,7 +69,8 @@ public:
    static std::string BuildDictPath();
 
 protected:
-   bool AppendDict(Dict *NewDict, DictKey const &name);
+   DictSet();
+   ~DictSet();
 
 private:
    /// Hash table of all dictionaries contained in this DictSet
index 3448c892f9db5646269541c7b19a21d077d556ad..92f1c492e3ac67f6fa1a7e839e13fa35a931b9a7 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntrySet.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/24 16:00:47 $
-  Version:   $Revision: 1.61 $
+  Date:      $Date: 2005/10/25 14:52:34 $
+  Version:   $Revision: 1.62 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,7 +19,7 @@
 #ifndef GDCMDOCENTRYSET_H
 #define GDCMDOCENTRYSET_H
 
-#include "gdcmBase.h"
+#include "gdcmRefCounter.h"
 #include "gdcmVRKey.h"
 #include "gdcmTagKey.h"
 
@@ -56,14 +56,11 @@ class DictEntry;
  *       members to this class since this class is designed as an adapter 
  *       in the form of an abstract base class.
  */
-class GDCM_EXPORT DocEntrySet : public Base
+class GDCM_EXPORT DocEntrySet : public RefCounter
 {
-public:
-   /// Canonical Constructor
-   DocEntrySet();
-   /// Canonical Destructor
-   virtual ~DocEntrySet() {}
+   gdcmTypeMacro(DocEntrySet);
 
+public:
    /// \brief write any type of entry to the entry set
    virtual void WriteContent (std::ofstream *fp, FileType filetype) = 0;
 
@@ -114,6 +111,11 @@ public:
    SeqEntry *NewSeqEntry(uint16_t group, uint16_t elem);
 
 protected:
+   /// Canonical Constructor
+   DocEntrySet();
+   /// Canonical Destructor
+   virtual ~DocEntrySet() {}
+
 // DictEntry  related utilities
    DictEntry *GetDictEntry(uint16_t group, uint16_t elem);
    DictEntry *GetDictEntry(uint16_t group, uint16_t elem,
index 3cdda736c6f137f59606f36d87e13e8e9c463515..0af2d956906dccab3f129b763677ef103d0951a3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/25 12:42:37 $
-  Version:   $Revision: 1.306 $
+  Date:      $Date: 2005/10/25 14:52:34 $
+  Version:   $Revision: 1.307 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -1204,7 +1204,7 @@ void Document::ParseSQ( SeqEntry *seqEntry,
          break;
       }
       // create the current SQItem
-      SQItem *itemSQ = new SQItem( seqEntry->GetDepthLevel() );
+      SQItem *itemSQ = SQItem::New( seqEntry->GetDepthLevel() );
       unsigned int l = newDocEntry->GetReadLength();
       
       if ( l == 0xffffffff )
@@ -1227,6 +1227,7 @@ void Document::ParseSQ( SeqEntry *seqEntry,
       // end try -----------------
  
       seqEntry->AddSQItem( itemSQ, SQItemNumber ); 
+      itemSQ->Delete();
       newDocEntry->Delete();
       SQItemNumber++;
       if ( !delim_mode && ((long)(Fp->tellg())-offset ) >= l_max )
index 1d8ce95c005e05588314684ccd684c975b4d39f9..ea455441c6acbf949a88a651795211e7453d40ef 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/19 12:01:51 $
-  Version:   $Revision: 1.126 $
+  Date:      $Date: 2005/10/25 14:52:34 $
+  Version:   $Revision: 1.127 $
  
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -39,9 +39,10 @@ class Dict;
  */
 class GDCM_EXPORT Document : public ElementSet
 {
-public:
+   gdcmTypeMacro(Document);
 
-typedef std::list<DicomElement> ListElements;
+public:
+   typedef std::list<DicomElement> ListElements;
 
 // Loading
    //Deprecated : use SetFileName() + Load()
index d924c6e867ed2106d94a46d2f5c0667e5c622116..26ae0a20eb32c5d426f27724309039116f66f5df 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/24 16:00:47 $
-  Version:   $Revision: 1.48 $
+  Date:      $Date: 2005/10/25 14:52:34 $
+  Version:   $Revision: 1.49 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -41,10 +41,9 @@ typedef std::map<TagKey, DocEntry *> TagDocEntryHT;
  */
 class GDCM_EXPORT ElementSet : public DocEntrySet
 {
-public:
-   ElementSet();
-   ~ElementSet();
+   gdcmTypeMacro(ElementSet);
 
+public:
    virtual void Print(std::ostream &os = std::cout, 
                       std::string const &indent = "" ); 
 
@@ -61,6 +60,8 @@ public:
    bool IsEmpty() { return TagHT.empty(); }
 
 protected:
+   ElementSet();
+   ~ElementSet();
 
 private:
 // Variables
index 2d76f3f0a5e4a38d9ad4734b02a6bd4192e8ff32..88b7d144787810412af48e9abfc330af7eef79f1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/25 14:36:30 $
-  Version:   $Revision: 1.294 $
+  Date:      $Date: 2005/10/25 14:52:34 $
+  Version:   $Revision: 1.295 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -1790,21 +1790,6 @@ void File::ReadEncapsulatedBasicOffsetTable()
 // These are the deprecated method that one day should be removed (after the next release)
 
 #ifndef GDCM_LEGACY_REMOVE
-/*
- *  brief  Constructor (DEPRECATED : temporaryly kept not to break the API)
- *  param  filename name of the file whose header we want to analyze
- *  deprecated do not use any longer
- */
-File::File( std::string const &filename )
-     :Document( )
-{    
-   RLEInfo  = new RLEFramesInfo;
-   JPEGInfo = new JPEGFragmentsInfo;
-
-   SetFileName( filename );
-   Load( ); // gdcm::Document is first Loaded, then the 'File part'
-}
-
 /*
  * \ brief   Loader. (DEPRECATED :  temporaryly kept not to break the API)
  * @ param   fileName file to be open for parsing
index 8e6e51adab74897ae5a5e5839f0ab235e80cc5a5..73590e8651a47fd6f776f9a6fa68d29c9e9cabba 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/06 18:54:50 $
-  Version:   $Revision: 1.117 $
+  Date:      $Date: 2005/10/25 14:52:34 $
+  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
@@ -98,10 +98,10 @@ enum ModalityType {
  */
 class GDCM_EXPORT File : public Document
 {
+   gdcmTypeMacro(File);
+
 public:
-   File();
-   GDCM_LEGACY(File( std::string const &filename ));
-   ~File();
+   static File *New() {return new File();}
 
    // Loading
    GDCM_LEGACY(bool Load( std::string const &filename ));
@@ -175,7 +175,9 @@ public:
    bool Write(std::string fileName, FileType filetype);
 
 protected:
+   File();
+   ~File();
+
    /// Store the RLE frames info obtained during parsing of pixels.
    RLEFramesInfo *RLEInfo;
    /// Store the JPEG fragments info obtained during parsing of pixels.
index 0d5cd3312282e3eac92df06859f1b282e92515a6..257bace4286f9054ea7978fe080075f25886af03 100644 (file)
@@ -4,8 +4,8 @@
   Module:    $RCSfile: gdcmFileHelper.cxx,v $
   Language:  C++
 
-  Date:      $Date: 2005/10/25 12:42:01 $
-  Version:   $Revision: 1.73 $
+  Date:      $Date: 2005/10/25 14:52:34 $
+  Version:   $Revision: 1.74 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -130,8 +130,7 @@ namespace gdcm
  */
 FileHelper::FileHelper( )
 { 
-   FileInternal = new File( );
-   SelfHeader = true;
+   FileInternal = File::New( );
    Initialize();
 }
 
@@ -152,7 +151,7 @@ FileHelper::FileHelper( )
 FileHelper::FileHelper(File *header)
 {
    FileInternal = header;
-   SelfHeader = false;
+   header->Register();
    Initialize();
    if ( FileInternal->IsReadable() )
    {
@@ -160,36 +159,6 @@ FileHelper::FileHelper(File *header)
    }
 }
 
-#ifndef GDCM_LEGACY_REMOVE
-/* 
- *  brief DEPRECATED : use SetFilename() + SetLoadMode() + Load() methods
- *        Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3
- *        file (gdcm::File only deals with the ... header)
- *        Opens (in read only and when possible) an existing file and checks
- *        for DICOM compliance. Returns NULL on failure.
- *        It will be up to the user to load the pixels into memory
- *  note  the in-memory representation of all available tags found in
- *        the DICOM header is post-poned to first header information access.
- *        This avoid a double parsing of public part of the header when
- *        one sets an a posteriori shadow dictionary (efficiency can be
- *        seen as a side effect).   
- *  param filename file to be opened for parsing
- *  deprecated  use SetFilename() + Load() methods
- */
-FileHelper::FileHelper(std::string const &filename )
-{
-   FileInternal = new File( );
-   FileInternal->SetFileName( filename );
-   FileInternal->Load();
-   SelfHeader = true;
-   Initialize();
-   if ( FileInternal->IsReadable() )
-   {
-      PixelReadConverter->GrabInformationsFromFile( FileInternal );
-   }
-}
-#endif
-
 /**
  * \brief canonical destructor
  * \note  If the header (gdcm::File) was created by the FileHelper constructor,
@@ -210,10 +179,7 @@ FileHelper::~FileHelper()
       delete Archive;
    }
 
-   if ( SelfHeader )
-   {
-      delete FileInternal;
-   }
+   FileInternal->Unregister();
    FileInternal = 0;
 }
 
@@ -1392,13 +1358,14 @@ void FileHelper::CheckMandatoryElements()
       // Create 'Source Image Sequence' SeqEntry
       SeqEntry *sis = SeqEntry::New (
             Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x2112) );
-      SQItem *sqi = new SQItem(1);
+      SQItem *sqi = SQItem::New(1);
       // (we assume 'SOP Instance UID' exists too) 
       // create 'Referenced SOP Class UID'
       DataEntry *e_0008_1150 = DataEntry::New(
             Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1150) );
       e_0008_1150->SetString( e_0008_0016->GetString());
       sqi->AddEntry(e_0008_1150);
+      e_0008_1150->Delete();
       
       // create 'Referenced SOP Instance UID'
       DataEntry *e_0008_0018 = FileInternal->GetDataEntry(0x0008, 0x0018);
@@ -1406,8 +1373,11 @@ void FileHelper::CheckMandatoryElements()
             Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1155) );
       e_0008_1155->SetString( e_0008_0018->GetString());
       sqi->AddEntry(e_0008_1155);
+      e_0008_1155->Delete();
+
+      sis->AddSQItem(sqi,1);
+      sqi->Delete();
 
-      sis->AddSQItem(sqi,1); 
       // temporarily replaces any previous 'Source Image Sequence' 
       Archive->Push(sis);
       sis->Delete();
index 7f7476d4fece7275b5c7cda8a694f5ff632563bb..899cb436b75980429536b6d2f5e0a7d7334ad677 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFileHelper.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/25 12:43:25 $
-  Version:   $Revision: 1.28 $
+  Date:      $Date: 2005/10/25 14:52:34 $
+  Version:   $Revision: 1.29 $
                                                                                 
   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 @@
 #define GDCMFILEHELPER_H
 
 #include "gdcmDebug.h"
-#include "gdcmBase.h"
+#include "gdcmRefCounter.h"
 
 
 namespace gdcm 
@@ -40,8 +40,10 @@ typedef void (*VOID_FUNCTION_PUINT8_PFILE_POINTER)(uint8_t *, File *);
  * for accessing the image/volume content. One can also use it to
  * write Dicom/ACR-NEMA/RAW files.
  */
-class GDCM_EXPORT FileHelper : public Base
+class GDCM_EXPORT FileHelper : public RefCounter
 {
+   gdcmTypeMacro(FileHelper);
+
 public:
    enum FileMode
    {
@@ -50,9 +52,8 @@ public:
    };
      
 public:
-   FileHelper( );
-   FileHelper( File *header );
-   GDCM_LEGACY(FileHelper( std::string const &filename ));
+   static FileHelper *New() {return new FileHelper();}
+   static FileHelper *New(File *header) {return new FileHelper(header);}
    
    virtual ~FileHelper();
 
@@ -149,6 +150,9 @@ public:
    bool Write         (std::string const &fileName);
 
 protected:
+   FileHelper( );
+   FileHelper( File *header );
+
    bool CheckWriteIntegrity();
 
    void SetWriteToRaw();
@@ -182,11 +186,6 @@ private:
    /// gdcm::File to use to load the file
    File *FileInternal;
 
-   /// \brief Whether the underlying \ref gdcm::File was loaded by
-   ///  the constructor or passed to the constructor. 
-   ///  When false the destructor is in charge of deletion.
-   bool SelfHeader;
-   
    /// Whether already parsed or not
    bool Parsed;
 
index b2864d5d081b94fb66d841f608db800190e5ab63..4a21aca32e87b949f204e6851c56b7c55b7cf197 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmGlobal.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 12:58:28 $
-  Version:   $Revision: 1.27 $
+  Date:      $Date: 2005/10/25 14:52:35 $
+  Version:   $Revision: 1.28 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -70,11 +70,11 @@ Global::Global()
       gdcmWarningMacro( "VR or TS or Dicts already allocated");
       return;
    }
-   Dicts     = new DictSet();
-   ValRes    = new VR();
-   TranSyn   = new TS();
-   GroupName = new DictGroupName();
-   ddElem    = new DicomDirElement();
+   Dicts     = DictSet::New();
+   ValRes    = VR::New();
+   TranSyn   = TS::New();
+   GroupName = DictGroupName::New();
+   ddElem    = DicomDirElement::New();
 }
 
 /**
@@ -82,11 +82,11 @@ Global::Global()
  */
 Global::~Global()
 {
-   delete Dicts;
-   delete ValRes;
-   delete TranSyn;
-   delete GroupName;
-   delete ddElem;
+   Dicts->Delete();
+   ValRes->Delete();
+   TranSyn->Delete();
+   GroupName->Delete();
+   ddElem->Delete();
 }
 
 //-----------------------------------------------------------------------------
index 42567308ea3d3fcd30d4d694814ab33ad9aa709f..0d8852258e9471ff5481c4fb87a026312dadb440 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/24 16:00:48 $
-  Version:   $Revision: 1.46 $
+  Date:      $Date: 2005/10/25 14:52:35 $
+  Version:   $Revision: 1.47 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -40,9 +40,10 @@ typedef std::list<DocEntry *> ListDocEntry;
  */ 
 class GDCM_EXPORT SQItem : public DocEntrySet 
 {
+   gdcmTypeMacro(SQItem);
+
 public:
-   SQItem(int depthLevel);
-   ~SQItem();
+   static SQItem *New(int depthLevel) {return new SQItem(depthLevel);}
 
    virtual void Print(std::ostream &os = std::cout, std::string const &indent = "" ); 
    void WriteContent(std::ofstream *fp, FileType filetype);
@@ -71,6 +72,9 @@ public:
    void SetDepthLevel(int depth) { SQDepthLevel = depth; }
 
 protected:
+   SQItem(int depthLevel);
+   ~SQItem();
+
 // Variables that need to be accessed in subclasses
    /// \brief Chained list of Doc Entries
    ListDocEntry DocEntries;
index c0647f9ded94d166f1bcea0f79c146e0d725bd02..615863efca6b641a4438396a97bb3b5d27d349a4 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSeqEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/24 16:00:48 $
-  Version:   $Revision: 1.59 $
+  Date:      $Date: 2005/10/25 14:52:35 $
+  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
@@ -116,6 +116,7 @@ void SeqEntry::AddSQItem(SQItem *sqItem, int itemNumber)
 //         Or we can add (or remove) anywhere, and SQItemNumber will be broken
    sqItem->SetSQItemNumber(itemNumber);
    Items.push_back(sqItem);
+   sqItem->Register();
 }
 
 /**
@@ -125,7 +126,7 @@ void SeqEntry::ClearSQItem()
 {
    for(ListSQItem::iterator cc = Items.begin(); cc != Items.end(); ++cc)
    {
-      delete *cc;
+      (*cc)->Unregister();
    }
    if (SeqTerm)
    {
index f025fd036130b2cbf8e5f0561d4def573330adec..c205856fcfe747e2f522b4ced5fee425ad68d203 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSerieHelper.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/25 12:40:03 $
-  Version:   $Revision: 1.29 $
+  Date:      $Date: 2005/10/25 14:52:35 $
+  Version:   $Revision: 1.30 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -68,7 +68,7 @@ void SerieHelper::ClearAll()
                                     it != l->end(); 
                                   ++it)
       {
-         delete *it; // remove each entry
+         (*it)->Delete(); // remove each entry
       }
       l->clear();
       delete l;     // remove the container
@@ -88,7 +88,7 @@ void SerieHelper::ClearAll()
 void SerieHelper::AddFileName(std::string const &filename)
 {
    // Create a DICOM file
-   File *header = new File ();
+   File *header = File::New();
    header->SetLoadMode(LoadMode);
    header->SetFileName( filename ); 
    header->Load();
@@ -139,13 +139,13 @@ void SerieHelper::AddFileName(std::string const &filename)
       else
       {
          // at least one rule was unmatched we need to deallocate the file:
-         delete header;
+         header->Delete();
       }
    }
    else
    {
       gdcmWarningMacro("Could not read file: " << filename );
-      delete header;
+      header->Delete();
    }
 }
 
index d89e4d5e2508612624996a8d162e92e7fe58d213..8a5e340886feb1b1ef833d43b7d7aa7404f60231 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmTS.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 10:43:32 $
-  Version:   $Revision: 1.21 $
+  Date:      $Date: 2005/10/25 14:52:35 $
+  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
@@ -19,7 +19,7 @@
 #ifndef GDCMTS_H
 #define GDCMTS_H
 
-#include "gdcmCommon.h"
+#include "gdcmRefCounter.h"
 
 #include <map>
 #include <string>
@@ -38,34 +38,35 @@ typedef std::map<TSKey, TSAtr> TSHT;    // Transfer Syntax Hash Table
  * \brief Container for dicom 'Transfer Syntax' Hash Table
  * \note   This is a singleton
  */
-class GDCM_EXPORT TS
+class GDCM_EXPORT TS : public RefCounter
 {
+   gdcmTypeMacro(TS);
+
 public:
-enum SpecialType {
-  ImplicitVRLittleEndian = 0,
-  ImplicitVRBigEndianPrivateGE,
-  ExplicitVRLittleEndian,
-  DeflatedExplicitVRLittleEndian,
-  ExplicitVRBigEndian,
-  JPEGBaselineProcess1,
-  JPEGExtendedProcess2_4,
-  JPEGExtendedProcess3_5,
-  JPEGSpectralSelectionProcess6_8,
-  JPEGFullProgressionProcess10_12,
-  JPEGLosslessProcess14,
-  JPEGLosslessProcess14_1,
-  JPEGLSLossless,
-  JPEGLSNearLossless,
-  JPEG2000Lossless,  
-  JPEG2000,
-  RLELossless,
-  MPEG2MainProfile,  
-  UnknownTS
-};
+   enum SpecialType {
+   ImplicitVRLittleEndian = 0,
+   ImplicitVRBigEndianPrivateGE,
+   ExplicitVRLittleEndian,
+   DeflatedExplicitVRLittleEndian,
+   ExplicitVRBigEndian,
+   JPEGBaselineProcess1,
+   JPEGExtendedProcess2_4,
+   JPEGExtendedProcess3_5,
+   JPEGSpectralSelectionProcess6_8,
+   JPEGFullProgressionProcess10_12,
+   JPEGLosslessProcess14,
+   JPEGLosslessProcess14_1,
+   JPEGLSLossless,
+   JPEGLSNearLossless,
+   JPEG2000Lossless,  
+   JPEG2000,
+   RLELossless,
+   MPEG2MainProfile,  
+   UnknownTS
+   };
 
 public:
-   TS();
-   ~TS();
+   static TS *New() {return new TS();}
 
    void Print(std::ostream &os = std::cout);
 
@@ -84,6 +85,10 @@ public:
    SpecialType GetSpecialTransferSyntax(TSKey const &key);
    const char* GetSpecialTransferSyntax(SpecialType t);
 
+protected:
+   TS();
+   ~TS();
+
 private:
    TSHT TsMap;
 };
index 399884c28e65ad3b045c1beb30c6dc747689b51a..7a2af7b5b5c5cdfafd8d35b948222ff337233d37 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmVR.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/23 14:56:27 $
-  Version:   $Revision: 1.24 $
+  Date:      $Date: 2005/10/25 14:52:35 $
+  Version:   $Revision: 1.25 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -19,7 +19,7 @@
 #ifndef GDCMVR_H
 #define GDCMVR_H
 
-#include "gdcmCommon.h"
+#include "gdcmRefCounter.h"
 #include "gdcmVRKey.h"
 
 #include <map>
@@ -39,11 +39,12 @@ typedef std::map<VRKey, VRAtr> VRHT;
  * \brief Container for dicom Value Representation Hash Table
  * \note   This is a singleton
  */
-class GDCM_EXPORT VR 
+class GDCM_EXPORT VR : public RefCounter
 {
+   gdcmTypeMacro(VR);
+
 public:
-   VR(void);
-   ~VR();
+   static VR *New() {return new VR();}
 
    void Print(std::ostream &os = std::cout);
 
@@ -67,6 +68,10 @@ public:
 
    unsigned short GetAtomicElementLength(VRKey const &tested);
 
+protected:
+   VR();
+   ~VR();
+
 private:
    VRHT vr;
 };
index a503fcb1f4282c44ec896facc12b72658a8ab0d7..24e3f929775c761a4418994cc46b5b9c36fb6299 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcmReader.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/09/20 08:50:57 $
-  Version:   $Revision: 1.84 $
+  Date:      $Date: 2005/10/25 14:52:37 $
+  Version:   $Revision: 1.85 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -69,7 +69,7 @@
 #include <vtkPointData.h>
 #include <vtkLookupTable.h>
 
-vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.84 $")
+vtkCxxRevisionMacro(vtkGdcmReader, "$Revision: 1.85 $")
 vtkStandardNewMacro(vtkGdcmReader)
 
 //-----------------------------------------------------------------------------
@@ -452,7 +452,7 @@ void vtkGdcmReader::LoadFileInformation()
       fclose(fp);
 
       // Read the file
-      file=new gdcm::File();
+      file=gdcm::File::New();
       file->SetLoadMode( LoadMode );
       file->SetFileName(filename->c_str() );
       file->Load();
@@ -463,7 +463,7 @@ void vtkGdcmReader::LoadFileInformation()
          vtkErrorMacro(<< "Gdcm cannot parse file " << filename->c_str());
          vtkErrorMacro(<< "Removing this file from read files: "
                         << filename->c_str());
-         delete file;
+         file->Delete();
          file=NULL;
          InternalFileList.push_back(file);
          continue;
@@ -479,7 +479,7 @@ void vtkGdcmReader::LoadFileInformation()
                        << "   File type found : " << type.c_str() 
                        << " (might be 8U, 8S, 16U, 16S, 32U, 32S) \n"
                        << "   Removing this file from read files");
-         delete file;
+         file->Delete();
          file=NULL;
          InternalFileList.push_back(file);
          continue;
@@ -499,7 +499,7 @@ void vtkGdcmReader::LoadFileInformation()
       }
       else if(!TestFileInformation(file))
       {
-         delete file;
+         file->Delete();
          file=NULL;
       }
 
@@ -681,7 +681,7 @@ void vtkGdcmReader::RemoveAllInternalFile(void)
                                  it!=InternalFileList.end();
                                  ++it)
       {
-         delete (*it);
+         (*it)->Delete();
       }
    }
    this->InternalFileList.clear();
@@ -741,7 +741,7 @@ void vtkGdcmReader::LoadImageInMemory(
    if(!f)
       return;
 
-   gdcm::FileHelper *fileH = new gdcm::FileHelper( f );
+   gdcm::FileHelper *fileH = gdcm::FileHelper::New( f );
    fileH->SetUserFunction( UserFunction );
 
    int numColumns = f->GetXSize();
@@ -821,7 +821,7 @@ void vtkGdcmReader::LoadImageInMemory(
       dst += 2 * planeSize;
    }
 
-   delete fileH;
+   fileH->Delete();
 }
 
 //-----------------------------------------------------------------------------
index e5b3b5197109396c6b1db3db5a2be67d0172b542..333be8f232ba5e4be1a472528bd1319ae05c8cf3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcmWriter.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:55 $
-  Version:   $Revision: 1.25 $
+  Date:      $Date: 2005/10/25 14:52:37 $
+  Version:   $Revision: 1.26 $
                                                                                 
   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,7 @@
 #define vtkFloatingPointType float
 #endif
 
-vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.25 $")
+vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.26 $")
 vtkStandardNewMacro(vtkGdcmWriter)
 
 //-----------------------------------------------------------------------------
@@ -332,7 +332,7 @@ void vtkGdcmWriter::RecursiveWrite(int axis, vtkImageData *cache,
 void vtkGdcmWriter::WriteDcmFile(char *fileName, vtkImageData *image)
 {
    // From here, the write of the file begins
-   gdcm::FileHelper *dcmFile = new gdcm::FileHelper();
+   gdcm::FileHelper *dcmFile = gdcm::FileHelper::New();
 
    // Set the image informations
    SetImageInformation(dcmFile, image);
@@ -367,7 +367,7 @@ void vtkGdcmWriter::WriteDcmFile(char *fileName, vtkImageData *image)
    {
       delete[] dcmFile->GetUserData();
    }
-   delete dcmFile;
+   dcmFile->Delete();
 }
 
 //-----------------------------------------------------------------------------