]> Creatis software - gdcm.git/blobdiff - src/gdcmDicomDir.cxx
- void AddSeriesDetail(uint16_t group, uint16_t elem, bool convert);
[gdcm.git] / src / gdcmDicomDir.cxx
index 1a47080925328ad312a6fd473843c6a7315c4d0f..b93876b2f4c27800969e7f388a326836b744dc25 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/29 12:48:45 $
-  Version:   $Revision: 1.176 $
+  Date:      $Date: 2005/12/13 16:32:20 $
+  Version:   $Revision: 1.181 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -202,13 +202,13 @@ bool DicomDir::DoTheLoadingJob( )
          char buf[2048];
          const char *cwd = getcwd(buf, 2048);
          if( cwd )
-           {
+         {
            SetFileName( buf ); // will be converted into a string
-           }
+         }
          else
-           {
+         {
            gdcmErrorMacro( "Path was too long to fit on 2048 bytes" );
-           }
+         }
       }
       NewMeta();
       gdcmDebugMacro( "Parse directory and create the DicomDir : " 
@@ -353,7 +353,7 @@ bool DicomDir::Write(std::string const &fileName)
 {  
    int i;
    uint16_t sq[6] = { 0x0004, 0x1220, 0x5153, 0x0000, 0xffff, 0xffff };
-   uint16_t sqt[4]= { 0xfffe, 0xe0dd, 0xffff, 0xffff };
+   uint16_t sqt[4]= { 0xfffe, 0xe0dd, 0x0000, 0x0000 };
 
    std::ofstream *fp = new std::ofstream(fileName.c_str(),  
                                          std::ios::out | std::ios::binary);
@@ -387,7 +387,7 @@ bool DicomDir::Write(std::string const &fileName)
    // force writing Sequence Delimitation Item
    for(i=0;i<4;++i)
    {
-      binary_write(*fp, sqt[i]);  // fffe e0dd ffff ffff 
+      binary_write(*fp, sqt[i]);  // fffe e0dd 0000 0000 
    }
 
    fp->close();
@@ -438,7 +438,7 @@ bool DicomDir::Anonymize()
 /**
  * \brief Copies all the attributes from an other DocEntrySet 
  * @param set entry to copy from
- * @remarks The contained DocEntries a not copied, only referenced
+ * @remarks The contained DocEntries are not copied, only referenced
  */
 void DicomDir::Copy(DocEntrySet *set)
 {
@@ -477,12 +477,12 @@ void DicomDir::CreateDicomDirChainedList(std::string const &path)
    File *f;
 
    DirListType fileList = dirList.GetFilenames();
-
+   unsigned int nbFile = fileList.size();
    for( DirListType::iterator it  = fileList.begin();
                               it != fileList.end();
                               ++it )
    {
-      Progress = (float)(count+1)/(float)fileList.size();
+      Progress = (float)(count+1)/(float)nbFile;
       CallProgressMethod();
       if ( Abort )
       {
@@ -523,32 +523,6 @@ void DicomDir::CreateDicomDirChainedList(std::string const &path)
    }
 }
 
-/**
- * \brief   CallStartMethod
- */
-void DicomDir::CallStartMethod()
-{
-   Progress = 0.0f;
-   Abort    = false;
-   CommandManager::ExecuteCommand(this,CMD_STARTPROGRESS);
-}
-
-/**
- * \brief   CallProgressMethod
- */
-void DicomDir::CallProgressMethod()
-{
-   CommandManager::ExecuteCommand(this,CMD_PROGRESS);
-}
-
-/**
- * \brief   CallEndMethod
- */
-void DicomDir::CallEndMethod()
-{
-   Progress = 1.0f;
-   CommandManager::ExecuteCommand(this,CMD_ENDPROGRESS);
-}
 
 //-----------------------------------------------------------------------------
 // Private
@@ -967,7 +941,8 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type,
                }
                else
                {
-                  val = &(header->GetFileName().c_str()[path.length()+1]);
+                  //val = &(header->GetFileName().c_str()[path.length()+1]);
+                  val = &(header->GetFileName().c_str()[path.length()]);
                }
        break;
     
@@ -1029,15 +1004,16 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type,
  * @param dst destination SQItem
  * @param src source SQItem
  */
-void DicomDir::MoveSQItem(DocEntrySet *dst,DocEntrySet *src)
+void DicomDir::MoveSQItem(DocEntrySet *dst, DocEntrySet *src)
 { 
    DocEntry *entry;
-
+// todo : rewrite the whole stuff, without using RemoveEntry an AddEntry,
+//        to save time
    entry = src->GetFirstEntry();
    while(entry)
    {
+      dst->AddEntry(entry);  // use it, *before* removing it!
       src->RemoveEntry(entry);
-      dst->AddEntry(entry);
       // we destroyed -> the current iterator is not longer valid
       entry = src->GetFirstEntry();
    }