)\r
\r
SET(libgdcm_la_SOURCES\r
- gdcmDicomDir.cxx\r
- gdcmDicomDirElement.cxx\r
- gdcmDict.cxx\r
- gdcmDictEntry.cxx\r
- gdcmDictSet.cxx\r
+\r
+ gdcmDicomDir.cxx\r
+ gdcmDicomDirElement.cxx\r
+ gdcmDict.cxx\r
+ gdcmDictEntry.cxx\r
+ gdcmDictSet.cxx\r
gdcmDirList.cxx\r
gdcmException.cxx\r
gdcmFile.cxx\r
libgdcm_la_LIBADD = \
$(top_builddir)/src/jpeg/libijg12/libgdcmijpeg12.la \
$(top_builddir)/src/jpeg/libijg8/libgdcmijpeg8.la \
- $(top_builddir)/src/jpeg/ljpg/libgdcmjpg.la
+ $(top_builddir)/src/jpeg/ljpg/libgdcmjpg.la
libgdcm_la_SOURCES= \
gdcmDicomDir.cxx \
gdcmDicomDirElement.cxx \
+ gdcmDicomDirImage.cxx \
+ gdcmDicomDirMeta.cxx \
+ gdcmDicomDirPatient.cxx \
+ gdcmDicomDirSerie.cxx \
+ gdcmDicomDirStudy.cxx \
gdcmDict.cxx \
gdcmDictEntry.cxx \
gdcmDictSet.cxx \
gdcmHeader.cxx \
gdcmHeaderEntry.cxx \
gdcmHeaderHelper.cxx \
- gdcmImage.cxx \
- gdcmMeta.cxx \
gdcmJpeg12.cxx \
gdcmJpeg2000.cxx \
gdcmJpeg.cxx \
gdcmObject.cxx \
gdcmParsePixels.cxx \
gdcmParser.cxx \
- gdcmPatient.cxx \
gdcmRLE.cxx \
- gdcmSerie.cxx \
- gdcmStudy.cxx \
gdcmTS.cxx \
gdcmUtil.cxx \
gdcmVR.cxx
gdcmCommon.h \
gdcmDicomDir.h \
gdcmDicomDirElement.h \
- gdcmDictEntry.h \
+ gdcmDicomDirImage.h \
+ gdcmDicomDirMeta.h \
+ gdcmDicomDirPatient.h \
+ gdcmDicomDirSerie.h \
+ gdcmDicomDirStudy.h \
+ gdcmDictEntry.h \
gdcmDict.h \
gdcmDictSet.h \
gdcmDirList.h \
gdcmHeaderEntry.h \
gdcmHeader.h \
gdcmHeaderHelper.h \
- gdcmImage.h \
- gdcmMeta.h \
gdcmObject.h \
gdcmParser.h \
- gdcmPatient.h \
- gdcmSerie.h \
- gdcmStudy.h \
gdcmVR.h \
gdcmTS.h
-
EXTRA_DIST = \
- gdcmUtil.h
+ gdcmUtil.h
// gdcmDicomDir.cxx
//-----------------------------------------------------------------------------
#include "gdcmDicomDir.h"
-#include "gdcmStudy.h"
-#include "gdcmSerie.h"
-#include "gdcmImage.h"
+#include "gdcmDicomDirStudy.h"
+#include "gdcmDicomDirSerie.h"
+#include "gdcmDicomDirImage.h"
#include "gdcmDirList.h"
#include "gdcmUtil.h"
// Constructor / Destructor
/*
* \ingroup gdcmDicomDir
- * \brief Constructor
- * @param Filename
+ * \brief Constructor : Parses recursively the directory and creates the DicomDir
+ * \ or uses an already built DICOMDIR, depending on 'parseDir' value
+ * @param Name name of the root directory (parseDir = true)
+ * name of the DICOMDIR (parseDir = false)
+ * @param parseDir true if user wants to explore the directories
* @param exception_on_error
*/
-gdcmDicomDir::gdcmDicomDir(const char *FileName, bool parseDir,
+gdcmDicomDir::gdcmDicomDir(const char *Name, bool parseDir,
bool exception_on_error):
- gdcmParser(FileName,exception_on_error,true)
+ gdcmParser(Name,exception_on_error,true)
{
- startMethod=NULL;
- progressMethod=NULL;
- endMethod=NULL;
- startMethodArgDelete=NULL;
+ startMethod= NULL;
+ progressMethod= NULL;
+ endMethod= NULL;
+ startMethodArgDelete= NULL;
progressMethodArgDelete=NULL;
- endMethodArgDelete=NULL;
- startArg=NULL;
- progressArg=NULL;
- endArg=NULL;
+ endMethodArgDelete= NULL;
+ startArg= NULL;
+ progressArg= NULL;
+ endArg= NULL;
- progress=NULL;
+ progress=0.0;
abort=false;
metaElems=NULL;
if(metaElems)
delete metaElems;
- for(ListPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
+ for(ListDicomDirPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
{
delete *cc;
}
metaElems->Print(os);
}
- for(ListPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
+ for(ListDicomDirPatient::iterator cc=patients.begin();cc!=patients.end();++cc)
{
(*cc)->SetPrintLevel(printLevel);
(*cc)->Print(os);
filePreamble=(char*)calloc(128,1);
fwrite(filePreamble,128,1,fp1);
fwrite("DICM",4,1,fp1);
- free(filePreamble);
-
+ free(filePreamble);
+ UpdateDirectoryRecordSequenceLength();
WriteEntries(fp1,DICOMDIR);
fclose(fp1);
// + we create the object for the precedent tag
// + loop to 1 -
- gdcmDicomDirType type=gdcmDicomDir::GDCM_META;
+ gdcmDicomDirType type=gdcmDicomDir::GDCM_DICOMDIR_META;
ListTag::iterator begin;
ListTag::iterator end;
end=i;
AddObjectToEnd(type,begin,end);
- type=gdcmDicomDir::GDCM_PATIENT;
+ type=gdcmDicomDir::GDCM_DICOMDIR_PATIENT;
begin=end;
}
end=i;
AddObjectToEnd(type,begin,end);
- type=gdcmDicomDir::GDCM_STUDY;
+ type=gdcmDicomDir::GDCM_DICOMDIR_STUDY;
begin=end;
}
end=i;
AddObjectToEnd(type,begin,end);
- type=gdcmDicomDir::GDCM_SERIE;
+ type=gdcmDicomDir::GDCM_DICOMDIR_SERIE;
begin=end;
}
end=i;
AddObjectToEnd(type,begin,end);
- type=gdcmDicomDir::GDCM_IMAGE;
+ type=gdcmDicomDir::GDCM_DICOMDIR_IMAGE;
begin=end;
}
}
switch(type)
{
- case gdcmDicomDir::GDCM_META:
- AddMetaToEnd(begin,end);
+ case gdcmDicomDir::GDCM_DICOMDIR_META:
+ AddDicomDirMetaToEnd(begin,end);
break;
- case gdcmDicomDir::GDCM_PATIENT:
- AddPatientToEnd(begin,end);
+ case gdcmDicomDir::GDCM_DICOMDIR_PATIENT:
+ AddDicomDirPatientToEnd(begin,end);
break;
- case gdcmDicomDir::GDCM_STUDY:
- AddStudyToEnd(begin,end);
+ case gdcmDicomDir::GDCM_DICOMDIR_STUDY:
+ AddDicomDirStudyToEnd(begin,end);
break;
- case gdcmDicomDir::GDCM_SERIE:
- AddSerieToEnd(begin,end);
+ case gdcmDicomDir::GDCM_DICOMDIR_SERIE:
+ AddDicomDirSerieToEnd(begin,end);
break;
- case gdcmDicomDir::GDCM_IMAGE:
- AddImageToEnd(begin,end);
+ case gdcmDicomDir::GDCM_DICOMDIR_IMAGE:
+ AddDicomDirImageToEnd(begin,end);
break;
}
}
* @param begin
* @param end
*/
-void gdcmDicomDir::AddMetaToEnd(ListTag::iterator begin,ListTag::iterator end)
+void gdcmDicomDir::AddDicomDirMetaToEnd(ListTag::iterator begin,ListTag::iterator end)
{
if(metaElems)
delete metaElems;
- metaElems = new gdcmMeta(begin,end);
+ metaElems = new gdcmDicomDirMeta(begin,end);
}
/*
* @param begin
* @param end
*/
-void gdcmDicomDir::AddPatientToEnd(ListTag::iterator begin,ListTag::iterator end)
+void gdcmDicomDir::AddDicomDirPatientToEnd(ListTag::iterator begin,ListTag::iterator end)
{
- patients.push_back(new gdcmPatient(begin,end));
+ patients.push_back(new gdcmDicomDirPatient(begin,end));
}
/*
* @param begin
* @param end
*/
- void gdcmDicomDir::AddStudyToEnd(ListTag::iterator begin,ListTag::iterator end)
+ void gdcmDicomDir::AddDicomDirStudyToEnd(ListTag::iterator begin,ListTag::iterator end)
{
if(patients.size()>0)
{
- ListPatient::iterator itp=patients.end();
+ ListDicomDirPatient::iterator itp=patients.end();
itp--;
- (*itp)->AddStudy(new gdcmStudy(begin,end));
+ (*itp)->AddDicomDirStudy(new gdcmDicomDirStudy(begin,end));
}
}
/*
* @param begin
* @param end
*/
-void gdcmDicomDir::AddSerieToEnd(ListTag::iterator begin,ListTag::iterator end)
+void gdcmDicomDir::AddDicomDirSerieToEnd(ListTag::iterator begin,ListTag::iterator end)
{
if(patients.size()>0)
{
- ListPatient::iterator itp=patients.end();
+ ListDicomDirPatient::iterator itp=patients.end();
itp--;
- if((*itp)->GetStudies().size()>0)
+ if((*itp)->GetDicomDirStudies().size()>0)
{
- ListStudy::iterator itst=(*itp)->GetStudies().end();
+ ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end();
itst--;
- (*itst)->AddSerie(new gdcmSerie(begin,end));
+ (*itst)->AddDicomDirSerie(new gdcmDicomDirSerie(begin,end));
}
}
}
* @param end
* @param
*/
- void gdcmDicomDir::AddImageToEnd(ListTag::iterator begin,ListTag::iterator end)
+ void gdcmDicomDir::AddDicomDirImageToEnd(ListTag::iterator begin,ListTag::iterator end)
{
if(patients.size()>0)
{
- ListPatient::iterator itp=patients.end();
+ ListDicomDirPatient::iterator itp=patients.end();
itp--;
- if((*itp)->GetStudies().size()>0)
+ if((*itp)->GetDicomDirStudies().size()>0)
{
- ListStudy::iterator itst=(*itp)->GetStudies().end();
+ ListDicomDirStudy::iterator itst=(*itp)->GetDicomDirStudies().end();
itst--;
- if((*itst)->GetSeries().size()>0)
+ if((*itst)->GetDicomDirSeries().size()>0)
{
- ListSerie::iterator its=(*itst)->GetSeries().end();
+ ListDicomDirSerie::iterator its=(*itst)->GetDicomDirSeries().end();
its--;
- (*its)->AddImage(new gdcmImage(begin,end));
+ (*its)->AddDicomDirImage(new gdcmDicomDirImage(begin,end));
}
}
}
*/
void gdcmDicomDir::SetElements(std::string &path,ListHeader &list)
{
- std::string patPrevName="", patPrevID="";
+ std::string patPrevName="", patPrevID="";
std::string studPrevInstanceUID="", studPrevID="";
- std::string serPrevInstanceUID="", serPrevID="";
+ std::string serPrevInstanceUID="", serPrevID="";
- std::string patCurName, patCurID;
+ std::string patCurName, patCurID;
std::string studCurInstanceUID, studCurID;
- std::string serCurInstanceUID, serCurID;
+ std::string serCurInstanceUID, serCurID;
- SetElement(path,GDCM_NONE,NULL);
+ SetElement(path,GDCM_DICOMDIR_NONE,NULL);
ListTag::iterator debPat=listEntries.begin();
for(ListHeader::iterator it=list.begin();it!=list.end();++it)
{
// get the current file characteristics
- patCurName=(*it)->GetEntryByNumber(0x0010,0x0010);
- patCurID=(*it)->GetEntryByNumber(0x0010,0x0011);
+ patCurName= (*it)->GetEntryByNumber(0x0010,0x0010);
+ patCurID= (*it)->GetEntryByNumber(0x0010,0x0011);
studCurInstanceUID=(*it)->GetEntryByNumber(0x0020,0x000d);
- studCurID=(*it)->GetEntryByNumber(0x0020,0x0010);
- serCurInstanceUID=(*it)->GetEntryByNumber(0x0020,0x000e);
- serCurID=(*it)->GetEntryByNumber(0x0020,0x0011);
+ studCurID= (*it)->GetEntryByNumber(0x0020,0x0010);
+ serCurInstanceUID= (*it)->GetEntryByNumber(0x0020,0x000e);
+ serCurID= (*it)->GetEntryByNumber(0x0020,0x0011);
if(patCurName!=patPrevName || patCurID!=patPrevID)
- SetElement(path,GDCM_PATIENT,*it);
+ SetElement(path,GDCM_DICOMDIR_PATIENT,*it);
// if new Study Deal with 'STUDY' Elements
if(studCurInstanceUID!=studPrevInstanceUID || studCurID!=studPrevID)
- SetElement(path,GDCM_STUDY,*it);
+ SetElement(path,GDCM_DICOMDIR_STUDY,*it);
// if new Serie Deal with 'SERIE' Elements
if(serCurInstanceUID!=serPrevInstanceUID || serCurID!=serPrevID)
- SetElement(path,GDCM_SERIE,*it);
+ SetElement(path,GDCM_DICOMDIR_SERIE,*it);
// Always Deal with 'IMAGE' Elements
- SetElement(path,GDCM_IMAGE,*it);
+ SetElement(path,GDCM_DICOMDIR_IMAGE,*it);
- patPrevName=patCurName;
- patPrevID=patCurID;
+ patPrevName= patCurName;
+ patPrevID= patCurID;
studPrevInstanceUID=studCurInstanceUID;
- studPrevID=studCurID;
- serPrevInstanceUID=serCurInstanceUID;
- serPrevID=serCurID;
+ studPrevID= studCurID;
+ serPrevInstanceUID= serCurInstanceUID;
+ serPrevID= serCurID;
}
}
switch(type)
{
- case GDCM_PATIENT:
- elemList=gdcmGlobal::GetDicomDirElements()->GetPatientElements();
+ case GDCM_DICOMDIR_PATIENT:
+ elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements();
break;
- case GDCM_STUDY:
- elemList=gdcmGlobal::GetDicomDirElements()->GetStudyElements();
+ case GDCM_DICOMDIR_STUDY:
+ elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements();
break;
- case GDCM_SERIE:
- elemList=gdcmGlobal::GetDicomDirElements()->GetSerieElements();
+ case GDCM_DICOMDIR_SERIE:
+ elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements();
break;
- case GDCM_IMAGE:
- elemList=gdcmGlobal::GetDicomDirElements()->GetImageElements();
+ case GDCM_DICOMDIR_IMAGE:
+ elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements();
break;
- case GDCM_NONE:
- elemList=gdcmGlobal::GetDicomDirElements()->GetMetaElements();
+ case GDCM_DICOMDIR_NONE:
+ elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements();
break;
default:
return;
{
val=it->value;
}
+ }
+ else
+ {
+ if (header->GetEntryLengthByNumber(tmpGr,tmpEl)== 0)
+ val=val=it->value;
}
+
entry->SetValue(val);
if(dictEntry)
{
- if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") )
+ if(dictEntry->GetGroup()==0xfffe)
+ {
+ entry->SetLength(entry->GetValue().length()); //JPR
+ }
+ else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") )
{
entry->SetLength(4);
}
entry->SetLength(entry->GetValue().length());
}
}
-
- listEntries.push_back(entry);
+ //listEntries.push_back(entry);
+ AddHeaderEntry(entry);
}
}
return(*header1<*header2);
}
+
+
+void gdcmDicomDir::UpdateDirectoryRecordSequenceLength() {
+ int offset = 0;
+ ListTag::iterator it;
+ guint16 gr, el;
+ string vr;
+ for(it=listEntries.begin();it!=listEntries.end();++it) {
+ gr = (*it)->GetGroup();
+ el = (*it)->GetElement();
+ vr = (*it)->GetVR();
+ if (gr !=0xfffe) {
+ if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ) {
+ offset += 4; // explicit VR AND OB, OW, SQ : 4 more bytes
+ }
+ offset += 2 + 2 + 4 + (*it)->GetLength();
+ } else {
+ offset += 4; // delimiters don't have a value.
+ }
+ }
+ bool res=SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps.
+ return;
+}
+
//-----------------------------------------------------------------------------
#include "gdcmHeader.h"
#include "gdcmCommon.h"
-#include "gdcmPatient.h"
-#include "gdcmMeta.h"
+#include "gdcmDicomDirPatient.h"
+#include "gdcmDicomDirMeta.h"
#include "gdcmDicomDirElement.h"
#include <list>
#include <vector>
//-----------------------------------------------------------------------------
-typedef std::list<gdcmPatient *> ListPatient;
+typedef std::list<gdcmDicomDirPatient *> ListDicomDirPatient;
typedef std::vector<gdcmHeader *> ListHeader;
-typedef GDCM_EXPORT void( gdcmMethod)(void * =NULL);
+typedef GDCM_EXPORT void(gdcmMethod)(void * = NULL);
//-----------------------------------------------------------------------------
/*
* \defgroup gdcmDicomDir
class GDCM_EXPORT gdcmDicomDir: public gdcmParser
{
public:
-// gdcmDicomDir(ListTag *l, bool exception_on_error = false);
+// gdcmDicomDir(ListTag *l,
+// bool exception_on_error = false);
gdcmDicomDir(const char *FileName,
bool parseDir = false,
bool exception_on_error = false);
// Informations contained in the parser
virtual bool IsReadable(void);
- inline gdcmMeta *GetMeta() {return metaElems;};
- inline ListPatient &GetPatients() {return patients;};
+ inline gdcmDicomDirMeta *GetDicomDirMeta() {return metaElems;};
+ inline ListDicomDirPatient &GetDicomDirPatients() {return patients;};
// Parsing
void ParseDirectory(void);
// Types
typedef enum
{
- GDCM_NONE,
- GDCM_META,
- GDCM_PATIENT,
- GDCM_STUDY,
- GDCM_SERIE,
- GDCM_IMAGE,
+ GDCM_DICOMDIR_NONE,
+ GDCM_DICOMDIR_META,
+ GDCM_DICOMDIR_PATIENT,
+ GDCM_DICOMDIR_STUDY,
+ GDCM_DICOMDIR_SERIE,
+ GDCM_DICOMDIR_IMAGE,
} gdcmDicomDirType;
protected:
void CreateDicomDir(void);
void AddObjectToEnd(gdcmDicomDirType type,
ListTag::iterator begin,ListTag::iterator end);
- void AddMetaToEnd (ListTag::iterator begin,ListTag::iterator end);
- void AddPatientToEnd(ListTag::iterator begin,ListTag::iterator end);
- void AddStudyToEnd (ListTag::iterator begin,ListTag::iterator end);
- void AddSerieToEnd (ListTag::iterator begin,ListTag::iterator end);
- void AddImageToEnd (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 SetElements(std::string &path,ListHeader &list);
void SetElement (std::string &path,gdcmDicomDirType type,gdcmHeader *header);
+
+ void UpdateDirectoryRecordSequenceLength(void);
static bool HeaderLessThan(gdcmHeader *header1,gdcmHeader *header2);
- gdcmMeta *metaElems;
- ListPatient patients;
+ gdcmDicomDirMeta *metaElems;
+ ListDicomDirPatient patients;
gdcmMethod *startMethod;
gdcmMethod *progressMethod;
elem.value = buff;
if(type=="metaElem")
- MetaList.push_back(elem);
+ DicomDirMetaList.push_back(elem);
else if(type=="patientElem")
- PatientList.push_back(elem);
+ DicomDirPatientList.push_back(elem);
else if(type=="studyElem")
- StudyList.push_back(elem);
+ DicomDirStudyList.push_back(elem);
else if(type=="serieElem")
- SerieList.push_back(elem);
+ DicomDirSerieList.push_back(elem);
else if(type=="imageElem")
- ImageList.push_back(elem);
+ DicomDirImageList.push_back(elem);
}
-
from.getline(buff, 1024, '\n');
}
from.close();
* \brief destructor
*/
gdcmDicomDirElement::~gdcmDicomDirElement() {
- MetaList.clear();
- PatientList.clear();
- StudyList.clear();
- SerieList.clear();
- ImageList.clear();
+ DicomDirMetaList.clear();
+ DicomDirPatientList.clear();
+ DicomDirStudyList.clear();
+ DicomDirSerieList.clear();
+ DicomDirImageList.clear();
}
//-----------------------------------------------------------------------------
char greltag[10]; //group element tag
s << "Meta Elements :"<<std::endl;
- for (it = MetaList.begin();it!=MetaList.end();++it)
+ for (it = DicomDirMetaList.begin();it!=DicomDirMetaList.end();++it)
{
sprintf(greltag,"%04x|%04x ",it->group,it->elem);
s << " ("<<greltag<<") = "<< it->value<<std::endl;
}
s << "Patient Elements :"<<std::endl;
- for (it = PatientList.begin();it!=PatientList.end();++it)
+ for (it = DicomDirPatientList.begin();it!=DicomDirPatientList.end();++it)
{
sprintf(greltag,"%04x|%04x ",it->group,it->elem);
s << " ("<<greltag<<") = "<< it->value<<std::endl;
}
s << "Study Elements :"<<std::endl;
- for (it = StudyList.begin();it!=StudyList.end();++it)
+ for (it = DicomDirStudyList.begin();it!=DicomDirStudyList.end();++it)
{
sprintf(greltag,"%04x|%04x ",it->group,it->elem);
s << " ("<<greltag<<") = "<< it->value<<std::endl;
}
s << "Serie Elements :"<<std::endl;
- for (it = SerieList.begin();it!=SerieList.end();++it)
+ for (it = DicomDirSerieList.begin();it!=DicomDirSerieList.end();++it)
{
sprintf(greltag,"%04x|%04x ",it->group,it->elem);
s << " ("<<greltag<<") = "<< it->value<<std::endl;
}
s << "Image Elements :"<<std::endl;
- for (it = ImageList.begin();it!=ImageList.end();++it)
+ for (it = DicomDirImageList.begin();it!=DicomDirImageList.end();++it)
{
sprintf(greltag,"%04x|%04x ",it->group,it->elem);
s << " ("<<greltag<<") = "<< it->value<<std::endl;
std::string value;
} gdcmElement;
-typedef std::list<gdcmElement> ListMetaElem;
-typedef std::list<gdcmElement> ListPatientElem;
-typedef std::list<gdcmElement> ListStudyElem;
-typedef std::list<gdcmElement> ListSerieElem;
-typedef std::list<gdcmElement> ListImageElem;
+typedef std::list<gdcmElement> ListDicomDirMetaElem;
+typedef std::list<gdcmElement> ListDicomDirPatientElem;
+typedef std::list<gdcmElement> ListDicomDirStudyElem;
+typedef std::list<gdcmElement> ListDicomDirSerieElem;
+typedef std::list<gdcmElement> ListDicomDirImageElem;
//-----------------------------------------------------------------------------
/*
void Print(std::ostream &os);
- ListMetaElem &GetMetaElements(void) {return(MetaList);};
- ListPatientElem &GetPatientElements(void) {return(PatientList);};
- ListStudyElem &GetStudyElements(void) {return(StudyList);};
- ListSerieElem &GetSerieElements(void) {return(SerieList);};
- ListImageElem &GetImageElements(void) {return(ImageList);};
+ ListDicomDirMetaElem &GetDicomDirMetaElements(void)
+ {return(DicomDirMetaList);};
+ ListDicomDirPatientElem &GetDicomDirPatientElements(void)
+ {return(DicomDirPatientList);};
+ ListDicomDirStudyElem &GetDicomDirStudyElements(void)
+ {return(DicomDirStudyList);};
+ ListDicomDirSerieElem &GetDicomDirSerieElements(void)
+ {return(DicomDirSerieList);};
+ ListDicomDirImageElem &GetDicomDirImageElements(void)
+ {return(DicomDirImageList);};
private:
- ListMetaElem MetaList;
- ListPatientElem PatientList;
- ListStudyElem StudyList;
- ListSerieElem SerieList;
- ListImageElem ImageList;
+ ListDicomDirMetaElem DicomDirMetaList;
+ ListDicomDirPatientElem DicomDirPatientList;
+ ListDicomDirStudyElem DicomDirStudyList;
+ ListDicomDirSerieElem DicomDirSerieList;
+ ListDicomDirImageElem DicomDirImageList;
};
//-----------------------------------------------------------------------------
-// gdcmImage.cxx
+// gdcmDicomDirImage.cxx
//-----------------------------------------------------------------------------
-#include "gdcmImage.h"
+#include "gdcmDicomDirImage.h"
//-----------------------------------------------------------------------------
// Constructor / Destructor
/**
- * \ingroup gdcmImage
+ * \ingroup gdcmDicomDirImage
* \brief
* @param begin iterator of begin for the object
* @param end iterator of end for the object
*/
-gdcmImage::gdcmImage(ListTag::iterator begin,ListTag::iterator end):
+gdcmDicomDirImage::gdcmDicomDirImage(ListTag::iterator begin,ListTag::iterator end):
gdcmObject(begin,end)
{
}
* \ingroup gdcmImage
* \brief Canonical destructor.
*/
-gdcmImage::~gdcmImage()
+gdcmDicomDirImage::~gdcmDicomDirImage()
{
}
//-----------------------------------------------------------------------------
// Print
/**
- * \ingroup gdcmImage
+ * \ingroup gdcmDicomDirImage
* \brief Prints the Object
* @return
*/
-void gdcmImage::Print(std::ostream &os)
+void gdcmDicomDirImage::Print(std::ostream &os)
{
os<<"IMAGE : ";
for(ListTag::iterator i=beginObj;i!=endObj;++i)
-// gdcmImage.h
+// gdcmDicomDirImage.h
//-----------------------------------------------------------------------------
-#ifndef GDCMIMAGE_H
-#define GDCMIMAGE_H
+#ifndef GDCMDICOMIMAGE_H
+#define GDCMDICOMIMAGE_H
#include "gdcmObject.h"
//-----------------------------------------------------------------------------
-class GDCM_EXPORT gdcmImage : public gdcmObject
+class GDCM_EXPORT gdcmDicomDirImage : public gdcmObject
{
public:
- gdcmImage(ListTag::iterator begin,ListTag::iterator end);
- ~gdcmImage(void);
+ gdcmDicomDirImage(ListTag::iterator begin,ListTag::iterator end);
+ ~gdcmDicomDirImage(void);
virtual void Print(std::ostream &os = std::cout);
};
-// gdcmMeta.h
+// gdcmDicomDirMeta.h
//-----------------------------------------------------------------------------
-#include "gdcmMeta.h"
+#include "gdcmDicomDirMeta.h"
//-----------------------------------------------------------------------------
// Constructor / Destructor
/**
- * \ingroup gdcmMeta
+ * \ingroup gdcmDicomDirMeta
* \brief
* @param begin iterator of begin for the object
* @param end iterator of end for the object
*/
-gdcmMeta::gdcmMeta(ListTag::iterator begin,ListTag::iterator end):
+gdcmDicomDirMeta::gdcmDicomDirMeta(ListTag::iterator begin,ListTag::iterator end):
gdcmObject(begin,end)
{
}
/**
- * \ingroup gdcmMeta
+ * \ingroup gdcmDicomDirMeta
* \brief Canonical destructor.
*/
-gdcmMeta::~gdcmMeta()
+gdcmDicomDirMeta::~gdcmDicomDirMeta()
{
}
//-----------------------------------------------------------------------------
// Print
/**
- * \ingroup gdcmMeta
+ * \ingroup gdcmDicomDirMeta
* \brief Prints the Object
* @return
*/
-void gdcmMeta::Print(std::ostream &os)
+void gdcmDicomDirMeta::Print(std::ostream &os)
{
os<<"META"<<std::endl;
gdcmObject::Print(os);
-// gdcmMeta.h
+// gdcmDicomDirMeta.h
//-----------------------------------------------------------------------------
-#ifndef GDCMMETA_H
-#define GDCMMETA_H
+#ifndef GDCMDICOMDIRMETA_H
+#define GDCMDICOMDIRMETA_H
#include "gdcmObject.h"
//-----------------------------------------------------------------------------
-class GDCM_EXPORT gdcmMeta : public gdcmObject
+class GDCM_EXPORT gdcmDicomDirMeta : public gdcmObject
{
public:
- gdcmMeta(ListTag::iterator begin,ListTag::iterator end);
- ~gdcmMeta(void);
+ gdcmDicomDirMeta(ListTag::iterator begin,ListTag::iterator end);
+ ~gdcmDicomDirMeta(void);
virtual void Print(std::ostream &os = std::cout);
};
-// gdcmPatient.cxx
+// gdcmDicomDirPatient.cxx
//-----------------------------------------------------------------------------
-#include "gdcmPatient.h"
+#include "gdcmDicomDirPatient.h"
//-----------------------------------------------------------------------------
// Constructor / Destructor
/**
- * \ingroup gdcmPatient
+ * \ingroup gdcmDicomDirPatient
* \brief
* @param begin iterator of begin for the object
* @param end iterator of end for the object
*/
-gdcmPatient::gdcmPatient(ListTag::iterator begin,ListTag::iterator end):
+gdcmDicomDirPatient::gdcmDicomDirPatient(ListTag::iterator begin,ListTag::iterator end):
gdcmObject(begin,end)
{
}
/**
- * \ingroup gdcmPatient
+ * \ingroup gdcmDicomDirPatient
* \brief Canonical destructor.
*/
-gdcmPatient::~gdcmPatient()
+gdcmDicomDirPatient::~gdcmDicomDirPatient()
{
- for(ListStudy::iterator cc = studies.begin();cc != studies.end();++cc)
+ for(ListDicomDirStudy::iterator cc = studies.begin();cc != studies.end();++cc)
{
delete *cc;
}
//-----------------------------------------------------------------------------
// Print
/**
- * \ingroup gdcmPatient
+ * \ingroup gdcmDicomDirPatient
* \brief Prints the Object
* @return
*/
-void gdcmPatient::Print(std::ostream &os)
+void gdcmDicomDirPatient::Print(std::ostream &os)
{
os<<"PATIENT"<<std::endl;
gdcmObject::Print(os);
- for(ListStudy::iterator cc = studies.begin();cc!=studies.end();++cc)
+ for(ListDicomDirStudy::iterator cc = studies.begin();cc!=studies.end();++cc)
{
(*cc)->SetPrintLevel(printLevel);
(*cc)->Print(os);
-// gdcmPatient.h
+// gdcmDicomDirPatient.h
//-----------------------------------------------------------------------------
#ifndef GDCMPATIENT_H
#define GDCMPATIENT_H
#include "gdcmObject.h"
-#include "gdcmStudy.h"
+#include "gdcmDicomDirStudy.h"
//-----------------------------------------------------------------------------
-typedef std::list<gdcmStudy *> ListStudy;
+typedef std::list<gdcmDicomDirStudy *> ListDicomDirStudy;
//-----------------------------------------------------------------------------
-class GDCM_EXPORT gdcmPatient : public gdcmObject
+class GDCM_EXPORT gdcmDicomDirPatient : public gdcmObject
{
public:
- gdcmPatient(ListTag::iterator begin,ListTag::iterator end);
- ~gdcmPatient(void);
+ gdcmDicomDirPatient(ListTag::iterator begin,ListTag::iterator end);
+ ~gdcmDicomDirPatient(void);
virtual void Print(std::ostream &os = std::cout);
- inline ListStudy &GetStudies() {return studies;};
- inline void AddStudy(gdcmStudy *obj) {studies.push_back(obj);};
+ inline ListDicomDirStudy &GetDicomDirStudies() {return studies;};
+ inline void AddDicomDirStudy(gdcmDicomDirStudy *obj) {studies.push_back(obj);};
private:
- ListStudy studies;
+ ListDicomDirStudy studies;
};
//-----------------------------------------------------------------------------
-// gdcmSequence.cxx
+// gdcmDicomDirSerie.cxx
//-----------------------------------------------------------------------------
-#include "gdcmSerie.h"
+#include "gdcmDicomDirSerie.h"
//-----------------------------------------------------------------------------
// Constructor / Destructor
/**
- * \ingroup gdcmSerie
+ * \ingroup gdcmDicomDirSerie
* \brief
* @param begin iterator of begin for the object
* @param end iterator of end for the object
*/
-gdcmSerie::gdcmSerie(ListTag::iterator begin,ListTag::iterator end):
+gdcmDicomDirSerie::gdcmDicomDirSerie(ListTag::iterator begin,ListTag::iterator end):
gdcmObject(begin,end)
{
}
/**
- * \ingroup gdcmSerie
+ * \ingroup gdcmDicomDirSerie
* \brief Canonical destructor.
*/
-gdcmSerie::~gdcmSerie()
+gdcmDicomDirSerie::~gdcmDicomDirSerie()
{
- for(ListImage::iterator cc = images.begin();cc != images.end();++cc)
+ for(ListDicomDirImage::iterator cc = images.begin();cc != images.end();++cc)
{
delete *cc;
}
//-----------------------------------------------------------------------------
// Print
/**
- * \ingroup gdcmSerie
+ * \ingroup gdcmDicomDirSerie
* \brief Prints the Object
* @return
*/
-void gdcmSerie::Print(std::ostream &os)
+void gdcmDicomDirSerie::Print(std::ostream &os)
{
os<<"SERIE"<<std::endl;
gdcmObject::Print(os);
- for(ListImage::iterator cc = images.begin();cc != images.end();++cc)
+ for(ListDicomDirImage::iterator cc = images.begin();cc != images.end();++cc)
{
(*cc)->SetPrintLevel(printLevel);
(*cc)->Print(os);
--- /dev/null
+// gdcmDicomDirSerie.h
+//-----------------------------------------------------------------------------
+#ifndef GDCMDICOMDIRSERIE_H
+#define GDCMDICOMDIRSERIE_H
+
+#include "gdcmObject.h"
+#include "gdcmDicomDirImage.h"
+
+//-----------------------------------------------------------------------------
+typedef std::list<gdcmDicomDirImage *> ListDicomDirImage;
+
+//-----------------------------------------------------------------------------
+class GDCM_EXPORT gdcmDicomDirSerie : public gdcmObject
+{
+public:
+ gdcmDicomDirSerie(ListTag::iterator begin,ListTag::iterator end);
+ ~gdcmDicomDirSerie(void);
+
+ virtual void Print(std::ostream &os = std::cout);
+
+ inline ListDicomDirImage &GetDicomDirImages() {return images;};
+ inline void AddDicomDirImage(gdcmDicomDirImage *obj) {images.push_back(obj);};
+
+private:
+ ListDicomDirImage images;
+};
+
+//-----------------------------------------------------------------------------
+#endif
-// gdcmStudy.cxx
+// gdcmDicomDirStudy.cxx
//-----------------------------------------------------------------------------
-#include "gdcmStudy.h"
+#include "gdcmDicomDirStudy.h"
//-----------------------------------------------------------------------------
// Constructor / Destructor
/**
- * \ingroup gdcmStudy
+ * \ingroup gdcmDicomDirStudy
* \brief
* @param begin iterator of begin for the object
* @param end iterator of end for the object
*/
-gdcmStudy::gdcmStudy(ListTag::iterator begin,ListTag::iterator end):
+gdcmDicomDirStudy::gdcmDicomDirStudy(ListTag::iterator begin,ListTag::iterator end):
gdcmObject(begin,end)
{
}
/**
- * \ingroup gdcmStudy
+ * \ingroup gdcmDicomDirStudy
* \brief Canonical destructor.
*/
-gdcmStudy::~gdcmStudy()
+gdcmDicomDirStudy::~gdcmDicomDirStudy()
{
- for(ListSerie::iterator cc = series.begin();cc != series.end();++cc)
+ for(ListDicomDirSerie::iterator cc = series.begin();cc != series.end();++cc)
{
delete *cc;
}
//-----------------------------------------------------------------------------
// Print
/**
- * \ingroup gdcmStudy
+ * \ingroup gdcmDicomDirStudy
* \brief Prints the Object
* @return
*/
-void gdcmStudy::Print(std::ostream &os)
+void gdcmDicomDirStudy::Print(std::ostream &os)
{
os<<"STUDY"<<std::endl;
gdcmObject::Print(os);
- for(ListSerie::iterator cc = series.begin();cc != series.end();++cc)
+ for(ListDicomDirSerie::iterator cc = series.begin();cc != series.end();++cc)
{
(*cc)->SetPrintLevel(printLevel);
(*cc)->Print(os);
--- /dev/null
+// gdcmDicomDirStudy.h
+//-----------------------------------------------------------------------------
+#ifndef GDCMDICOMDIRSTUDY_H
+#define GDCMDICOMDIRSTUDY_H
+
+#include "gdcmObject.h"
+#include "gdcmDicomDirSerie.h"
+
+//-----------------------------------------------------------------------------
+typedef std::list<gdcmDicomDirSerie *> ListDicomDirSerie;
+
+//-----------------------------------------------------------------------------
+class GDCM_EXPORT gdcmDicomDirStudy : public gdcmObject {
+public:
+ gdcmDicomDirStudy(ListTag::iterator begin,ListTag::iterator end);
+ ~gdcmDicomDirStudy(void);
+
+ virtual void Print(std::ostream &os = std::cout);
+
+ inline ListDicomDirSerie &GetDicomDirSeries() {return series;};
+ inline void AddDicomDirSerie(gdcmDicomDirSerie *obj) {series.push_back(obj);};
+
+private:
+ ListDicomDirSerie series;
+};
+
+//-----------------------------------------------------------------------------
+#endif
if ( EntryToDelete )
delete EntryToDelete;
}
-
// Since AddNewEntry adds symetrical in both KeyHt and NameHT we can
// assume all the pointed gdcmDictEntries are already cleaned-up when
// we cleaned KeyHt.
* \ingroup gdcmDict
* \brief adds a new Dicom Dictionary Entry
* @param NewEntry entry to add
- * @return false if Dicom Element already existed
+ * @return false if Dicom Element already exists
*/
bool gdcmDict::AddNewEntry(gdcmDictEntry *NewEntry)
{
}
// Just for fun :-(
- // (if any) remove or replace
+ // (if any) remove or replace all the stuff that contains a Date
//0008 0012 DA ID Instance Creation Date
//0008 0020 DA ID Study Date
inline virtual std::string GetEntryByNumber (guint16 group, guint16 element)
{ return(gdcmParser::GetEntryByNumber(group,element)); }
+
inline virtual std::string GetEntryVRByNumber(guint16 group, guint16 element)
{ return(gdcmParser::GetEntryVRByNumber(group,element)); }
+ inline virtual int GetEntryLengthByNumber(guint16 group, guint16 element)
+ { return(gdcmParser::GetEntryLengthByNumber(group,element)); }
+
inline virtual std::string GetEntryByName (std::string tagName)
{ return(gdcmParser::GetEntryByName(tagName)); }
+
inline virtual std::string GetEntryVRByName (std::string tagName)
{ return(gdcmParser::GetEntryVRByName(tagName)); }
inline virtual bool SetEntryByNumber(std::string content,guint16 group, guint16 element)
{ return(gdcmParser::SetEntryByNumber(content,group,element)); }
+
inline virtual bool SetEntryByName(std::string content,std::string tagName)
{ return(gdcmParser::SetEntryByName(content,tagName)); }
-// gdcmHeader.cxx
+// gdcmParser.cxx
//-----------------------------------------------------------------------------
#include "gdcmParser.h"
#include "gdcmUtil.h"
return elem->GetVR();
}
+
/**
* \ingroup gdcmParser
* \brief Searches within Header Entries (Dicom Elements) parsed with
return elem->GetVR();
}
+/**
+ * \ingroup gdcmParser
+ * \brief Searches within Header Entries (Dicom Elements) parsed with
+ * the public and private dictionaries
+ * for the value length of a given tag..
+ * @param group Group of the searched tag.
+ * @param element Element of the searched tag.
+ * @return Corresponding element length; -2 if not found
+ */
+int gdcmParser::GetEntryLengthByNumber(guint16 group, guint16 element) {
+ gdcmHeaderEntry* elem = GetHeaderEntryByNumber(group, element);
+ if ( !elem )
+ return -2;
+ return elem->GetLength();
+}
/**
* \ingroup gdcmParser
* \brief Sets the value (string) of the Header Entry (Dicom Element)
* @param l new length to substitute with
* @param group group of the Entry to modify
* @param element element of the Entry to modify
- * @return 1 on success, 0 otherwise.
+ * @return true on success, false otherwise.
*/
bool gdcmParser::SetEntryLengthByNumber(guint32 l,
guint16 group,
* \brief Gets (from Header) the offset of a 'non string' element value
* (LoadElementValues has already be executed)
* @param Group group of the Entry
- * @param Elem element of the Entry
+ * @param Elem element of the Entry
* @return File Offset of the Element Value
*/
size_t gdcmParser::GetEntryOffsetByNumber(guint16 Group, guint16 Elem)
*/
gdcmHeaderEntry* gdcmParser::GetHeaderEntryByNumber(guint16 group, guint16 element)
{
- TagKey key = gdcmDictEntry::TranslateToKey(group, element);
+ TagKey key = gdcmDictEntry::TranslateToKey(group, element);
if ( ! tagHT.count(key))
return NULL;
return tagHT.find(key)->second;
// TODO : find a trick (in STL?) to do it, at low cost !
void *ptr;
-
+ int ff=0xffffffff;
// TODO (?) tester les echecs en ecriture (apres chaque fwrite)
int compte =0;
// === Deal with the length
// --------------------
if(((*tag2)->GetLength())%2==1)
- {
+ {
(*tag2)->SetValue((*tag2)->GetValue()+"\0");
- (*tag2)->SetLength((*tag2)->GetLength()+1);
+ (*tag2)->SetLength((*tag2)->GetReadLength()+1);
}
gr = (*tag2)->GetGroup();
fwrite ( &gr,(size_t)2 ,(size_t)1 ,_fp); //group
fwrite ( &el,(size_t)2 ,(size_t)1 ,_fp); //element
- // if ( (type == ExplicitVR) && (gr <= 0x0002) ) // ?!? < 2
- if ( (type == ExplicitVR) || (type == DICOMDIR) )
- {
+ if ( (type == ExplicitVR) || (type == DICOMDIR) ) {
// EXPLICIT VR
guint16 z=0, shortLgr;
- if (vr == "unkn")
- { // Unknown was 'written'
- shortLgr=lgr;
+
+ if (gr == 0xfffe) { // NO Value Representation for 'delimiters'
+ // no length : write ffffffff
+ fwrite (&ff,(size_t)4 ,(size_t)1 ,_fp);
+ continue; // NO value for 'delimiters'
+ }
+
+ shortLgr=lgr;
+ if (vr == "unkn") { // Unknown was 'written'
+ // deal with Little Endian
fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,_fp);
fwrite ( &z, (size_t)2 ,(size_t)1 ,_fp);
- }
- else
- {
- if (gr != 0xfffe)
- { // NO value for 'delimiters'
- if (vr == "unkn") // Unknown was 'written'
- fwrite(&z,(size_t)2 ,(size_t)1 ,_fp);
- else
- fwrite (vr.c_str(),(size_t)2 ,(size_t)1 ,_fp);
- }
-
- if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") || gr == 0xfffe)
- {
- if (gr != 0xfffe)
+ } else {
+ fwrite (vr.c_str(),(size_t)2 ,(size_t)1 ,_fp);
+ if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ){
fwrite ( &z, (size_t)2 ,(size_t)1 ,_fp);
fwrite ( &lgr,(size_t)4 ,(size_t)1 ,_fp);
- }
- else
- {
- shortLgr=lgr;
- fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,_fp);
- }
+ } else {
+ fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,_fp);
+ }
}
}
else // IMPLICIT VR
// === Deal with the value
// -------------------
if (vr == "SQ") continue; // no "value" to write for the SEQuences
- if (gr == 0xfffe)continue;
+ if (gr == 0xfffe)continue; // no "value" to write for the delimiters
if (voidArea != NULL)
{ // there is a 'non string' LUT, overlay, etc
}
}
+
+/**
+ * \ingroup gdcmParser
+ * \brief writes on disc according to the requested format
+ * (ACR-NEMA, ExplicitVR, ImplicitVR) the image
+ * \warning Uses the H Table, instead of the Chained List
+ * in order to be compliant with the old way to proceed
+ * (added elements taken in to account)
+ * Only THERALYS, during a transitory phase is supposed
+ * to use this method !!!
+ * \warning DON'T try, right now, to write a DICOM image
+ * from an ACR Header (meta elements will be missing!)
+ * @param _fp already open file pointer
+ * @param type type of the File to be written
+ * (ACR-NEMA, ExplicitVR, ImplicitVR)
+ */
+void gdcmParser::WriteEntriesDeprecated(FILE *_fp,FileType type) {
+ guint16 gr, el;
+ guint32 lgr;
+ const char * val;
+ std::string vr;
+ guint32 val_uint32;
+ guint16 val_uint16;
+
+ std::vector<std::string> tokens;
+
+ void *ptr;
+
+ // Tout ceci ne marche QUE parce qu'on est sur un proc Little Endian
+ // restent a tester les echecs en ecriture (apres chaque fwrite)
+
+ for (TagHeaderEntryHT::iterator tag2=tagHT.begin();
+ tag2 != tagHT.end();
+ ++tag2){
+
+ gr = tag2->second->GetGroup();
+ el = tag2->second->GetElement();
+ lgr = tag2->second->GetLength();
+ val = tag2->second->GetValue().c_str();
+ vr = tag2->second->GetVR();
+
+ // std::cout << "Tag "<< std::hex << gr << " " << el << std::endl;
+
+ if ( type == ACR ) {
+ if (gr < 0x0008) continue; // ignore pure DICOM V3 groups
+ if (gr %2) continue; // ignore shadow groups
+ if (vr == "SQ" ) continue; // ignore Sequences
+ if (gr == 0xfffe ) continue; // ignore delimiters
+ }
+
+ fwrite ( &gr,(size_t)2 ,(size_t)1 ,_fp); //group
+ fwrite ( &el,(size_t)2 ,(size_t)1 ,_fp); //element
+
+ if ( (type == ExplicitVR) && (gr <= 0x0002) ) {
+ // EXPLICIT VR
+ guint16 z=0, shortLgr;
+ fwrite (vr.c_str(),(size_t)2 ,(size_t)1 ,_fp);
+
+ if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ) {
+ fwrite ( &z, (size_t)2 ,(size_t)1 ,_fp);
+ fwrite ( &lgr,(size_t)4 ,(size_t)1 ,_fp);
+
+ } else {
+ shortLgr=lgr;
+ fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,_fp);
+ }
+ } else { // IMPLICIT VR
+ fwrite ( &lgr,(size_t)4 ,(size_t)1 ,_fp);
+ }
+
+ if (vr == "US" || vr == "SS") {
+ tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
+ Tokenize (tag2->second->GetValue(), tokens, "\\");
+ for (unsigned int i=0; i<tokens.size();i++) {
+ val_uint16 = atoi(tokens[i].c_str());
+ ptr = &val_uint16;
+ fwrite ( ptr,(size_t)2 ,(size_t)1 ,_fp);
+ }
+ tokens.clear();
+ continue;
+ }
+ if (vr == "UL" || vr == "SL") {
+ tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
+ Tokenize (tag2->second->GetValue(), tokens, "\\");
+ for (unsigned int i=0; i<tokens.size();i++) {
+ val_uint32 = atoi(tokens[i].c_str());
+ ptr = &val_uint32;
+ fwrite ( ptr,(size_t)4 ,(size_t)1 ,_fp);
+ }
+ tokens.clear();
+ continue;
+ }
+ // Pixels are never loaded in the element !
+ if ((gr == 0x7fe0) && (el == 0x0010) ) break;
+
+ fwrite ( val,(size_t)lgr ,(size_t)1 ,_fp); // Elem value
+ }
+}
+
+
+
+
+
+
/**
* \ingroup gdcmParser
* \brief Swaps back the bytes of 4-byte long integer accordingly to
guint16 group = Entry->GetGroup();
std::string vr = Entry->GetVR();
guint16 length16;
+
if( (element == NumPixel) && (group == GrPixel) )
{
dbg.SetDebug(GDCM_DEBUG);
// Actually, length= 0xffff means that we deal with
// Unknown Sequence Length
}
-
FixHeaderEntryFoundLength(Entry, (guint32)length16);
return;
}
else
{
- // Either implicit VR or a non DICOM conformal (see not below) explicit
+ // Either implicit VR or a non DICOM conformal (see note below) explicit
// VR that ommited the VR of (at least) this element. Farts happen.
// [Note: according to the part 5, PS 3.5-2001, section 7.1 p25
// on Data elements "Implicit and Explicit VR Data Elements shall
// not coexist in a Data Set and Data Sets nested within it".]
// Length is on 4 bytes.
+
FixHeaderEntryFoundLength(Entry, ReadInt32());
return;
}
else if(Entry->GetGroup() == 0xfffe)
{
+ // cout << "ReadLength " <<Entry->GetReadLength() << " UsableLength " << FoundLength << endl;
+ // Entry->Print();
// sometimes, length seems to be wrong
FoundLength =0; // some more clever checking to be done !
// I give up!
// only gdcm-MR-PHILIPS-16-Multi-Seq.dcm
- // causes troubles :-(
+ // causes troubles :-(
}
Entry->SetUsableLength(FoundLength);
virtual std::string GetEntryVRByName (std::string tagName);
virtual std::string GetEntryByNumber (guint16 group, guint16 element);
virtual std::string GetEntryVRByNumber(guint16 group, guint16 element);
+ virtual int GetEntryLengthByNumber(guint16 group, guint16 element);
virtual bool SetEntryByName (std::string content, std::string tagName);
virtual bool SetEntryByNumber(std::string content, guint16 group, guint16 element);
void UpdateGroupLength(bool SkipSequence = false, FileType type = ImplicitVR);
void WriteEntries(FILE *_fp,FileType type);
+ void WriteEntriesDeprecated(FILE *_fp,FileType type); // JPR
+
+ void AddHeaderEntry (gdcmHeaderEntry *);
// Variables
FILE *fp;
void LoadHeaderEntries (void);
void LoadHeaderEntry (gdcmHeaderEntry *);
- void AddHeaderEntry (gdcmHeaderEntry *);
void FindHeaderEntryLength(gdcmHeaderEntry *);
void FindHeaderEntryVR (gdcmHeaderEntry *);
bool CheckHeaderEntryVR (gdcmHeaderEntry *, VRKey);
-// gdcmSerie.h
+// gdcmDicomDirSerie.h
//-----------------------------------------------------------------------------
-#ifndef GDCMSERIE_H
-#define GDCMSERIE_H
+#ifndef GDCMDICOMDIRSERIE_H
+#define GDCMDICOMDIRSERIE_H
#include "gdcmObject.h"
-#include "gdcmImage.h"
+#include "gdcmDicomDirImage.h"
//-----------------------------------------------------------------------------
-typedef std::list<gdcmImage *> ListImage;
+typedef std::list<gdcmDicomDirImage *> ListDicomDirImage;
//-----------------------------------------------------------------------------
-class GDCM_EXPORT gdcmSerie : public gdcmObject
+class GDCM_EXPORT gdcmDicomDirSerie : public gdcmObject
{
public:
- gdcmSerie(ListTag::iterator begin,ListTag::iterator end);
- ~gdcmSerie(void);
+ gdcmDicomDirSerie(ListTag::iterator begin,ListTag::iterator end);
+ ~gdcmDicomDirSerie(void);
virtual void Print(std::ostream &os = std::cout);
- inline ListImage &GetImages() {return images;};
- inline void AddImage(gdcmImage *obj) {images.push_back(obj);};
+ inline ListDicomDirImage &GetDicomDirImages() {return images;};
+ inline void AddDicomDirImage(gdcmDicomDirImage *obj) {images.push_back(obj);};
private:
- ListImage images;
+ ListDicomDirImage images;
};
//-----------------------------------------------------------------------------
+++ /dev/null
-// gdcmStudy.h
-//-----------------------------------------------------------------------------
-#ifndef GDCMSTUDY_H
-#define GDCMSTUDY_H
-
-#include "gdcmObject.h"
-#include "gdcmSerie.h"
-
-//-----------------------------------------------------------------------------
-typedef std::list<gdcmSerie *> ListSerie;
-
-//-----------------------------------------------------------------------------
-class GDCM_EXPORT gdcmStudy : public gdcmObject
-{
-public:
- gdcmStudy(ListTag::iterator begin,ListTag::iterator end);
- ~gdcmStudy(void);
-
- virtual void Print(std::ostream &os = std::cout);
-
- inline ListSerie &GetSeries() {return series;};
- inline void AddSerie(gdcmSerie *obj) {series.push_back(obj);};
-
-private:
- ListSerie series;
-};
-
-//-----------------------------------------------------------------------------
-#endif
gdcmGlobal gdcmGlob;
gdcmGlobal::gdcmGlobal(void) {
- if (VR || TS || Dicts)
+ if (VR || TS || Dicts || ddElem)
dbg.Verbose(0, "gdcmGlobal::gdcmGlobal : VR or TS or Dicts already allocated");
- Dicts = new gdcmDictSet();
- VR = new gdcmVR();
- TS = new gdcmTS();
+ Dicts = new gdcmDictSet();
+ VR = new gdcmVR();
+ TS = new gdcmTS();
ddElem = new gdcmDicomDirElement();
}