+2004-12-03 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+ * Remove memory leaks on the DicomDir
+ * Remove some useless datas in DicomDirObject
+ * Add usefull methods in SQItem, to be complient withe the ElementSet
+
2004-12-03 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
* src/gdcmFile.[h|cxx] : now use FileType instead of TWriteType.
Program: gdcm
Module: $RCSfile: TestAllEntryVerify.cxx,v $
Language: C++
- Date: $Date: 2004/11/16 04:28:20 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2004/12/03 17:13:17 $
+ 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
class ReferenceFileParser
{
+public:
+ ReferenceFileParser();
+ bool Open( std::string& referenceFileName );
+ void Print();
+ void SetDataPath(std::string&);
+ bool Check();
+ bool Check( std::string fileName );
+
+private:
bool AddKeyValuePairToMap( std::string& key, std::string& value );
std::istream& eatwhite(std::istream& is);
std::string ExtractFirstString(std::string& toSplit);
void CleanUpLine( std::string& line );
+ bool Check( MapFileValuesType::iterator &fileIt );
std::string ExtractValue(std::string& toSplit) throw ( ParserException );
void ParseRegularLine( std::string& line ) throw ( ParserException );
void FirstPassReferenceFile() throw ( ParserException );
void HandleKey( std::string& line ) throw ( ParserException );
bool HandleValue( std::string& line ) throw ( ParserException );
static uint16_t axtoi( char* );
-public:
- ReferenceFileParser();
- bool Open( std::string& referenceFileName );
- void Print();
- void SetDataPath(std::string&);
- bool Check();
private:
/// The directory containing the images to check:
std::string DataPath;
DataPath = inDataPath;
}
-bool ReferenceFileParser::AddKeyValuePairToMap( std::string& key, std::string& value )
+bool ReferenceFileParser::AddKeyValuePairToMap( std::string& key,
+ std::string& value )
{
if ( !CurrentMapEntryValuesPtr )
return false;
bool ReferenceFileParser::Check()
{
+ int ret = true;
for (MapFileValuesType::iterator i = ProducedMap.begin();
i != ProducedMap.end();
++i)
{
- std::string fileName = DataPath + i->first;
- std::cout << Indent << "FileName: " << fileName << std::endl;
- gdcm::Header* tested = new gdcm::Header( fileName.c_str() );
- if( !tested->IsReadable() )
- {
- std::cerr << Indent << "Image not gdcm compatible:"
+ ret &= Check(i);
+ }
+ std::cout << Indent << std::endl;
+ return ret;
+}
+
+bool ReferenceFileParser::Check( std::string fileName )
+{
+ MapFileValuesType::iterator it = ProducedMap.find(fileName);
+ if( it != ProducedMap.end() )
+ {
+ return Check(it);
+ }
+ std::cerr << Indent << "Failed\n"
+ << Indent << "Image not found :"
<< fileName << std::endl;
- delete tested;
- return false;
- }
+ return false;
+}
- MapEntryValuesPtr KeyValues = i->second;
- for (MapEntryValues::iterator j = KeyValues->begin();
- j != KeyValues->end();
- ++j)
- {
- std::string key = j->first;
+bool ReferenceFileParser::Check( MapFileValuesType::iterator &fileIt )
+{
+ std::string fileName = DataPath + fileIt->first;
+ std::cout << Indent << "FileName: " << fileName << std::endl;
+ gdcm::Header* tested = new gdcm::Header( fileName.c_str() );
+ if( !tested->IsReadable() )
+ {
+ std::cerr << Indent << "Failed\n"
+ << Indent << "Image not gdcm compatible:"
+ << fileName << std::endl;
+ delete tested;
+ return false;
+ }
- std::string groupString = key.substr( 0, 4 );
- char* groupCharPtr;
- groupCharPtr = new char(groupString.length() + 1);
- strcpy( groupCharPtr, groupString.c_str() );
+ MapEntryValuesPtr KeyValues = fileIt->second;
+ for (MapEntryValues::iterator j = KeyValues->begin();
+ j != KeyValues->end();
+ ++j)
+ {
+ std::string key = j->first;
- std::string groupElement = key.substr( key.find_first_of( "|" ) + 1, 4 );
- char* groupElementPtr;
- groupElementPtr = new char(groupElement.length() + 1);
- strcpy( groupElementPtr, groupElement.c_str() );
+ std::string groupString = key.substr( 0, 4 );
+ std::string groupElement = key.substr( key.find_first_of( "|" ) + 1, 4 );
- uint16_t group = axtoi( groupCharPtr );
- uint16_t element = axtoi( groupElementPtr );
+ uint16_t group = axtoi( &(groupString[0]) );
+ uint16_t element = axtoi( &(groupElement[0]) );
- std::string testedValue = tested->GetEntryByNumber(group, element);
- if ( testedValue != j->second )
+ std::string testedValue = tested->GetEntryByNumber(group, element);
+ if ( testedValue != j->second )
+ {
+ // Oops make sure this is only the \0 that differ
+ if( testedValue[j->second.size()] != '\0' ||
+ strncmp(testedValue.c_str(),
+ j->second.c_str(), j->second.size()) != 0)
{
- // Oops make sure this is only the \0 that differ
- if( testedValue[j->second.size()] != '\0' ||
- strncmp(testedValue.c_str(),
- j->second.c_str(), j->second.size()) != 0)
- {
- std::cout << Indent << "Uncorrect value for key "
- << key << std::endl
- << Indent << " read value ["
- << testedValue << "]" << std::endl
- << Indent << " reference value ["
- << j->second << "]" << std::endl;
+ std::cout << Indent << "Failed\n"
+ << Indent << "Uncorrect value for key "
+ << key << std::endl
+ << Indent << " read value ["
+ << testedValue << "]" << std::endl
+ << Indent << " reference value ["
+ << j->second << "]" << std::endl;
return false;
- }
}
}
- delete tested;
- std::cout << Indent << " OK" << std::endl;
}
- std::cout << Indent << std::endl;
+ delete tested;
+ std::cout << Indent << " OK" << std::endl;
+
return true;
}
std::string::size_type endPos = toSplit.find_last_of( '"' );
// Make sure we have at most two " in toSplit:
- std::string noQuotes = toSplit.substr( beginPos + 1, endPos - beginPos - 1);
- if ( noQuotes.find_first_of( '"' ) != std::string::npos )
+ //std::string noQuotes = toSplit.substr( beginPos + 1, endPos - beginPos - 1);
+ //if ( noQuotes.find_first_of( '"' ) != std::string::npos )
+ // throw ParserException( "more than two quote character" );
+ if ( toSplit.find_first_of( '"',beginPos+1 ) != endPos )
throw ParserException( "more than two quote character" );
// No leading quote means this is not a value:
int TestAllEntryVerify(int argc, char* argv[])
{
- if ( argc > 1 )
+ if ( argc > 2 )
{
std::cerr << " Usage: " << argv[0]
- << " (no arguments needed)." << std::endl;
+ << " fileName" << std::endl;
return 1;
}
std::cout << " apply the following tests : "<< std::endl;
std::cout << " step 1: parse the image and call IsReadable(). " << std::endl;
std::cout << " step 2: look for the entry corresponding to the image" << std::endl;
- std::cout << " in the reference file: " << referenceFilename << std::endl;
+ std::cout << " in the reference file: \n"
+ << " " << referenceFilename << std::endl;
std::cout << " step 3: check that each reference tag value listed for this"
<< std::endl;
std::cout << " entry matches the tag encountered at parsing step 1."
ReferenceFileParser Parser;
if ( !Parser.Open(referenceFilename) )
{
- std::cout << " Corrupted reference file name: "
- << referenceFilename << std::endl;
+ std::cout << " failed"
+ << " Corrupted reference file name: "
+ << referenceFilename << std::endl;
return 1;
}
Parser.SetDataPath(referenceDir);
// Parser.Print();
- if ( Parser.Check() )
- return 0;
- return 1;
+ std::cout << "Reference fil loaded -->\n"
+ << "Check files : \n";
+
+ int ret;
+ if ( argc >= 2 )
+ {
+ ret = Parser.Check( argv[1] );
+ }
+ else
+ {
+ ret = Parser.Check();
+ }
+ return !ret;
}
Program: gdcm
Module: $RCSfile: gdcmDicomDir.cxx,v $
Language: C++
- Date: $Date: 2004/11/30 17:04:01 $
- Version: $Revision: 1.83 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ Version: $Revision: 1.84 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
:Document( )
{
Initialize(); // sets all private fields to NULL
- std::string pathBidon = "Bidon"; // Sorry, NULL not allowed ...
MetaElems = NewMeta();
}
Initialize(); // sets all private fields to NULL
// if user passed a root directory, sure we didn't get anything
-
if ( TagHT.begin() == TagHT.end() ) // when user passed a Directory to parse
{
dbg.Verbose(0, "DicomDir::DicomDir : entry HT empty");
SetProgressMethod(NULL);
SetEndMethod(NULL);
- TagHT.clear();
for(ListDicomDirPatient::iterator cc = Patients.begin();
cc!= Patients.end();
++cc)
Progress = 0.0;
Abort = false;
- MetaElems = 0;
+ MetaElems = NULL;
}
}
fp->close();
+ delete fp;
+
return true;
}
break;
}
+std::cerr<<"File : "<<it->c_str()<<std::endl;
header = new Header( it->c_str() );
if( !header )
{
"DicomDir::CreateDicomDirChainedList: "
"failure in new Header ",
it->c_str() );
+ continue;
}
if( header->IsReadable() )
dbg.Verbose( 1,
"DicomDir::CreateDicomDirChainedList: readable ",
it->c_str() );
-
}
else
{
//for each Header of the chained list, add/update the Patient/Study/Serie/Image info
SetElements(tmp, list);
CallEndMethod();
+
+ for(VectDocument::iterator it=list.begin();
+ it!=list.end();
+ ++it)
+ {
+ delete dynamic_cast<Header *>(*it);
+ }
}
/**
DicomDirMeta * DicomDir::NewMeta()
{
- DicomDirMeta *m = new DicomDirMeta( &TagHT );
+ DicomDirMeta *m = new DicomDirMeta();
if ( TagHT.begin() != TagHT.end() ) // after Document Parsing
{
ListDicomDirPatientElem const & elemList =
Global::GetDicomDirElements()->GetDicomDirPatientElements();
- SQItem *s = new SQItem(0);
+ DicomDirPatient *p = new DicomDirPatient();
// for all the DicomDirPatient Elements
for( it = elemList.begin(); it != elemList.end(); ++it )
{
entry->SetLength( entry->GetValue().length() );
}
- s->AddDocEntry( entry );
+ p->AddDocEntry( entry );
}
- DicomDirPatient *p = new DicomDirPatient(s, &TagHT);
Patients.push_front( p );
return p;
DictEntry *dictEntry;
ValEntry *entry;
std::string val;
- SQItem *si = new SQItem(0); // all the items will be at level 1
+ SQItem *si;
switch( type )
{
case GDCM_DICOMDIR_IMAGE:
elemList = Global::GetDicomDirElements()->GetDicomDirImageElements();
+ si = new DicomDirImage();
+ if( !AddDicomDirImageToEnd(static_cast<DicomDirImage *>(si)) )
+ {
+ dbg.Verbose(0,"DicomDir::SetElement:",
+ "Add DicomDirImageToEnd failed");
+ }
break;
-
case GDCM_DICOMDIR_SERIE:
elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements();
+ si = new DicomDirSerie();
+ if( !AddDicomDirSerieToEnd(static_cast<DicomDirSerie *>(si)) )
+ {
+ dbg.Verbose(0,"DicomDir::SetElement:",
+ "Add DicomDirSerieToEnd failed");
+ }
break;
-
case GDCM_DICOMDIR_STUDY:
elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements();
+ si = new DicomDirStudy();
+ if( !AddDicomDirStudyToEnd(static_cast<DicomDirStudy *>(si)) )
+ {
+ dbg.Verbose(0,"DicomDir::SetElement:",
+ "Add DicomDirStudyToEnd failed");
+ }
break;
-
case GDCM_DICOMDIR_PATIENT:
elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements();
+ si = new DicomDirPatient();
+ if( !AddDicomDirPatientToEnd(static_cast<DicomDirPatient *>(si)) )
+ {
+ dbg.Verbose(0,"DicomDir::SetElement:",
+ "Add DicomDirPatientToEnd failed");
+ }
break;
-
case GDCM_DICOMDIR_META:
elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements();
+ si = new DicomDirMeta();
+ if( MetaElems )
+ {
+ dbg.Verbose(0,"DicomDir::SetElement:",
+ "MetaElements already exist, they will be destroyed");
+ delete MetaElems;
+ }
+ MetaElems = static_cast<DicomDirMeta *>(si);
break;
-
default:
return;
}
}
si->AddEntry(entry);
}
- switch( type )
- {
- case GDCM_DICOMDIR_IMAGE:
- AddDicomDirImageToEnd(si);
- break;
-
- case GDCM_DICOMDIR_SERIE:
- AddDicomDirSerieToEnd(si);
- break;
-
- case GDCM_DICOMDIR_STUDY:
- AddDicomDirStudyToEnd(si);
- break;
-
- case GDCM_DICOMDIR_PATIENT:
- AddDicomDirPatientToEnd(si);
- break;
-
- default:
- return;
- }
- //int count=1; // find a trick to increment
- //s->AddEntry(si, count); // Seg Faults
-
}
//-----------------------------------------------------------------------------
DocEntry * d;
std::string v;
+ SQItem * si;
for( ListSQItem::iterator i = listItems.begin();
i !=listItems.end(); ++i )
{
if( v == "PATIENT " )
{
- AddDicomDirPatientToEnd( *i );
+ si = new DicomDirPatient();
+ AddDicomDirPatientToEnd( static_cast<DicomDirPatient *>(si) );
type = DicomDir::GDCM_DICOMDIR_PATIENT;
}
else if( v == "STUDY " )
{
- AddDicomDirStudyToEnd( *i );
+ si = new DicomDirStudy();
+ AddDicomDirStudyToEnd( static_cast<DicomDirStudy *>(si) );
type = DicomDir::GDCM_DICOMDIR_STUDY;
}
else if( v == "SERIES" )
{
- AddDicomDirSerieToEnd( *i );
+ si = new DicomDirSerie();
+ AddDicomDirSerieToEnd( static_cast<DicomDirSerie *>(si) );
type = DicomDir::GDCM_DICOMDIR_SERIE;
}
else if( v == "IMAGE " )
{
- AddDicomDirImageToEnd( *i );
+ si = new DicomDirImage();
+ AddDicomDirImageToEnd( static_cast<DicomDirImage *>(si) );
type = DicomDir::GDCM_DICOMDIR_IMAGE;
}
else
// neither an 'IMAGE' SQItem. Skip to next item.
continue;
}
+ MoveSQItem(si,*i);
}
+ TagHT.clear();
}
/**
* \ingroup DicomDir
* \brief Well ... there is only one occurence
*/
-void DicomDir::AddDicomDirMeta()
+bool DicomDir::AddDicomDirMeta()
{
if( MetaElems )
{
delete MetaElems;
}
- MetaElems = new DicomDirMeta( &TagHT );
+ MetaElems = new DicomDirMeta();
+ return true;
}
/**
* \brief AddDicomDirPatientToEnd
* @param s SQ Item to enqueue to the DicomPatient chained List
*/
-void DicomDir::AddDicomDirPatientToEnd(SQItem *s)
+bool DicomDir::AddDicomDirPatientToEnd(DicomDirPatient *dd)
{
- Patients.push_back(new DicomDirPatient(s, &TagHT));
+ Patients.push_back(dd);
+ return true;
}
/**
* \brief AddDicomDirStudyToEnd
* @param s SQ Item to enqueue to the DicomDirStudy chained List
*/
- void DicomDir::AddDicomDirStudyToEnd(SQItem *s)
+bool DicomDir::AddDicomDirStudyToEnd(DicomDirStudy *dd)
{
if( Patients.size() > 0 )
{
ListDicomDirPatient::iterator itp = Patients.end();
itp--;
- (*itp)->AddDicomDirStudy(new DicomDirStudy(s, &TagHT));
+ (*itp)->AddDicomDirStudy(dd);
+ return true;
}
+ return false;
}
/**
* \brief AddDicomDirSerieToEnd
* @param s SQ Item to enqueue to the DicomDirSerie chained List
*/
-void DicomDir::AddDicomDirSerieToEnd(SQItem *s)
+bool DicomDir::AddDicomDirSerieToEnd(DicomDirSerie *dd)
{
if( Patients.size() > 0 )
{
ListDicomDirStudy::const_iterator itst =
(*itp)->GetDicomDirStudies().end();
itst--;
- (*itst)->AddDicomDirSerie(new DicomDirSerie(s, &TagHT));
+ (*itst)->AddDicomDirSerie(dd);
+ return true;
}
}
+ return false;
}
/**
* \brief AddDicomDirImageToEnd
* @param s SQ Item to enqueue to the DicomDirImage chained List
*/
- void DicomDir::AddDicomDirImageToEnd(SQItem *s)
+bool DicomDir::AddDicomDirImageToEnd(DicomDirImage *dd)
{
if( Patients.size() > 0 )
{
{
ListDicomDirSerie::const_iterator its = (*itst)->GetDicomDirSeries().end();
its--;
- (*its)->AddDicomDirImage(new DicomDirImage(s, &TagHT));
+ (*its)->AddDicomDirImage(dd);
+ return true;
}
}
}
+ return false;
}
/**
std::string studCurInstanceUID, studCurID;
std::string serCurInstanceUID, serCurID;
+ bool first = true;
for( VectDocument::const_iterator it = list.begin();
it != list.end(); ++it )
{
// get the current file characteristics
- 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);
+ 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);
- if( patCurName != patPrevName || patCurID != patPrevID)
+ if( patCurName != patPrevName || patCurID != patPrevID || first )
{
SetElement(path, GDCM_DICOMDIR_PATIENT, *it);
+ first = true;
}
// if new Study Deal with 'STUDY' Elements
- if( studCurInstanceUID != studPrevInstanceUID || studCurID != studPrevID )
+ if( studCurInstanceUID != studPrevInstanceUID || studCurID != studPrevID
+ || first )
{
SetElement(path, GDCM_DICOMDIR_STUDY, *it);
+ first = true;
}
// if new Serie Deal with 'SERIE' Elements
- if( serCurInstanceUID != serPrevInstanceUID || serCurID != serPrevID )
+ if( serCurInstanceUID != serPrevInstanceUID || serCurID != serPrevID
+ || first )
{
SetElement(path, GDCM_DICOMDIR_SERIE, *it);
+ first = true;
}
// Always Deal with 'IMAGE' Elements
studPrevID = studCurID;
serPrevInstanceUID = serCurInstanceUID;
serPrevID = serCurID;
+ first = false;
+ }
+}
+
+/**
+ * \ingroup DicomDir
+ * \brief Move the content of the src SQItem to the dst SQItem
+ * Only DocEntry's are moved
+ *
+ */
+void DicomDir::MoveSQItem(SQItem* dst,SQItem *src)
+{
+ DocEntry *entry;
+
+ src->Initialize();
+ entry = src->GetNextEntry();
+ while(entry)
+ {
+ src->RemoveEntryNoDestroy(entry);
+ dst->AddEntry(entry);
+
+ src->Initialize();
+ entry = src->GetNextEntry();
}
}
Program: gdcm
Module: $RCSfile: gdcmDicomDir.h,v $
Language: C++
- Date: $Date: 2004/11/16 10:25:53 $
- Version: $Revision: 1.39 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ Version: $Revision: 1.40 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
private:
void Initialize();
void CreateDicomDir();
- void AddDicomDirMeta();
- void AddDicomDirPatientToEnd(SQItem* s);
- void AddDicomDirStudyToEnd (SQItem* s);
- void AddDicomDirSerieToEnd (SQItem* s);
- void AddDicomDirImageToEnd (SQItem* s);
+
+ bool AddDicomDirMeta();
+ bool AddDicomDirPatientToEnd(DicomDirPatient* dd);
+ bool AddDicomDirStudyToEnd (DicomDirStudy* dd);
+ bool AddDicomDirSerieToEnd (DicomDirSerie* dd);
+ bool AddDicomDirImageToEnd (DicomDirImage* dd);
void SetElements(std::string const & path, VectDocument const &list);
void SetElement (std::string const & path, DicomDirType type,
Document* header);
+ void MoveSQItem(SQItem* dst,SQItem *src);
static bool HeaderLessThan(Document* header1, Document* header2);
Program: gdcm
Module: $RCSfile: gdcmDicomDirImage.cxx,v $
Language: C++
- Date: $Date: 2004/10/25 03:35:19 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ 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
{
//-----------------------------------------------------------------------------
// Constructor / Destructor
-
-/**
- * \ingroup DicomDirImage
- * \brief Constructor
- * @param s SQ Item holding the elements
- * @param ptagHT pointer to the HTable (DicomDirObject needs it
- * to build the DocEntries)
- */
-DicomDirImage::DicomDirImage(SQItem *s, TagDocEntryHT *ptagHT):
- DicomDirObject(ptagHT)
-{
- DocEntries = s->GetDocEntries();
-}
-
/**
* \ingroup DicomDirImage
* \brief Constructor
* @param ptagHT pointer to the HTable (DicomDirObject needs it
* to build the DocEntries)
*/
-DicomDirImage::DicomDirImage(TagDocEntryHT *ptagHT):
- DicomDirObject(ptagHT)
+DicomDirImage::DicomDirImage():
+ DicomDirObject()
{
}
/**
Program: gdcm
Module: $RCSfile: gdcmDicomDirImage.h,v $
Language: C++
- Date: $Date: 2004/10/25 03:35:19 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ 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
class GDCM_EXPORT DicomDirImage : public DicomDirObject
{
public:
- DicomDirImage(SQItem *s, TagDocEntryHT *ptagHT);
- DicomDirImage(TagDocEntryHT *ptagHT);
-
+ DicomDirImage();
~DicomDirImage();
void Print(std::ostream &os = std::cout);
Program: gdcm
Module: $RCSfile: gdcmDicomDirMeta.cxx,v $
Language: C++
- Date: $Date: 2004/11/25 15:46:10 $
- Version: $Revision: 1.15 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ Version: $Revision: 1.16 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* \ingroup DicomDirMeta
* \brief Constructor
*/
-DicomDirMeta::DicomDirMeta(TagDocEntryHT* ptagHT):
- DicomDirObject(ptagHT)
+DicomDirMeta::DicomDirMeta():
+ DicomDirObject()
{
}
Program: gdcm
Module: $RCSfile: gdcmDicomDirMeta.h,v $
Language: C++
- Date: $Date: 2004/11/25 15:46:11 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ 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
class GDCM_EXPORT DicomDirMeta : public DicomDirObject
{
public:
- DicomDirMeta(TagDocEntryHT *ptagHT);
-
+ DicomDirMeta();
~DicomDirMeta();
virtual void Print(std::ostream &os = std::cout);
Program: gdcm
Module: $RCSfile: gdcmDicomDirObject.cxx,v $
Language: C++
- Date: $Date: 2004/10/25 04:08:20 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ 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
* @param depth Sequence depth level
*/
-DicomDirObject::DicomDirObject(TagDocEntryHT *ptagHT, int depth)
+DicomDirObject::DicomDirObject(int depth)
: SQItem (depth)
{
- PtagHT = ptagHT;
}
Program: gdcm
Module: $RCSfile: gdcmDicomDirObject.h,v $
Language: C++
- Date: $Date: 2004/10/25 03:35:19 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ Version: $Revision: 1.7 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
public:
- DicomDirObject(TagDocEntryHT *ptagHT, int depth = 0);
+ DicomDirObject(int depth = 1);
~DicomDirObject();
/**
Program: gdcm
Module: $RCSfile: gdcmDicomDirPatient.cxx,v $
Language: C++
- Date: $Date: 2004/11/25 15:46:11 $
- Version: $Revision: 1.19 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ 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
// Constructor / Destructor
/**
* \brief Constructor
- * @param s SQ Item holding the elements related to this "PATIENT" part
* @param ptagHT pointer to the HTable (DicomDirObject needs it
* to build the HeaderEntries)
*/
-DicomDirPatient::DicomDirPatient(SQItem *s, TagDocEntryHT *ptagHT) :
- DicomDirObject(ptagHT)
-{
- DocEntries = s->GetDocEntries();
-}
-/**
- * \brief Constructor
- * @param ptagHT pointer to the HTable (DicomDirObject needs it
- * to build the HeaderEntries)
- */
-DicomDirPatient::DicomDirPatient(TagDocEntryHT* ptagHT):
- DicomDirObject(ptagHT)
+DicomDirPatient::DicomDirPatient():
+ DicomDirObject()
{
}
/**
ListDicomDirStudyElem const & elemList =
Global::GetDicomDirElements()->GetDicomDirStudyElements();
- DicomDirStudy* st = new DicomDirStudy( PtagHT );
+ DicomDirStudy* st = new DicomDirStudy();
st->FillObject(elemList);
Studies.push_front(st);
Program: gdcm
Module: $RCSfile: gdcmDicomDirPatient.h,v $
Language: C++
- Date: $Date: 2004/11/25 15:46:11 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ 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
class GDCM_EXPORT DicomDirPatient : public DicomDirObject
{
public:
- DicomDirPatient(SQItem *s, TagDocEntryHT *ptagHT);
- DicomDirPatient(TagDocEntryHT *ptagHT);
-
+ DicomDirPatient();
~DicomDirPatient();
void Print(std::ostream &os = std::cout);
Program: gdcm
Module: $RCSfile: gdcmDicomDirSerie.cxx,v $
Language: C++
- Date: $Date: 2004/11/25 15:46:11 $
- Version: $Revision: 1.21 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ 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
// Constructor / Destructor
/**
* \brief Constructor
- * @param s SQ Item holding the elements related to this "SERIE" part
* @param ptagHT pointer to the HTable (DicomDirObject needs it
* to build the DocEntries)
*/
-DicomDirSerie::DicomDirSerie(SQItem* s, TagDocEntryHT* ptagHT) :
- DicomDirObject(ptagHT)
-{
- DocEntries = s->GetDocEntries();
-}
-
-/**
- * \brief Constructor
- * @param ptagHT pointer to the HTable (DicomDirObject needs it
- * to build the DocEntries)
- */
-DicomDirSerie::DicomDirSerie(TagDocEntryHT* ptagHT):
- DicomDirObject(ptagHT)
+DicomDirSerie::DicomDirSerie():
+ DicomDirObject()
{
}
/**
ListDicomDirImageElem const & elemList =
Global::GetDicomDirElements()->GetDicomDirImageElements();
- DicomDirImage* st = new DicomDirImage(PtagHT);
+ DicomDirImage* st = new DicomDirImage();
FillObject(elemList);
Images.push_front(st);
Program: gdcm
Module: $RCSfile: gdcmDicomDirSerie.h,v $
Language: C++
- Date: $Date: 2004/11/25 15:46:11 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ 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
class GDCM_EXPORT DicomDirSerie : public DicomDirObject
{
public:
- DicomDirSerie( SQItem* s, TagDocEntryHT* ptagHT );
- DicomDirSerie( TagDocEntryHT* ptagHT );
-
+ DicomDirSerie();
~DicomDirSerie();
void Print( std::ostream& os = std::cout );
Program: gdcm
Module: $RCSfile: gdcmDicomDirStudy.cxx,v $
Language: C++
- Date: $Date: 2004/11/25 15:46:11 $
- Version: $Revision: 1.18 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ 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
{
//-----------------------------------------------------------------------------
// Constructor / Destructor
-
-/**
- * \ingroup DicomDirStudy
- * \brief constructor
- * @param s SQ Item holding the elements related to this "STUDY" part
- * @param ptagHT pointer to the HTable (DicomDirObject needs it
- * to build the HeaderEntries)
- */
-DicomDirStudy::DicomDirStudy(SQItem* s, TagDocEntryHT* ptagHT):
- DicomDirObject(ptagHT)
-{
- DocEntries = s->GetDocEntries();
-}
/**
* \ingroup DicomDirStudy
* \brief constructor
* @param ptagHT pointer to the HTable (DicomDirObject needs it
* to build the HeaderEntries)
*/
-DicomDirStudy::DicomDirStudy(TagDocEntryHT* ptagHT):
- DicomDirObject(ptagHT)
+DicomDirStudy::DicomDirStudy():
+ DicomDirObject()
{
}
/**
ListDicomDirSerieElem const & elemList =
Global::GetDicomDirElements()->GetDicomDirSerieElements();
- DicomDirSerie* st = new DicomDirSerie(PtagHT);
+ DicomDirSerie* st = new DicomDirSerie();
FillObject(elemList);
Series.push_front(st);
Program: gdcm
Module: $RCSfile: gdcmDicomDirStudy.h,v $
Language: C++
- Date: $Date: 2004/11/25 15:46:11 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ 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
class GDCM_EXPORT DicomDirStudy : public DicomDirObject
{
public:
- DicomDirStudy(SQItem *s, TagDocEntryHT *ptagHT);
- DicomDirStudy(TagDocEntryHT *ptagHT);
-
+ DicomDirStudy();
~DicomDirStudy();
void Print(std::ostream &os = std::cout);
Program: gdcm
Module: $RCSfile: gdcmElementSet.cxx,v $
Language: C++
- Date: $Date: 2004/11/25 15:46:11 $
- Version: $Revision: 1.32 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ 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 Clear the hash table from given entry BUT keep the entry.
- * @param entryToRemove Entry to remove.
+ * \brief Clear the hash table from given entry AND delete the entry.
+ * @param entryToRemove Entry to remove AND delete.
+ * \warning Some problems when using under Windows... prefer the use of
+ * Initialize / GetNext methods
*/
-bool ElementSet::RemoveEntryNoDestroy(DocEntry* entryToRemove)
+bool ElementSet::RemoveEntry( DocEntry* entryToRemove)
{
const TagKey& key = entryToRemove->GetKey();
if( TagHT.count(key) == 1 )
{
TagHT.erase(key);
dbg.Verbose(0, "ElementSet::RemoveEntry: one element erased.");
+ delete entryToRemove;
return true;
}
- dbg.Verbose(0, "ElementSet::RemoveEntry: key not present: ");
+ dbg.Verbose(0, "ElementSet::RemoveEntry: key not present");
return false ;
}
/**
- * \brief Clear the hash table from given entry AND delete the entry.
- * @param entryToRemove Entry to remove AND delete.
- * \warning Some problems when using under Windows... prefer the use of
- * Initialize / GetNext methods
+ * \brief Clear the hash table from given entry BUT keep the entry.
+ * @param entryToRemove Entry to remove.
*/
-bool ElementSet::RemoveEntry( DocEntry* entryToRemove)
+bool ElementSet::RemoveEntryNoDestroy(DocEntry* entryToRemove)
{
const TagKey& key = entryToRemove->GetKey();
if( TagHT.count(key) == 1 )
{
TagHT.erase(key);
dbg.Verbose(0, "ElementSet::RemoveEntry: one element erased.");
- delete entryToRemove;
return true;
}
- dbg.Verbose(0, "ElementSet::RemoveEntry: key not present: ");
+ dbg.Verbose(0, "ElementSet::RemoveEntry: key not present");
return false ;
}
Program: gdcm
Module: $RCSfile: gdcmSQItem.cxx,v $
Language: C++
- Date: $Date: 2004/11/25 15:46:11 $
- Version: $Revision: 1.38 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ Version: $Revision: 1.39 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
}
return false;
}
-//-----------------------------------------------------------------------------
-// Protected
+/**
+ * \brief Clear the hash table from given entry AND delete the entry.
+ * @param entryToRemove Entry to remove AND delete.
+ * \warning Some problems when using under Windows... prefer the use of
+ * Initialize / GetNext methods
+ */
+bool SQItem::RemoveEntry( DocEntry* entryToRemove)
+{
+ for(ListDocEntry::iterator it = DocEntries.begin();
+ it != DocEntries.end();
+ ++it)
+ {
+ if( *it == entryToRemove)
+ {
+ DocEntries.erase(it);
+ dbg.Verbose(0, "SQItem::RemoveEntry: one element erased.");
+ delete entryToRemove;
+ return true;
+ }
+ }
+
+ dbg.Verbose(0, "SQItem::RemoveEntry: value not present ");
+ return false ;
+}
+
+/**
+ * \brief Clear the hash table from given entry BUT keep the entry.
+ * @param entryToRemove Entry to remove.
+ */
+bool SQItem::RemoveEntryNoDestroy(DocEntry* entryToRemove)
+{
+ for(ListDocEntry::iterator it = DocEntries.begin();
+ it != DocEntries.end();
+ ++it)
+ {
+ if( *it == entryToRemove)
+ {
+ DocEntries.erase(it);
+ dbg.Verbose(0, "SQItem::RemoveEntry: one element erased.");
+ return true;
+ }
+ }
+
+ dbg.Verbose(0, "SQItem::RemoveEntry: value not present ");
+ return false ;
+}
+
+/**
+ * \brief Initialise the visit of the chained list
+ */
+void SQItem::Initialize()
+{
+ ItDocEntries = DocEntries.begin();
+}
+
+/**
+ * \brief Get the next entry whil visiting the chained list
+ * \return The next DocEntry if found, otherwhise NULL
+ */
+DocEntry *SQItem::GetNextEntry()
+{
+ if (ItDocEntries != DocEntries.end())
+ {
+ DocEntry *tmp = *ItDocEntries;
+ ++ItDocEntries;
+
+ return(tmp);
+ }
+ else
+ {
+ return(NULL);
+ }
+}
+//-----------------------------------------------------------------------------
+// Protected
/**
* \brief Gets a Dicom Element inside a SQ Item Entry, by number
* @return
Program: gdcm
Module: $RCSfile: gdcmSQItem.h,v $
Language: C++
- Date: $Date: 2004/11/30 16:24:31 $
- Version: $Revision: 1.24 $
+ Date: $Date: 2004/12/03 17:13:18 $
+ Version: $Revision: 1.25 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/// this SQ Item.
void AddDocEntry(DocEntry *e) { DocEntries.push_back(e); };
- virtual bool AddEntry(DocEntry *Entry); // add to the List
+ bool AddEntry(DocEntry *Entry); // add to the List
+ bool RemoveEntry(DocEntry *EntryToRemove);
+ bool RemoveEntryNoDestroy(DocEntry *EntryToRemove);
DocEntry *GetDocEntryByNumber(uint16_t group, uint16_t element);
// FIXME method to write
/// Accessor on \ref BaseTagKey.
BaseTagKey const & GetBaseTagKey() const { return BaseTagKeyNested; }
+ void Initialize();
+ DocEntry *GetNextEntry();
protected:
// Variables that need to be access in subclasses
- /// \brief chained list of (Elementary) Doc Entries
+ /// \brief Chained list of (Elementary) Doc Entries
ListDocEntry DocEntries;
+ /// Chained list iterator, used to visit the TagHT variable
+ ListDocEntry::iterator ItDocEntries;
///\brief pointer to the HTable of the Document,
/// (because we don't know it within any DicomDirObject nor any SQItem)