- gdcmObject is no longer composed of 2 pointers in a chained list, but is an SQItem
- useless gdcmDicomDir::WriteEntries method is removed
- useless gdcmDicomDir::AddObjectToEnd method is removed
- WARNING : BuidUpDicomDir not yet debugged, but I prefer to commit right now.
-> See you tomorow
Program: gdcm
Module: $RCSfile: gdcmDicomDir.cxx,v $
Language: C++
- Date: $Date: 2004/08/02 16:42:14 $
- Version: $Revision: 1.63 $
+ Date: $Date: 2004/08/26 15:29:52 $
+ Version: $Revision: 1.64 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
gdcmDicomDir::gdcmDicomDir()
:gdcmDocument( )
{
- Initialize();
+ Initialize(); // sets all private fields to NULL
std::string pathBidon = "Bidon"; // Sorry, NULL not allowed ...
SetElement(pathBidon, GDCM_DICOMDIR_META, NULL); // Set the META elements
// que l'on ai passe un root directory ou un DICOMDIR
// et quelle que soit la valeur de parseDir,
// on a deja lance gdcmDocument
- Initialize();
+ Initialize(); // sets all private fields to NULL
// gdcmDocument already executed
// if user passed a root directory, sure we didn't get anything
- if ( TagHT.begin() == TagHT.end() )
+ if ( TagHT.begin() == TagHT.end() ) // when user passed a Directory to parse
{
dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : entry HT empty");
// we get current directory name
char* dummy = new char[1000];
getcwd(dummy, (size_t)1000);
- std::cout << "Directory to parse : [" << dummy << "]" << std::endl;
SetFileName( dummy ); // will be converted into a string
delete[] dummy; // no longer needed
}
- if ( parseDir )
+ if ( parseDir ) // user asked for a recursive parsing of a root directory
{
+ metaElems = NewMeta();
+
dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : Parse directory"
" and create the DicomDir");
ParseDirectory();
// apres le constructeur
}
}
- else
+ else // Only if user passed a DICOMDIR
{
// Directory record sequence
gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220);
SetStartMethod(NULL);
SetProgressMethod(NULL);
SetEndMethod(NULL);
-
- if ( metaElems )
- {
- delete metaElems;
- }
-
for(ListDicomDirPatient::iterator cc = patients.begin();
cc!= patients.end();
++cc)
{
delete *cc;
}
+ if ( metaElems )
+ {
+ delete metaElems;
+ }
}
//-----------------------------------------------------------------------------
*/
bool gdcmDicomDir::Write(std::string const & fileName)
-{
- FILE * fp1 = fopen(fileName.c_str(), "wb");
- if( !fp1 )
+{
+ uint16_t sq[5] = { 0x0004, 0x1220, 0x0000, 0xffff, 0xffff };
+ uint16_t sqt[3]= { 0xfffe, 0xe0dd, 0x0000 };
+
+ FILE * fp = fopen(fileName.c_str(), "wb");
+ if( !fp )
{
printf("Failed to open(write) File [%s] \n", fileName.c_str());
return false;
}
- char * filePreamble = new char[128];
- fwrite(filePreamble,128,1,fp1);
- fwrite("DICM",4,1,fp1);
+ uint8_t* filePreamble = new uint8_t[128];
+ memset(filePreamble, 0, 128);
+ fwrite(filePreamble,128,1,fp);
+ fwrite("DICM",4,1,fp);
delete[] filePreamble;
- UpdateDirectoryRecordSequenceLength();
- WriteEntries(fp1);
-
- fclose( fp1 );
+ // UpdateDirectoryRecordSequenceLength(); // TODO (if *really* usefull)
+ gdcmDicomDirMeta *ptrMeta = GetDicomDirMeta();
+ ptrMeta->Write(fp, gdcmExplicitVR);
+
+ // force writing 0004|1220 [SQ ], that CANNOT exist within gdcmDicomDirMeta
+ fwrite(&sq[0],4,1,fp); // 0004 1220
+ fwrite("SQ" ,2,1,fp); // SQ
+ fwrite(&sq[2],6,1,fp); // 00 ffffffff
+
+ for(ListDicomDirPatient::iterator cc = patients.begin();cc!=patients.end();++cc)
+ {
+ (*cc)->Write( fp, gdcmExplicitVR );
+ }
+ // force writing Sequence Delimitation Item
+ fwrite(&sqt[0],4,1,fp); // fffe e0dd
+ fwrite("UL" ,2,1,fp); // UL
+ fwrite(&sqt[2],1,1,fp); // 00
+ fclose( fp );
return true;
}
-/**
- * \brief Writes in a file using the tree-like structure.
- * @param _fp already open file pointer
- */
-
-void gdcmDicomDir::WriteEntries(FILE *) //_fp
-{
- /// \todo (?) tester les echecs en ecriture
- /// (apres chaque fwrite, dans le WriteEntry)
-
-
-/* TODO : to go on compiling
-
- gdcmDicomDirMeta *ptrMeta;
- ListDicomDirPatient::iterator itPatient;
- ListDicomDirStudy::iterator itStudy;
- ListDicomDirSerie::iterator itSerie;
- ListDicomDirImage::iterator itImage;
- ListTag::iterator i;
-
- ptrMeta= GetDicomDirMeta();
- for(i=ptrMeta->debut();i!=ptrMeta->fin();++i) {
- WriteEntry(*i,_fp, gdcmExplicitVR);
- }
-
- itPatient = GetDicomDirPatients().begin();
- while ( itPatient != GetDicomDirPatients().end() ) {
- for(i=(*itPatient)->debut();i!=(*itPatient)->fin();++i) {
- WriteEntry(*i,_fp, gdcmExplicitVR);
- }
- itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
- while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) {
- for(i=(*itStudy)->debut();i!=(*itStudy)->fin();++i) {
- WriteEntry(*i,_fp, gdcmExplicitVR);
- }
- itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
- while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) {
- for(i=(*itSerie)->debut();i!=(*itSerie)->fin();++i) {
- WriteEntry(*i,_fp, gdcmExplicitVR);
- }
- itImage = ((*itSerie)->GetDicomDirImages()).begin();
- while (itImage != (*itSerie)->GetDicomDirImages().end() ) {
- for(i=(*itImage)->debut();i!=(*itImage)->fin();++i) {
- WriteEntry(*i,_fp, gdcmExplicitVR);
- }
- ++itImage;
- }
- ++itSerie;
- }
- ++itStudy;
- }
- ++itPatient;
- }
- */
-}
-
//-----------------------------------------------------------------------------
// Protected
std::string tmp = fileList.GetDirName();
//for each Header of the chained list, add/update the Patient/Study/Serie/Image info
- SetElements(tmp, list);
-
+ SetElements(tmp, list);
CallEndMethod();
}
* \ingroup gdcmDicomDir
* \brief adds *the* Meta to a partially created DICOMDIR
*/
-
- /// \todo FIXME : Heuuuuu ! Il prend les Entries du Document deja parse,
- /// il ne fabrique rien !
gdcmDicomDirMeta * gdcmDicomDir::NewMeta()
{
gdcmDicomDirMeta *m = new gdcmDicomDirMeta( &TagHT );
- for ( TagDocEntryHT::iterator cc = TagHT.begin();
- cc != TagHT.end(); ++cc)
- {
- m->AddDocEntry( cc->second );
+
+ if ( TagHT.begin() != TagHT.end() ) // after Document Parsing
+ {
+ TagDocEntryHT::iterator lastOneButSequence = TagHT.end();
+ lastOneButSequence --;
+ // This works because ALL the 'out of Sequence' Tags belong to Meta Elems
+ // (we skip 0004|1220 [Directory record sequence] )
+ for ( TagDocEntryHT::iterator cc = TagHT.begin();
+ cc != lastOneButSequence;
+ ++cc)
+ {
+ m->AddDocEntry( cc->second );
+ }
}
+ else // after root directory parsing
+ {
+ //cout << "gdcmDicomDir::NewMeta avec FillObject" << endl;
+ std::list<gdcmElement> elemList;
+ elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements();
+ m->FillObject(elemList);
+ // we create the Sequence manually
+ //gdcmSeqEntry *se =NewSeqEntryByNumber(0x0004, 0x1220); // NOT YET!
+ //m->AddEntry(se);
+ }
+ m->SetSQItemNumber(0); // To avoid further missprinting
return m;
}
gdcmDictEntry *dictEntry;
gdcmValEntry *entry;
std::string val;
- //gdcmObject *o;
+ gdcmSQItem *si = new gdcmSQItem(0); // all the items will be at level 1
switch( type )
{
case GDCM_DICOMDIR_IMAGE:
case GDCM_DICOMDIR_META:
elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements();
+ // add already done ?
break;
default:
return;
}
+ // removed all the seems-to-be-useless stuff about Referenced Image Sequence
+ // to avoid further troubles
+ // imageElem 0008 1140 "" // Referenced Image Sequence
+ // imageElem fffe e000 "" // 'no length' item : length to be set to 0xffffffff later
+ // imageElem 0008 1150 "" // Referenced SOP Class UID : to be set/forged later
+ // imageElem 0008 1155 "" // Referenced SOP Instance UID : to be set/forged later
+ // imageElem fffe e00d "" // Item delimitation : length to be set to ZERO later
+ // for all the relevant elements found in their own spot of the DicomDir.dic
+ // FIXME : troubles found when it's a SeqEntry
for( it = elemList.begin(); it != elemList.end(); ++it)
{
tmpGr = it->group;
tmpEl = it->elem;
dictEntry = GetPubDict()->GetDictEntryByNumber(tmpGr, tmpEl);
+
entry = new gdcmValEntry( dictEntry ); // Be sure it's never a BinEntry !
entry->SetOffset(0); // just to avoid further missprinting
+ entry->SetLength(0); // just to avoid further missprinting
if( header ) // NULL when we Build Up (ex nihilo) a DICOMDIR
// or when we add the META elems
- {
val = header->GetEntryByNumber(tmpGr, tmpEl);
- }
else
- {
val = GDCM_UNFOUND;
- }
if( val == GDCM_UNFOUND)
{
val = header->GetFileName();
}
else
- {
val = &(header->GetFileName().c_str()[path.length()]);
- }
}
else
- {
val = it->value;
- }
}
else
{
if ( header->GetEntryLengthByNumber(tmpGr,tmpEl) == 0 )
- {
val = it->value;
- }
}
- entry->SetValue( val );
+ // GDCM_UNFOUND or not !
+
+ entry->SetValue( val ); // troubles expected when vr=SQ ...
if( dictEntry )
{
entry->SetLength( entry->GetValue().length() );
}
}
- std::cout << " was TagHT[entry->GetKey()] = entry " << std::endl;
- if ( type == GDCM_DICOMDIR_META ) {
+
+ if ( type == GDCM_DICOMDIR_META ) // fusible : should never print !
std::cout << " special Treatment for GDCM_DICOMDIR_META" << std::endl;
-
- }
- //TagHT[entry->GetKey()] = entry; // FIXME : use a SEQUENCE !
+ 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
+
}
/**
if( v == "PATIENT " )
{
AddDicomDirPatientToEnd( *i );
- //AddObjectToEnd(type,*i);
type = gdcmDicomDir::GDCM_DICOMDIR_PATIENT;
}
else if( v == "STUDY " )
{
AddDicomDirStudyToEnd( *i );
- // AddObjectToEnd(type,*i);
type = gdcmDicomDir::GDCM_DICOMDIR_STUDY;
}
else if( v == "SERIES" )
{
AddDicomDirSerieToEnd( *i );
- // AddObjectToEnd(type,*i);
type = gdcmDicomDir::GDCM_DICOMDIR_SERIE;
}
else if( v == "IMAGE " )
{
AddDicomDirImageToEnd( *i );
- // AddObjectToEnd(type,*i);
type = gdcmDicomDir::GDCM_DICOMDIR_IMAGE;
}
else
}
}
-/**
- * \ingroup gdcmDicomDir
- * \brief AddObjectToEnd
- * @param type
- * @param begin iterator on the first DocEntry within the chained List
- * @param end iterator on the last DocEntry within the chained List
- */
-
-// now useless ?
-
-/*void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,gdcmSQItem *s)
-{
- if(s==NULL) // ??
- return;
-
- switch(type)
- {
- case gdcmDicomDir::GDCM_DICOMDIR_META:
- AddDicomDirMeta();
- break;
- case gdcmDicomDir::GDCM_DICOMDIR_PATIENT:
- AddDicomDirPatientToEnd(s);
- break;
- case gdcmDicomDir::GDCM_DICOMDIR_STUDY:
- AddDicomDirStudyToEnd(s);
- break;
- case gdcmDicomDir::GDCM_DICOMDIR_SERIE:
- AddDicomDirSerieToEnd(s);
- break;
- case gdcmDicomDir::GDCM_DICOMDIR_IMAGE:
- AddDicomDirImageToEnd(s);
- break;
- case gdcmDicomDir::GDCM_DICOMDIR_NONE:
- AddDicomDirImageToEnd(s); //FIXME
- break;
- }
-}
-
-*/
-
/**
* \ingroup gdcmDicomDir
* \brief Well ... there is only one occurence
std::string studCurInstanceUID, studCurID;
std::string serCurInstanceUID, serCurID;
- SetElement( path, GDCM_DICOMDIR_META,NULL);
+ //SetElement( path, GDCM_DICOMDIR_META,NULL); // already done (NewMeta)
for( VectDocument::iterator it = list.begin();
it != list.end(); ++it )
Program: gdcm
Module: $RCSfile: gdcmDicomDir.h,v $
Language: C++
- Date: $Date: 2004/08/02 16:42:14 $
- Version: $Revision: 1.26 $
+ Date: $Date: 2004/08/26 15:29:52 $
+ Version: $Revision: 1.27 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
gdcmDicomDirMeta* NewMeta();
gdcmDicomDirPatient* NewPatient();
-// Write
- void WriteEntries(FILE *_fp);
+// Write
bool Write(std::string const & fileName);
/// Types of the gdcmObject within the gdcmDicomDir
Program: gdcm
Module: $RCSfile: gdcmDicomDirImage.h,v $
Language: C++
- Date: $Date: 2004/08/01 02:39:09 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2004/08/26 15:29:52 $
+ 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
~gdcmDicomDirImage();
- virtual void Print(std::ostream &os = std::cout);
+ virtual void Print(std::ostream &os = std::cout);
};
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmDicomDirMeta.cxx,v $
Language: C++
- Date: $Date: 2004/08/01 02:39:09 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2004/08/26 15:29:52 $
+ Version: $Revision: 1.6 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
// Print
/**
- * \ingroup gdcmDicomDirMeta
* \brief Prints the Object
- * @return
*/
void gdcmDicomDirMeta::Print(std::ostream &os)
{
gdcmObject::Print(os);
}
+
//-----------------------------------------------------------------------------
// Public
+
+/**
+ * \brief Writes the Object
+ * @return
+ */
+void gdcmDicomDirMeta::Write(FILE *fp, FileType t)
+{
+ gdcmObject::Write(fp, t);
+}
+
//-----------------------------------------------------------------------------
// Protected
Program: gdcm
Module: $RCSfile: gdcmDicomDirMeta.h,v $
Language: C++
- Date: $Date: 2004/08/01 02:39:09 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2004/08/26 15:29:52 $
+ Version: $Revision: 1.6 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
~gdcmDicomDirMeta();
virtual void Print(std::ostream &os = std::cout);
+ virtual void Write(FILE * fp, FileType t);
};
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmDicomDirPatient.cxx,v $
Language: C++
- Date: $Date: 2004/08/01 02:39:09 $
- Version: $Revision: 1.10 $
+ Date: $Date: 2004/08/26 15:29:52 $
+ Version: $Revision: 1.11 $
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 gdcmDicomDirPatient
* \brief Constructor
* @param s SQ Item holding the elements related to this "PATIENT" part
* @param ptagHT pointer to the HTable (gdcmObject needs it
docEntries = s->GetDocEntries();
}
/**
- * \ingroup gdcmDicomDirPatient
* \brief Constructor
* @param ptagHT pointer to the HTable (gdcmObject needs it
* to build the gdcmHeaderEntries)
{
}
/**
- * \ingroup gdcmDicomDirPatient
* \brief Canonical destructor.
*/
gdcmDicomDirPatient::~gdcmDicomDirPatient()
//-----------------------------------------------------------------------------
// Print
/**
- * \ingroup gdcmDicomDirPatient
* \brief Prints the Object
* @return
*/
}
}
+/**
+ * \brief Writes the Object
+ * @return
+ */
+void gdcmDicomDirPatient::Write(FILE *fp, FileType t)
+{
+ gdcmObject::Write(fp, t);
+
+ for(ListDicomDirStudy::iterator cc = studies.begin();cc!=studies.end();++cc)
+ {
+ (*cc)->Write( fp, t );
+ }
+}
//-----------------------------------------------------------------------------
// Public
/**
- * \ingroup gdcmDicomDir
* \brief adds a new Patient at the begining of the PatientList
* of a partially created DICOMDIR
*/
Program: gdcm
Module: $RCSfile: gdcmDicomDirPatient.h,v $
Language: C++
- Date: $Date: 2004/08/01 02:39:09 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2004/08/26 15:29:52 $
+ 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
~gdcmDicomDirPatient();
virtual void Print(std::ostream &os = std::cout);
-
+ virtual void Write(FILE *fp, FileType t);
/// Returns the STUDY chained List for this PATIENT.
ListDicomDirStudy &GetDicomDirStudies() { return studies; };
Program: gdcm
Module: $RCSfile: gdcmDicomDirSerie.cxx,v $
Language: C++
- Date: $Date: 2004/08/01 00:59:21 $
- Version: $Revision: 1.12 $
+ Date: $Date: 2004/08/26 15:29:52 $
+ 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
+
+/**
+ * \brief Writes the Object
+ * @return
+ */
+void gdcmDicomDirSerie::Write(FILE *fp, FileType t)
+{
+ gdcmObject::Write(fp, t);
+
+ for(ListDicomDirImage::iterator cc = images.begin();cc!=images.end();++cc)
+ {
+ (*cc)->Write( fp, t );
+ }
+}
+
/**
* \brief adds a new Image (with the basic elements) to a partially created DICOMDIR
*/
Program: gdcm
Module: $RCSfile: gdcmDicomDirSerie.h,v $
Language: C++
- Date: $Date: 2004/08/01 02:39:09 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2004/08/26 15:29:52 $
+ 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
~gdcmDicomDirSerie();
virtual void Print(std::ostream &os = std::cout);
+ virtual void Write(FILE *fp, FileType t);
/**
* \ingroup gdcmDicomDirSerie
* \brief returns the IMAGE chained List for this SERIE.
Program: gdcm
Module: $RCSfile: gdcmDicomDirStudy.cxx,v $
Language: C++
- Date: $Date: 2004/08/01 02:39:09 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2004/08/26 15:29:52 $
+ Version: $Revision: 1.10 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//-----------------------------------------------------------------------------
// Public
+/**
+ * \brief Writes the Object
+ * @return
+ */
+void gdcmDicomDirStudy::Write(FILE *fp, FileType t)
+{
+ gdcmObject::Write(fp, t);
+
+ for(ListDicomDirSerie::iterator cc = series.begin();cc!=series.end();++cc)
+ {
+ (*cc)->Write( fp, t );
+ }
+}
+
/**
* \ingroup gdcmDicomStudy
* \brief adds a new Serie at the begining of the SerieList
Program: gdcm
Module: $RCSfile: gdcmDicomDirStudy.h,v $
Language: C++
- Date: $Date: 2004/08/01 02:39:09 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2004/08/26 15:29:52 $
+ 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
~gdcmDicomDirStudy();
virtual void Print(std::ostream &os = std::cout);
+ virtual void Write(FILE *fp, FileType t);
/**
* \ingroup gdcmDicomDirStudy
* \brief returns the SERIE chained List for this STUDY.
Program: gdcm
Module: $RCSfile: gdcmDocEntrySet.cxx,v $
Language: C++
- Date: $Date: 2004/08/01 03:20:23 $
- Version: $Revision: 1.15 $
+ Date: $Date: 2004/08/26 15:29:52 $
+ 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
/**
- * \brief Build a new Element Value from all the low level arguments.
+ * \brief Build a new Val Entry from all the low level arguments.
* Check for existence of dictionary entry, and build
* a default one when absent.
* @param Group group number of the underlying DictEntry
/**
- * \brief Build a new Element Value from all the low level arguments.
+ * \brief Build a new Bin Entry from all the low level arguments.
* Check for existence of dictionary entry, and build
* a default one when absent.
* @param Group group number of the underlying DictEntry
}
return newEntry;
}
+
+/**
+ * \brief Build a new Seq Entry from all the low level arguments.
+ * Check for existence of dictionary entry, and build
+ * a default one when absent.
+ * @param Group group number of the underlying DictEntry
+ * @param Elem element number of the underlying DictEntry
+ */
+gdcmSeqEntry *gdcmDocEntrySet::NewSeqEntryByNumber(uint16_t Group,
+ uint16_t Elem)
+{
+ // Find out if the tag we encountered is in the dictionaries:
+ gdcmDictEntry *DictEntry = GetDictEntryByNumber(Group, Elem);
+ if (!DictEntry)
+ DictEntry = NewVirtualDictEntry(Group, Elem);
+
+ gdcmSeqEntry *NewEntry = new gdcmSeqEntry(DictEntry, 1); // FIXME : 1
+ if (!NewEntry)
+ {
+ dbg.Verbose(1, "gdcmDocument::NewSeqEntryByNumber",
+ "failed to allocate gdcmSeqEntry");
+ return NULL;
+ }
+ return NewEntry;
+}
//-----------------------------------------------------------------------------
// Protected
Program: gdcm
Module: $RCSfile: gdcmDocEntrySet.h,v $
Language: C++
- Date: $Date: 2004/08/01 03:20:23 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2004/08/26 15:29:52 $
+ 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
gdcmDocEntry* NewDocEntryByNumber(uint16_t group,
uint16_t element);
gdcmDocEntry* NewDocEntryByName (std::string const & name);
+ gdcmSeqEntry* NewSeqEntryByNumber(uint16_t group,
+ uint16_t element);
// DictEntry related utilities
gdcmDictEntry *GetDictEntryByName (std::string const & name);
Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2004/08/16 04:34:56 $
- Version: $Revision: 1.67 $
+ Date: $Date: 2004/08/26 15:29:53 $
+ Version: $Revision: 1.68 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
return;
}
-
+
dbg.Verbose(0, "gdcmDocument::gdcmDocument: starting parsing of file: ",
Filename.c_str());
rewind(Fp);
{
if( Filetype == gdcmUnknown)
{
- std::cout << " gdcmDocument::IsReadable: Filetype " << Filetype
- << " " << "gdcmUnknown " << gdcmUnknown << std::endl; //JPR
dbg.Verbose(0, "gdcmDocument::IsReadable: wrong filetype");
return false;
}
return b;
}
+
+/*
+ * \brief Modifies the value of a given Header Entry (Dicom Element)
+ * when it exists. Create it when unexistant.
+ * @param Group Group number of the Entry
+ * @param Elem Element number of the Entry
+ * \return pointer to the modified/created SeqEntry (NULL when creation
+ * failed).
+ */
+gdcmSeqEntry * gdcmDocument::ReplaceOrCreateByNumber(
+ uint16_t group,
+ uint16_t elem)
+{
+ gdcmSeqEntry* b = 0;
+ gdcmDocEntry* a = GetDocEntryByNumber( group, elem);
+ if (!a)
+ {
+ a = NewSeqEntryByNumber(group, elem);
+ if (!a)
+ {
+ return 0;
+ }
+
+ b = new gdcmSeqEntry(a, 1); // FIXME : 1 (Depth)
+ AddEntry(b);
+ }
+ return b;
+}
+
/**
* \brief Set a new value if the invoked element exists
* Seems to be useless !!!
a=( ((a<< 8) & 0xff00ff00) | ((a>>8) & 0x00ff00ff) );
break;
default :
- std::cout << "swapCode= " << SwapCode << std::endl;
+ //std::cout << "swapCode= " << SwapCode << std::endl;
dbg.Error(" gdcmDocument::SwapLong : unset swap code");
a = 0;
}
}
delete newDocEntry;
}
-
return l; // Probably useless
}
{
uint16_t element = entry->GetElement();
std::string vr = entry->GetVR();
- uint16_t length16;
-
+ uint16_t length16;
if ( Filetype == gdcmExplicitVR && !entry->IsImplicitVR() )
{
Program: gdcm
Module: $RCSfile: gdcmDocument.h,v $
Language: C++
- Date: $Date: 2004/08/02 16:42:14 $
- Version: $Revision: 1.30 $
+ Date: $Date: 2004/08/26 15:29:53 $
+ Version: $Revision: 1.31 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
gdcmBinEntry* ReplaceOrCreateByNumber(void *voidArea, int lgth,
uint16_t group, uint16_t elem);
+ gdcmSeqEntry* ReplaceOrCreateByNumber(uint16_t group, uint16_t elem);
bool ReplaceIfExistByNumber ( std::string const & value,
uint16_t group,
uint16_t elem );
private:
// Read
- long ParseDES(gdcmDocEntrySet *set, long offset, long l_max,bool delim_mode);
- long ParseSQ (gdcmSeqEntry *seq, long offset, long l_max, bool delim_mode);
+ long ParseDES(gdcmDocEntrySet *set,long offset, long l_max, bool delim_mode);
+ long ParseSQ (gdcmSeqEntry *seq, long offset, long l_max, bool delim_mode);
void LoadDocEntry (gdcmDocEntry *);
void FindDocEntryLength(gdcmDocEntry *) throw ( gdcmFormatError );
Program: gdcm
Module: $RCSfile: gdcmFile.cxx,v $
Language: C++
- Date: $Date: 2004/08/02 16:42:14 $
- Version: $Revision: 1.120 $
+ Date: $Date: 2004/08/26 15:29:53 $
+ Version: $Revision: 1.121 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
typedef std::pair<TagDocEntryHT::iterator,TagDocEntryHT::iterator> IterHT;
-//-----------------------------------------------------------------------------
+//-------------------------------------------------------------------------
// Constructor / Destructor
/**
* \ingroup gdcmFile
Program: gdcm
Module: $RCSfile: gdcmObject.h,v $
Language: C++
- Date: $Date: 2004/08/01 00:59:21 $
- Version: $Revision: 1.18 $
+ Date: $Date: 2004/08/26 15:29:53 $
+ 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
class GDCM_EXPORT gdcmObject : public gdcmSQItem
{
public:
+
+ gdcmObject(TagDocEntryHT *ptagHT, int depth = 0);
+ virtual ~gdcmObject();
/**
* \brief Sets the print level for the Dicom Header
* \note 0 for Light Print; 1 for 'medium' Print, 2 for Heavy
protected:
// Constructor and destructor are protected to avoid end user to
- // instanciate from this class.
- gdcmObject(TagDocEntryHT *ptagHT, int depth = 0);
- virtual ~gdcmObject();
+ // instanciate from this class.
+ // NO ! gdcmDicomDir needs to instanciate it!
// Members :
///\brief detail level to be printed
Program: gdcm
Module: $RCSfile: gdcmSQItem.cxx,v $
Language: C++
- Date: $Date: 2004/08/01 03:20:23 $
- Version: $Revision: 1.23 $
+ Date: $Date: 2004/08/26 15:29:53 $
+ 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
os << s.str();
Entry->SetPrintLevel(2);
- Entry->Print(os);
+ Entry->Print(os);
if ( gdcmSeqEntry* SeqEntry = dynamic_cast<gdcmSeqEntry*>(Entry) )
{
(void)SeqEntry; //not used
Program: gdcm
Module: $RCSfile: gdcmSeqEntry.cxx,v $
Language: C++
- Date: $Date: 2004/07/21 14:02:11 $
- Version: $Revision: 1.22 $
+ Date: $Date: 2004/08/26 15:29:53 $
+ Version: $Revision: 1.23 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
delimitor_mode = false;
seq_term = NULL;
SQDepthLevel = depth;
+ UsableLength = 0;
+ ReadLength = 0xffffffff;
}
+/**
+ * \brief Constructor from a given gdcmSeqEntry
+ * @param e Pointer to existing Doc entry
+ */
+gdcmSeqEntry::gdcmSeqEntry(gdcmDocEntry* e, int depth) : gdcmDocEntry(e->GetDictEntry())
+{
+ this->UsableLength = 0;
+ this->ReadLength = 0xffffffff;
+ this->ImplicitVR = e->IsImplicitVR();
+ this->Offset = e->GetOffset();
+ //this->printLevel = e->GetPrintLevel(); // no longer exists ?!?
+ this->SQDepthLevel = e->GetDepthLevel();
+}
/**
* \brief Canonical destructor.
*/
++cc)
{
(*cc)->Write(fp, filetype);
-
- fwrite ( &item_term_gr,(size_t)2 ,(size_t)1 ,fp);
- fwrite ( &item_term_el,(size_t)2 ,(size_t)1 ,fp);
- fwrite ( &seq_term_lg, (size_t)4 ,(size_t)1 ,fp); // Heu .....
+
+ //we force the writting of an Item Delimitation item
+ // because we wrote the Item as a 'no Length' item
+ fwrite ( &item_term_gr,(size_t)2 ,(size_t)1 ,fp);
+ fwrite ( &item_term_el,(size_t)2 ,(size_t)1 ,fp);
+ fwrite ( &seq_term_lg, (size_t)4 ,(size_t)1 ,fp); // Heu .....
}
- //we force the writting of a Sequence Delimitaion item
+
+ //we force the writting of a Sequence Delimitation item
// because we wrote the Sequence as a 'no Length' sequence
fwrite ( &seq_term_gr,(size_t)2 ,(size_t)1 ,fp);
fwrite ( &seq_term_el,(size_t)2 ,(size_t)1 ,fp);
Program: gdcm
Module: $RCSfile: gdcmSeqEntry.h,v $
Language: C++
- Date: $Date: 2004/07/02 13:55:28 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2004/08/26 15:29:53 $
+ 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:
gdcmSeqEntry(gdcmDictEntry* e, int depth);
+ gdcmSeqEntry(gdcmDocEntry* d, int depth);
virtual ~gdcmSeqEntry();
virtual void Print(std::ostream &os = std::cout);