Program: gdcm
Module: $RCSfile: gdcmDicomDir.cxx,v $
Language: C++
- Date: $Date: 2004/09/24 11:39:21 $
- Version: $Revision: 1.69 $
+ Date: $Date: 2004/10/09 03:21:55 $
+ Version: $Revision: 1.71 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
- http://www.creatis.insa-lyon.fr/Public/Gdcm/License.htm for details.
+ http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
=========================================================================*/
-#include <string>
-#include <algorithm>
-#include <sys/types.h>
-
-#ifdef _MSC_VER
- #include <direct.h>
-#else
- #include <unistd.h>
-#endif
-
#include "gdcmDicomDir.h"
#include "gdcmDicomDirStudy.h"
#include "gdcmDicomDirSerie.h"
#include "gdcmSQItem.h"
#include "gdcmValEntry.h"
+#include <string>
+#include <algorithm>
+#include <sys/types.h>
+
+#ifdef _MSC_VER
+ #include <direct.h>
+#else
+ #include <unistd.h>
+#endif
+
//-----------------------------------------------------------------------------
// For full DICOMDIR description, see:
// PS 3.3-2003, pages 731-750
{
Initialize(); // sets all private fields to NULL
std::string pathBidon = "Bidon"; // Sorry, NULL not allowed ...
- metaElems = NewMeta();
+ MetaElems = NewMeta();
}
/**
{
// user passed '.' as Name
// we get current directory name
- char* dummy = new char[1000];
+ char dummy[1000];
getcwd(dummy, (size_t)1000);
SetFileName( dummy ); // will be converted into a string
- delete[] dummy; // no longer needed
}
if ( parseDir ) // user asked for a recursive parsing of a root directory
{
- metaElems = NewMeta();
+ MetaElems = NewMeta();
dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : Parse directory"
" and create the DicomDir");
SetStartMethod(NULL);
SetProgressMethod(NULL);
SetEndMethod(NULL);
- for(ListDicomDirPatient::iterator cc = patients.begin();
- cc!= patients.end();
+ for(ListDicomDirPatient::iterator cc = Patients.begin();
+ cc!= Patients.end();
++cc)
{
delete *cc;
}
- if ( metaElems )
+ if ( MetaElems )
{
- delete metaElems;
+ delete MetaElems;
}
}
*/
void gdcmDicomDir::Print(std::ostream &os)
{
- if(metaElems)
+ if( MetaElems )
{
- metaElems->SetPrintLevel(PrintLevel);
- metaElems->Print(os);
+ MetaElems->SetPrintLevel(PrintLevel);
+ MetaElems->Print(os);
}
- for(ListDicomDirPatient::iterator cc = patients.begin();
- cc != patients.end();
+ for(ListDicomDirPatient::iterator cc = Patients.begin();
+ cc != Patients.end();
++cc)
{
(*cc)->SetPrintLevel( PrintLevel );
{
return false;
}
- if( !metaElems )
+ if( !MetaElems )
{
return false;
}
- if( patients.size() <= 0 )
+ if( Patients.size() <= 0 )
{
return false;
}
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 = 0;
+ StartMethod = NULL;
+ ProgressMethod = NULL;
+ EndMethod = NULL;
+ StartMethodArgDelete = NULL;
+ ProgressMethodArgDelete = NULL;
+ EndMethodArgDelete = NULL;
+ StartArg = NULL;
+ ProgressArg = NULL;
+ EndArg = NULL;
+
+ Progress = 0.0;
+ Abort = false;
+
+ MetaElems = 0;
}
void gdcmDicomDir::SetStartMethod(gdcmMethod* method, void* arg,
gdcmMethod* argDelete )
{
- if( startArg && startMethodArgDelete )
+ if( StartArg && StartMethodArgDelete )
{
- startMethodArgDelete( startArg );
+ StartMethodArgDelete( StartArg );
}
- startMethod = method;
- startArg = arg;
- startMethodArgDelete = argDelete;
+ StartMethod = method;
+ StartArg = arg;
+ StartMethodArgDelete = argDelete;
}
/**
*/
void gdcmDicomDir::SetStartMethodArgDelete(gdcmMethod* method)
{
- startMethodArgDelete = method;
+ StartMethodArgDelete = method;
}
/**
void gdcmDicomDir::SetProgressMethod(gdcmMethod* method, void* arg,
gdcmMethod* argDelete )
{
- if( progressArg && progressMethodArgDelete )
+ if( ProgressArg && ProgressMethodArgDelete )
{
- progressMethodArgDelete( progressArg );
+ ProgressMethodArgDelete( ProgressArg );
}
- progressMethod = method;
- progressArg = arg;
- progressMethodArgDelete = argDelete;
+ ProgressMethod = method;
+ ProgressArg = arg;
+ ProgressMethodArgDelete = argDelete;
}
/**
*/
void gdcmDicomDir::SetProgressMethodArgDelete(gdcmMethod* method)
{
- progressMethodArgDelete = method;
+ ProgressMethodArgDelete = method;
}
/**
void gdcmDicomDir::SetEndMethod(gdcmMethod* method, void* arg,
gdcmMethod* argDelete )
{
- if( endArg && endMethodArgDelete )
+ if( EndArg && EndMethodArgDelete )
{
- endMethodArgDelete( endArg );
+ EndMethodArgDelete( EndArg );
}
- endMethod = method;
- endArg = arg;
- endMethodArgDelete = argDelete;
+ EndMethod = method;
+ EndArg = arg;
+ EndMethodArgDelete = argDelete;
}
/**
*/
void gdcmDicomDir::SetEndMethodArgDelete(gdcmMethod* method)
{
- endMethodArgDelete = method;
+ EndMethodArgDelete = method;
}
/**
return false;
}
- uint8_t* filePreamble = new uint8_t[128];
+ uint8_t filePreamble[128];
memset(filePreamble, 0, 128);
fwrite(filePreamble,128,1,fp);
fwrite("DICM",4,1,fp);
- delete[] filePreamble;
gdcmDicomDirMeta *ptrMeta = GetDicomDirMeta();
ptrMeta->Write(fp, gdcmExplicitVR);
// force writing 0004|1220 [SQ ], that CANNOT exist within gdcmDicomDirMeta
fwrite(&sq[0],8,1,fp); // 0004 1220 ffff ffff
- for(ListDicomDirPatient::iterator cc = patients.begin();cc!=patients.end();++cc)
+ for(ListDicomDirPatient::iterator cc = Patients.begin();
+ cc != Patients.end();
+ ++cc )
{
(*cc)->Write( fp, gdcmExplicitVR );
}
gdcmHeader *header;
TagHT.clear();
- patients.clear();
+ Patients.clear();
for( gdcmDirList::iterator it = fileList.begin();
it != fileList.end();
++it )
{
- progress = (float)(count+1)/(float)fileList.size();
+ Progress = (float)(count+1)/(float)fileList.size();
CallProgressMethod();
- if( abort )
+ if( Abort )
{
break;
}
// for all the DicomDirPatient Elements
for( it = elemList.begin(); it != elemList.end(); ++it )
{
- tmpGr = it->group;
- tmpEl = it->elem;
+ tmpGr = it->Group;
+ tmpEl = it->Elem;
dictEntry = GetPubDict()->GetDictEntryByNumber(tmpGr, tmpEl);
entry = new gdcmValEntry( dictEntry );
entry->SetOffset(0); // just to avoid further missprinting
- entry->SetValue( it->value );
+ entry->SetValue( it->Value );
// dealing with value length ...
}
gdcmDicomDirPatient *p = new gdcmDicomDirPatient(s, &TagHT);
- patients.push_front( p );
+ Patients.push_front( p );
return p;
}
for( it = elemList.begin(); it != elemList.end(); ++it)
{
- tmpGr = it->group;
- tmpEl = it->elem;
+ tmpGr = it->Group;
+ tmpEl = it->Elem;
dictEntry = GetPubDict()->GetDictEntryByNumber(tmpGr, tmpEl);
entry = new gdcmValEntry( dictEntry ); // Be sure it's never a BinEntry !
entry->SetOffset(0); // just to avoid further missprinting
entry->SetLength(0); // just to avoid further missprinting
- if( header ) // NULL when we Build Up (ex nihilo) a DICOMDIR
- // or when we add the META elems
+ if( header )
+ {
+ // NULL when we Build Up (ex nihilo) a DICOMDIR
+ // or when we add the META elems
val = header->GetEntryByNumber(tmpGr, tmpEl);
+ }
else
+ {
val = GDCM_UNFOUND;
+ }
if( val == GDCM_UNFOUND)
{
val = header->GetFileName();
}
else
+ {
val = &(header->GetFileName().c_str()[path.length()]);
+ }
}
else
- val = it->value;
+ {
+ val = it->Value;
+ }
}
else
{
if ( header->GetEntryLengthByNumber(tmpGr,tmpEl) == 0 )
- val = it->value;
+ val = it->Value;
}
// GDCM_UNFOUND or not !
*/
void gdcmDicomDir::CallStartMethod()
{
- progress = 0.0f;
- abort = false;
- if( startMethod )
+ Progress = 0.0f;
+ Abort = false;
+ if( StartMethod )
{
- startMethod( startArg );
+ StartMethod( StartArg );
}
}
*/
void gdcmDicomDir::CallProgressMethod()
{
- if( progressMethod )
+ if( ProgressMethod )
{
- progressMethod( progressArg );
+ ProgressMethod( ProgressArg );
}
}
*/
void gdcmDicomDir::CallEndMethod()
{
- progress = 1.0f;
- if( endMethod )
+ Progress = 1.0f;
+ if( EndMethod )
{
- endMethod( endArg );
+ EndMethod( EndArg );
}
}
}
gdcmDicomDirType type = gdcmDicomDir::GDCM_DICOMDIR_META;
- metaElems = NewMeta();
+ MetaElems = NewMeta();
ListSQItem listItems = s->GetSQItems();
*/
void gdcmDicomDir::AddDicomDirMeta()
{
- if( metaElems )
+ if( MetaElems )
{
- delete metaElems;
+ delete MetaElems;
}
- metaElems = new gdcmDicomDirMeta( &TagHT );
+ MetaElems = new gdcmDicomDirMeta( &TagHT );
}
/**
*/
void gdcmDicomDir::AddDicomDirPatientToEnd(gdcmSQItem *s)
{
- patients.push_back(new gdcmDicomDirPatient(s, &TagHT));
+ Patients.push_back(new gdcmDicomDirPatient(s, &TagHT));
}
/**
*/
void gdcmDicomDir::AddDicomDirStudyToEnd(gdcmSQItem *s)
{
- if( patients.size() > 0 )
+ if( Patients.size() > 0 )
{
- ListDicomDirPatient::iterator itp = patients.end();
+ ListDicomDirPatient::iterator itp = Patients.end();
itp--;
(*itp)->AddDicomDirStudy(new gdcmDicomDirStudy(s, &TagHT));
}
*/
void gdcmDicomDir::AddDicomDirSerieToEnd(gdcmSQItem *s)
{
- if( patients.size() > 0 )
+ if( Patients.size() > 0 )
{
- ListDicomDirPatient::iterator itp = patients.end();
+ ListDicomDirPatient::iterator itp = Patients.end();
itp--;
if( (*itp)->GetDicomDirStudies().size() > 0 )
*/
void gdcmDicomDir::AddDicomDirImageToEnd(gdcmSQItem *s)
{
- if( patients.size() > 0 )
+ if( Patients.size() > 0 )
{
- ListDicomDirPatient::iterator itp = patients.end();
+ ListDicomDirPatient::iterator itp = Patients.end();
itp--;
if( (*itp)->GetDicomDirStudies().size() > 0 )