Program: gdcm
Module: $RCSfile: gdcmDicomDir.cxx,v $
Language: C++
- Date: $Date: 2004/07/19 03:34:11 $
- Version: $Revision: 1.57 $
+ Date: $Date: 2004/07/21 14:02:10 $
+ Version: $Revision: 1.58 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
// Constructor / Destructor
-void gdcmDicomDir::Initialize()
-{
- startMethod = NULL;
- progressMethod = NULL;
- endMethod = NULL;
- startMethodArgDelete = NULL;
- progressMethodArgDelete = NULL;
- endMethodArgDelete = NULL;
- startArg = NULL;
- progressArg = NULL;
- endArg = NULL;
-
- progress = 0.0;
- abort = false;
+/**
+ * \ingroup gdcmDicomDir
+ * \brief Constructor : creates an empty gdcmDicomDir
+ * @param exception_on_error whether we want to throw an exception or not
+ */
+gdcmDicomDir::gdcmDicomDir(bool exception_on_error):
+ gdcmDocument( exception_on_error )
+{
+ Initialize();
- metaElems = (gdcmDicomDirMeta *)0;
+ std::string pathBidon = "Bidon"; // Sorry, NULL not allowed ...
+ SetElement(pathBidon, GDCM_DICOMDIR_META, NULL); // Set the META elements
+ AddDicomDirMeta();
}
-
/**
* \brief Constructor Parses recursively the directory and creates the DicomDir
* or uses an already built DICOMDIR, depending on 'parseDir' value.
// gdcmDocument already executed
// if user passed a root directory, sure we didn't get anything
- if( TagHT.begin() == TagHT.end() )
+ if ( TagHT.begin() == TagHT.end() )
{
dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : entry HT empty");
- if( fileName.size() == 1 && fileName[0] == '.' )
+ if ( fileName.size() == 1 && fileName[0] == '.' )
{
// user passed '.' as Name
// we get current directory name
char* dummy = new char[1000];
getcwd(dummy, (size_t)1000);
+ std::cout << "Directory to parse : [" << dummy << "]" << std::endl;
SetFileName( dummy ); // will be converted into a string
- delete[] dummy; // no longer needed
+ delete[] dummy; // no longer needed
}
- if( parseDir )
+ if ( parseDir )
{
dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : Parse directory"
" and create the DicomDir");
else
{
/// \todo if parseDir == false, it should be tagged as an error
+ // NON ! il suffit d'appeler ParseDirectory()
+ // apres le constructeur
}
}
else
}
}
-/**
- * \ingroup gdcmDicomDir
- * \brief Constructor : creates an empty gdcmDicomDir
- * @param exception_on_error whether we want to throw an exception or not
- */
-gdcmDicomDir::gdcmDicomDir(bool exception_on_error):
- gdcmDocument( exception_on_error )
-{
- Initialize();
-
- std::string pathBidon = "Bidon"; // Sorry, NULL not allowed ...
- SetElement(pathBidon, GDCM_DICOMDIR_META, NULL); // Set the META elements
- AddDicomDirMeta();
-}
-
/**
* \brief Canonical destructor
*/
SetProgressMethod(NULL);
SetEndMethod(NULL);
- if( metaElems )
+ if ( metaElems )
{
delete metaElems;
}
return true;
}
+/**
+ * \brief Sets all fields to NULL
+ */
+
+void gdcmDicomDir::Initialize()
+{
+ startMethod = NULL;
+ progressMethod = NULL;
+ endMethod = NULL;
+ startMethodArgDelete = NULL;
+ progressMethodArgDelete = NULL;
+ endMethodArgDelete = NULL;
+ startArg = NULL;
+ progressArg = NULL;
+ endArg = NULL;
+
+ progress = 0.0;
+ abort = false;
+
+ metaElems = (gdcmDicomDirMeta *)0;
+}
+
+
/**
* \ingroup gdcmDicomDir
* \brief fills the whole structure, starting from a root Directory
header = new gdcmHeader(it->c_str(),false,true);
if(!header) {
- std::cout << "echec new Header " << it->c_str() << std::endl; // JPR
+ std::cout << "failure in new Header " << it->c_str() << std::endl; // JPR
}
if(header->IsReadable()) {
list.push_back(header); // adds the file header to the chained list
uint16_t tmpGr,tmpEl;
gdcmDictEntry *dictEntry;
gdcmValEntry *entry;
-
+
+ std::list<gdcmElement> elemList;
+ elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
+// Looks nice, but gdcmDicomDir IS NOT a gdcmObject ...
+// gdcmDicomDirPatient *p = new gdcmDicomDirPatient(ptagHT);
+// FillObject(elemList);
+// patients.push_front( p );
+// return p;
+/// \todo TODO : find a trick to use FillObject !!!
+
gdcmSQItem *s = new gdcmSQItem(0);
-
- std::list<gdcmElement> elemList =
- gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
-
- /// \todo TODO : use FillObject !!!
- // for all the DicomDirPatient Elements
-
+ // for all the DicomDirPatient Elements
for( it = elemList.begin(); it != elemList.end(); ++it )
{
tmpGr = it->group;
gdcmDictEntry *dictEntry;
gdcmValEntry *entry;
std::string val;
-
+ gdcmObject *o;
switch( type )
{
- case GDCM_DICOMDIR_PATIENT:
- elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
- break;
- case GDCM_DICOMDIR_STUDY:
- elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements();
+ case GDCM_DICOMDIR_IMAGE:
+ elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements();
break;
+
case GDCM_DICOMDIR_SERIE:
elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements();
break;
- case GDCM_DICOMDIR_IMAGE:
- elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements();
+
+ case GDCM_DICOMDIR_STUDY:
+ elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements();
break;
+
+ case GDCM_DICOMDIR_PATIENT:
+ elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
+ break;
+
case GDCM_DICOMDIR_META:
elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements();
break;
+
default:
return;
}
entry->SetOffset(0); // just to avoid further missprinting
- if( header )
+ if( header ) // NULL when we Build Up (ex nihilo) a DICOMDIR
+ // or when we add the META elems
{
val = header->GetEntryByNumber(tmpGr, tmpEl);
}
{
if( dictEntry->GetGroup() == 0xfffe )
{
- entry->SetLength( entry->GetValue().length() );
+ entry->SetLength( entry->GetValue().length() ); // FIXME
}
else if( dictEntry->GetVR() == "UL" || dictEntry->GetVR() == "SL" )
{
entry->SetLength( entry->GetValue().length() );
}
}
- //AddDocEntry(entry); // both in H Table and in chained list
- TagHT[entry->GetKey()] = entry; // FIXME : use a SEQUENCE !
+ std::cout << " was TagHT[entry->GetKey()] = entry " << std::endl;
+ if ( type == GDCM_DICOMDIR_META ) {
+ std::cout << " special Treatment for GDCM_DICOMDIR_META" << std::endl;
+
+ }
+ //TagHT[entry->GetKey()] = entry; // FIXME : use a SEQUENCE !
}
}
// + we create the object for the precedent tag
// + loop to 1 -
- gdcmDicomDirType type = gdcmDicomDir::GDCM_DICOMDIR_META;
-
// Directory record sequence
gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220);
if ( !e )
if ( !s )
{
dbg.Verbose(0, "gdcmDicomDir::CreateDicomDir: no SeqEntry present");
+ // useless : (0x0004,0x1220) IS a Sequence !
return;
}
+ gdcmDicomDirType type = gdcmDicomDir::GDCM_DICOMDIR_META;
+ metaElems = NewMeta();
+
ListSQItem listItems = s->GetSQItems();
- gdcmDicomDirMeta *m = new gdcmDicomDirMeta(&TagHT);
- (void)m; //??
gdcmDocEntry * d;
std::string v;