#include <sys/types.h>
#include <errno.h>
-#include <unistd.h>
+
+#ifdef _MSC_VER
+ #include <direct.h>
+#else
+ #include <unistd.h>
+#endif
//-----------------------------------------------------------------------------
// For full DICOMDIR description, see:
{
// que l'on ai passe un root directory ou un DICOMDIR
// et quelle que soit la valeur de parseDir,
- // on a lance gdcmParser
-
- cout << "---------------------------------------------- " << Name <<endl;
-
-
+ // on a lance gdcmParser
startMethod= NULL;
progressMethod= NULL;
metaElems=NULL;
// gdcmParser already executed
-// Si on a passe un root directory, on est assuré de n'avoir rien ramené
+// if user passed a root directory, sure we didn't get anything
if( GetListEntry().begin()==GetListEntry().end() )
{
- // Si, en plus, parseDir == false, ca devrait etre une erreur
+ // if parseDir == false, it should be tagged as an error
dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : entry list empty");
if(strlen(Name)==1 && Name[0]=='.') { // user passed '.' as Name
// we get current directory name
- char*dummy=(char*) malloc(1000); // TODO : check with Windoze
+ char*dummy=(char*) malloc(1000); // TODO : check with Windoze // JPR
+#ifdef _MSC_VER
+ _getcwd(dummy,(size_t)1000);
+#else
getcwd(dummy,(size_t)1000);
+#endif
SetFileName(dummy); // will be converted into a string
free(dummy); // no longer needed
}
ParseDirectory();
}
}
- else
+ else {
CreateDicomDir();
+ CheckBoundaries(); // to maintain consistency between
+ // home-made gdcmDicomDir
+ // and the ones comming from a DICOMDIR file
+ }
}
/*
fwrite(filePreamble,128,1,fp1);
fwrite("DICM",4,1,fp1);
free(filePreamble);
- //UpdateDirectoryRecordSequenceLength(); // a reecrire en utilisant
+ //UpdateDirectoryRecordSequenceLength(); // a reecrire en utilisant JPR
// la structure arborescente JPR
WriteDicomDirEntries(fp1);
std::sort(list.begin(),list.end(),gdcmDicomDir::HeaderLessThan);
std::string tmp=fileList.GetDirName();
+
//for each Header of the chained list, add/update the Patient/Study/Serie/Image info
SetElements(tmp,list);
-
+
CallEndMethod();
}
+
+
+void gdcmDicomDir::CheckBoundaries()
+{
+ ListDicomDirPatient::iterator itPatient;
+ ListDicomDirStudy::iterator itStudy;
+ ListDicomDirSerie::iterator itSerie;
+ ListDicomDirImage::iterator itImage;
+ ListTag::iterator i,j;
+
+ GetDicomDirMeta()->ResetBoundaries(0);
+
+ itPatient = GetDicomDirPatients().begin();
+ while ( itPatient != GetDicomDirPatients().end() ) {
+ (*itPatient)->ResetBoundaries(1);
+ itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
+ while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) {
+ (*itStudy)->ResetBoundaries(1);
+ itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
+ while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) {
+ (*itSerie)->ResetBoundaries(1);
+ itImage = ((*itSerie)->GetDicomDirImages()).begin();
+ while (itImage != (*itSerie)->GetDicomDirImages().end() ) {
+ (*itImage)->ResetBoundaries(1);
+ ++itImage;
+ }
+ ++itSerie;
+ }
+ ++itStudy;
+ }
+ ++itPatient;
+ }
+}
+
+
/*
* \ingroup gdcmDicomDir
* \brief adds a new Patient to a partially created DICOMDIR