]> Creatis software - gdcm.git/blobdiff - Example/makeDicomDir.cxx
* src/gdcmFile.[h|cxx] : now use FileType instead of TWriteType.
[gdcm.git] / Example / makeDicomDir.cxx
index 02146feb4caf13e1ae7d82a48d9eadde0fb8fc43..4ffd464bf6af83313f0ce96a2457076a350e25a9 100644 (file)
@@ -1,3 +1,20 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: makeDicomDir.cxx,v $
+  Language:  C++
+  Date:      $Date: 2004/11/16 04:26:18 $
+  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
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
 #include <iostream>
 #include "gdcm.h"
 #include "gdcmDocEntry.h"
@@ -5,31 +22,6 @@
 #include "gdcmDicomDirPatient.h"
 #include "gdcmDirList.h"
 
-#include <fstream>
-#ifdef GDCM_NO_ANSI_STRING_STREAM
-#  include <strstream>
-#  define  ostringstream ostrstream
-# else
-#  include <sstream>
-#endif
-
-#define  ostringstream ostrstream
-
-#include <sys/types.h>
-#include <errno.h>
-
-// for Directory pb
-#ifdef _MSC_VER 
-   #include <windows.h> 
-   #include <direct.h>
-#else
-   #include <dirent.h>   
-   #include <unistd.h>
-#endif
-
-#include <vector>
-#include <algorithm>
-
 // ---
 void StartMethod(void *toto) {
   (void)toto;
@@ -52,7 +44,7 @@ void EndMethod(void *toto) {
   */  
 
 int main(int argc, char* argv[]) {
-   gdcmDicomDir *dcmdir;
+  gdcm::DicomDir *dcmdir;
    std::string dirName;   
 
    if (argc > 1)
@@ -60,33 +52,22 @@ int main(int argc, char* argv[]) {
    else
       dirName = GDCM_DATA_ROOT;
 
-   dcmdir=new gdcmDicomDir(dirName);
-      
+   dcmdir = new gdcm::DicomDir(dirName, true); // we ask for Directory parsing
+
    dcmdir->SetStartMethod(StartMethod, (void *) NULL);
    dcmdir->SetEndMethod(EndMethod);
-    std::cout << "---before ParseDirectory------------------" << std::endl;   
-   dcmdir->ParseDirectory();   
-   std::cout << "---after ParseDirectory------------------" << std::endl;
    
-   ListDicomDirPatient lp = dcmdir->GetDicomDirPatients();
+   gdcm::ListDicomDirPatient lp = dcmdir->GetDicomDirPatients();
    if (! lp.size() ) 
    {
       std::cout << "makeDicomDir: no patient list present. Exiting."
                 << std::endl;
       return 1;
    }
-   gdcmDicomDirPatient *p = *(lp.begin());
-   dcmdir->SetPrintLevel(2);
-   p->Print();
-   std::cout << "---------------------" << std::endl;   
-
-   dcmdir->SetPrintLevel(-1);
-   dcmdir->Print();
-
-   dcmdir->Write("NewDICOMDIR");
+    
+   dcmdir->WriteDicomDir("NewDICOMDIR");
    std::cout<<std::flush;
 
    delete dcmdir;
-
    return 0;
 }