Program: gdcm
Module: $RCSfile: gdcmDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/01/12 17:57:58 $
- Version: $Revision: 1.98 $
+ Date: $Date: 2005/01/17 10:59:52 $
+ Version: $Revision: 1.103 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
DicomDir::DicomDir(std::string const &fileName, bool parseDir ):
Document( fileName )
{
- // Whatever user passed (a root directory or a DICOMDIR)
- // and whatever the value of parseDir was,
- // Document is already executed
+ // At this step, Document constructor is already executed,
+ // whatever user passed (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
// if user passed a root directory, sure we didn't get anything
if ( TagHT.begin() == TagHT.end() ) // when user passed a Directory to parse
{
- gdcmVerboseMacro( "Entry HT empty");
+ if (!parseDir)
+ gdcmVerboseMacro( "Entry HT empty for file: "<<fileName);
+ // Only if user passed a root directory
+ // ------------------------------------
if ( fileName == "." )
{
// user passed '.' as Name
else
{
/// \todo if parseDir == false, it should be tagged as an error
- // NON ! il suffit d'appeler ParseDirectory()
- // apres le constructeur
+ // NO ! user may just call ParseDirectory() *after* constructor
}
}
- else // Only if user passed a DICOMDIR
+ // Only if user passed a DICOMDIR
+ // ------------------------------
+ else
{
// Directory record sequence
DocEntry *e = GetDocEntry(0x0004, 0x1220);
if ( !e )
{
- gdcmVerboseMacro( "NO Directory record sequence (0x0004,0x1220)");
+ gdcmVerboseMacro( "NO 'Directory record sequence' (0x0004,0x1220)"
+ << " in file " << fileName);
/// \todo FIXME : what do we do when the parsed file IS NOT a
/// DICOMDIR file ?
}
/**
* \brief Canonical Printer
*/
-void DicomDir::Print(std::ostream &os)
+void DicomDir::Print(std::ostream &os, std::string const & )
{
if( MetaElems )
{
*/
bool DicomDir::IsReadable()
{
- if( !Document::IsReadable() )
+ if( Filetype == Unknown)
{
+ gdcmVerboseMacro( "Wrong filetype");
return false;
}
if( !MetaElems )
{
+ gdcmVerboseMacro( "Meta Elements missing in DicomDir");
return false;
}
if( Patients.size() <= 0 )
{
+ gdcmVerboseMacro( "NO Patient in DicomDir");
return false;
}
void DicomDir::CreateDicomDirChainedList(std::string const & path)
{
CallStartMethod();
- DirList fileList(path,1); // gets recursively the file list
+ DirList dirList(path,1); // gets recursively the file list
unsigned int count = 0;
VectDocument list;
Header *header;
- for( DirList::iterator it = fileList.begin();
+ DirListType fileList = dirList.GetFilenames();
+
+ for( DirListType::iterator it = fileList.begin();
it != fileList.end();
++it )
{
// sorts Patient/Study/Serie/
std::sort(list.begin(), list.end(), DicomDir::HeaderLessThan );
- std::string tmp = fileList.GetDirName();
+ std::string tmp = dirList.GetDirName();
//for each Header of the chained list, add/update the Patient/Study/Serie/Image info
SetElements(tmp, list);
CallEndMethod();
{
return *header1 < *header2;
}
+
+/**
+ * \brief Initialise the visit of the DicomDirPatients of the DicomDir
+ */
+void DicomDir::InitTraversal()
+{
+ ItDicomDirPatient = Patients.begin();
+}
+
+/**
+ * \brief Get the next entry while visiting the DicomDirPatients
+ * \return The next DicomDirPatient if found, otherwhise NULL
+ */
+DicomDirPatient *DicomDir::GetNextEntry()
+{
+ if (ItDicomDirPatient != Patients.end())
+ {
+ DicomDirPatient *tmp = *ItDicomDirPatient;
+ ++ItDicomDirPatient;
+ return tmp;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+
} // end namespace gdcm
//-----------------------------------------------------------------------------