From: jpr Date: Wed, 21 Jul 2004 14:02:10 +0000 (+0000) Subject: JPR X-Git-Tag: Version0.5.bp~37 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=81fe774739a1629471fcc2705549fa56dad44a70;p=gdcm.git JPR Now, Parsing and Printing a DICOMDIR do work! ( troubles remain in makeDicomDir and BuildUpDicomDir :-( --- diff --git a/Example/BuildUpDicomDir.cxx b/Example/BuildUpDicomDir.cxx index 54493a15..c52275f5 100644 --- a/Example/BuildUpDicomDir.cxx +++ b/Example/BuildUpDicomDir.cxx @@ -54,6 +54,9 @@ int main(int argc, char* argv[]) dcmdir=new gdcmDicomDir(); printf( "BuildUpDicomDir: exiting new DicomDir\n"); + printf( "\n------- BuildUpDicomDir: Test Print Meta only -----\n"); + ((gdcmDocument *)dcmdir)->Print(); + gdcmDicomDirPatient *p1=dcmdir->NewPatient(); p1->SetEntryByNumber("patientONE",0x0010, 0x0010); diff --git a/Example/PrintDicomDir.cxx b/Example/PrintDicomDir.cxx index 89ba25c0..00adffc0 100644 --- a/Example/PrintDicomDir.cxx +++ b/Example/PrintDicomDir.cxx @@ -129,12 +129,12 @@ int main(int argc, char* argv[]) } */ -/* + cout << std::endl << std::endl << " = DICOMDIR full content ==========================================" << std::endl<< std::endl; e1->Print(); -*/ + std::cout<Print(); + std::cout << "---after constructor; Print as a DICOMDIR ------" << std::endl; + dcmdir->Print(); + dcmdir->SetStartMethod(StartMethod, (void *) NULL); dcmdir->SetEndMethod(EndMethod); + std::cout << "---before ParseDirectory------------------" << std::endl; dcmdir->ParseDirectory(); - std::cout << "---after ParseDirectory------------------" << std::endl; + std::cout << "---after ParseDirectory------------------" << std::endl; ListDicomDirPatient lp = dcmdir->GetDicomDirPatients(); if (! lp.size() ) diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index b3e0d686..fa59a3b7 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.cxx,v $ Language: C++ - Date: $Date: 2004/07/19 03:34:11 $ - Version: $Revision: 1.57 $ + Date: $Date: 2004/07/21 14:02:10 $ + Version: $Revision: 1.58 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -46,25 +46,21 @@ //----------------------------------------------------------------------------- // Constructor / Destructor -void gdcmDicomDir::Initialize() -{ - startMethod = NULL; - progressMethod = NULL; - endMethod = NULL; - startMethodArgDelete = NULL; - progressMethodArgDelete = NULL; - endMethodArgDelete = NULL; - startArg = NULL; - progressArg = NULL; - endArg = NULL; - - progress = 0.0; - abort = false; +/** + * \ingroup gdcmDicomDir + * \brief Constructor : creates an empty gdcmDicomDir + * @param exception_on_error whether we want to throw an exception or not + */ +gdcmDicomDir::gdcmDicomDir(bool exception_on_error): + gdcmDocument( exception_on_error ) +{ + Initialize(); - metaElems = (gdcmDicomDirMeta *)0; + std::string pathBidon = "Bidon"; // Sorry, NULL not allowed ... + SetElement(pathBidon, GDCM_DICOMDIR_META, NULL); // Set the META elements + AddDicomDirMeta(); } - /** * \brief Constructor Parses recursively the directory and creates the DicomDir * or uses an already built DICOMDIR, depending on 'parseDir' value. @@ -90,21 +86,22 @@ gdcmDicomDir::gdcmDicomDir(std::string const & fileName, bool parseDir, // 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() ) { dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : entry HT empty"); - if( fileName.size() == 1 && fileName[0] == '.' ) + if ( fileName.size() == 1 && fileName[0] == '.' ) { // user passed '.' as Name // 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 + delete[] dummy; // no longer needed } - if( parseDir ) + if ( parseDir ) { dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : Parse directory" " and create the DicomDir"); @@ -113,6 +110,8 @@ gdcmDicomDir::gdcmDicomDir(std::string const & fileName, bool parseDir, else { /// \todo if parseDir == false, it should be tagged as an error + // NON ! il suffit d'appeler ParseDirectory() + // apres le constructeur } } else @@ -130,21 +129,6 @@ gdcmDicomDir::gdcmDicomDir(std::string const & fileName, bool parseDir, } } -/** - * \ingroup gdcmDicomDir - * \brief Constructor : creates an empty gdcmDicomDir - * @param exception_on_error whether we want to throw an exception or not - */ -gdcmDicomDir::gdcmDicomDir(bool exception_on_error): - gdcmDocument( exception_on_error ) -{ - Initialize(); - - std::string pathBidon = "Bidon"; // Sorry, NULL not allowed ... - SetElement(pathBidon, GDCM_DICOMDIR_META, NULL); // Set the META elements - AddDicomDirMeta(); -} - /** * \brief Canonical destructor */ @@ -154,7 +138,7 @@ gdcmDicomDir::~gdcmDicomDir() SetProgressMethod(NULL); SetEndMethod(NULL); - if( metaElems ) + if ( metaElems ) { delete metaElems; } @@ -216,6 +200,29 @@ bool gdcmDicomDir::IsReadable() return true; } +/** + * \brief Sets all fields to NULL + */ + +void gdcmDicomDir::Initialize() +{ + startMethod = NULL; + progressMethod = NULL; + endMethod = NULL; + startMethodArgDelete = NULL; + progressMethodArgDelete = NULL; + endMethodArgDelete = NULL; + startArg = NULL; + progressArg = NULL; + endArg = NULL; + + progress = 0.0; + abort = false; + + metaElems = (gdcmDicomDirMeta *)0; +} + + /** * \ingroup gdcmDicomDir * \brief fills the whole structure, starting from a root Directory @@ -447,7 +454,7 @@ void gdcmDicomDir::CreateDicomDirChainedList(std::string const & path) header = new gdcmHeader(it->c_str(),false,true); if(!header) { - std::cout << "echec new Header " << it->c_str() << std::endl; // JPR + std::cout << "failure in new Header " << it->c_str() << std::endl; // JPR } if(header->IsReadable()) { list.push_back(header); // adds the file header to the chained list @@ -500,16 +507,19 @@ gdcmDicomDirPatient * gdcmDicomDir::NewPatient() uint16_t tmpGr,tmpEl; gdcmDictEntry *dictEntry; gdcmValEntry *entry; - + + std::list elemList; + elemList=gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements(); +// Looks nice, but gdcmDicomDir IS NOT a gdcmObject ... +// gdcmDicomDirPatient *p = new gdcmDicomDirPatient(ptagHT); +// FillObject(elemList); +// patients.push_front( p ); +// return p; +/// \todo TODO : find a trick to use FillObject !!! + gdcmSQItem *s = new gdcmSQItem(0); - - std::list elemList = - gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements(); - - /// \todo TODO : use FillObject !!! - // for all the DicomDirPatient Elements - + // for all the DicomDirPatient Elements for( it = elemList.begin(); it != elemList.end(); ++it ) { tmpGr = it->group; @@ -567,24 +577,29 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type, gdcmDictEntry *dictEntry; gdcmValEntry *entry; std::string val; - + gdcmObject *o; switch( type ) { - case GDCM_DICOMDIR_PATIENT: - elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements(); - break; - case GDCM_DICOMDIR_STUDY: - elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements(); + case GDCM_DICOMDIR_IMAGE: + elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements(); break; + case GDCM_DICOMDIR_SERIE: elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirSerieElements(); break; - case GDCM_DICOMDIR_IMAGE: - elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirImageElements(); + + case GDCM_DICOMDIR_STUDY: + elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirStudyElements(); break; + + case GDCM_DICOMDIR_PATIENT: + elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirPatientElements(); + break; + case GDCM_DICOMDIR_META: elemList = gdcmGlobal::GetDicomDirElements()->GetDicomDirMetaElements(); break; + default: return; } @@ -598,7 +613,8 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type, entry->SetOffset(0); // just to avoid further missprinting - if( header ) + if( header ) // NULL when we Build Up (ex nihilo) a DICOMDIR + // or when we add the META elems { val = header->GetEntryByNumber(tmpGr, tmpEl); } @@ -646,7 +662,7 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type, { if( dictEntry->GetGroup() == 0xfffe ) { - entry->SetLength( entry->GetValue().length() ); + entry->SetLength( entry->GetValue().length() ); // FIXME } else if( dictEntry->GetVR() == "UL" || dictEntry->GetVR() == "SL" ) { @@ -665,8 +681,12 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type, entry->SetLength( entry->GetValue().length() ); } } - //AddDocEntry(entry); // both in H Table and in chained list - TagHT[entry->GetKey()] = entry; // FIXME : use a SEQUENCE ! + std::cout << " was TagHT[entry->GetKey()] = entry " << std::endl; + if ( type == GDCM_DICOMDIR_META ) { + std::cout << " special Treatment for GDCM_DICOMDIR_META" << std::endl; + + } + //TagHT[entry->GetKey()] = entry; // FIXME : use a SEQUENCE ! } } @@ -724,8 +744,6 @@ void gdcmDicomDir::CreateDicomDir() // + we create the object for the precedent tag // + loop to 1 - - gdcmDicomDirType type = gdcmDicomDir::GDCM_DICOMDIR_META; - // Directory record sequence gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220); if ( !e ) @@ -740,12 +758,14 @@ void gdcmDicomDir::CreateDicomDir() if ( !s ) { dbg.Verbose(0, "gdcmDicomDir::CreateDicomDir: no SeqEntry present"); + // useless : (0x0004,0x1220) IS a Sequence ! return; } + gdcmDicomDirType type = gdcmDicomDir::GDCM_DICOMDIR_META; + metaElems = NewMeta(); + ListSQItem listItems = s->GetSQItems(); - gdcmDicomDirMeta *m = new gdcmDicomDirMeta(&TagHT); - (void)m; //?? gdcmDocEntry * d; std::string v; diff --git a/src/gdcmDicomDirSerie.cxx b/src/gdcmDicomDirSerie.cxx index ecdb07c2..0b62c553 100644 --- a/src/gdcmDicomDirSerie.cxx +++ b/src/gdcmDicomDirSerie.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirSerie.cxx,v $ Language: C++ - Date: $Date: 2004/06/20 18:08:47 $ - Version: $Revision: 1.10 $ + Date: $Date: 2004/07/21 14:02:10 $ + 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 @@ -75,7 +75,7 @@ void gdcmDicomDirSerie::Print(std::ostream &os) //----------------------------------------------------------------------------- // Public /** - * \brief adds a new Image to a partially created DICOMDIR + * \brief adds a new Image (with the basic elements) to a partially created DICOMDIR */ gdcmDicomDirImage * gdcmDicomDirSerie::NewImage(void) { std::list elemList; diff --git a/src/gdcmObject.cxx b/src/gdcmObject.cxx index 331c4107..953131b2 100644 --- a/src/gdcmObject.cxx +++ b/src/gdcmObject.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmObject.cxx,v $ Language: C++ - Date: $Date: 2004/07/17 22:47:01 $ - Version: $Revision: 1.22 $ + Date: $Date: 2004/07/21 14:02:10 $ + 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 @@ -28,7 +28,7 @@ * * @param ptagHT pointer to the HTable (gdcmObject needs it * to build the gdcmDocEntries) - * @param depth Seaquence depth level + * @param depth Sequence depth level */ gdcmObject::gdcmObject(TagDocEntryHT *ptagHT, int depth) @@ -80,9 +80,7 @@ void gdcmObject::FillObject(std::list elemList) { uint16_t tmpGr,tmpEl; gdcmDictEntry *dictEntry; gdcmValEntry *entry; - - //gdcmSQItem *s = new gdcmSQItem; - + // for all the Elements found in they own part of the DicomDir dict. for(it=elemList.begin();it!=elemList.end();++it) { diff --git a/src/gdcmSeqEntry.cxx b/src/gdcmSeqEntry.cxx index 9ba911ee..38793b60 100644 --- a/src/gdcmSeqEntry.cxx +++ b/src/gdcmSeqEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSeqEntry.cxx,v $ Language: C++ - Date: $Date: 2004/07/02 13:55:28 $ - Version: $Revision: 1.21 $ + Date: $Date: 2004/07/21 14:02:11 $ + 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 @@ -104,7 +104,7 @@ void gdcmSeqEntry::Write(FILE *fp, FileType 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); + fwrite ( &seq_term_lg, (size_t)4 ,(size_t)1 ,fp); // Heu ..... } //we force the writting of a Sequence Delimitaion item // because we wrote the Sequence as a 'no Length' sequence