]> Creatis software - gdcm.git/blobdiff - src/gdcmDicomDir.cxx
*** empty log message ***
[gdcm.git] / src / gdcmDicomDir.cxx
index 2fef35c1eb68023591088dab324e7d07d5a1431c..ee3b95c18920c33bb0bf28ac6234044a2d54ea3c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/09 21:55:55 $
-  Version:   $Revision: 1.78 $
+  Date:      $Date: 2004/11/30 17:04:01 $
+  Version:   $Revision: 1.83 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include <algorithm>
 #include <sys/types.h>
 
+#ifdef _MSC_VER
+#define getcwd _getcwd
+#endif
+
 #if defined( _MSC_VER) || defined(__BORLANDC__)
    #include <direct.h>
 #else
    #include <unistd.h>
 #endif
+
 namespace gdcm 
 {
 
@@ -121,7 +126,8 @@ DicomDir::DicomDir(std::string const & fileName, bool parseDir ):
          /// \todo FIXME : what do we do when the parsed file IS NOT a
          ///       DICOMDIR file ?         
       }
-      CreateDicomDir();
+      else
+         CreateDicomDir();
    }
 }
 
@@ -133,6 +139,8 @@ DicomDir::~DicomDir()
    SetStartMethod(NULL);
    SetProgressMethod(NULL);
    SetEndMethod(NULL);
+
+   TagHT.clear();
    for(ListDicomDirPatient::iterator cc = Patients.begin();
                                      cc!= Patients.end();
                                    ++cc)
@@ -229,14 +237,15 @@ void DicomDir::ParseDirectory()
 
 /**
  * \ingroup DicomDir
- * \brief   Set the start method to call when the parsing of the directory starts
+ * \brief   Set the start method to call when the parsing of the
+ *          directory starts.
  * @param   method Method to call
  * @param   arg    Argument to pass to the method
  * @param   argDelete    Argument 
  * \warning In python : the arg parameter isn't considered
  */
-void DicomDir::SetStartMethod(Method* method, void* arg, 
-                              Method* argDelete )
+void DicomDir::SetStartMethod( DicomDir::Method* method, void* arg, 
+                               DicomDir::Method* argDelete )
 {
    if( StartArg && StartMethodArgDelete )
    {
@@ -255,21 +264,22 @@ void DicomDir::SetStartMethod(Method* method, void* arg,
  *          class is destroyed
  * @param   method Method to call to delete the argument
  */
-void DicomDir::SetStartMethodArgDelete(Method* method
+void DicomDir::SetStartMethodArgDelete( DicomDir::Method* method 
 {
    StartMethodArgDelete = method;
 }
 
 /**
  * \ingroup DicomDir
- * \brief   Set the progress method to call when the parsing of the directory progress
+ * \brief   Set the progress method to call when the parsing of the
+ *          directory progress
  * @param   method Method to call
  * @param   arg    Argument to pass to the method
  * @param   argDelete    Argument  
  * \warning In python : the arg parameter isn't considered
  */
-void DicomDir::SetProgressMethod(Method* method, void* arg, 
-                                 Method* argDelete )
+void DicomDir::SetProgressMethod( DicomDir::Method* method, void* arg, 
+                                  DicomDir::Method* argDelete )
 {
    if( ProgressArg && ProgressMethodArgDelete )
    {
@@ -288,7 +298,7 @@ void DicomDir::SetProgressMethod(Method* method, void* arg,
  *          class is destroyed          
  * @param   method Method to call to delete the argument
  */
-void DicomDir::SetProgressMethodArgDelete(Method* method)
+void DicomDir::SetProgressMethodArgDelete( DicomDir::Method* method )
 {
    ProgressMethodArgDelete = method;
 }
@@ -301,8 +311,8 @@ void DicomDir::SetProgressMethodArgDelete(Method* method)
  * @param   argDelete    Argument 
  * \warning In python : the arg parameter isn't considered
  */
-void DicomDir::SetEndMethod(Method* method, void* arg, 
-                            Method* argDelete )
+void DicomDir::SetEndMethod( DicomDir::Method* method, void* arg, 
+                             DicomDir::Method* argDelete )
 {
    if( EndArg && EndMethodArgDelete )
    {
@@ -317,18 +327,18 @@ void DicomDir::SetEndMethod(Method* method, void* arg,
 /**
  * \ingroup DicomDir
  * \brief   Set the method to delete the argument
- *          The argument is destroyed when the method is changed or when the class
- *          is destroyed
+ *          The argument is destroyed when the method is changed or when
+ *          the class is destroyed
  * @param   method Method to call to delete the argument
  */
-void DicomDir::SetEndMethodArgDelete(Method* method)
+void DicomDir::SetEndMethodArgDelete( DicomDir::Method* method )
 {
    EndMethodArgDelete = method;
 }
 
 /**
  * \ingroup DicomDir
- * \brief   writes on disc a DICOMDIR
+ * \brief    writes on disc a DICOMDIR
  * \ warning does NOT add the missing elements in the header :
  *           it's up to the user doing it !
  * \todo : to be re-written using the DICOMDIR tree-like structure
@@ -358,7 +368,7 @@ bool DicomDir::WriteDicomDir(std::string const& fileName)
    binary_write( *fp, "DICM");
  
    DicomDirMeta *ptrMeta = GetDicomDirMeta();
-   ptrMeta->Write(fp, ExplicitVR);
+   ptrMeta->WriteContent(fp, ExplicitVR);
    
    // force writing 0004|1220 [SQ ], that CANNOT exist within DicomDirMeta
    for(i=0;i<4;++i)
@@ -370,7 +380,7 @@ bool DicomDir::WriteDicomDir(std::string const& fileName)
                                      cc != Patients.end();
                                    ++cc )
    {
-      (*cc)->Write( fp, ExplicitVR );
+      (*cc)->WriteContent( fp, ExplicitVR );
    }
    
    // force writing Sequence Delimitation Item
@@ -399,9 +409,6 @@ void DicomDir::CreateDicomDirChainedList(std::string const & path)
    VectDocument list;
    Header *header;
 
-   TagHT.clear();
-   Patients.clear();
-
    for( DirList::iterator it  = fileList.begin();
                               it != fileList.end();
                               ++it )
@@ -530,7 +537,7 @@ DicomDirPatient * DicomDir::NewPatient()
    DicomDirPatient *p = new DicomDirPatient(s, &TagHT);
    Patients.push_front( p );
 
-   return p;   
+   return p;
 }
 
 /**
@@ -551,6 +558,7 @@ void DicomDir::SetElement(std::string const & path, DicomDirType type,
    ValEntry *entry;
    std::string val;
    SQItem *si = new SQItem(0); // all the items will be at level 1
+
    switch( type )
    {
       case GDCM_DICOMDIR_IMAGE:
@@ -775,7 +783,7 @@ void DicomDir::CreateDicomDir()
       return;
    }
 
-   DicomDirType type = DicomDir::GDCM_DICOMDIR_META;
+   DicomDirType type; // = DicomDir::GDCM_DICOMDIR_META;
    MetaElems = NewMeta();
 
    ListSQItem listItems = s->GetSQItems();
@@ -921,6 +929,9 @@ void DicomDir::AddDicomDirSerieToEnd(SQItem *s)
  */
 void DicomDir::SetElements(std::string const & path, VectDocument const &list)
 {
+   TagHT.clear();
+   Patients.clear();
+
    std::string patPrevName         = "", patPrevID  = "";
    std::string studPrevInstanceUID = "", studPrevID = "";
    std::string serPrevInstanceUID  = "", serPrevID  = "";