]> Creatis software - gdcm.git/blobdiff - src/gdcmFileHelper.cxx
Message
[gdcm.git] / src / gdcmFileHelper.cxx
index 0d5cd3312282e3eac92df06859f1b282e92515a6..e2326b53faf0abf8d6af3649d64fcfa207fd5c36 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/26 08:28:58 $
+  Version:   $Revision: 1.76 $
                                                                                 
   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();
 }
 
@@ -151,44 +150,16 @@ FileHelper::FileHelper( )
  */
 FileHelper::FileHelper(File *header)
 {
-   FileInternal = header;
-   SelfHeader = false;
-   Initialize();
-   if ( FileInternal->IsReadable() )
-   {
-      PixelReadConverter->GrabInformationsFromFile( FileInternal );
-   }
-}
+   gdcmAssertMacro(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;
+   FileInternal = header;
+   FileInternal->Register();
    Initialize();
    if ( FileInternal->IsReadable() )
    {
       PixelReadConverter->GrabInformationsFromFile( FileInternal );
    }
 }
-#endif
 
 /**
  * \brief canonical destructor
@@ -210,11 +181,7 @@ FileHelper::~FileHelper()
       delete Archive;
    }
 
-   if ( SelfHeader )
-   {
-      delete FileInternal;
-   }
-   FileInternal = 0;
+   FileInternal->Unregister();
 }
 
 //-----------------------------------------------------------------------------
@@ -1260,7 +1227,7 @@ To be moved to User's guide / WIKI  ?
     are force to current Date and Time
     
 -->  Conversion Type (0x0008,0x0064)
-     is forced to 'SYN'
+     is forced to 'SYN' (Synthetic Image)
      
 --> Study ID, Series Number, Instance Number, Patient Orientation (Type 2)
     are created, with empty value if there are missing.
@@ -1392,13 +1359,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 +1374,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();
@@ -1448,8 +1419,22 @@ void FileHelper::CheckMandatoryElements()
    // Accession Number
    CopyMandatoryEntry(0x0008,0x0050,"");
    
-   // Conversion Type ... FIXME (type 1)
+   // Conversion Type.
+   // Other possible values are :
    // See PS 3.3, Page 408
+   
+   // DV = Digitized Video
+   // DI = Digital Interface   
+   // DF = Digitized Film
+   // WSD = Workstation
+   // SD = Scanned Document
+   // SI = Scanned Image
+   // DRW = Drawing
+   // SYN = Synthetic Image
+
+   // FIXME : Must we Force Value, or Default value ?
+   // Is it Type 1 for any Modality ?
+   //    --> Answer seems to be NO :-(
    CopyMandatoryEntry(0x0008,0x0064,"SYN");
 
 // ----- Add Mandatory Entries if missing ---