From: jpr Date: Fri, 4 Feb 2005 14:49:01 +0000 (+0000) Subject: * Add GetFirstValEntry + GetNexxtValEntry, for Python users X-Git-Tag: Version1.0.bp~88 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=0f8bcdd7eb7538bda5c38c4587c0ae54cb0c3693;p=gdcm.git * Add GetFirstValEntry + GetNexxtValEntry, for Python users * Some more Doxygenation + typo fixing --- diff --git a/src/gdcmDocEntry.h b/src/gdcmDocEntry.h index b77f2943..7571fd72 100644 --- a/src/gdcmDocEntry.h +++ b/src/gdcmDocEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.h,v $ Language: C++ - Date: $Date: 2005/02/02 16:18:48 $ - Version: $Revision: 1.45 $ + Date: $Date: 2005/02/04 14:49:01 $ + Version: $Revision: 1.46 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -41,6 +41,7 @@ class GDCM_EXPORT DocEntry : public Base { public: DocEntry(DictEntry*); + /// \brief Canonical Destructor virtual ~DocEntry() {}; virtual void Print (std::ostream &os = std::cout, std::string const &indent = ""); diff --git a/src/gdcmDocEntrySet.cxx b/src/gdcmDocEntrySet.cxx index 6a4597f0..04dc3a1d 100644 --- a/src/gdcmDocEntrySet.cxx +++ b/src/gdcmDocEntrySet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.cxx,v $ Language: C++ - Date: $Date: 2005/02/02 16:18:48 $ - Version: $Revision: 1.52 $ + Date: $Date: 2005/02/04 14:49:01 $ + Version: $Revision: 1.53 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -252,7 +252,7 @@ ValEntry *DocEntrySet::InsertValEntry(std::string const &value, TagName const &vr ) { ValEntry *valEntry = 0; - DocEntry *currentEntry = GetDocEntry( group, elem); + DocEntry *currentEntry = GetDocEntry( group, elem ); if (currentEntry) { @@ -278,7 +278,7 @@ ValEntry *DocEntrySet::InsertValEntry(std::string const &value, // Create a new valEntry if necessary if( !valEntry ) { - valEntry = NewValEntry(group, elem, vr); + valEntry = NewValEntry( group, elem, vr ); if ( !AddEntry(valEntry) ) { @@ -294,11 +294,12 @@ ValEntry *DocEntrySet::InsertValEntry(std::string const &value, return valEntry; } -/* +/** * \brief Modifies the value of a given Header Entry (Dicom Element) * when it exists. Create it with the given value when unexistant. * A copy of the binArea is made to be kept in the Document. * @param binArea (binary) value to be set + * @param lgth length of the Bin Area we want to set * @param group Group number of the Entry * @param elem Element number of the Entry * @param vr V(alue) R(epresentation) of the Entry -if private Entry- @@ -310,7 +311,7 @@ BinEntry *DocEntrySet::InsertBinEntry(uint8_t *binArea, int lgth, TagName const &vr ) { BinEntry *binEntry = 0; - DocEntry *currentEntry = GetDocEntry( group, elem); + DocEntry *currentEntry = GetDocEntry( group, elem ); // Verify the currentEntry if (currentEntry) @@ -370,7 +371,7 @@ BinEntry *DocEntrySet::InsertBinEntry(uint8_t *binArea, int lgth, return binEntry; } -/* +/** * \brief Modifies the value of a given Header Entry (Dicom Element) * when it exists. Creates it when unexistant. * @param group Group number of the Entry @@ -440,7 +441,7 @@ bool DocEntrySet::CheckIfEntryExist(uint16_t group, uint16_t elem ) * @param vr VR of the new Entry */ ValEntry *DocEntrySet::NewValEntry(uint16_t group,uint16_t elem, - TagName const & vr) + TagName const &vr) { DictEntry *dictEntry = GetDictEntry(group, elem, vr); gdcmAssertMacro(dictEntry); @@ -507,10 +508,10 @@ SeqEntry* DocEntrySet::NewSeqEntry(uint16_t group, uint16_t elem) * @param vm VM (Value Multiplicity) of the underlying DictEntry * @param name english name */ -DictEntry* DocEntrySet::NewVirtualDictEntry( uint16_t group,uint16_t elem, - TagName const & vr, - TagName const & vm, - TagName const & name ) +DictEntry* DocEntrySet::NewVirtualDictEntry( uint16_t group, uint16_t elem, + TagName const &vr, + TagName const &vm, + TagName const &name ) { return Global::GetDicts()->NewVirtualDictEntry(group,elem,vr,vm,name); } diff --git a/src/gdcmDocEntrySet.h b/src/gdcmDocEntrySet.h index c1374a1b..4328fe1c 100644 --- a/src/gdcmDocEntrySet.h +++ b/src/gdcmDocEntrySet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.h,v $ Language: C++ - Date: $Date: 2005/02/02 16:18:48 $ - Version: $Revision: 1.47 $ + Date: $Date: 2005/02/04 14:49:01 $ + Version: $Revision: 1.48 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -59,7 +59,9 @@ typedef std::string BaseTagKey; class GDCM_EXPORT DocEntrySet : public Base { public: + /// Canonical Constructor DocEntrySet() {}; + /// Canonical Destructor virtual ~DocEntrySet() {}; /// \brief write any type of entry to the entry set @@ -73,10 +75,14 @@ public: virtual bool RemoveEntry(DocEntry *EntryToRemove) = 0; /// \brief Removes any type of entry out of the entry set, DOESN'T destroy it virtual bool RemoveEntryNoDestroy(DocEntry *EntryToRemove) = 0; - + /// Gets the first entry of any type of set virtual DocEntry *GetFirstEntry()=0; + /// Gets the next entry of any type of set virtual DocEntry *GetNextEntry()=0; - + /// Gets the first ValEntry of set (for Python users) + virtual ValEntry *GetFirstValEntry()=0; + /// Gets the next ValEntry of set (for Python users) + virtual ValEntry *GetNextValEntry()=0; virtual std::string GetEntryValue(uint16_t group, uint16_t elem); virtual void *GetEntryBinArea(uint16_t group, uint16_t elem); virtual int GetEntryLength(uint16_t group, uint16_t elem); @@ -105,7 +111,7 @@ public: uint16_t group, uint16_t elem, TagName const &vr = GDCM_UNKNOWN); virtual SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem); - + /// tells us if the set contains no entry virtual bool IsEmpty() = 0; virtual bool CheckIfEntryExist(uint16_t group, uint16_t elem); diff --git a/src/gdcmElementSet.cxx b/src/gdcmElementSet.cxx index 1330a42f..7b306ee2 100644 --- a/src/gdcmElementSet.cxx +++ b/src/gdcmElementSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.cxx,v $ Language: C++ - Date: $Date: 2005/02/02 16:18:48 $ - Version: $Revision: 1.53 $ + Date: $Date: 2005/02/04 14:49:01 $ + Version: $Revision: 1.54 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -135,7 +135,8 @@ void ElementSet::ClearEntry() } /** - * \brief Get the first entry while visiting the DocEntrySet + * \brief Get the first entry while visiting *the* 'zero level' DocEntrySet + * (DocEntries out of any Sequence) * \return The first DocEntry if found, otherwhise NULL */ DocEntry *ElementSet::GetFirstEntry() @@ -147,7 +148,8 @@ DocEntry *ElementSet::GetFirstEntry() } /** - * \brief Get the next entry while visiting the Hash table (TagHT) + * \brief Get the next entry while visiting *the* 'zero level' DocEntrySet + * (DocEntries out of any Sequence) * \note : meaningfull only if GetFirstEntry already called * \return The next DocEntry if found, otherwhise NULL */ @@ -161,6 +163,45 @@ DocEntry *ElementSet::GetNextEntry() return NULL; } +/** + * \brief Get the first ValEntry while visiting *the* 'zero level' DocEntrySet + * (DocEntries out of any Sequence) + * This method is designed for Python users + * \return The first ValEntry if found, otherwhise NULL + */ +ValEntry *ElementSet::GetFirstValEntry() +{ + gdcm::ValEntry *valEntry; + gdcm::DocEntry *d = GetFirstEntry(); + // an other iterator is needed to allow user iterate + // at the same time both on DocEntries and ValEntries + ItValEntryTagHT = ItTagHT; + if ( valEntry = dynamic_cast(d)) + return valEntry; + return GetNextValEntry(); +} + +/** + * \brief Get the next ValEntry while visiting *the* 'zero level' DocEntrySet + * (DocEntries out of any Sequence) + * \note : meaningfull only if GetFirstValEntry already called + * \return The next ValEntry if found, otherwhise NULL + */ +ValEntry *ElementSet::GetNextValEntry() +{ + gdcm::ValEntry *valEntry; + gdcm::DocEntry *d = ItValEntryTagHT->second; + ++ItValEntryTagHT; + while( d ) + { + if ( valEntry = dynamic_cast(d)) + return valEntry; + else + return GetNextValEntry(); + } + return 0; +} + /** * \brief retrieves a Dicom Element using (group, element) * @param group Group number of the searched Dicom Element diff --git a/src/gdcmElementSet.h b/src/gdcmElementSet.h index dcf695ad..e5a60a0e 100644 --- a/src/gdcmElementSet.h +++ b/src/gdcmElementSet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.h,v $ Language: C++ - Date: $Date: 2005/02/02 16:18:48 $ - Version: $Revision: 1.41 $ + Date: $Date: 2005/02/04 14:49:01 $ + Version: $Revision: 1.42 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -58,9 +58,10 @@ public: DocEntry *GetFirstEntry(); DocEntry *GetNextEntry(); - + ValEntry *GetFirstValEntry(); + ValEntry *GetNextValEntry(); DocEntry *GetDocEntry(uint16_t group, uint16_t elem); - + /// Tells us if the ElementSet contains no entry bool IsEmpty() { return TagHT.empty(); }; protected: @@ -69,8 +70,10 @@ private: // Variables /// Hash Table (map), to provide fast access TagDocEntryHT TagHT; - /// Hash Table (map) iterator, used to visit the TagHT variable - TagDocEntryHT::iterator ItTagHT; + /// iterator, used to visit the TagHT variable + TagDocEntryHT::iterator ItTagHT; + /// iterator, used to visit the TagHT variable, seeking only for ValEntries + TagDocEntryHT::iterator ItValEntryTagHT; }; } // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmFileHelper.cxx b/src/gdcmFileHelper.cxx index 5e7ed07e..bde7e0f9 100644 --- a/src/gdcmFileHelper.cxx +++ b/src/gdcmFileHelper.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFileHelper.cxx,v $ Language: C++ - Date: $Date: 2005/02/02 16:18:48 $ - Version: $Revision: 1.11 $ + Date: $Date: 2005/02/04 14:49:01 $ + 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 @@ -133,7 +133,7 @@ FileHelper::~FileHelper() * @param elem element number of the Dicom Element to modify */ bool FileHelper::SetValEntry(std::string const &content, - uint16_t group, uint16_t elem) + uint16_t group, uint16_t elem) { return FileInternal->SetValEntry(content,group,elem); } @@ -149,7 +149,7 @@ bool FileHelper::SetValEntry(std::string const &content, * @param elem element number of the Dicom Element to modify */ bool FileHelper::SetBinEntry(uint8_t *content, int lgth, - uint16_t group, uint16_t elem) + uint16_t group, uint16_t elem) { return FileInternal->SetBinEntry(content,lgth,group,elem); } @@ -164,28 +164,29 @@ bool FileHelper::SetBinEntry(uint8_t *content, int lgth, * failed). */ ValEntry *FileHelper::InsertValEntry(std::string const &content, - uint16_t group, uint16_t elem) + uint16_t group, uint16_t elem) { return FileInternal->InsertValEntry(content,group,elem); } -/* +/** * \brief Modifies the value of a given DocEntry (Dicom entry) * when it exists. Create it with the given value when unexistant. * A copy of the binArea is made to be kept in the Document. * @param binArea (binary) value to be set + * @param lgth new value length * @param group Group number of the Entry * @param elem Element number of the Entry * \return pointer to the modified/created Dicom entry (NULL when creation * failed). */ BinEntry *FileHelper::InsertBinEntry(uint8_t *binArea, int lgth, - uint16_t group, uint16_t elem) + uint16_t group, uint16_t elem) { return FileInternal->InsertBinEntry(binArea,lgth,group,elem); } -/* +/** * \brief Modifies the value of a given DocEntry (Dicom entry) * when it exists. Create it with the given value when unexistant. * A copy of the binArea is made to be kept in the Document. @@ -235,9 +236,9 @@ size_t FileHelper::GetImageDataRawSize() } /** - * \brief - Allocates necessary memory, + * \brief - Allocates necessary memory, * - Reads the pixels from disk (uncompress if necessary), - * - Transforms YBR pixels, if any, into RGB pixels + * - Transforms YBR pixels, if any, into RGB pixels, * - Transforms 3 planes R, G, B, if any, into a single RGB Plane * - Transforms single Grey plane + 3 Palettes into a RGB Plane * - Copies the pixel data (image[s]/volume[s]) to newly allocated zone. @@ -347,9 +348,11 @@ size_t FileHelper::GetImageDataIntoVector (void *destination, size_t maxSize) * 'volume'Pixels are presented as C-like 3D arrays : plane per plane * \warning Since the pixels are not copied, it is the caller's responsability * not to deallocate its data before gdcm uses them (e.g. with - * the Write() method. - * @param inData user supplied pixel area - * @param expectedSize total image size, in Bytes + * the Write() method ) + * @param inData user supplied pixel area (uint8_t* is just for the compiler. + * user is allowed to pass any kind of pixelsn since the size is + * given in bytes) + * @param expectedSize total image size, *in Bytes* * * @return boolean */ @@ -361,10 +364,15 @@ void FileHelper::SetImageData(uint8_t *inData, size_t expectedSize) /** * \brief Set the image data defined by the user * \warning When writting the file, this data are get as default data to write + * @param inData user supplied pixel area (uint8_t* is just for the compiler. + * user is allowed to pass any kind of pixelsn since the size is + * given in bytes) + * @param expectedSize total image size, *in Bytes* + */ -void FileHelper::SetUserData(uint8_t *data, size_t expectedSize) +void FileHelper::SetUserData(uint8_t *inData, size_t expectedSize) { - PixelWriteConverter->SetUserData(data,expectedSize); + PixelWriteConverter->SetUserData(inData,expectedSize); } /** diff --git a/src/gdcmFileHelper.h b/src/gdcmFileHelper.h index 7c55cb41..18ab4bb9 100644 --- a/src/gdcmFileHelper.h +++ b/src/gdcmFileHelper.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFileHelper.h,v $ Language: C++ - Date: $Date: 2005/02/03 10:03:07 $ - Version: $Revision: 1.9 $ + Date: $Date: 2005/02/04 14:49:01 $ + 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 @@ -95,17 +95,32 @@ public: uint8_t* GetLutRGBA(); // Write mode - void SetWriteModeToRaw() { SetWriteMode(WMODE_RAW); }; + + /// \brief Tells the writer we want to write a Raw File (no header) + void SetWriteModeToRaw() { SetWriteMode(WMODE_RAW); }; + /// \brief Tells the writer we want to write RGB image when possible + /// (as opposite to 'Grey pixels + Palettes color') void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); }; + /// \brief Sets the Write Mode ( ) void SetWriteMode(FileMode mode) { WriteMode = mode; }; + /// \brief Gets the Write Mode ( ) FileMode GetWriteMode() { return WriteMode; }; // Write format + + /// \brief Tells the writer we want to write as Implicit VR void SetWriteTypeToDcmImplVR() { SetWriteType(ImplicitVR); }; + /// \brief Tells the writer we want to write as Explicit VR void SetWriteTypeToDcmExplVR() { SetWriteType(ExplicitVR); }; + /// \brief Tells the writer we want to write as ACR-NEMA void SetWriteTypeToAcr() { SetWriteType(ACR); }; + /// \brief Tells the writer we want to write as LibIDO void SetWriteTypeToAcrLibido() { SetWriteType(ACR_LIBIDO); }; + /// \brief Tells the writer which format want to write + /// (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO) void SetWriteType(FileType format) { WriteType = format; }; + /// \brief Gets the format we want to write + /// (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO) FileType GetWriteType() { return WriteType; }; // Write pixels of ONE image on hard drive @@ -153,15 +168,20 @@ private: /// Wether already parsed or not bool Parsed; - /// Utility pixel converter + // Utility pixel converter + /// \brief Pointer to the PixelReadConverter PixelReadConvert *PixelReadConverter; + /// \brief Pointer to the PixelWriteConverter PixelWriteConvert *PixelWriteConverter; // Utility header archive + /// \brief Pointer to the DocEntryArchive (used while writting process) DocEntryArchive *Archive; // Write variables + /// \brief (WMODE_RAW, WMODE_RGB) FileMode WriteMode; + /// \brief (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO) FileType WriteType; }; } // end namespace gdcm diff --git a/src/gdcmSQItem.cxx b/src/gdcmSQItem.cxx index e6b4e1c9..1b46a482 100644 --- a/src/gdcmSQItem.cxx +++ b/src/gdcmSQItem.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSQItem.cxx,v $ Language: C++ - Date: $Date: 2005/02/02 16:18:48 $ - Version: $Revision: 1.66 $ + Date: $Date: 2005/02/04 14:49:01 $ + Version: $Revision: 1.67 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -210,7 +210,7 @@ DocEntry *SQItem::GetFirstEntry() } /** - * \brief Get the next Dicom entry while visiting the chained list + * \brief Get the next Dicom entry while visiting the SQItem * \return The next DocEntry if found, otherwhise NULL */ DocEntry *SQItem::GetNextEntry() @@ -221,6 +221,42 @@ DocEntry *SQItem::GetNextEntry() return NULL; } +/** + * \brief Get the first ValEntry while visiting theSQItem + * This method is designed for Python users + * \return The first ValEntry if found, otherwhise NULL + */ +ValEntry *SQItem::GetFirstValEntry() +{ + gdcm::ValEntry *valEntry; + gdcm::DocEntry *d = GetFirstEntry(); + // an other iterator is needed to allow user iterate + // at the same time both on DocEntries and ValEntries + ItValEntries = ItDocEntries; + if ( valEntry = dynamic_cast(d)) + return valEntry; + return GetNextValEntry(); +} + +/** + * \brief Get the next ValEntry while visiting the SQItem + * \return The next ValEntry if found, otherwhise NULL + */ +ValEntry *SQItem::GetNextValEntry() +{ + gdcm::ValEntry *valEntry; + gdcm::DocEntry *d = *ItValEntries; + ++ItValEntries; + while( d ) + { + if ( valEntry = dynamic_cast(d)) + return valEntry; + else + return GetNextValEntry(); + } + return 0; +} + /** * \brief Gets a Dicom Element inside a SQ Item Entry * @param group Group number of the Entry diff --git a/src/gdcmSQItem.h b/src/gdcmSQItem.h index 88e1717f..a6f8b75f 100644 --- a/src/gdcmSQItem.h +++ b/src/gdcmSQItem.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSQItem.h,v $ Language: C++ - Date: $Date: 2005/02/02 16:18:49 $ - Version: $Revision: 1.39 $ + Date: $Date: 2005/02/04 14:49:01 $ + 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 @@ -44,7 +44,7 @@ public: SQItem(int depthLevel); ~SQItem(); - virtual void Print(std::ostream &os = std::cout, std::string const & indent = "" ); + virtual void Print(std::ostream &os = std::cout, std::string const &indent = "" ); void WriteContent(std::ofstream *fp, FileType filetype); bool AddEntry(DocEntry *Entry); // add to the List @@ -55,6 +55,9 @@ public: DocEntry *GetFirstEntry(); DocEntry *GetNextEntry(); + ValEntry *GetFirstValEntry(); + ValEntry *GetNextValEntry(); + DocEntry *GetDocEntry(uint16_t group, uint16_t elem); bool IsEmpty() { return DocEntries.empty(); }; @@ -77,12 +80,14 @@ public: BaseTagKey const &GetBaseTagKey() const { return BaseTagKeyNested; } protected: -// Variables that need to be access in subclasses - /// \brief Chained list of (Elementary) Doc Entries +// Variables that need to be accessed in subclasses + /// \brief Chained list of Doc Entries ListDocEntry DocEntries; - /// Chained list iterator, used to visit the TagHT variable + /// Iterator, used to visit the entries ListDocEntry::iterator ItDocEntries; - + /// Iterator, used to visit the Val Entries (for Python users) + ListDocEntry::iterator ItValEntries; + private: /// \brief Sequences can be nested. This \ref SQDepthLevel represents /// the level of the nesting of instances of this class. diff --git a/src/gdcmSeqEntry.h b/src/gdcmSeqEntry.h index f3919280..621c0614 100644 --- a/src/gdcmSeqEntry.h +++ b/src/gdcmSeqEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSeqEntry.h,v $ Language: C++ - Date: $Date: 2005/02/02 16:18:49 $ - Version: $Revision: 1.32 $ + Date: $Date: 2005/02/04 14:49:01 $ + 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 @@ -44,7 +44,7 @@ public: SeqEntry( DocEntry *d, int depth ); ~SeqEntry(); - void Print(std::ostream &os = std::cout, std::string const & indent = "" ); + void Print(std::ostream &os = std::cout, std::string const &indent = "" ); void WriteContent(std::ofstream *fp, FileType filetype); void AddSQItem(SQItem *it, int itemNumber); @@ -58,7 +58,8 @@ public: void SetDelimitorMode(bool dm) { DelimitorMode = dm; } /// Sets the Sequence Delimitation Item - void SetDelimitationItem(DocEntry *e) { SeqTerm = e;} + void SetDelimitationItem(DocEntry *e) { SeqTerm = e; } + /// Gets the Sequence Delimitation Item DocEntry *GetDelimitationItem() { return SeqTerm;} /// Gets the depth level