Program: gdcm
Module: $RCSfile: gdcmBinEntry.cxx,v $
Language: C++
- Date: $Date: 2004/06/25 12:58:24 $
- Version: $Revision: 1.19 $
+ Date: $Date: 2004/08/01 00:59:21 $
+ Version: $Revision: 1.20 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
*/
gdcmBinEntry::gdcmBinEntry(gdcmDictEntry* e) : gdcmValEntry(e)
{
- this->voidArea = NULL;
+ voidArea = NULL;
}
/**
*/
gdcmBinEntry::gdcmBinEntry(gdcmDocEntry* e) : gdcmValEntry(e->GetDictEntry())
{
- this->UsableLength = e->GetLength();
- this->ReadLength = e->GetReadLength();
- this->ImplicitVR = e->IsImplicitVR();
- this->Offset = e->GetOffset();
- this->printLevel = e->GetPrintLevel();
- this->SQDepthLevel = e->GetDepthLevel();
+ UsableLength = e->GetLength();
+ ReadLength = e->GetReadLength();
+ ImplicitVR = e->IsImplicitVR();
+ Offset = e->GetOffset();
+ printLevel = e->GetPrintLevel();
+ SQDepthLevel = e->GetDepthLevel();
- this->voidArea = NULL; // let's be carefull !
+ voidArea = NULL; // let's be carefull !
}
/**
* \brief Canonical destructor.
*/
-gdcmBinEntry::~gdcmBinEntry(){
+gdcmBinEntry::~gdcmBinEntry()
+{
if (voidArea)
+ {
free (voidArea);
+ voidArea = NULL; // let's be carefull !
+ }
}
gdcmDocEntry::Print(os);
std::ostringstream s;
void *voidArea = GetVoidArea();
- if (voidArea != NULL)
+ if (voidArea)
{
s << " [gdcm::Binary data loaded with length is "
<< GetLength() << "]";
else
{
if ( GetLength() == 0 )
+ {
s << " []";
+ }
else
{
s << " [gdcm::Binary data NOT loaded]";
/*
* \brief canonical Writer
*/
-void gdcmBinEntry::Write(FILE *fp, FileType filetype) {
+void gdcmBinEntry::Write(FILE *fp, FileType filetype)
+{
gdcmDocEntry::Write(fp, filetype);
void *voidArea = GetVoidArea();
- int lgr=GetLength();
- if (voidArea != NULL)
- { // there is a 'non string' LUT, overlay, etc
+ int lgr = GetLength();
+ if (voidArea)
+ {
+ // there is a 'non string' LUT, overlay, etc
fwrite ( voidArea,(size_t)lgr ,(size_t)1 ,fp); // Elem value
- return;
- }
+ }
}
//-----------------------------------------------------------------------------
// Public
Program: gdcm
Module: $RCSfile: gdcmDicomDirPatient.cxx,v $
Language: C++
- Date: $Date: 2004/06/20 18:08:47 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2004/08/01 00:59:21 $
+ Version: $Revision: 1.9 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
*/
void gdcmDicomDirPatient::Print(std::ostream &os)
{
- os<<"PATIENT"<<std::endl;
+ os << "PATIENT" << std::endl;
gdcmObject::Print(os);
- for(ListDicomDirStudy::iterator cc = studies.begin();cc!=studies.end();++cc)
+ for(ListDicomDirStudy::iterator cc = studies.begin();
+ cc != studies.end(); ++cc)
{
- (*cc)->SetPrintLevel(printLevel);
+ (*cc)->SetPrintLevel(PrintLevel);
(*cc)->Print(os);
}
}
* \brief adds a new Patient at the begining of the PatientList
* of a partially created DICOMDIR
*/
-gdcmDicomDirStudy * gdcmDicomDirPatient::NewStudy(void) {
- std::list<gdcmElement> elemList;
- elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements();
+gdcmDicomDirStudy * gdcmDicomDirPatient::NewStudy()
+{
+ std::list<gdcmElement> elemList =
+ gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements();
- gdcmDicomDirStudy *st = new gdcmDicomDirStudy( ptagHT);
+ gdcmDicomDirStudy *st = new gdcmDicomDirStudy( PtagHT );
st->FillObject(elemList);
studies.push_front(st);
return st;
-
-
}
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmDicomDirSerie.cxx,v $
Language: C++
- Date: $Date: 2004/07/21 14:02:10 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2004/08/01 00:59:21 $
+ Version: $Revision: 1.12 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
*/
gdcmDicomDirSerie::~gdcmDicomDirSerie()
{
- for(ListDicomDirImage::iterator cc = images.begin();cc != images.end();++cc)
+ for(ListDicomDirImage::iterator cc = images.begin();
+ cc != images.end();
+ ++cc)
{
delete *cc;
}
*/
void gdcmDicomDirSerie::Print(std::ostream &os)
{
- os<<"SERIE"<<std::endl;
+ os << "SERIE" << std::endl;
gdcmObject::Print(os);
- for(ListDicomDirImage::iterator cc = images.begin();cc != images.end();++cc)
+ for(ListDicomDirImage::iterator cc = images.begin();
+ cc != images.end();
+ ++cc)
{
- (*cc)->SetPrintLevel(printLevel);
+ (*cc)->SetPrintLevel(PrintLevel);
(*cc)->Print(os);
}
}
/**
* \brief adds a new Image (with the basic elements) to a partially created DICOMDIR
*/
-gdcmDicomDirImage * gdcmDicomDirSerie::NewImage(void) {
- std::list<gdcmElement> elemList;
- elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements();
-
- gdcmDicomDirImage *st = new gdcmDicomDirImage(ptagHT);
+gdcmDicomDirImage * gdcmDicomDirSerie::NewImage()
+{
+ std::list<gdcmElement> elemList =
+ gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements();
+
+ gdcmDicomDirImage *st = new gdcmDicomDirImage(PtagHT);
FillObject(elemList);
images.push_front(st);
+
return st;
}
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmDicomDirStudy.cxx,v $
Language: C++
- Date: $Date: 2004/06/20 18:08:47 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2004/08/01 00:59:21 $
+ Version: $Revision: 1.8 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
os<<"STUDY"<<std::endl;
gdcmObject::Print(os);
- for(ListDicomDirSerie::iterator cc = series.begin();cc != series.end();++cc)
+ for(ListDicomDirSerie::iterator cc = series.begin();
+ cc != series.end();
+ ++cc)
{
- (*cc)->SetPrintLevel(printLevel);
+ (*cc)->SetPrintLevel(PrintLevel);
(*cc)->Print(os);
}
}
* \brief adds a new Serie at the begining of the SerieList
* of a partially created DICOMDIR
*/
-gdcmDicomDirSerie * gdcmDicomDirStudy::NewSerie(void) {
-
- std::list<gdcmElement> elemList;
- elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements();
+gdcmDicomDirSerie * gdcmDicomDirStudy::NewSerie()
+{
+ std::list<gdcmElement> elemList =
+ gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements();
- gdcmDicomDirSerie *st = new gdcmDicomDirSerie(ptagHT);
+ gdcmDicomDirSerie *st = new gdcmDicomDirSerie(PtagHT);
FillObject(elemList);
series.push_front(st);
+
return st;
}
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmDictSet.cxx,v $
Language: C++
- Date: $Date: 2004/07/02 13:55:27 $
- Version: $Revision: 1.32 $
+ Date: $Date: 2004/08/01 00:59:21 $
+ Version: $Revision: 1.33 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* \brief The Dictionnary Set obtained with this constructor simply
* contains the Default Public dictionnary.
*/
-gdcmDictSet::gdcmDictSet(void)
+gdcmDictSet::gdcmDictSet()
{
DictPath = BuildDictPath();
std::string PubDictFile(DictPath);
Program: gdcm
Module: $RCSfile: gdcmDictSet.h,v $
Language: C++
- Date: $Date: 2004/07/02 13:55:27 $
- Version: $Revision: 1.21 $
+ Date: $Date: 2004/08/01 00:59:21 $
+ Version: $Revision: 1.22 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* \par having many in memory representations of the same dictionary
* (saving memory).
*/
-class GDCM_EXPORT gdcmDictSet {
+class GDCM_EXPORT gdcmDictSet
+{
public:
// TODO Swig int LoadDictFromFile(std::string filename);
// QUESTION: the following function might not be thread safe !? Maybe
// TODO Swig int LoadDictFromName(std::string filename);
// TODO Swig int LoadAllDictFromDirectory(std::string DirectoryName);
// TODO Swig std::string* GetAllDictNames();
- gdcmDictSet(void);
- ~gdcmDictSet(void);
+ gdcmDictSet();
+ ~gdcmDictSet();
void Print(std::ostream& os);
- std::list<std::string> *GetPubDictEntryNames(void);
+ std::list<std::string> *GetPubDictEntryNames();
std::map<std::string, std::list<std::string> > *
- GetPubDictEntryNamesByCategory(void);
+ GetPubDictEntryNamesByCategory();
gdcmDict *LoadDictFromFile(std::string FileName, DictKey Name);
gdcmDict *GetDict(DictKey DictName);
- gdcmDict *GetDefaultPubDict(void);
+ gdcmDict *GetDefaultPubDict();
gdcmDictEntry *NewVirtualDictEntry(uint16_t group, uint16_t element,
std::string vr = "Unknown",
std::string fourth = "Unknown",
std::string name = "Unknown");
- static std::string BuildDictPath(void);
+ static std::string BuildDictPath();
protected:
bool AppendDict(gdcmDict *NewDict,DictKey Name);
Program: gdcm
Module: $RCSfile: gdcmDirList.cxx,v $
Language: C++
- Date: $Date: 2004/07/26 19:36:56 $
- Version: $Revision: 1.18 $
+ Date: $Date: 2004/08/01 00:59:21 $
+ Version: $Revision: 1.19 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
}
else
{
- this->push_back(dirName+fileName);
+ push_back(dirName+fileName);
numberOfFiles++;
}
stat(fileName.c_str(), &buf); //really discard output ?
if( S_ISREG(buf.st_mode) ) //is it a regular file?
{
- this->push_back( fileName );
+ push_back( fileName );
numberOfFiles++;
}
else if( S_ISDIR(buf.st_mode) ) //directory?
Program: gdcm
Module: $RCSfile: gdcmDocEntry.cxx,v $
Language: C++
- Date: $Date: 2004/07/02 13:55:27 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2004/08/01 00:59:21 $
+ Version: $Revision: 1.14 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* \brief Constructor from a given gdcmDictEntry
* @param in Pointer to existing dictionary entry
*/
-gdcmDocEntry::gdcmDocEntry(gdcmDictEntry* in) {
+gdcmDocEntry::gdcmDocEntry(gdcmDictEntry* in)
+{
ImplicitVR = false;
entry = in;
}
* \brief Prints the common part of gdcmValEntry, gdcmBinEntry, gdcmSeqEntry
* @param os ostream we want to print in
*/
-void gdcmDocEntry::Print(std::ostream & os) {
-
+void gdcmDocEntry::Print(std::ostream & os)
+{
printLevel=2; // FIXME
size_t o;
sprintf(greltag,"%04x|%04x ",g,e);
s << greltag ;
- if (printLevel>=2) {
+ if (printLevel>=2)
+ {
s << "lg : ";
lgth = GetReadLength(); // ReadLength, as opposed to UsableLength
- if (lgth == 0xffffffff) {
+ if (lgth == 0xffffffff)
+ {
sprintf(st,"x(ffff)"); // I said : "x(ffff)" !
s.setf(std::ios::left);
s << std::setw(10-strlen(st)) << " ";
s << st << " ";
s.setf(std::ios::left);
s << std::setw(8) << "-1";
- } else {
+ }
+ else
+ {
sprintf(st,"x(%x)",lgth);
s.setf(std::ios::left);
s << std::setw(10-strlen(st)) << " ";
s << "[" << vr << "] ";
- if (printLevel>=1) {
+ if (printLevel >= 1)
+ {
s.setf(std::ios::left);
s << std::setw(66-GetName().length()) << " ";
}
* \ingroup gdcmDocEntry
* \brief Writes the common part of any gdcmValEntry, gdcmBinEntry, gdcmSeqEntry
*/
-void gdcmDocEntry::Write(FILE *fp, FileType filetype) {
-
+void gdcmDocEntry::Write(FILE *fp, FileType filetype)
+{
uint32_t FFFF = 0xffffffff;
uint16_t group = GetGroup();
gdcmVRKey vr = GetVR();
uint16_t el = GetElement();
uint32_t lgr = GetReadLength();
- if ( (group == 0xfffe) && (el == 0x0000) )
+ if ( (group == 0xfffe) && (el == 0x0000) )
+ {
// Fix in order to make some MR PHILIPS images e-film readable
// see gdcmData/gdcm-MR-PHILIPS-16-Multi-Seq.dcm:
// we just *always* ignore spurious fffe|0000 tag !
- return;
+ return;
+ }
//
// ----------- Writes the common part
fwrite ( &group,(size_t)2 ,(size_t)1 ,fp); //group
fwrite ( &el, (size_t)2 ,(size_t)1 ,fp); //element
- if ( filetype == gdcmExplicitVR ) {
-
+ if ( filetype == gdcmExplicitVR )
+ {
// Special case of delimiters:
- if (group == 0xfffe) {
+ if (group == 0xfffe)
+ {
// Delimiters have NO Value Representation
// Hence we skip writing the VR.
// In order to avoid further troubles, we choose to write them
// TODO : verify if the Sequence Delimitor Item was forced during Parsing
- int ff=0xffffffff;
+ int ff = 0xffffffff;
fwrite (&ff,(size_t)4 ,(size_t)1 ,fp);
return;
}
- uint16_t z=0;
+ uint16_t z = 0;
uint16_t shortLgr = lgr;
- if (vr == "unkn") { // Unknown was 'written'
+ 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 {
+ }
+ else
+ {
fwrite (vr.c_str(),(size_t)2 ,(size_t)1 ,fp);
if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") || (vr == "UN") )
{
fwrite ( &z, (size_t)2 ,(size_t)1 ,fp);
- if (vr == "SQ") {
- // we set SQ length to ffffffff
- // and we shall write a Sequence Delimitor Item
- // at the end of the Sequence!
+ if (vr == "SQ")
+ {
+ // we set SQ length to ffffffff
+ // and we shall write a Sequence Delimitor Item
+ // at the end of the Sequence!
fwrite ( &FFFF,(size_t)4 ,(size_t)1 ,fp);
- } else {
+ }
+ else
+ {
fwrite ( &lgr,(size_t)4 ,(size_t)1 ,fp);
}
- } else {
+ }
+ else
+ {
fwrite ( &shortLgr,(size_t)2 ,(size_t)1 ,fp);
}
}
}
else // IMPLICIT VR
{
- if (vr == "SQ") {
- fwrite ( &FFFF,(size_t)4 ,(size_t)1 ,fp);
- } else {
- fwrite ( &lgr,(size_t)4 ,(size_t)1 ,fp);
- }
+ if (vr == "SQ")
+ {
+ fwrite ( &FFFF,(size_t)4 ,(size_t)1 ,fp);
+ }
+ else
+ {
+ fwrite ( &lgr,(size_t)4 ,(size_t)1 ,fp);
+ }
}
}
* \ingroup gdcmDocEntry
* \brief Gets the full length of the elementary DocEntry (not only value length)
*/
-uint32_t gdcmDocEntry::GetFullLength(void) {
- uint32_t l;
- l = GetReadLength();
- if ( IsImplicitVR() )
+uint32_t gdcmDocEntry::GetFullLength()
+{
+ uint32_t l = GetReadLength();
+ if ( IsImplicitVR() )
+ {
l = l + 8; // 2 (gr) + 2 (el) + 4 (lgth)
- else
+ }
+ else
+ {
if ( GetVR()=="OB" || GetVR()=="OW" || GetVR()=="SQ" )
+ {
l = l + 12; // 2 (gr) + 2 (el) + 2 (vr) + 2 (unused) + 4 (lgth)
+ }
else
+ {
l = l + 8; // 2 (gr) + 2 (el) + 2 (vr) + 2 (lgth)
- return(l);
+ }
+ }
+ return l;
}
/**
* \ingroup gdcmDocEntry
* \brief Copies all the attributes from an other DocEntry
*/
-void gdcmDocEntry::Copy (gdcmDocEntry* e) {
- this->entry = e->entry;
- this->UsableLength = e->UsableLength;
- this->ReadLength = e->ReadLength;
- this->ImplicitVR = e->ImplicitVR;
- this->Offset = e->Offset;
- this->printLevel = e->printLevel;
+void gdcmDocEntry::Copy (gdcmDocEntry* e)
+{
+ entry = e->entry;
+ UsableLength = e->UsableLength;
+ ReadLength = e->ReadLength;
+ ImplicitVR = e->ImplicitVR;
+ Offset = e->Offset;
+ printLevel = e->printLevel;
// TODO : remove gdcmDocEntry SQDepth
}
* \brief tells us if entry is the last one of a 'no length' SequenceItem
* (fffe,e00d)
*/
-bool gdcmDocEntry::isItemDelimitor() {
- if ( (GetGroup() == 0xfffe) && (GetElement() == 0xe00d) )
- return true;
- else
- return false;
+bool gdcmDocEntry::isItemDelimitor()
+{
+ return (GetGroup() == 0xfffe && GetElement() == 0xe00d);
}
/**
* \ingroup gdcmDocEntry
* \brief tells us if entry is the last one of a 'no length' Sequence
* (fffe,e0dd)
*/
-bool gdcmDocEntry::isSequenceDelimitor() {
- if (GetGroup() == 0xfffe && GetElement() == 0xe0dd)
- return true;
- else
- return false;
+bool gdcmDocEntry::isSequenceDelimitor()
+{
+ return (GetGroup() == 0xfffe && GetElement() == 0xe0dd);
}
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmDocEntry.h,v $
Language: C++
- Date: $Date: 2004/07/31 18:43:43 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2004/08/01 00:59:21 $
+ Version: $Revision: 1.15 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
public:
gdcmDocEntry(gdcmDictEntry*);
-
+
/// Returns the Dicom Group number of the current Dicom Header Entry
uint16_t GetGroup() { return entry->GetGroup(); };
void SetPrintLevel(int level) { printLevel = level; };
/// \brief Gets the print level for the Dicom Header Elements
- int GetPrintLevel() { return(printLevel); };
+ int GetPrintLevel() { return printLevel; };
virtual void Print (std::ostream & os = std::cout);
virtual void Write(FILE *fp, FileType filetype);
Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2004/07/31 23:30:04 $
- Version: $Revision: 1.61 $
+ Date: $Date: 2004/08/01 00:59:21 $
+ Version: $Revision: 1.62 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
bool gdcmDocument::operator<(gdcmDocument &document)
{
// Patient Name
- std::string s1 = this->GetEntryByNumber(0x0010,0x0010);
+ std::string s1 = GetEntryByNumber(0x0010,0x0010);
std::string s2 = document.GetEntryByNumber(0x0010,0x0010);
if(s1 < s2)
{
else
{
// Patient ID
- s1 = this->GetEntryByNumber(0x0010,0x0020);
+ s1 = GetEntryByNumber(0x0010,0x0020);
s2 = document.GetEntryByNumber(0x0010,0x0020);
if ( s1 < s2 )
{
else
{
// Study Instance UID
- s1 = this->GetEntryByNumber(0x0020,0x000d);
+ s1 = GetEntryByNumber(0x0020,0x000d);
s2 = document.GetEntryByNumber(0x0020,0x000d);
if ( s1 < s2 )
{
else
{
// Serie Instance UID
- s1 = this->GetEntryByNumber(0x0020,0x000e);
+ s1 = GetEntryByNumber(0x0020,0x000e);
s2 = document.GetEntryByNumber(0x0020,0x000e);
if ( s1 < s2 )
{
Program: gdcm
Module: $RCSfile: gdcmHeaderHelper.cxx,v $
Language: C++
- Date: $Date: 2004/06/25 20:48:25 $
- Version: $Revision: 1.40 $
+ Date: $Date: 2004/08/01 00:59:21 $
+ Version: $Revision: 1.41 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
void gdcmSerieHeader::AddFileName(std::string const & filename)
{
gdcmHeader *header = new gdcmHeader( filename );
- this->CoherentGdcmFileList.push_back( header );
+ CoherentGdcmFileList.push_back( header );
}
/**
*/
void gdcmSerieHeader::AddGdcmFile(gdcmHeader *file)
{
- this->CoherentGdcmFileList.push_back( file );
+ CoherentGdcmFileList.push_back( file );
}
/**
{
//use string and not const char*:
gdcmHeader *header = new gdcmHeader( *it );
- this->CoherentGdcmFileList.push_back( header );
+ CoherentGdcmFileList.push_back( header );
}
}
Program: gdcm
Module: $RCSfile: gdcmObject.cxx,v $
Language: C++
- Date: $Date: 2004/07/21 14:02:10 $
- Version: $Revision: 1.23 $
+ Date: $Date: 2004/08/01 00:59:21 $
+ Version: $Revision: 1.24 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
*/
gdcmObject::gdcmObject(TagDocEntryHT *ptagHT, int depth)
- : gdcmSQItem (depth) {
- this->ptagHT = ptagHT;
+ : gdcmSQItem (depth)
+{
+ PtagHT = ptagHT;
}
* \ingroup gdcmObject
* \brief Canonical destructor.
*/
-gdcmObject::~gdcmObject(void) {
+gdcmObject::~gdcmObject()
+{
}
* related to this 'object'
* @return
*/
-TagDocEntryHT gdcmObject::GetEntry(void) {
+TagDocEntryHT gdcmObject::GetEntry()
+{
TagDocEntryHT HT;
docEntries=GetDocEntries();
- for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i) {
+ for(ListDocEntry::iterator i = docEntries.begin();
+ i != docEntries.end(); ++i)
+ {
HT[(*i)->GetKey()]=*i;
}
- return(HT);
+ return HT;
}
//-----------------------------------------------------------------------------
* \brief add the 'Object' related Dicom Elements to the listEntries
* of a partially created DICOMDIR
*/
-void gdcmObject::FillObject(std::list<gdcmElement> elemList) {
-
+void gdcmObject::FillObject(std::list<gdcmElement> elemList)
+{
// FillObject rempli le SQItem qui sera accroche au bon endroit
std::list<gdcmElement>::iterator it;
gdcmValEntry *entry;
// for all the Elements found in they own part of the DicomDir dict.
- for(it=elemList.begin();it!=elemList.end();++it)
+ for(it = elemList.begin(); it != elemList.end(); ++it)
{
- tmpGr=it->group;
- tmpEl=it->elem;
- dictEntry=gdcmGlobal::GetDicts()->GetDefaultPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
- entry=new gdcmValEntry(dictEntry);
+ tmpGr = it->group;
+ tmpEl = it->elem;
+ dictEntry = gdcmGlobal::GetDicts()->GetDefaultPubDict()->GetDictEntryByNumber(tmpGr,tmpEl);
+ entry = new gdcmValEntry(dictEntry);
entry->SetOffset(0); // just to avoid further missprinting
entry->SetValue(it->value);
{
entry->SetLength(entry->GetValue().length());
}
- else if( (dictEntry->GetVR()=="UL") || (dictEntry->GetVR()=="SL") )
+ else if( dictEntry->GetVR() == "UL" || dictEntry->GetVR() == "SL" )
{
entry->SetLength(4);
}
- else if( (dictEntry->GetVR()=="US") || (dictEntry->GetVR()=="SS") )
+ else if( dictEntry->GetVR() == "US" || dictEntry->GetVR() == "SS" )
{
entry->SetLength(2);
}
- else if(dictEntry->GetVR()=="SQ")
+ else if( dictEntry->GetVR() == "SQ" )
{
entry->SetLength(0xffffffff);
}
Program: gdcm
Module: $RCSfile: gdcmObject.h,v $
Language: C++
- Date: $Date: 2004/06/20 18:08:48 $
- Version: $Revision: 1.17 $
+ Date: $Date: 2004/08/01 00:59:21 $
+ Version: $Revision: 1.18 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
class GDCM_EXPORT gdcmObject : public gdcmSQItem
{
public:
-
/**
* \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; };
+ void SetPrintLevel(int level) { PrintLevel = level; };
- TagDocEntryHT GetEntry(void);
+ TagDocEntryHT GetEntry();
void FillObject(std::list<gdcmElement> elemList);
protected:
// Constructor and destructor are protected to avoid end user to
// instanciate from this class.
gdcmObject(TagDocEntryHT *ptagHT, int depth = 0);
- virtual ~gdcmObject(void);
+ virtual ~gdcmObject();
// Members :
///\brief detail level to be printed
- int printLevel;
-
-private:
+ int PrintLevel;
};
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmSQItem.cxx,v $
Language: C++
- Date: $Date: 2004/07/17 22:47:01 $
- Version: $Revision: 1.21 $
+ Date: $Date: 2004/08/01 00:59:21 $
+ Version: $Revision: 1.22 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* \brief Constructor from a given gdcmSQItem
*/
gdcmSQItem::gdcmSQItem(int depthLevel )
- : gdcmDocEntrySet(depthLevel) {
+ : gdcmDocEntrySet(depthLevel)
+{
SQDepthLevel = depthLevel +1;
}
/*
* \brief canonical Printer
*/
- void gdcmSQItem::Print(std::ostream & os) {
+ void gdcmSQItem::Print(std::ostream & os)
+ {
std::ostringstream s;
- if (SQDepthLevel>0)
+ if (SQDepthLevel > 0)
{
- for (int i=0;i<SQDepthLevel;i++)
+ for (int i = 0; i < SQDepthLevel; ++i)
+ {
s << " | " ;
+ }
}
std::cout << s.str() << " --- SQItem number " << SQItemNumber << std::endl;
- for (ListDocEntry::iterator i = docEntries.begin();
+ for (ListDocEntry::iterator i = docEntries.begin();
i != docEntries.end();
++i)
{
PrintEndLine = false;
}
if (PrintEndLine)
+ {
os << std::endl;
+ }
}
}
// It will be written outside, because ALL the SQItems are written
// as 'no length'
if ( (*i)->isItemDelimitor() )
+ {
break;
+ }
// Fix in order to make some MR PHILIPS images e-film readable
// see gdcmData/gdcm-MR-PHILIPS-16-Multi-Seq.dcm:
// we just *always* ignore spurious fffe|0000 tag !
- if ( ((*i)->GetGroup() == 0xfffe) && ((*i)->GetElement() == 0x0000) )
- break;
+ if ( (*i)->GetGroup() == 0xfffe && (*i)->GetElement() == 0x0000 )
+ {
+ break;
+ }
// It's up to the gdcmDocEntry Writter to write the SQItem begin element
// (fffe|e000) as a 'no length' one
bool gdcmSQItem::SetEntryByNumber(std::string val,uint16_t group,
uint16_t element)
{
- for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i)
+ for(ListDocEntry::iterator i = docEntries.begin(); i != docEntries.end(); ++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 gdcmDocument :-(
- gdcmValEntry* Entry = (gdcmValEntry*)0;
+ gdcmValEntry* entry = 0;
gdcmTagKey key = gdcmDictEntry::TranslateToKey(group, element);
- if ( ! ptagHT->count(key))
+ if ( ! PtagHT->count(key))
{
// we assume a Public Dictionnary *is* loaded
- gdcmDict *PubDict = gdcmGlobal::GetDicts()->GetDefaultPubDict();
+ 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,
+ gdcmDictEntry *dictEntry = pubDict->GetDictEntryByNumber(group,
element);
- if (DictEntry == NULL)
+ if (dictEntry == NULL)
{
- DictEntry=gdcmGlobal::GetDicts()->NewVirtualDictEntry(group,
- element,
- "UN",
- "??","??");
+ dictEntry =
+ gdcmGlobal::GetDicts()->NewVirtualDictEntry(group, element,
+ "UN", "??", "??");
}
// we assume the constructor didn't fail
- Entry = new gdcmValEntry(DictEntry);
+ entry = new gdcmValEntry(dictEntry);
/// \todo
/// ----
/// better we don't assume too much !
/// gdcmSQItem is now used to describe any DICOMDIR related object
- } else {
- gdcmDocEntry* FoundEntry = ptagHT->find(key)->second;
- Entry = dynamic_cast<gdcmValEntry*>(FoundEntry);
- if (!Entry)
+ }
+ else
+ {
+ gdcmDocEntry* foundEntry = PtagHT->find(key)->second;
+ entry = dynamic_cast<gdcmValEntry*>(foundEntry);
+ if (!entry)
+ {
dbg.Verbose(0, "gdcmSQItem::SetEntryByNumber: docEntries"
" contains non gdcmValEntry occurences");
+ }
}
- if (Entry)
- Entry->SetValue(val);
- Entry->SetLength(val.length());
- docEntries.insert(i,Entry);
+ if (entry)
+ {
+ entry->SetValue(val);
+ }
+ entry->SetLength(val.length());
+ docEntries.insert(i,entry);
+
return true;
}
if (group == (*i)->GetGroup() && element == (*i)->GetElement() )
{
- if ( gdcmValEntry* Entry = dynamic_cast<gdcmValEntry*>(*i) )
- Entry->SetValue(val);
+ if ( gdcmValEntry* entry = dynamic_cast<gdcmValEntry*>(*i) )
+ {
+ entry->SetValue(val);
+ }
(*i)->SetLength(val.length());
return true;
}
*/
gdcmDocEntry *gdcmSQItem::GetDocEntryByNumber(uint16_t group, uint16_t element)
{
- for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i)
+ for(ListDocEntry::iterator i = docEntries.begin();
+ i != docEntries.end(); ++i)
{
- if ( (*i)->GetGroup()==group && (*i)->GetElement()==element)
+ if ( (*i)->GetGroup() == group && (*i)->GetElement() == element )
{
- return (*i);
+ return *i;
}
- }
- return NULL;
+ }
+ return 0;
}
/**
*/
std::string gdcmSQItem::GetEntryByNumber(uint16_t group, uint16_t element)
-{
- for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i)
+{
+ for(ListDocEntry::iterator i = docEntries.begin();
+ i != docEntries.end(); ++i)
{
- if ( (*i)->GetGroup()==group && (*i)->GetElement()==element)
+ if ( (*i)->GetGroup() == group && (*i)->GetElement() == element)
{
- return ((gdcmValEntry *)(*i))->GetValue();
+ return ((gdcmValEntry *)(*i))->GetValue(); //FIXME
}
- }
+ }
return GDCM_UNFOUND;
}
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmSQItem.h,v $
Language: C++
- Date: $Date: 2004/07/19 11:51:26 $
- Version: $Revision: 1.12 $
+ Date: $Date: 2004/08/01 00:59:22 $
+ Version: $Revision: 1.13 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
public:
gdcmSQItem(int);
- ~gdcmSQItem(void);
+ ~gdcmSQItem();
virtual void Print(std::ostream &os = std::cout);
virtual void Write(FILE *fp, FileType filetype);
int GetSQItemNumber() { return SQItemNumber; };
- void SetSQItemNumber(int itemNumber) { SQItemNumber=itemNumber; };
+ void SetSQItemNumber(int itemNumber) { SQItemNumber = itemNumber; };
protected:
///\brief pointer to the HTable of the gdcmDocument,
/// (because we don't know it within any gdcmObject nor any gdcmSQItem)
- TagDocEntryHT *ptagHT;
+ TagDocEntryHT *PtagHT;
private:
Program: gdcm
Module: $RCSfile: gdcmValEntry.cxx,v $
Language: C++
- Date: $Date: 2004/07/20 08:29:13 $
- Version: $Revision: 1.18 $
+ Date: $Date: 2004/08/01 00:59:22 $
+ Version: $Revision: 1.19 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
*/
gdcmValEntry::gdcmValEntry(gdcmDocEntry* e) : gdcmDocEntry(e->GetDictEntry())
{
- this->UsableLength = e->GetLength();
- this->ReadLength = e->GetReadLength();
- this->ImplicitVR = e->IsImplicitVR();
- this->Offset = e->GetOffset();
- this->printLevel = e->GetPrintLevel();
- this->SQDepthLevel = e->GetDepthLevel();
+ UsableLength = e->GetLength();
+ ReadLength = e->GetReadLength();
+ ImplicitVR = e->IsImplicitVR();
+ Offset = e->GetOffset();
+ printLevel = e->GetPrintLevel();
+ SQDepthLevel = e->GetDepthLevel();
- this->voidArea = NULL; // will be in BinEntry ?
+ voidArea = NULL; // will be in BinEntry ?
}
/**
* \brief Canonical destructor.
*/
-gdcmValEntry::~gdcmValEntry (void)
+gdcmValEntry::~gdcmValEntry ()
{
if (!voidArea) // will be in BinEntry
+ {
free(voidArea);
+ voidArea = NULL; // let's be carefull !
+ }
}
-
//-----------------------------------------------------------------------------
// Print
/**
// Display the UID value (instead of displaying only the rough code)
// First 'clean' trailing character (space or zero)
- if (g == 0x0002) { // Any more to be displayed ?
- if ( (e == 0x0010) || (e == 0x0002) ) {
+ if (g == 0x0002)
+ {
+ // Any more to be displayed ?
+ if ( (e == 0x0010) || (e == 0x0002) )
+ {
if ( v.length() != 0 ) // for brain damaged headers
+ {
if ( ! isdigit(v[v.length()-1]) )
+ {
v.erase(v.length()-1, 1);
+ }
+ }
s << " ==>\t[" << ts->GetValue(v) << "]";
}
- } else {
- if (g == 0x0008) {
- if ( (e == 0x0016) || (e == 0x1150) ) {
+ }
+ else
+ {
+ if (g == 0x0008)
+ {
+ if ( e == 0x0016 || e == 0x1150 )
+ {
if ( v.length() != 0 ) // for brain damaged headers
+ {
if ( ! isdigit(v[v.length()-1]) )
+ {
v.erase(v.length()-1, 1);
+ }
+ }
s << " ==>\t[" << ts->GetValue(v) << "]";
}
- } else {
- if (g == 0x0004) {
- if ( (e == 0x1510) || (e == 0x1512) ) {
- if ( v.length() != 0 ) // for brain damaged headers
- if ( ! isdigit(v[v.length()-1]) )
- v.erase(v.length()-1, 1);
+ }
+ else
+ {
+ if (g == 0x0004)
+ {
+ if ( (e == 0x1510) || (e == 0x1512) )
+ {
+ if ( v.length() != 0 ) // for brain damaged headers
+ {
+ if ( ! isdigit(v[v.length()-1]) )
+ {
+ v.erase(v.length()-1, 1);
+ }
+ }
s << " ==>\t[" << ts->GetValue(v) << "]";
}
}
if ( (vr == "UL") || (vr == "US") || (vr == "SL") || (vr == "SS") )
{
if (v == "4294967295") // to avoid troubles in convertion
+ {
sprintf (st," x(ffffffff)");
- else {
- if ( GetLength() !=0 )
+ }
+ else
+ {
+ if ( GetLength() !=0 )
+ {
sprintf(st," x(%x)", atoi(v.c_str()));//FIXME
- else
- sprintf(st," ");
+ }
+ else
+ {
+ sprintf(st," ");
+ }
}
s << st;
}
void gdcmValEntry::Write(FILE *fp, FileType filetype)
{
gdcmDocEntry::Write(fp, filetype);
- std::string vr=GetVR();
- int lgr=GetReadLength();
+ std::string vr = GetVR();
+ int lgr = GetReadLength();
if (vr == "US" || vr == "SS")
{
// some 'Short integer' fields may be mulivaluated
std::vector<std::string> tokens;
tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
Tokenize (GetValue(), tokens, "\\");
- for (unsigned int i=0; i<tokens.size();i++) {
+ for (unsigned int i=0; i<tokens.size();i++)
+ {
uint16_t val_uint16 = atoi(tokens[i].c_str());
void *ptr = &val_uint16;
fwrite ( ptr,(size_t)2 ,(size_t)1 ,fp);
std::vector<std::string> tokens;
tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
Tokenize (GetValue(), tokens, "\\");
- for (unsigned int i=0; i<tokens.size();i++){
+ for (unsigned int i=0; i<tokens.size();i++)
+ {
uint32_t val_uint32 = atoi(tokens[i].c_str());
void *ptr = &val_uint32;
fwrite ( ptr,(size_t)4 ,(size_t)1 ,fp);
Program: gdcm
Module: $RCSfile: gdcmValEntry.h,v $
Language: C++
- Date: $Date: 2004/07/02 13:55:28 $
- Version: $Revision: 1.18 $
+ Date: $Date: 2004/08/01 00:59:22 $
+ Version: $Revision: 1.19 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* \brief The dicom header of a Dicom file contains a set of such entries
* (when successfuly parsed against a given Dicom dictionary)
*/
-class GDCM_EXPORT gdcmValEntry : public gdcmDocEntry {
-
+class GDCM_EXPORT gdcmValEntry : public gdcmDocEntry
+{
public:
-
gdcmValEntry(gdcmDictEntry* e);
-
gdcmValEntry(gdcmDocEntry* d);
virtual ~gdcmValEntry();
std::string GetValue() { return value; };
/// Sets the value (string) of the current Dicom Document Entry
- void SetValue(std::string val) { value = val; };
+ void SetValue(std::string const & val) { value = val; };
/// Sets the value (void *) of the current Dicom Document Entry
void SetVoidArea(void * val) { voidArea = val; };
virtual void Print(std::ostream &os = std::cout);
virtual void Write(FILE *fp, FileType filetype);
-protected:
+protected:
/// \brief for 'non string' values. Will be move to gdcmBinEntry, later
void* voidArea; // clean it out later
private:
-
// Members :
/// \brief Document Entry value, internaly represented as a std::string