Program: gdcm
Module: $RCSfile: gdcmDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/03/09 19:29:38 $
- Version: $Revision: 1.136 $
+ Date: $Date: 2005/06/17 12:36:07 $
+ Version: $Revision: 1.141 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// Directory Record Type Directory Record Types which may be included
// in the next lower-level directory Entity
//
-// (Root directory Entity) PATIENT
+// (Root directory Entity) PATIENT, TOPIC, PRIVATE
//
-// PATIENT STUDY
+// PATIENT STUDY, PRIVATE
//
-// STUDY SERIES, VISIT, RESULTS, STUDY COMPONENT
+// STUDY SERIES, VISIT, RESULTS, STUDY COMPONENT, PRIVATE
//
// SERIES IMAGE, OVERLAYS, MODALITY LUT, VOI LUT,
// CURVE, STORED PRINT, RT DOSE, RT STRUCTURE SET
// RT PLAN, RT TREAT RECORD, PRESENTATION, WAVEFORM,
// SR DOCUMENT, KEY OBJECT DOC, SPECTROSCOPY,
-// RAW DATA, REGISTRATION, FIDUCIAL
+// RAW DATA, REGISTRATION, FIDUCIAL, PRIVATE,
+// ENCAP DOC
// IMAGE
// OVERLAY
// MODALITY LUT
// RAW DATA
// REGISTRATION
// FIDUCIAL
+// PRIVATE
+// ENCAP DOC
//
// ----------------------
// The current gdcm version only deals with :
* and wants to use it
*/
DicomDir::DicomDir(std::string const &fileName, bool parseDir ):
- Document( fileName )
+ Document( )
{
// At this step, Document constructor is already executed,
- // whatever user passed (a root directory or a DICOMDIR)
+ // 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)
- Initialize(); // sets all private fields to NULL
+ ParseDir = parseDir;
+ SetLoadMode (0x00000000); // concerns only dicom files
+ Load( fileName );
+}
- // if user passed a root directory, sure we didn't get anything
+/**
+ * \brief Canonical destructor
+ */
+DicomDir::~DicomDir()
+{
+ SetStartMethod(NULL);
+ SetProgressMethod(NULL);
+ SetEndMethod(NULL);
- if ( GetFirstEntry() == 0 ) // when user passed a Directory to parse
+ ClearPatient();
+ if ( MetaElems )
{
- if (!parseDir)
- gdcmWarningMacro( "Entry HT empty for file: "<<fileName);
+ delete MetaElems;
+ }
+}
- // Only if user passed a root directory
- // ------------------------------------
- if ( fileName == "." )
- {
- // user passed '.' as Name
- // we get current directory name
- char dummy[1000];
- getcwd(dummy, (size_t)1000);
- SetFileName( dummy ); // will be converted into a string
- }
+//-----------------------------------------------------------------------------
+// Public
- if ( parseDir ) // user asked for a recursive parsing of a root directory
- {
- NewMeta();
+bool DicomDir::Load(std::string const &fileName )
+{
+ Filename = fileName;
+ // We should clean out anything that already exists.
- gdcmWarningMacro( "Parse directory and create the DicomDir");
- ParseDirectory();
+ Initialize(); // sets all private fields to NULL
+
+ if (!ParseDir)
+ {
+ // Only if user passed a DICOMDIR
+ // ------------------------------
+ Fp = 0;
+ if ( !OpenFile() )
+ {
+ return false;
}
- /*
- else
+ Document::Load(fileName);
+ if ( GetFirstEntry() == 0 ) // when user passed a Directory to parse
{
- // user may just call ParseDirectory() *after* constructor
+ gdcmWarningMacro( "Entry HT empty for file: "<< fileName);
+ return false;
}
- */
- }
- // Only if user passed a DICOMDIR
- // ------------------------------
- else
- {
// Directory record sequence
DocEntry *e = GetDocEntry(0x0004, 0x1220);
if ( !e )
{
gdcmWarningMacro( "NO 'Directory record sequence' (0x0004,0x1220)"
<< " in file " << fileName);
+ return false;
}
else
CreateDicomDir();
}
-}
-
-/**
- * \brief Canonical destructor
- */
-DicomDir::~DicomDir()
-{
- SetStartMethod(NULL);
- SetProgressMethod(NULL);
- SetEndMethod(NULL);
-
- ClearPatient();
- if ( MetaElems )
+ else
{
- delete MetaElems;
+ // Only if user passed a root directory
+ // ------------------------------------
+ if ( fileName == "." )
+ {
+ // user passed '.' as Name
+ // we get current directory name
+ char dummy[1000];
+ getcwd(dummy, (size_t)1000);
+ SetFileName( dummy ); // will be converted into a string
+ }
+ NewMeta();
+ gdcmWarningMacro( "Parse directory and create the DicomDir : " << Filename );
+
+ ParseDirectory();
}
+ return true;
}
-//-----------------------------------------------------------------------------
-// Public
/**
* \brief This predicate, based on hopefully reasonable heuristics,
* decides whether or not the current document was properly parsed
DocEntry *entry = GetFirstEntry();
if( entry )
{
- MetaElems = new DicomDirMeta(true);
+ MetaElems = new DicomDirMeta(true); // true = empty
entry = GetFirstEntry();
while( entry )
}
else // after root directory parsing
{
- MetaElems = new DicomDirMeta(false);
+ MetaElems = new DicomDirMeta(false); // false = not empty
}
MetaElems->SetSQItemNumber(0); // To avoid further missprinting
return MetaElems;
StartMethodArgDelete = argDelete;
}
+
/**
* \brief Set the progress method to call when the parsing of the
* directory progress
}
return true;
}
+
//-----------------------------------------------------------------------------
// Protected
/**
DirList dirList(path,1); // gets recursively the file list
unsigned int count = 0;
VectDocument list;
- File *header;
+ File *f;
DirListType fileList = dirList.GetFilenames();
break;
}
- header = new File( it->c_str() );
- if( !header )
- {
- gdcmWarningMacro( "Failure in new gdcm::File " << it->c_str() );
- continue;
- }
+ f = new File( );
+ f->SetLoadMode(LoadMode); // we allow user not to load Sequences...
+ f->Load( it->c_str() );
+
+// if( !f )
+// {
+// gdcmWarningMacro( "Failure in new gdcm::File " << it->c_str() );
+// continue;
+// }
- if( header->IsReadable() )
+ if( f->IsReadable() )
{
// Add the file to the chained list:
- list.push_back(header);
+ list.push_back(f);
gdcmWarningMacro( "Readable " << it->c_str() );
}
else
{
- delete header;
+ delete f;
}
count++;
}
}
/**
- * \brief create a 'DicomDir' from a DICOMDIR Header
+ * \brief create a 'gdcm::DicomDir' from a DICOMDIR Header
*/
void DicomDir::CreateDicomDir()
{