From: jpr Date: Tue, 8 Jun 2004 09:15:17 +0000 (+0000) Subject: moved from gdcmParser to gdcmDocument. X-Git-Tag: Version0.5.bp~149 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=30d2b02b938fe912d866b40ca2b9842961481ab2;p=gdcm.git moved from gdcmParser to gdcmDocument. Please wait a little more before using --- diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 20d81973..f4dc21dc 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -20,6 +20,10 @@ #include "gdcmDebug.h" #include "gdcmGlobal.h" +#include "gdcmSeqEntry.h" +#include "gdcmSQItem.h" +#include "gdcmValEntry.h" + //----------------------------------------------------------------------------- // For full DICOMDIR description, see: // PS 3.3-2003, pages 731-750 @@ -43,11 +47,11 @@ */ gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir, bool exception_on_error): - gdcmParser(FileName,exception_on_error,true) // true : enable SeQuences + gdcmDocument(FileName,exception_on_error,true) // true : enable SeQuences { // que l'on ai passe un root directory ou un DICOMDIR // et quelle que soit la valeur de parseDir, - // on a lance gdcmParser + // on a lance gdcmDocument startMethod= NULL; progressMethod= NULL; @@ -62,22 +66,22 @@ gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir, progress=0.0; abort=false; - metaElems=NULL; + metaElems=NULL; -// gdcmParser already executed +// gdcmDocument already executed // if user passed a root directory, sure we didn't get anything - if( GetListEntry().begin()==GetListEntry().end() ) + if( GetEntry().begin()==GetEntry().end() ) { // if parseDir == false, it should be tagged as an error - dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : entry list empty"); + dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : entry HT empty"); if(strlen(FileName)==1 && FileName[0]=='.') { // user passed '.' as Name // we get current directory name char* dummy= new char[1000]; getcwd(dummy, (size_t)1000); SetFileName(dummy); // will be converted into a string - delete[] dummy; // no longer needed + delete[] dummy; // no longer needed } if(parseDir) @@ -88,10 +92,13 @@ gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir, } } else { + gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); // Directory record sequence + if (e==NULL) { + dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record sequence (0x0004,0x1220)" + ); + // FIXME : what to do when the parsed file IS NOT a DICOMDIR file ? + } CreateDicomDir(); - CheckBoundaries(); // to maintain consistency between - // home-made gdcmDicomDir - // and the ones comming from a DICOMDIR file } } @@ -101,7 +108,7 @@ gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir, * @param exception_on_error whether we want to throw an exception or not */ gdcmDicomDir::gdcmDicomDir(bool exception_on_error): - gdcmParser(exception_on_error) + gdcmDocument(exception_on_error) { startMethod= NULL; progressMethod= NULL; @@ -118,7 +125,7 @@ gdcmDicomDir::gdcmDicomDir(bool exception_on_error): std::string pathBidon = ""; // Sorry, NULL not allowed ... SetElement(pathBidon, GDCM_DICOMDIR_META, NULL); // Set the META elements - AddDicomDirMetaToEnd(listEntries.begin(),--listEntries.end()); + AddDicomDirMeta(); } @@ -169,12 +176,12 @@ void gdcmDicomDir::Print(std::ostream &os) * decides whether or not the current header was properly parsed * and contains the mandatory information for being considered as * a well formed and usable DicomDir. - * @return true when gdcmParser is the one of a reasonable DicomDir, + * @return true when gdcmDocument is the one of a reasonable DicomDir, * false otherwise. */ bool gdcmDicomDir::IsReadable(void) { - if(!gdcmParser::IsReadable()) + if(!gdcmDocument::IsReadable()) return(false); if(!metaElems) return(false); @@ -328,6 +335,9 @@ void gdcmDicomDir::WriteEntries(FILE *_fp) /// \todo (?) tester les echecs en ecriture /// (apres chaque fwrite, dans le WriteEntry) + +/* TODO : to go on compiling + gdcmDicomDirMeta *ptrMeta; ListDicomDirPatient::iterator itPatient; ListDicomDirStudy::iterator itStudy; @@ -368,6 +378,7 @@ void gdcmDicomDir::WriteEntries(FILE *_fp) } ++itPatient; } + */ } //----------------------------------------------------------------------------- @@ -375,7 +386,7 @@ void gdcmDicomDir::WriteEntries(FILE *_fp) /** * \ingroup gdcmDicomDir - * \brief create a gdcmHeader-like chained list from a root Directory + * \brief create a gdcmDocument-like chained list from a root Directory * @param path entry point of the tree-like structure */ void gdcmDicomDir::CreateDicomDirChainedList(std::string path) @@ -387,7 +398,7 @@ void gdcmDicomDir::CreateDicomDirChainedList(std::string path) ListHeader list; gdcmHeader *header; - listEntries.clear(); + tagHT.clear(); patients.clear(); for(gdcmDirList::iterator it=fileList.begin(); @@ -420,74 +431,55 @@ void gdcmDicomDir::CreateDicomDirChainedList(std::string path) /** * \ingroup gdcmDicomDir - * \brief modifies the limits of a gdcmObject, created from a DICOMDIR file + * \brief adds *the* Meta to a partially created DICOMDIR */ - -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; + + // FIXME : Heuuuuu ! Il prend les Entries du Document deja parse, + // il ne fabrique rien ! + +gdcmDicomDirMeta * gdcmDicomDir::NewMeta(void) { + gdcmDicomDirMeta *m = new gdcmDicomDirMeta(&tagHT); + for (TagDocEntryHT::iterator cc = tagHT.begin();cc != tagHT.end();++cc) { + m->AddDocEntry(cc->second); } -} + return m; +} /** * \ingroup gdcmDicomDir - * \brief adds a new Patient to a partially created DICOMDIR + * \brief adds a new Patient (with the basic elements) to a partially created DICOMDIR */ gdcmDicomDirPatient * gdcmDicomDir::NewPatient(void) { std::list elemList; std::list::iterator it; guint16 tmpGr,tmpEl; gdcmDictEntry *dictEntry; - gdcmHeaderEntry *entry; + gdcmValEntry *entry; + + gdcmSQItem *s = new gdcmSQItem(0); elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements(); - std::list::iterator debInsertion, finInsertion, i,j; - - debInsertion = metaElems->fin(); - ++debInsertion; - finInsertion=debInsertion; + + // TODO : use FillObject !!! - // for all the DicomDirPatient Elements + // for all the DicomDirPatient Elements + for(it=elemList.begin();it!=elemList.end();++it) { tmpGr=it->group; tmpEl=it->elem; dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl); - entry=new gdcmHeaderEntry(dictEntry); - entry->SetOffset(0); // just to avoid missprinting - entry->SetValue(it->value); + entry=new gdcmValEntry(dictEntry); + entry->SetOffset(0); // just to avoid further missprinting + entry->SetValue(it->value); + // dealing with value length ... + if(dictEntry->GetGroup()==0xfffe) - { + { entry->SetLength(entry->GetValue().length()); - } + } else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") ) { entry->SetLength(4); @@ -504,21 +496,124 @@ gdcmDicomDirPatient * gdcmDicomDir::NewPatient(void) { { entry->SetLength(entry->GetValue().length()); } - - tagHT.insert( PairHT(entry->GetKey(),entry) ); // add in the (multimap) H Table - listEntries.insert(debInsertion ,entry); // en tete de liste des Patients - ++finInsertion; + s->AddDocEntry(entry); } - i=metaElems->fin(); - i++; - - gdcmDicomDirPatient *p = new gdcmDicomDirPatient(i, --debInsertion, - &tagHT, &listEntries); + gdcmDicomDirPatient *p = new gdcmDicomDirPatient(s, &tagHT); patients.push_front(p); return p; } + +/** + * \ingroup gdcmDicomDir + * \brief adds to the HTable + * the gdcmEntries (Dicom Elements) corresponding to the given type + * @param path full path file name (only used when type = GDCM_DICOMDIR_IMAGE + * @param type gdcmObject type to create (GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...) + * @param header gdcmHeader of the current file + */ +void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,gdcmHeader *header) +{ + std::list elemList; + std::list::iterator it; + guint16 tmpGr, tmpEl; + gdcmDictEntry *dictEntry; + gdcmDocEntry *entry; + std::string val; + + switch(type) + { + case GDCM_DICOMDIR_PATIENT: + elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements(); + break; + case GDCM_DICOMDIR_STUDY: + elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements(); + break; + case GDCM_DICOMDIR_SERIE: + elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements(); + break; + case GDCM_DICOMDIR_IMAGE: + elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements(); + break; + case GDCM_DICOMDIR_META: + elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements(); + break; + default: + return; + } + + for(it=elemList.begin();it!=elemList.end();++it) + { + tmpGr=it->group; + tmpEl=it->elem; + dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl); + entry=new gdcmDocEntry(dictEntry); + entry->SetOffset(0); // just to avoid further missprinting + + if(header) + val=header->GetEntryByNumber(tmpGr,tmpEl); + else + val=GDCM_UNFOUND; + + if(val==GDCM_UNFOUND) + { + if((tmpGr==0x0004) &&(tmpEl==0x1130) ) // File-set ID + { + // force to the *end* File Name + val=GetName(path); + } + else if( (tmpGr==0x0004) && (tmpEl==0x1500) ) // Only used for image + { + if(header->GetFileName().substr(0,path.length())!=path) + { + dbg.Verbose(0, "gdcmDicomDir::SetElement : the base path of file name is incorrect"); + val=header->GetFileName(); + } + else { + val=&(header->GetFileName().c_str()[path.length()]); + } + } + else + { + val=it->value; + } + } + else + { + if (header->GetEntryLengthByNumber(tmpGr,tmpEl)== 0) + val=it->value; + } + + ((gdcmValEntry *)entry)->SetValue(val); + + if(dictEntry) + { + if(dictEntry->GetGroup()==0xfffe) + { + entry->SetLength(((gdcmValEntry *)entry)->GetValue().length()); + } + else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") ) + { + entry->SetLength(4); + } + else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") ) + { + entry->SetLength(2); + } + else if(dictEntry->GetVR()=="SQ") + { + entry->SetLength(0xffffffff); + } + else + { + entry->SetLength(((gdcmValEntry *)entry)->GetValue().length()); + } + } + //AddDocEntry(entry); // both in H Table and in chained list + tagHT[entry->GetKey()] = entry; // FIXME : use a SEQUENCE ! + } +} /** * \ingroup gdcmDicomDir * \brief CallStartMethod @@ -567,132 +662,139 @@ void gdcmDicomDir::CreateDicomDir() // + loop to 1 - gdcmDicomDirType type=gdcmDicomDir::GDCM_DICOMDIR_META; - ListTag::iterator begin; - ListTag::iterator end, end2; - - begin=listEntries.begin(); - end=begin; - for(ListTag::iterator i=end;i !=listEntries.end();++i) - { - std::string v=(*i)->GetValue(); + + gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); // Directory record sequence + if (e==NULL) { + dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record sequence (0x0004,0x1220)" + ); + // FIXME : what to do when the parsed file IS NOT a DICOMDIR file ? + return; + } + + gdcmDicomDirMeta *m = new gdcmDicomDirMeta(&tagHT); + + gdcmSeqEntry *s = (gdcmSeqEntry *)e; // FIXME : It is allowed ??? + ListSQItem listItems = s->GetSQItems(); + + gdcmDocEntry * d; + for(ListSQItem::iterator i=listItems.begin(); i !=listItems.end();++i) + { + d=(*i)->GetDocEntryByNumber(0x0004, 0x1430); // Directory Record Type + std::string v=((gdcmValEntry *)d)->GetValue(); + if(v=="PATIENT ") - { - end=end2=i; - AddObjectToEnd(type,begin,--end2); + { + AddDicomDirPatientToEnd(*i); + //AddObjectToEnd(type,*i); type=gdcmDicomDir::GDCM_DICOMDIR_PATIENT; - begin=end; } - if(v=="STUDY ") + else if(v=="STUDY ") { - end=end2=i; - AddObjectToEnd(type,begin,--end2); + AddDicomDirStudyToEnd(*i); + // AddObjectToEnd(type,*i); type=gdcmDicomDir::GDCM_DICOMDIR_STUDY; - begin=end; } - if(v=="SERIES") + else if(v=="SERIES") { - end=end2=i; - AddObjectToEnd(type,begin,--end2); + AddDicomDirSerieToEnd(*i); + // AddObjectToEnd(type,*i); type=gdcmDicomDir::GDCM_DICOMDIR_SERIE; - begin=end; } - if(v=="IMAGE ") + else if(v=="IMAGE ") { - end=end2=i; - AddObjectToEnd(type,begin,--end2); + AddDicomDirImageToEnd(*i); + // AddObjectToEnd(type,*i); type=gdcmDicomDir::GDCM_DICOMDIR_IMAGE; - begin=end; } + + else + continue ; // It was 'non PATIENT', 'non STUDY', 'non SERIE', 'non IMAGE' SQItem } - - end=end2=listEntries.end(); - if(begin!=end) - AddObjectToEnd(type,begin,--end2); } /** * \ingroup gdcmDicomDir * \brief AddObjectToEnd * @param type - * @param begin iterator on the first HeaderEntry within the chained List - * @param end iterator on the last HeaderEntry within the chained List + * @param begin iterator on the first DocEntry within the chained List + * @param end iterator on the last DocEntry within the chained List */ -void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin,ListTag::iterator end) + +// now useless ? + +/*void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,gdcmSQItem *s) { - if(begin==end) + if(s==NULL) // ?? return; switch(type) { case gdcmDicomDir::GDCM_DICOMDIR_META: - AddDicomDirMetaToEnd(begin,end); + AddDicomDirMeta(); break; case gdcmDicomDir::GDCM_DICOMDIR_PATIENT: - AddDicomDirPatientToEnd(begin,end); + AddDicomDirPatientToEnd(s); break; case gdcmDicomDir::GDCM_DICOMDIR_STUDY: - AddDicomDirStudyToEnd(begin,end); + AddDicomDirStudyToEnd(s); break; case gdcmDicomDir::GDCM_DICOMDIR_SERIE: - AddDicomDirSerieToEnd(begin,end); + AddDicomDirSerieToEnd(s); break; case gdcmDicomDir::GDCM_DICOMDIR_IMAGE: - AddDicomDirImageToEnd(begin,end); + AddDicomDirImageToEnd(s); + break; + case gdcmDicomDir::GDCM_DICOMDIR_NONE: + AddDicomDirImageToEnd(s); //FIXME break; - case gdcmDicomDir::GDCM_DICOMDIR_NONE: - AddDicomDirImageToEnd(begin,end); //FIXME - break; } } +*/ + /** * \ingroup gdcmDicomDir - * \brief Well ... Not realy to end, there is only one occurence - * @param begin iterator on the first HeaderEntry within the chained List - * @param end iterator on the last HeaderEntry within the chained List + * \brief Well ... there is only one occurence */ -void gdcmDicomDir::AddDicomDirMetaToEnd(ListTag::iterator begin,ListTag::iterator end) +void gdcmDicomDir::AddDicomDirMeta() { if(metaElems) delete metaElems; - metaElems = new gdcmDicomDirMeta(begin,end,&tagHT,&listEntries); + metaElems = new gdcmDicomDirMeta(&tagHT); } /** * \ingroup gdcmDicomDir * \brief AddDicomDirPatientToEnd - * @param begin iterator on the first HeaderEntry within the chained List - * @param end iterator on the last HeaderEntry within the chained List + * @param s SQ Item to enqueue to the DicomPatient chained List */ -void gdcmDicomDir::AddDicomDirPatientToEnd(ListTag::iterator begin,ListTag::iterator end) +void gdcmDicomDir::AddDicomDirPatientToEnd(gdcmSQItem *s) { - patients.push_back(new gdcmDicomDirPatient(begin,end,&tagHT, &listEntries)); + patients.push_back(new gdcmDicomDirPatient(s, &tagHT)); } /** * \ingroup gdcmDicomDir * \brief AddDicomDirStudyToEnd - * @param begin iterator on the first HeaderEntry within the chained List - * @param end iterator on the last HeaderEntry within the chained List + * @param s SQ Item to enqueue to the DicomDirStudy chained List */ - void gdcmDicomDir::AddDicomDirStudyToEnd(ListTag::iterator begin,ListTag::iterator end) + void gdcmDicomDir::AddDicomDirStudyToEnd(gdcmSQItem *s) { if(patients.size()>0) { ListDicomDirPatient::iterator itp=patients.end(); itp--; - (*itp)->AddDicomDirStudy(new gdcmDicomDirStudy(begin,end,&tagHT, &listEntries)); + (*itp)->AddDicomDirStudy(new gdcmDicomDirStudy(s, &tagHT)); } } /** * \ingroup gdcmDicomDir * \brief AddDicomDirSerieToEnd - * @param begin iterator on the first HeaderEntry within the chained List - * @param end iterator on the last HeaderEntry within the chained List + * @param s SQ Item to enqueue to the DicomDirSerie chained List */ -void gdcmDicomDir::AddDicomDirSerieToEnd(ListTag::iterator begin,ListTag::iterator end) +void gdcmDicomDir::AddDicomDirSerieToEnd(gdcmSQItem *s) { if(patients.size()>0) { @@ -703,7 +805,7 @@ void gdcmDicomDir::AddDicomDirSerieToEnd(ListTag::iterator begin,ListTag::iterat { ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end(); itst--; - (*itst)->AddDicomDirSerie(new gdcmDicomDirSerie(begin,end,&tagHT, &listEntries)); + (*itst)->AddDicomDirSerie(new gdcmDicomDirSerie(s, &tagHT)); } } } @@ -711,10 +813,9 @@ void gdcmDicomDir::AddDicomDirSerieToEnd(ListTag::iterator begin,ListTag::iterat /** * \ingroup gdcmDicomDir * \brief AddDicomDirImageToEnd - * @param begin iterator on the first HeaderEntry within the chained List - * @param end iterator on the last HeaderEntry within the chained List + * @param s SQ Item to enqueue to the DicomDirImage chained List */ - void gdcmDicomDir::AddDicomDirImageToEnd(ListTag::iterator begin,ListTag::iterator end) + void gdcmDicomDir::AddDicomDirImageToEnd(gdcmSQItem *s) { if(patients.size()>0) { @@ -730,7 +831,7 @@ void gdcmDicomDir::AddDicomDirSerieToEnd(ListTag::iterator begin,ListTag::iterat { ListDicomDirSerie::iterator its=(*itst)->GetDicomDirSeries().end(); its--; - (*its)->AddDicomDirImage(new gdcmDicomDirImage(begin,end,&tagHT, &listEntries)); + (*its)->AddDicomDirImage(new gdcmDicomDirImage(s, &tagHT)); } } } @@ -754,7 +855,6 @@ void gdcmDicomDir::SetElements(std::string &path, ListHeader &list) SetElement(path,GDCM_DICOMDIR_META,NULL); - ListTag::iterator debPat=listEntries.begin(); for(ListHeader::iterator it=list.begin();it!=list.end();++it) { // get the current file characteristics @@ -788,117 +888,6 @@ void gdcmDicomDir::SetElements(std::string &path, ListHeader &list) } } -/** - * \ingroup gdcmDicomDir - * \brief adds to the HTable and at the end of the Chained List - * the gdcmEntries (Dicom Elements) corresponding to the given type - * @param path full path file name(only used when type = GDCM_DICOMDIR_IMAGE - * @param type gdcmObject type to create (GDCM_DICOMDIR_PATIENT, GDCM_DICOMDIR_STUDY, GDCM_DICOMDIR_SERIE ...) - * @param header gdcmHeader of the current file - */ -void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type,gdcmHeader *header) -{ - std::list elemList; - std::list::iterator it; - guint16 tmpGr, tmpEl; - gdcmDictEntry *dictEntry; - gdcmHeaderEntry *entry; - std::string val; - - switch(type) - { - case GDCM_DICOMDIR_PATIENT: - elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements(); - break; - case GDCM_DICOMDIR_STUDY: - elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements(); - break; - case GDCM_DICOMDIR_SERIE: - elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements(); - break; - case GDCM_DICOMDIR_IMAGE: - elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements(); - break; - case GDCM_DICOMDIR_META: - elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements(); - break; - default: - return; - } - - for(it=elemList.begin();it!=elemList.end();++it) - { - tmpGr=it->group; - tmpEl=it->elem; - dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl); - entry=new gdcmHeaderEntry(dictEntry); - entry->SetOffset(0); // just to avoid missprinting - - if(header) - val=header->GetEntryByNumber(tmpGr,tmpEl); - else - val=GDCM_UNFOUND; - - if(val==GDCM_UNFOUND) - { - if((tmpGr==0x0004) &&(tmpEl==0x1130) ) // File-set ID - { - // force to the *end* File Name - val=GetName(path); - } - else if( (tmpGr==0x0004) && (tmpEl==0x1500) ) // Only used for image - { - if(header->GetFileName().substr(0,path.length())!=path) - { - dbg.Verbose(0, "gdcmDicomDir::SetElement : the base path of file name is incorrect"); - val=header->GetFileName(); - } - else { - val=&(header->GetFileName().c_str()[path.length()]); - } - } - else - { - val=it->value; - } - } - else - { - if (header->GetEntryLengthByNumber(tmpGr,tmpEl)== 0) - val=it->value; - } - - entry->SetValue(val); - - if(dictEntry) - { - if(dictEntry->GetGroup()==0xfffe) - { - entry->SetLength(entry->GetValue().length()); - } - else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") ) - { - entry->SetLength(4); - } - else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") ) - { - entry->SetLength(2); - } - else if(dictEntry->GetVR()=="SQ") - { - entry->SetLength(0xffffffff); - } - else - { - entry->SetLength(entry->GetValue().length()); - } - } - //AddHeaderEntry(entry); // both in H Table and in chained list - tagHT.insert( PairHT( entry->GetKey(),entry) ); - listEntries.push_back(entry); - //wasUpdated = 1; // is private - } -} /** * \ingroup gdcmDicomDir * \brief compares two dgcmHeaders @@ -914,6 +903,11 @@ bool gdcmDicomDir::HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2) */ void gdcmDicomDir::UpdateDirectoryRecordSequenceLength() { + +// FIXME : to go on compiling + +// to be re written ! +/* int offset = 0; ListTag::iterator it; guint16 gr, el; @@ -934,6 +928,7 @@ void gdcmDicomDir::UpdateDirectoryRecordSequenceLength() { //bool res=SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps. SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps. return; + */ } //----------------------------------------------------------------------------- diff --git a/src/gdcmDicomDir.h b/src/gdcmDicomDir.h index d2d02487..40bf6100 100644 --- a/src/gdcmDicomDir.h +++ b/src/gdcmDicomDir.h @@ -24,7 +24,7 @@ typedef GDCM_EXPORT void(gdcmMethod)(void * = NULL); * \brief gdcmDicomDir defines an object representing a DICOMDIR in memory. * */ -class GDCM_EXPORT gdcmDicomDir: public gdcmParser +class GDCM_EXPORT gdcmDicomDir: public gdcmDocument { public: // gdcmDicomDir(ListTag *l, @@ -37,14 +37,14 @@ public: ~gdcmDicomDir(void); /** - * \ingroup gdcmParser + * \ingroup gdcmDicomDir * \brief Sets the print level for the Dicom Header * \note 0 for Light Print; 1 for 'medium' Print, 2 for Heavy */ void SetPrintLevel(int level) { printLevel = level; }; /** - * \ingroup gdcmParser + * \ingroup gdcmDicomDir * \brief canonical Printer * \sa SetPrintLevel */ @@ -52,22 +52,17 @@ public: // Informations contained in the parser virtual bool IsReadable(void); -/** - * \ingroup gdcmDicomDir - * \brief returns a pointer to the gdcmDicomDirMeta for this DICOMDIR. - */ + +/// \brief returns a pointer to the gdcmDicomDirMeta for this DICOMDIR. inline gdcmDicomDirMeta *GetDicomDirMeta() {return metaElems;}; -/** - * \ingroup gdcmDicomDir - * \brief returns the PATIENT chained List for this DICOMDIR. - */ + + /// \brief returns the PATIENT chained List for this DICOMDIR. inline ListDicomDirPatient &GetDicomDirPatients() {return patients;}; // Parsing void ParseDirectory(void); - void CheckBoundaries(void); void SetStartMethod(gdcmMethod *,void * =NULL,gdcmMethod * =NULL); void SetStartMethodArgDelete(gdcmMethod *); @@ -75,24 +70,21 @@ public: void SetProgressMethodArgDelete(gdcmMethod *); void SetEndMethod(gdcmMethod *,void * =NULL,gdcmMethod * =NULL); void SetEndMethodArgDelete(gdcmMethod *); -/** - * \ingroup gdcmDicomDir - * \brief GetProgress. - */ + +/// \brief GetProgress GetProgress inline float GetProgress(void) {return(progress);}; -/** - * \ingroup gdcmDicomDir - * \brief AbortProgress. - */ inline void AbortProgress(void) + +/// \brief AbortProgress AbortProgress + inline void AbortProgress(void) {abort=true; }; -/** - * \ingroup gdcmDicomDir - * \brief IsAborted. - */ inline bool IsAborted(void) + +/// \brief IsAborted IsAborted + inline bool IsAborted(void) {return(abort); }; // Adding + gdcmDicomDirMeta * NewMeta(void); gdcmDicomDirPatient * NewPatient(void); // Write @@ -119,13 +111,12 @@ protected: private: void CreateDicomDir(void); - void AddObjectToEnd(gdcmDicomDirType type, - ListTag::iterator begin,ListTag::iterator end); - void AddDicomDirMetaToEnd (ListTag::iterator begin,ListTag::iterator end); - void AddDicomDirPatientToEnd(ListTag::iterator begin,ListTag::iterator end); - void AddDicomDirStudyToEnd (ListTag::iterator begin,ListTag::iterator end); - void AddDicomDirSerieToEnd (ListTag::iterator begin,ListTag::iterator end); - void AddDicomDirImageToEnd (ListTag::iterator begin,ListTag::iterator end); +// void AddObjectToEnd(gdcmDicomDirType type, gdcmSQItem *s); + void AddDicomDirMeta (); + void AddDicomDirPatientToEnd(gdcmSQItem *s); + void AddDicomDirStudyToEnd (gdcmSQItem *s); + void AddDicomDirSerieToEnd (gdcmSQItem *s); + void AddDicomDirImageToEnd (gdcmSQItem *s); void SetElements(std::string &path,ListHeader &list); void SetElement (std::string &path,gdcmDicomDirType type,gdcmHeader *header); @@ -135,13 +126,11 @@ private: static bool HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2); // Variables -/** -* \brief pointer on *the* gdcmObject 'DicomDirMeta Elements' -*/ + +/// \brief pointer on *the* gdcmObject 'DicomDirMeta Elements' gdcmDicomDirMeta *metaElems; -/** -* \brief chained list of DicomDirPatient (to be exploited recursively) -*/ + +/// \brief chained list of DicomDirPatient (to be exploited recursively) ListDicomDirPatient patients; /// pointer to the initialisation method for any progress bar diff --git a/src/gdcmDicomDirImage.cxx b/src/gdcmDicomDirImage.cxx index c9fd47b7..a8905981 100644 --- a/src/gdcmDicomDirImage.cxx +++ b/src/gdcmDicomDirImage.cxx @@ -1,32 +1,27 @@ // gdcmDicomDirImage.cxx //----------------------------------------------------------------------------- #include "gdcmDicomDirImage.h" - +#include "gdcmValEntry.h" //----------------------------------------------------------------------------- // Constructor / Destructor /** * \ingroup gdcmDicomDirImage * \brief Constructor - * @param begin iterator (inside the gdcmParser chained list) - * on the first Header Entry (i.e Dicom Element) - * related to this "IMAGE" part - * @param end iterator (inside the gdcmParser chained list) - * on the last Header Entry (i.e Dicom Element) - * related to this 'IMAGE' part + * @param s SQ Item holdoing the elements * @param ptagHT pointer to the HTable (gdcmObject needs it - * to build the gdcmHeaderEntries) - * @param plistEntries pointer to the chained List (gdcmObject needs it - * to build the gdcmHeaderEntries) + * to build the gdcmDocEntries) */ -gdcmDicomDirImage::gdcmDicomDirImage(ListTag::iterator begin, - ListTag::iterator end, - TagHeaderEntryHT *ptagHT, - ListTag *plistEntries): - gdcmObject(begin,end,ptagHT,plistEntries) +gdcmDicomDirImage::gdcmDicomDirImage(gdcmSQItem *s, TagDocEntryHT *ptagHT): + gdcmObject(ptagHT) { + docEntries = s->GetDocEntries(); } +gdcmDicomDirImage::gdcmDicomDirImage(TagDocEntryHT *ptagHT): + gdcmObject(ptagHT) +{ +} /** * \ingroup gdcmDicomDirImage * \brief Canonical destructor. @@ -45,10 +40,10 @@ gdcmDicomDirImage::~gdcmDicomDirImage() void gdcmDicomDirImage::Print(std::ostream &os) { os<<"IMAGE : "; - for(ListTag::iterator i=beginObj;i!=endObj;++i) + for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i) { if( ((*i)->GetGroup()==0x0004) && ((*i)->GetElement()==0x1500) ) - os<<(*i)->GetValue(); + os<<((gdcmValEntry *)(*i))->GetValue(); } os<GetDocEntries(); } +gdcmDicomDirPatient::gdcmDicomDirPatient(TagDocEntryHT *ptagHT): + gdcmObject(ptagHT) +{ +} /** * \ingroup gdcmDicomDirPatient * \brief Canonical destructor. @@ -71,8 +66,9 @@ gdcmDicomDirStudy * gdcmDicomDirPatient::NewStudy(void) { std::list elemList; elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements(); - FillObject(elemList); - gdcmDicomDirStudy *st = new gdcmDicomDirStudy(i, j, ptagHT, plistEntries); + gdcmDicomDirStudy *st = new gdcmDicomDirStudy( ptagHT); + st->FillObject(elemList); + studies.push_front(st); return st; diff --git a/src/gdcmDicomDirPatient.h b/src/gdcmDicomDirPatient.h index 3569e505..87c039bd 100644 --- a/src/gdcmDicomDirPatient.h +++ b/src/gdcmDicomDirPatient.h @@ -5,7 +5,7 @@ #include "gdcmObject.h" #include "gdcmDicomDirStudy.h" - +#include "gdcmSQItem.h" //----------------------------------------------------------------------------- typedef std::list ListDicomDirStudy; @@ -13,8 +13,9 @@ typedef std::list ListDicomDirStudy; class GDCM_EXPORT gdcmDicomDirPatient : public gdcmObject { public: - gdcmDicomDirPatient(ListTag::iterator begin,ListTag::iterator end, - TagHeaderEntryHT *ptagHT, ListTag *plistEntries); + gdcmDicomDirPatient(gdcmSQItem *s, TagDocEntryHT *ptagHT); + gdcmDicomDirPatient(TagDocEntryHT *ptagHT); + ~gdcmDicomDirPatient(void); virtual void Print(std::ostream &os = std::cout); diff --git a/src/gdcmDicomDirSerie.cxx b/src/gdcmDicomDirSerie.cxx index 1272df3c..f632168c 100644 --- a/src/gdcmDicomDirSerie.cxx +++ b/src/gdcmDicomDirSerie.cxx @@ -8,25 +8,19 @@ // Constructor / Destructor /** * \brief Constructor - * @param begin iterator (inside the gdcmParser chained list) - * on the first Header Entry (i.e Dicom Element) - * related to this "SERIE" part - * @param end iterator (inside the gdcmParser chained list) - * on the last Header Entry (i.e Dicom Element) - * related to this 'SERIE' part + * @param s SQ Item holding the elements related to this "SERIE" part * @param ptagHT pointer to the HTable (gdcmObject needs it - * to build the gdcmHeaderEntries) - * @param plistEntries pointer to the chained List (gdcmObject needs it - * to build the gdcmHeaderEntries) + * to build the gdcmDocEntries) */ -gdcmDicomDirSerie::gdcmDicomDirSerie(ListTag::iterator begin, - ListTag::iterator end, - TagHeaderEntryHT *ptagHT, - ListTag *plistEntries ): - gdcmObject(begin,end,ptagHT,plistEntries) +gdcmDicomDirSerie::gdcmDicomDirSerie(gdcmSQItem *s, TagDocEntryHT *ptagHT): + gdcmObject(ptagHT) +{ + docEntries = s->GetDocEntries(); +} +gdcmDicomDirSerie::gdcmDicomDirSerie(TagDocEntryHT *ptagHT): + gdcmObject(ptagHT) { } - /** * \brief Canonical destructor. */ @@ -65,8 +59,8 @@ gdcmDicomDirImage * gdcmDicomDirSerie::NewImage(void) { std::list elemList; elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements(); + gdcmDicomDirImage *st = new gdcmDicomDirImage(ptagHT); FillObject(elemList); - gdcmDicomDirImage *st = new gdcmDicomDirImage(i, j, ptagHT, plistEntries); images.push_front(st); return st; } diff --git a/src/gdcmDicomDirSerie.h b/src/gdcmDicomDirSerie.h index d9df59fd..c009dc08 100644 --- a/src/gdcmDicomDirSerie.h +++ b/src/gdcmDicomDirSerie.h @@ -13,8 +13,8 @@ typedef std::list ListDicomDirImage; class GDCM_EXPORT gdcmDicomDirSerie : public gdcmObject { public: - gdcmDicomDirSerie(ListTag::iterator begin,ListTag::iterator end, - TagHeaderEntryHT *ptagHT, ListTag *plistEntries); + gdcmDicomDirSerie(gdcmSQItem *s, TagDocEntryHT *ptagHT); + gdcmDicomDirSerie(TagDocEntryHT *ptagHT); ~gdcmDicomDirSerie(void); virtual void Print(std::ostream &os = std::cout); diff --git a/src/gdcmDicomDirStudy.cxx b/src/gdcmDicomDirStudy.cxx index f6509abb..df6b97ca 100644 --- a/src/gdcmDicomDirStudy.cxx +++ b/src/gdcmDicomDirStudy.cxx @@ -9,25 +9,20 @@ /** * \ingroup gdcmDicomDirStudy * \brief constructor - * @param begin iterator (inside the gdcmParser chained list) - * on the first Header Entry (i.e Dicom Element) - * related to this "STUDY" part - * @param end iterator (inside the gdcmParser chained list) - * on the last Header Entry (i.e Dicom Element) - * related to this 'STUDY' part + * @param s SQ Item holding the elements related to this "STUDY" part * @param ptagHT pointer to the HTable (gdcmObject needs it * to build the gdcmHeaderEntries) - * @param plistEntries pointer to the chained List (gdcmObject needs it - * to build the gdcmHeaderEntries) */ -gdcmDicomDirStudy::gdcmDicomDirStudy(ListTag::iterator begin, - ListTag::iterator end, - TagHeaderEntryHT *ptagHT, - ListTag *plistEntries): - gdcmObject(begin,end,ptagHT,plistEntries) +gdcmDicomDirStudy::gdcmDicomDirStudy(gdcmSQItem *s, TagDocEntryHT *ptagHT): + gdcmObject(ptagHT) { + docEntries = s->GetDocEntries(); } +gdcmDicomDirStudy::gdcmDicomDirStudy(TagDocEntryHT *ptagHT): + gdcmObject(ptagHT) +{ +} /** * \ingroup gdcmDicomDirStudy * \brief Canonical destructor. @@ -72,8 +67,8 @@ gdcmDicomDirSerie * gdcmDicomDirStudy::NewSerie(void) { std::list elemList; elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements(); + gdcmDicomDirSerie *st = new gdcmDicomDirSerie(ptagHT); FillObject(elemList); - gdcmDicomDirSerie *st = new gdcmDicomDirSerie(i, j, ptagHT, plistEntries); series.push_front(st); return st; } diff --git a/src/gdcmDicomDirStudy.h b/src/gdcmDicomDirStudy.h index 91b24d56..75dbfa86 100644 --- a/src/gdcmDicomDirStudy.h +++ b/src/gdcmDicomDirStudy.h @@ -12,8 +12,8 @@ typedef std::list ListDicomDirSerie; //----------------------------------------------------------------------------- class GDCM_EXPORT gdcmDicomDirStudy : public gdcmObject { public: - gdcmDicomDirStudy(ListTag::iterator begin,ListTag::iterator end, - TagHeaderEntryHT *ptagHT, ListTag *plistEntries); + gdcmDicomDirStudy(gdcmSQItem *s, TagDocEntryHT *ptagHT); + gdcmDicomDirStudy(TagDocEntryHT *ptagHT); ~gdcmDicomDirStudy(void); diff --git a/src/gdcmDirList.cxx b/src/gdcmDirList.cxx index e3a00ccc..5f8f3ccc 100644 --- a/src/gdcmDirList.cxx +++ b/src/gdcmDirList.cxx @@ -92,15 +92,9 @@ void gdcmDirList::Explore(std::string dirName,bool recursive) } #else - // None of these functions is in POSIX. The functions scandir() and - // alphasort() are from BSD 4.3, and have been available under Linux since - // libc4. Libc4 and libc5 use the more precise prototype - struct dirent **namelist; int n=scandir(dirName.c_str(), &namelist, 0, alphasort); - //if n < 0 should raise error - for (int i= 0;i < n; i++) { fileName=namelist[i]->d_name; @@ -113,9 +107,7 @@ void gdcmDirList::Explore(std::string dirName,bool recursive) { this->push_back(dirName+fileName); } - free(namelist[i]); } - free(namelist); #endif } diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 0777c3d7..bf0bd1a2 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -4,7 +4,7 @@ #include "gdcmDebug.h" #include "jpeg/ljpg/jpegless.h" -typedef std::pair IterHT; +typedef std::pair IterHT; //----------------------------------------------------------------------------- // Constructor / Destructor @@ -735,8 +735,8 @@ bool gdcmFile::WriteBase (std::string fileName, FileType type) { // the *last* of the (GrPixel, NumPixel), if many. TagKey key = gdcmDictEntry::TranslateToKey(grPixel, numPixel); - TagHeaderEntryHT::iterator p2; - gdcmHeaderEntry *PixelElement; + TagDocEntryHT::iterator p2; + gdcmDocEntry *PixelElement; IterHT it= Header->GetEntry().equal_range(key); // get a pair of iterators first-last synonym diff --git a/src/gdcmHeader.cxx b/src/gdcmHeader.cxx index 8096eb16..15bf00f6 100644 --- a/src/gdcmHeader.cxx +++ b/src/gdcmHeader.cxx @@ -5,6 +5,7 @@ #include "gdcmUtil.h" #include "gdcmDebug.h" #include "gdcmTS.h" +#include "gdcmValEntry.h" #include @@ -23,14 +24,14 @@ gdcmHeader::gdcmHeader(const char *InFilename, bool exception_on_error, bool enable_sequences, bool ignore_shadow): - gdcmParser(InFilename,exception_on_error,enable_sequences,ignore_shadow) + gdcmDocument(InFilename,exception_on_error,enable_sequences,ignore_shadow) { - +/* typedef struct { guint32 totalSQlength; guint32 alreadyParsedlength; } pileElem; - +*/ // for some ACR-NEMA images GrPixel, NumPixel is *not* 7fe0,0010 // We may encounter the 'RETired' (0x0028, 0x0200) tag @@ -57,120 +58,7 @@ gdcmHeader::gdcmHeader(const char *InFilename, NumPixel = 0x1010; else NumPixel = 0x0010; - - TagKey key = gdcmDictEntry::TranslateToKey(GrPixel, NumPixel); - countGrPixel = GetEntry().count(key); - - // we set the SQ Depth of each Header Entry - - int top =-1; - int countSQ = 0; - pileElem pile[100]; // Hope embedded sequence depth is no that long ! - - int currentParsedlength = 0; - int totalElementlength; - std::ostringstream tab; - tab << " "; - - // GDCM_DEBUG - // Sorry; Dealing with e-film breaker images - // will (certainly) cause a lot of troubles ... - // I prefer keeping my 'trace' on . - for (ListTag::iterator i = listEntries.begin(); - i != listEntries.end(); - ++i) { - (*i)->SetSQDepthLevel(countSQ); - if ( (*i)->GetVR() == "SQ" && (*i)->GetReadLength() != 0) { // SQ found - countSQ++; - top ++; - if ( top >= 20) { -#ifdef GDCM_DEBUG - std::cout << "Kaie ! Kaie! SQ Stack Overflow" << std::endl; -#endif //GDCM_DEBUG - return; - } -#ifdef GDCM_DEBUG - std::cout << "\n >>>>> empile niveau " << top - << "; Lgr SeQ: " << (*i)->GetReadLength() - << "\n" <GetReadLength(); - pile[top].alreadyParsedlength = 0; - currentParsedlength = 0; - - } else { // non SQ found - if (countSQ != 0) { // we are 'inside a SeQuence' - if ( (*i)->GetGroup()==0xfffe && (*i)->GetElement()==0xe0dd) { - // we just found 'end of SeQuence' - -#ifdef GDCM_DEBUG - std::cout << "fffe,e0dd : depile" << std::endl; -#endif //GDCM_DEBUG - - currentParsedlength += 8; // gr:2 elem:2 vr:2 lgt:2 - countSQ --; - top --; - pile[top].alreadyParsedlength += currentParsedlength; - } else { - // we are on a 'standard' elem - // or a Zero-length SeQuence - - totalElementlength = (*i)->GetFullLength(); - currentParsedlength += totalElementlength; - pile[top].alreadyParsedlength += totalElementlength; - - if (pile[top].totalSQlength == 0xffffffff) { -#ifdef GDCM_DEBUG - std::cout << "totalSeQlength == 0xffffffff" << std::endl; -#endif //GDCM_DEBUG - } else { -#ifdef GDCM_DEBUG - std::cout << "alrdyPseLgt:" - << pile[top].alreadyParsedlength << " totSeQlgt: " - << pile[top].totalSQlength << " curPseLgt: " - << currentParsedlength - << std::endl; -#endif //GDCM_DEBUG - while (pile[top].alreadyParsedlength==pile[top].totalSQlength) { -#ifdef GDCM_DEBUG - std::cout << " \n<<<<<< On depile niveau " << top - << " \n" << std::endl; -#endif //GDCM_DEBUG - (*i)->SetSQDepthLevel(countSQ); - currentParsedlength = pile[top].alreadyParsedlength; - countSQ --; - top --; - if (top >=0) { - pile[top].alreadyParsedlength += currentParsedlength +12; - // 12 : length of 'SQ embedded' SQ element - currentParsedlength += 8; // gr:2 elem:2 vr:2 lgt:2 - -#ifdef GDCM_DEBUG - std::cout << pile[top].alreadyParsedlength << " " - << pile[top].totalSQlength << " " - << currentParsedlength - << std::endl; -#endif //GDCM_DEBUG - } - if (top == -1) { - currentParsedlength = 0; - break; - } - } - } - } - } // end : 'inside a SeQuence' - } -#ifdef GDCM_DEBUG - for (int k=0; k<(*i)->GetSQDepthLevel();k++) { - std::cout << tab; - } - (*i)->SetPrintLevel(2); - (*i)->Print(); -#endif //GDCM_DEBUG - } // end for } /** @@ -178,7 +66,7 @@ gdcmHeader::gdcmHeader(const char *InFilename, * @param exception_on_error whether we want to throw an exception or not */ gdcmHeader::gdcmHeader(bool exception_on_error) : - gdcmParser(exception_on_error) + gdcmDocument(exception_on_error) { } @@ -203,18 +91,22 @@ gdcmHeader::~gdcmHeader (void) { */ void gdcmHeader::PrintEntryNoSQ(std::ostream & os) { +// FIXME : Is it of any use, now? + +/* int depth; for (ListTag::iterator i = listEntries.begin(); i != listEntries.end(); ++i) { depth= (*i)->GetSQDepthLevel(); - if ( depth != 0 /*|| (*i)->GetVR() =="SQ" */){ + if ( depth != 0 ){ continue; } (*i)->SetPrintLevel(printLevel); (*i)->Print(os); } + */ } /** @@ -225,7 +117,9 @@ void gdcmHeader::PrintEntryNoSQ(std::ostream & os) { * \warning : will be removed * @return */ -void gdcmHeader::PrintEntryNiceSQ(std::ostream & os) { +void gdcmHeader::PrintEntryNiceSQ(std::ostream & os) { + +/* std::ostringstream tab; tab << " "; @@ -241,7 +135,9 @@ void gdcmHeader::PrintEntryNiceSQ(std::ostream & os) { (*i)->SetPrintLevel(printLevel); (*i)->Print(os); - } // end for + } // end for + + */ } //----------------------------------------------------------------------------- @@ -257,19 +153,19 @@ void gdcmHeader::PrintEntryNiceSQ(std::ostream & os) { * false otherwise. */ bool gdcmHeader::IsReadable(void) { - if(!gdcmParser::IsReadable()) { + if(!gdcmDocument::IsReadable()) { return(false); } std::string res = GetEntryByNumber(0x0028, 0x0005); if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 ) return false; // Image Dimensions - if ( !GetHeaderEntryByNumber(0x0028, 0x0100) ) + if ( !GetDocEntryByNumber(0x0028, 0x0100) ) return false; // "Bits Allocated" - if ( !GetHeaderEntryByNumber(0x0028, 0x0101) ) + if ( !GetDocEntryByNumber(0x0028, 0x0101) ) return false; // "Bits Stored" - if ( !GetHeaderEntryByNumber(0x0028, 0x0102) ) + if ( !GetDocEntryByNumber(0x0028, 0x0102) ) return false; // "High Bit" - if ( !GetHeaderEntryByNumber(0x0028, 0x0103) ) + if ( !GetDocEntryByNumber(0x0028, 0x0103) ) return false; // "Pixel Representation" i.e. 'Sign' return true; } @@ -281,12 +177,12 @@ bool gdcmHeader::IsReadable(void) { * @return True when JPEGBaseLineProcess1found. False in all other cases. */ bool gdcmHeader::IsJPEGBaseLineProcess1TransferSyntax(void) { - gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); + gdcmDocEntry* Element = GetDocEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadHeaderEntrySafe(Element); + LoadDocEntrySafe(Element); - std::string Transfer = Element->GetValue(); + std::string Transfer = ((gdcmValEntry *)Element)->GetValue(); if ( Transfer == "1.2.840.10008.1.2.4.50" ) return true; return false; @@ -299,11 +195,11 @@ bool gdcmHeader::IsJPEGBaseLineProcess1TransferSyntax(void) { * @return True when JPEGExtendedProcess2-4 found. False in all other cases. */ bool gdcmHeader::IsJPEGExtendedProcess2_4TransferSyntax(void) { - gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); + gdcmDocEntry* Element = GetDocEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadHeaderEntrySafe(Element); - return ( Element->GetValue() == "1.2.840.10008.1.2.4.51" ); + LoadDocEntrySafe(Element); + return ( ((gdcmValEntry *)Element)->GetValue() == "1.2.840.10008.1.2.4.51" ); } /** @@ -313,12 +209,12 @@ bool gdcmHeader::IsJPEGExtendedProcess2_4TransferSyntax(void) { * @return True when JPEGExtendedProcess3-5 found. False in all other cases. */ bool gdcmHeader::IsJPEGExtendedProcess3_5TransferSyntax(void) { - gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); + gdcmDocEntry* Element = GetDocEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadHeaderEntrySafe(Element); + LoadDocEntrySafe(Element); - std::string Transfer = Element->GetValue(); + std::string Transfer = ((gdcmValEntry *)Element)->GetValue(); if ( Transfer == "1.2.840.10008.1.2.4.52" ) return true; return false; @@ -332,12 +228,12 @@ bool gdcmHeader::IsJPEGExtendedProcess3_5TransferSyntax(void) { * other cases. */ bool gdcmHeader::IsJPEGSpectralSelectionProcess6_8TransferSyntax(void) { - gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); + gdcmDocEntry* Element = GetDocEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadHeaderEntrySafe(Element); + LoadDocEntrySafe(Element); - std::string Transfer = Element->GetValue(); + std::string Transfer = ((gdcmValEntry *)Element)->GetValue(); if ( Transfer == "1.2.840.10008.1.2.4.53" ) return true; return false; @@ -351,12 +247,12 @@ bool gdcmHeader::IsJPEGSpectralSelectionProcess6_8TransferSyntax(void) { * other cases. */ bool gdcmHeader::IsRLELossLessTransferSyntax(void) { - gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); + gdcmDocEntry* Element = GetDocEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadHeaderEntrySafe(Element); + LoadDocEntrySafe(Element); - std::string Transfer = Element->GetValue(); + std::string Transfer = ((gdcmValEntry *)Element)->GetValue(); if ( Transfer == "1.2.840.10008.1.2.5" ) { return true; } @@ -371,16 +267,18 @@ bool gdcmHeader::IsRLELossLessTransferSyntax(void) { * other cases. */ bool gdcmHeader::IsJPEGLossless(void) { - gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); + gdcmDocEntry* Element = GetDocEntryByNumber(0x0002, 0x0010); // faire qq chose d'intelligent a la place de ça if ( !Element ) return false; - LoadHeaderEntrySafe(Element); + LoadDocEntrySafe(Element); - const char * Transfert = Element->GetValue().c_str(); + const char * Transfert = ((gdcmValEntry *)Element)->GetValue().c_str(); + if ( memcmp(Transfert+strlen(Transfert)-2 ,"70",2)==0) return true; if ( memcmp(Transfert+strlen(Transfert)-2 ,"55",2)==0) return true; - if (Element->GetValue() == "1.2.840.10008.1.2.4.57") return true; + + if (((gdcmValEntry *)Element)->GetValue() == "1.2.840.10008.1.2.4.57") return true; return false; } @@ -393,12 +291,12 @@ bool gdcmHeader::IsJPEGLossless(void) { * other cases. */ bool gdcmHeader::IsJPEG2000(void) { - gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010); + gdcmDocEntry* Element = GetDocEntryByNumber(0x0002, 0x0010); if ( !Element ) return false; - LoadHeaderEntrySafe(Element); + LoadDocEntrySafe(Element); - std::string Transfer = Element->GetValue(); + std::string Transfer = ((gdcmValEntry *)Element)->GetValue(); if ( (Transfer == "1.2.840.10008.1.2.4.90") || (Transfer == "1.2.840.10008.1.2.4.91") ) return true; @@ -415,7 +313,7 @@ bool gdcmHeader::IsDicomV3(void) { // Anyway, it's to late check if the 'Preamble' was found ... // And ... would it be a rich idea to check ? // (some 'no Preamble' DICOM images exist !) - return (GetHeaderEntryByNumber(0x0002, 0x0010) != NULL); + return (GetDocEntryByNumber(0x0002, 0x0010) != NULL); } /** @@ -601,26 +499,9 @@ std::string gdcmHeader::GetPixelType(void) { * @return Pixel Offset */ size_t gdcmHeader::GetPixelOffset(void) { - // - // If the element (0x0088,0x0200) 'icone image sequence' is found - // (grPixel,numPixel) is stored twice : the first one for the icon - // the second one for the image ... - // pb : sometimes , (0x0088,0x0200) exists, but doesn't contain *anything* - // see gdcmData/MxTwinLossLess.dcm ... - - /** - * \todo Clean me - *std::string icone = GetEntryByNumber(0x0088,0x0200); //icone image sequence - */ - IterHT it = GetHeaderEntrySameNumber(GrPixel,NumPixel); - TagKey key = gdcmDictEntry::TranslateToKey(GrPixel,NumPixel); - gdcmHeaderEntry* PixelElement; - if (countGrPixel == 1) - PixelElement = (it.first)->second; - else { - PixelElement = (++it.first)->second; // hope there are no more than 2 ! - } + gdcmDocEntry* PixelElement = GetDocEntryByNumber(GrPixel,NumPixel); + if (PixelElement) { return PixelElement->GetOffset(); } else { @@ -643,14 +524,7 @@ size_t gdcmHeader::GetPixelOffset(void) { */ size_t gdcmHeader::GetPixelAreaLength(void) { - IterHT it = GetHeaderEntrySameNumber(GrPixel,NumPixel); - TagKey key = gdcmDictEntry::TranslateToKey(GrPixel,NumPixel); - gdcmHeaderEntry* PixelElement; - - if (countGrPixel==1) - PixelElement = (it.first)->second; - else - PixelElement = (++it.first)->second; + gdcmDocEntry* PixelElement = GetDocEntryByNumber(GrPixel,NumPixel); if (PixelElement) { return PixelElement->GetLength(); @@ -677,22 +551,22 @@ bool gdcmHeader::HasLUT(void) { // Check the presence of the LUT Descriptors, and LUT Tables // LutDescriptorRed - if ( !GetHeaderEntryByNumber(0x0028,0x1101) ) + if ( !GetDocEntryByNumber(0x0028,0x1101) ) return false; // LutDescriptorGreen - if ( !GetHeaderEntryByNumber(0x0028,0x1102) ) + if ( !GetDocEntryByNumber(0x0028,0x1102) ) return false; // LutDescriptorBlue - if ( !GetHeaderEntryByNumber(0x0028,0x1103) ) + if ( !GetDocEntryByNumber(0x0028,0x1103) ) return false; // Red Palette Color Lookup Table Data - if ( !GetHeaderEntryByNumber(0x0028,0x1201) ) + if ( !GetDocEntryByNumber(0x0028,0x1201) ) return false; // Green Palette Color Lookup Table Data - if ( !GetHeaderEntryByNumber(0x0028,0x1202) ) + if ( !GetDocEntryByNumber(0x0028,0x1202) ) return false; // Blue Palette Color Lookup Table Data - if ( !GetHeaderEntryByNumber(0x0028,0x1203) ) + if ( !GetDocEntryByNumber(0x0028,0x1203) ) return false; // FIXME : (0x0028,0x3006) : LUT Data (CTX dependent) // NOT taken into account, but we don't know how to use it ... @@ -889,11 +763,11 @@ void gdcmHeader::SetImageDataSize(size_t ImageDataSize) { std::string content1; char car[20]; - // Assumes HeaderEntry (GrPixel, NumPixel) is unique ... + // Assumes DocEntry (GrPixel, NumPixel) is unique ... //\todo deal with multiplicity (see gdcmData/icone.dcm) sprintf(car,"%d",ImageDataSize); - gdcmHeaderEntry *a = GetHeaderEntryByNumber(GrPixel, NumPixel); + gdcmDocEntry *a = GetDocEntryByNumber(GrPixel, NumPixel); a->SetLength(ImageDataSize); ImageDataSize+=8; @@ -955,7 +829,7 @@ void gdcmHeader::SetImageDataSize(size_t ImageDataSize) { return(false); } -bool gdcmHeader::WriteEntry(gdcmHeaderEntry *tag, FILE *_fp,FileType type) +bool gdcmHeader::WriteEntry(gdcmDocEntry *tag, FILE *_fp,FileType type) { guint32 length = tag->GetLength(); @@ -963,7 +837,7 @@ bool gdcmHeader::WriteEntry(gdcmHeaderEntry *tag, FILE *_fp,FileType type) // bytes. When this is not the case, pad with an additional byte: if(length%2==1) { - tag->SetValue(tag->GetValue()+"\0"); + // tag->SetValue(tag->GetValue()+"\0"); // to go on compiling tag->SetLength(tag->GetReadLength()+1); } @@ -995,8 +869,8 @@ bool gdcmHeader::WriteEntry(gdcmHeaderEntry *tag, FILE *_fp,FileType type) */ bool gdcmHeader::anonymizeHeader() { - gdcmHeaderEntry *patientNameHE = GetHeaderEntryByNumber (0x0010, 0x0010); - // gdcmHeaderEntry *patientIDHE = GetHeaderEntryByNumber (0x0010, 0x0020); + gdcmDocEntry *patientNameHE = GetDocEntryByNumber (0x0010, 0x0010); + // gdcmDocEntry *patientIDHE = GetDocEntryByNumber (0x0010, 0x0020); ReplaceIfExistByNumber (" ",0x0010, 0x2154); // Telephone ReplaceIfExistByNumber (" ",0x0010, 0x1040); // Adress diff --git a/src/gdcmHeader.h b/src/gdcmHeader.h index 3d856414..a6a861c1 100644 --- a/src/gdcmHeader.h +++ b/src/gdcmHeader.h @@ -4,8 +4,8 @@ #define GDCMHEADER_H #include "gdcmCommon.h" -#include "gdcmParser.h" - +//#include "gdcmParser.h" +#include "gdcmDocument.h" //----------------------------------------------------------------------------- /** * \brief @@ -26,7 +26,7 @@ * protected due to Swig limitations for as Has_a dependency between * gdcmFile and gdcmHeader. */ -class GDCM_EXPORT gdcmHeader : public gdcmParser +class GDCM_EXPORT gdcmHeader : public gdcmDocument { protected: /// In some cases (e.g. for some ACR-NEMA images) the Header Entry Element @@ -110,40 +110,40 @@ public: // there are protected in the parent class inline virtual std::string GetEntryByNumber (guint16 group, guint16 element) - { return(gdcmParser::GetEntryByNumber(group,element)); } + { return(gdcmDocument::GetEntryByNumber(group,element)); } inline virtual std::string GetEntryVRByNumber(guint16 group, guint16 element) - { return(gdcmParser::GetEntryVRByNumber(group,element)); } + { return(gdcmDocument::GetEntryVRByNumber(group,element)); } inline virtual int GetEntryLengthByNumber(guint16 group, guint16 element) - { return(gdcmParser::GetEntryLengthByNumber(group,element)); } + { return(gdcmDocument::GetEntryLengthByNumber(group,element)); } inline virtual std::string GetEntryByName (std::string tagName) - { return(gdcmParser::GetEntryByName(tagName)); } + { return(gdcmDocument::GetEntryByName(tagName)); } inline virtual std::string GetEntryVRByName (std::string tagName) - { return(gdcmParser::GetEntryVRByName(tagName)); } + { return(gdcmDocument::GetEntryVRByName(tagName)); } inline virtual bool SetEntryByNumber(std::string content, guint16 group, guint16 element) - { return(gdcmParser::SetEntryByNumber(content,group,element)); } + { return(gdcmDocument::SetEntryByNumber(content,group,element)); } inline virtual bool SetEntryByName(std::string content,std::string tagName) - { return(gdcmParser::SetEntryByName(content,tagName)); } + { return(gdcmDocument::SetEntryByName(content,tagName)); } inline virtual bool SetEntryLengthByNumber(guint32 l, guint16 group, guint16 element) - { return(gdcmParser::SetEntryLengthByNumber(l,group,element)); } + { return(gdcmDocument::SetEntryLengthByNumber(l,group,element)); } inline virtual void UpdateShaEntries(void) - { gdcmParser::UpdateShaEntries(); } + { gdcmDocument::UpdateShaEntries(); } /// Read (used in gdcmFile) void SetImageDataSize(size_t ExpectedSize); bool operator<(gdcmHeader &header); - bool WriteEntry(gdcmHeaderEntry *tag,FILE *_fp,FileType type); + bool WriteEntry(gdcmDocEntry *tag,FILE *_fp,FileType type); virtual void PrintEntryNoSQ (std::ostream &os = std::cout); diff --git a/src/gdcmObject.cxx b/src/gdcmObject.cxx index e747b3b3..25cba3b5 100644 --- a/src/gdcmObject.cxx +++ b/src/gdcmObject.cxx @@ -3,30 +3,24 @@ #include "gdcmObject.h" #include "gdcmGlobal.h" #include "gdcmDebug.h" +#include "gdcmValEntry.h" //----------------------------------------------------------------------------- /** * \ingroup gdcmObject * \brief Constructor - * @param begin iterator on the first Header Entry (i.e Dicom Element) - * related to this 'Object' - * @param end iterator on the last Header Entry - * (i.e Dicom Element) related to this 'Object' + * * @param ptagHT pointer to the HTable (gdcmObject needs it - * to build the gdcmHeaderEntries) - * @param plistEntries pointer to the chained List (gdcmObject needs it - * to build the gdcmHeaderEntries) + * to build the gdcmDocEntries) + * @param depth Seaquence depth level */ -gdcmObject::gdcmObject(ListTag::iterator begin, ListTag::iterator end, - TagHeaderEntryHT *ptagHT, ListTag *plistEntries) { - beginObj = begin; - endObj = end; + +gdcmObject::gdcmObject(TagDocEntryHT *ptagHT, int depth) + : gdcmSQItem (depth) { this->ptagHT = ptagHT; - this->plistEntries = plistEntries; - if(begin==end) - dbg.Verbose(0, "gdcmObject::gdcmObject empty list"); } + /** * \ingroup gdcmObject * \brief Canonical destructor. @@ -34,141 +28,12 @@ gdcmObject::gdcmObject(ListTag::iterator begin, ListTag::iterator end, gdcmObject::~gdcmObject(void) { } -//----------------------------------------------------------------------------- -// Print -/** - * \ingroup gdcmObject - * \brief Prints the Object - * @return - */ -void gdcmObject::Print(std::ostream &os) { - if(printLevel>=0) { - ListTag::iterator i; - for(i=beginObj;;++i) { - (*i)->SetPrintLevel(printLevel); - (*i)->Print(os); - if (i == endObj) break; - } - } -} + //----------------------------------------------------------------------------- // Public -/** - * \ingroup gdcmObject - * \brief Get the value of an Header Entries (i.e Dicom Element) by number - * @return - */ -std::string gdcmObject::GetEntryByNumber(guint16 group, guint16 element) { - for(ListTag::iterator i=beginObj;;++i) { - if ( (*i)->GetGroup()==group && (*i)->GetElement()==element) - return (*i)->GetValue(); - if (i == endObj) break; - } - return GDCM_UNFOUND; -} - -/** - * \ingroup gdcmObject - * \brief Get the value of an Header Entries (i.e Dicom Element) by name - * @param name : name of the searched element. - * @return - */ -std::string gdcmObject::GetEntryByName(TagName name) { - gdcmDict *PubDict=gdcmGlobal::GetDicts()->GetDefaultPubDict(); - gdcmDictEntry *dictEntry = (*PubDict).GetDictEntryByName(name); - - if( dictEntry == NULL) - return GDCM_UNFOUND; - return GetEntryByNumber(dictEntry->GetGroup(),dictEntry->GetElement()); -} -/** - * \ingroup gdcmObject - * \brief Set the 'boundaries' gdcmObject (gdcmDicomDirPatient, - * gdcmDicomDirStudy, gdcmDicomDirSerie, gdcmDicomDirImage) - * comming for the parsing of a DICOMDIR file - * \warning NOT en user intended function - * @param flag = 0 when META to be dealt with - */ -void gdcmObject::ResetBoundaries(int flag) { - - if (flag) { // it's NOT a META - // upwards to fffe,e000 - for( i=j=debut(); - ((*i)->GetGroup() != 0xfffe) && ((*i)->GetElement() != 0xe000); - --i,j--) { - } - beginObj=j; - } - - // upwards again to fffe,e000 - if (fin()== (--(plistEntries->end())) ) // Don't try anything more when end - return; // of Chained List is reached - - for( i=j=fin(); - ((*i)->GetGroup() != 0xfffe) && ((*i)->GetElement() != 0xe000); - --i,j--) { - } - j--; - endObj=j; -} -/** - * \brief Sets Entry (Dicom Element) value of an element, - * specified by it's tag (Group, Number) - * and the length, too ... - * If the Element is not found, it's just created ! - * \warning we suppose, right now, the element belongs to a Public Group - * (NOT a shadow one) - * @param val string value to set - * @param group Group of the searched tag. - * @param element Element of the searched tag. - * @return true if element was found or created successfully - */ - bool gdcmObject::SetEntryByNumber(std::string val,guint16 group, - guint16 element) { - - for(ListTag::iterator i=beginObj;;++i) { - if ( (*i)->GetGroup() == 0xfffe && (*i)->GetElement() == 0xe000 ) - continue; - if ( group < (*i)->GetGroup() || - (group == (*i)->GetGroup() && element < (*i)->GetElement()) ){ - // instead of ReplaceOrCreateByNumber - // that is a method of gdcmParser :-( - gdcmHeaderEntry *Entry; - TagKey key = gdcmDictEntry::TranslateToKey(group, element); - if ( ! ptagHT->count(key)) { - // we assume a Public Dictionnary *is* loaded - gdcmDict *PubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict(); - // if the invoked (group,elem) doesn't exist inside the Dictionary - // we create a VirtualDictEntry - gdcmDictEntry *DictEntry = PubDict->GetDictEntryByNumber(group, element); - if (DictEntry == NULL) { - DictEntry=gdcmGlobal::GetDicts()->NewVirtualDictEntry(group,element,"UN","??","??"); - } - // we assume the constructor didn't fail - Entry = new gdcmHeaderEntry(DictEntry); - /// \todo - /// ---- - /// better we don't assume too much ! - /// in the next release, gdcmObject will be used - /// to describe any Header Entry ... - } else { - Entry = ptagHT->find(key)->second; - } - Entry->SetValue(val); - Entry->SetLength(val.length()); - plistEntries->insert(i,Entry); - return true; - } - if (group == (*i)->GetGroup() && element == (*i)->GetElement() ) { - (*i)->SetValue(val); - (*i)->SetLength(val.length()); - return true; - } - } -} /** * \ingroup gdcmObject * \brief Builds a hash table (multimap) containing @@ -176,11 +41,11 @@ void gdcmObject::ResetBoundaries(int flag) { * related to this 'object' * @return */ -TagHeaderEntryHT gdcmObject::GetEntry(void) { - TagHeaderEntryHT HT; - for(ListTag::iterator i=beginObj;;++i) { - HT.insert( PairHT( (*i)->GetKey(),(*i)) ); - if (i == endObj) break; +TagDocEntryHT gdcmObject::GetEntry(void) { + TagDocEntryHT HT; + docEntries=GetDocEntries(); + for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i) { + HT[(*i)->GetKey()]=*i; } return(HT); } @@ -191,16 +56,14 @@ TagHeaderEntryHT gdcmObject::GetEntry(void) { * pointers to all Header Entries (i.e Dicom Element) * related to this 'object' * @return - */ + */ + + // FIXME : what was it used for ?!? + /* ListTag gdcmObject::GetListEntry(void) { - ListTag list; - for(ListTag::iterator i=beginObj;;++i) { - list.push_back(*i); - if (i == endObj) break; - } - return(list); + return(GetDocEntries()); } - +*/ //----------------------------------------------------------------------------- // Protected @@ -210,24 +73,28 @@ ListTag gdcmObject::GetListEntry(void) { * of a partially created DICOMDIR */ void gdcmObject::FillObject(std::list elemList) { + + // FillObject rempli le SQItem qui sera accroche au bon endroit + std::list::iterator it; guint16 tmpGr,tmpEl; gdcmDictEntry *dictEntry; - gdcmHeaderEntry *entry; - - debInsertion = this->fin(); - ++debInsertion; - finInsertion=debInsertion; + gdcmValEntry *entry; + + //gdcmSQItem *s = new gdcmSQItem; + // for all the Elements found in they own part of the DicomDir dict. for(it=elemList.begin();it!=elemList.end();++it) { tmpGr=it->group; tmpEl=it->elem; dictEntry=gdcmGlobal::GetDicts()->GetDefaultPubDict()->GetDictEntryByNumber(tmpGr,tmpEl); - entry=new gdcmHeaderEntry(dictEntry); + entry=new gdcmValEntry(dictEntry); entry->SetOffset(0); // just to avoid further missprinting entry->SetValue(it->value); + // dealing with value length ... + if(dictEntry->GetGroup()==0xfffe) { entry->SetLength(entry->GetValue().length()); @@ -246,17 +113,11 @@ void gdcmObject::FillObject(std::list elemList) { } else { - entry->SetLength(entry->GetValue().length()); + entry->SetLength(entry->GetValue().length()); } - ptagHT->insert( PairHT(entry->GetKey(),entry) ); // add in the (multimap) H Table - plistEntries->insert(debInsertion ,entry); // add at the begining of the Patient list - ++finInsertion; - } - - i=fin(); - i++; - j=debInsertion; - j--; + //docEntries->insert(debInsertion ,entry); // ??? // add at the begining of the Patient list + AddDocEntry(entry); + } } //----------------------------------------------------------------------------- // Private diff --git a/src/gdcmObject.h b/src/gdcmObject.h index 7e842e00..67ba4737 100644 --- a/src/gdcmObject.h +++ b/src/gdcmObject.h @@ -6,9 +6,12 @@ #include #include #include "gdcmCommon.h" -#include "gdcmHeaderEntry.h" -#include "gdcmParser.h" +#include "gdcmDocEntry.h" +//#include "gdcmParser.h" +#include "gdcmDocument.h" #include "gdcmDicomDirElement.h" +#include "gdcmSQItem.h" + //----------------------------------------------------------------------------- class gdcmObject; typedef std::list ListContent; @@ -18,9 +21,10 @@ typedef std::list ListContent; * \ingroup gdcmObject * \brief Base object */ -class GDCM_EXPORT gdcmObject +class GDCM_EXPORT gdcmObject : public gdcmSQItem { public: + /** * \ingroup gdcmParser * \brief Sets the print level for the Dicom Header @@ -28,78 +32,26 @@ public: */ void SetPrintLevel(int level) { printLevel = level; }; - virtual void Print(std::ostream &os = std::cout); - - std::string GetEntryByNumber(guint16 group, guint16 element); - std::string GetEntryByName(TagName name); + + // std::string GetEntryByNumber(guint16 group, guint16 element); + // std::string GetEntryByName(TagName name); bool SetEntryByNumber(std::string val,guint16 group,guint16 element); - TagHeaderEntryHT GetEntry(void); - ListTag GetListEntry(void); - - void ResetBoundaries(int flag); -/** - * \ingroup gdcmObject - * \brief returns an iterator on the first Header Entry (i.e Dicom Element), - * inside the DICOMDIR chained list, - * related to this 'Object' - * @return - */ - ListTag::iterator debut(void) - { return(beginObj);} - /** - * \ingroup gdcmObject - * \brief returns an iterator on the last Header Entry (i.e Dicom Element), - * inside the DICOMDIR chained list, - * related to this 'Object' - * @return - */ - ListTag::iterator fin (void) - { return(endObj); } + TagDocEntryHT GetEntry(void); + void FillObject(std::list elemList); protected: + // constructor and destructor are protected to avoid end user to instanciate this class. - gdcmObject(ListTag::iterator begin,ListTag::iterator end, - TagHeaderEntryHT *ptagHT, ListTag *plistEntries); + gdcmObject(TagDocEntryHT *ptagHT, int depth = 0); virtual ~gdcmObject(void); - void FillObject(std::list elemList); +// variables : -/** -* \brief iterator on the first Header Entry (i.e Dicom Element), -* inside the DICOMDIR chained list, -* related to this 'Object' -*/ - ListTag::iterator beginObj; -/** -* \brief iterator on the last Header Entry (i.e Dicom Element), -* inside the DICOMDIR chained list, -* related to this 'Object' -*/ - ListTag::iterator endObj; -/** -* \brief pointer to the HTable of the gdcmParser, -* (because we don't know it within any gdcmObject) -*/ - TagHeaderEntryHT *ptagHT; -/** -* \brief pointer to the Chained List of the gdcmParser, -* (because we don't know it within any gdcmObject) -*/ - ListTag *plistEntries; -/** -* \brief detail level to be printed -*/ +///\brief detail level to be printed int printLevel; - - /** - * \brief used to pass variables to FillObject function - * Works as 'global' variable - */ - std::list::iterator debInsertion, finInsertion, i,j; private: - }; //-----------------------------------------------------------------------------