From 0ad9dae4659b21bfd5c834c1af724eab4dcdf4f6 Mon Sep 17 00:00:00 2001 From: jpr Date: Sun, 23 Jan 2005 10:12:31 +0000 Subject: [PATCH] Some normalizations : - Move some methods to parent class - Position correctly the entry points for JPEG2000 and JPEG-LS (JPG-LS in NOT jpeg 'lossless') - Remove deprecated and useless methods - Update comments - Update Doxygenation --- Example/PrintFile.cxx | 10 ++-- Example/TestPapyrus.cxx | 10 ++-- Testing/TestTS.cxx | 5 +- src/gdcmBase.cxx | 6 +-- src/gdcmBinEntry.cxx | 19 ++++---- src/gdcmDicomDir.cxx | 16 +++---- src/gdcmDicomDirImage.cxx | 6 +-- src/gdcmDicomDirMeta.cxx | 6 +-- src/gdcmDicomDirPatient.cxx | 6 +-- src/gdcmDicomDirSerie.cxx | 6 +-- src/gdcmDicomDirStudy.cxx | 6 +-- src/gdcmDict.cxx | 6 +-- src/gdcmDictEntry.cxx | 9 +++- src/gdcmDictSet.cxx | 6 +-- src/gdcmDirList.h | 15 +++--- src/gdcmDocEntry.cxx | 6 +-- src/gdcmDocEntrySet.cxx | 13 ++--- src/gdcmDocument.cxx | 89 +++++++++++++++-------------------- src/gdcmDocument.h | 24 +++++----- src/gdcmElementSet.cxx | 67 ++++++++++++++++++++++++-- src/gdcmElementSet.h | 15 ++++-- src/gdcmFile.cxx | 9 ++-- src/gdcmFile.h | 15 +++--- src/gdcmFileHelper.cxx | 5 +- src/gdcmFileHelper.h | 8 ++-- src/gdcmGlobal.cxx | 6 +-- src/gdcmJPEGFragmentsInfo.cxx | 15 +++--- src/gdcmPixelReadConvert.cxx | 32 +++++++------ src/gdcmPixelReadConvert.h | 11 +++-- src/gdcmPixelWriteConvert.cxx | 32 +++++++++---- src/gdcmSeqEntry.cxx | 9 ++-- src/gdcmTS.cxx | 74 ++++++++++++++++++++++------- src/gdcmTS.h | 11 +++-- src/gdcmUtil.cxx | 12 ++--- src/gdcmValEntry.cxx | 23 ++++++--- 35 files changed, 373 insertions(+), 235 deletions(-) diff --git a/Example/PrintFile.cxx b/Example/PrintFile.cxx index de95dc45..c8873176 100644 --- a/Example/PrintFile.cxx +++ b/Example/PrintFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: PrintFile.cxx,v $ Language: C++ - Date: $Date: 2005/01/21 11:40:52 $ - Version: $Revision: 1.24 $ + Date: $Date: 2005/01/23 10:12:31 $ + 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 @@ -45,16 +45,16 @@ int main(int argc, char* argv[]) if (argc > 3) gdcm::Debug::SetDebugOn(); - e1= new gdcm::File( fileName.c_str() ); + e1 = new gdcm::File( fileName.c_str() ); f1 = new gdcm::FileHelper(e1); if (argc > 2) { int level = atoi(argv[2]); - e1->SetPrintLevel(level); + f1->SetPrintLevel(level); } - e1->Print(); + f1->Print(); std::cout << "\n\n" << std::endl; diff --git a/Example/TestPapyrus.cxx b/Example/TestPapyrus.cxx index 63ae5e04..9d918d18 100644 --- a/Example/TestPapyrus.cxx +++ b/Example/TestPapyrus.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestPapyrus.cxx,v $ Language: C++ - Date: $Date: 2005/01/21 11:40:52 $ - Version: $Revision: 1.5 $ + Date: $Date: 2005/01/23 10:12:32 $ + 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 @@ -96,7 +96,7 @@ int main(int argc, char* argv[]) // Look for private Papyrus Sequence gdcm::SeqEntry *seqPapyrus= h->GetSeqEntry(0x0041, 0x1050); - if (!h) + if (!seqPapyrus) { std::cout << "NOT a Papyrus File" << std::endl; delete h; @@ -165,12 +165,16 @@ int main(int argc, char* argv[]) int lgrImage = iRows*iColumns * iSamplesPerPixel * (iBitsAllocated/8); // compute number of images + + int nbImages = seqPapyrus->GetNumberOfSQItems(); +/* int nbImages = 0; while (sqi) { nbImages++; sqi = seqPapyrus->GetNextSQItem(); } +*/ std::cout <<"Number of frames :" << nbImages << std::endl; // allocate enough room to get the pixels of all images. diff --git a/Testing/TestTS.cxx b/Testing/TestTS.cxx index 58226439..77d528b9 100644 --- a/Testing/TestTS.cxx +++ b/Testing/TestTS.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestTS.cxx,v $ Language: C++ - Date: $Date: 2005/01/11 17:19:38 $ - Version: $Revision: 1.7 $ + Date: $Date: 2005/01/23 10:12:32 $ + 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 @@ -67,7 +67,6 @@ int TestTS(int , char *[]) std::cout << ts.IsJPEGLossless( "1.2.840.10008.1.2.5") << std::endl; std::cout << ts.IsJPEG2000( "1.2.840.10008.1.2.5") << std::endl; std::cout << ts.IsJPEG( "1.2.840.10008.1.2.5") << std::endl; - std::cout << ts.IsEncapsulate( "1.2.840.10008.1.2.5") << std::endl; std::cout << ts.GetSpecialTransferSyntax( ts.GetSpecialTransferSyntax( "1.2.840.10008.1.2.5")) << std::endl; std::cout << gdcm::Global::GetTS()->IsRLELossless( "1.2.840.10008.1.2.5" ) << std::endl; diff --git a/src/gdcmBase.cxx b/src/gdcmBase.cxx index a74a2cdc..dcba3c95 100644 --- a/src/gdcmBase.cxx +++ b/src/gdcmBase.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmBase.cxx,v $ Language: C++ - Date: $Date: 2005/01/18 14:28:32 $ - Version: $Revision: 1.7 $ + Date: $Date: 2005/01/23 10:12:32 $ + 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 @@ -44,7 +44,7 @@ Base::~Base() /** * \brief Print all the object * @param os The output stream to be written to. - * @param indent indent + * @param indent Indentation string to be prepended during printing */ void Base::Print(std::ostream &, std::string const & ) { diff --git a/src/gdcmBinEntry.cxx b/src/gdcmBinEntry.cxx index 62dfc3da..194ca5ff 100644 --- a/src/gdcmBinEntry.cxx +++ b/src/gdcmBinEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmBinEntry.cxx,v $ Language: C++ - Date: $Date: 2005/01/19 15:58:00 $ - Version: $Revision: 1.54 $ + Date: $Date: 2005/01/23 10:12:32 $ + Version: $Revision: 1.55 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -46,9 +46,6 @@ BinEntry::BinEntry(DocEntry *e) : ValEntry(e->GetDictEntry()) { Copy(e); - //FIXME - //SQDepthLevel = e->GetDepthLevel(); - BinArea = 0; // let's be carefull ! SelfArea = true; } @@ -68,10 +65,11 @@ BinEntry::~BinEntry() //----------------------------------------------------------------------------- // Print -/* - * \brief canonical Printer +/** + * \brief Prints a BinEntry (Dicom entry) + * @param os ostream we want to print in + * @param indent Indentation string to be prepended during printing */ - void BinEntry::Print(std::ostream &os, std::string const & ) { os << "B "; @@ -94,8 +92,7 @@ void BinEntry::Print(std::ostream &os, std::string const & ) { //s << " [gdcm::Binary data NOT loaded]"; s << " [" <GetSQItems(); DocEntry *d; std::string v; @@ -813,7 +814,6 @@ void DicomDir::CreateDicomDir() if( si ) MoveSQItem(si,tmpSI); - tmpSI=s->GetNextSQItem(); } // friend hunting : this one will be difficult to remove ! @@ -1000,7 +1000,7 @@ void DicomDir::MoveSQItem(SQItem *dst,SQItem *src) } /** - * \brief compares two dgcmHeaders + * \brief compares two files */ bool DicomDir::HeaderLessThan(Document *header1, Document *header2) { diff --git a/src/gdcmDicomDirImage.cxx b/src/gdcmDicomDirImage.cxx index 6ad054f8..688886fd 100644 --- a/src/gdcmDicomDirImage.cxx +++ b/src/gdcmDicomDirImage.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirImage.cxx,v $ Language: C++ - Date: $Date: 2005/01/20 16:16:42 $ - Version: $Revision: 1.19 $ + Date: $Date: 2005/01/23 10:12:33 $ + 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 @@ -50,7 +50,7 @@ DicomDirImage::~DicomDirImage() /** * \brief Prints the Object * @param os ostream to write to - * @param indent indent + * @param indent Indentation string to be prepended during printing * @return */ void DicomDirImage::Print(std::ostream &os, std::string const & ) diff --git a/src/gdcmDicomDirMeta.cxx b/src/gdcmDicomDirMeta.cxx index 516150de..b008d0e5 100644 --- a/src/gdcmDicomDirMeta.cxx +++ b/src/gdcmDicomDirMeta.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirMeta.cxx,v $ Language: C++ - Date: $Date: 2005/01/20 16:16:42 $ - Version: $Revision: 1.24 $ + Date: $Date: 2005/01/23 10:12:33 $ + 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 @@ -53,7 +53,7 @@ DicomDirMeta::~DicomDirMeta() /** * \brief Prints the Meta Elements * @param os ostream to write to - * @param indent indent + * @param indent Indentation string to be prepended during printing */ void DicomDirMeta::Print(std::ostream &os, std::string const & ) { diff --git a/src/gdcmDicomDirPatient.cxx b/src/gdcmDicomDirPatient.cxx index cc2ba5b5..ceeea5b4 100644 --- a/src/gdcmDicomDirPatient.cxx +++ b/src/gdcmDicomDirPatient.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirPatient.cxx,v $ Language: C++ - Date: $Date: 2005/01/20 16:16:42 $ - Version: $Revision: 1.30 $ + Date: $Date: 2005/01/23 10:12:33 $ + 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 @@ -60,7 +60,7 @@ DicomDirPatient::~DicomDirPatient() /** * \brief Prints the Object * @param os ostream to write to - * @param indent indent + * @param indent Indentation string to be prepended during printing */ void DicomDirPatient::Print(std::ostream &os, std::string const & ) { diff --git a/src/gdcmDicomDirSerie.cxx b/src/gdcmDicomDirSerie.cxx index 5ae79875..5b0b3179 100644 --- a/src/gdcmDicomDirSerie.cxx +++ b/src/gdcmDicomDirSerie.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirSerie.cxx,v $ Language: C++ - Date: $Date: 2005/01/20 16:16:42 $ - Version: $Revision: 1.32 $ + Date: $Date: 2005/01/23 10:12:33 $ + 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 @@ -59,7 +59,7 @@ DicomDirSerie::~DicomDirSerie() /** * \brief Prints the Object * @param os ostream to write to - * @param indent indent + * @param indent Indentation string to be prepended during printing */ void DicomDirSerie::Print(std::ostream &os, std::string const &) { diff --git a/src/gdcmDicomDirStudy.cxx b/src/gdcmDicomDirStudy.cxx index 6c43c6b0..b2ef7523 100644 --- a/src/gdcmDicomDirStudy.cxx +++ b/src/gdcmDicomDirStudy.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirStudy.cxx,v $ Language: C++ - Date: $Date: 2005/01/20 16:16:42 $ - Version: $Revision: 1.29 $ + Date: $Date: 2005/01/23 10:12:33 $ + Version: $Revision: 1.30 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -58,7 +58,7 @@ DicomDirStudy::~DicomDirStudy() /** * \brief Prints the Object * @param os ostream to write to - * @param indent indent + * @param indent Indentation string to be prepended during printing * @return */ void DicomDirStudy::Print(std::ostream &os, std::string const & ) diff --git a/src/gdcmDict.cxx b/src/gdcmDict.cxx index d56ff7c2..162b79c0 100644 --- a/src/gdcmDict.cxx +++ b/src/gdcmDict.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDict.cxx,v $ Language: C++ - Date: $Date: 2005/01/18 14:28:32 $ - Version: $Revision: 1.68 $ + Date: $Date: 2005/01/23 10:12:33 $ + Version: $Revision: 1.69 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -91,7 +91,7 @@ Dict::~Dict() * \brief Print all the dictionary entries contained in this dictionary. * Entries will be sorted by tag i.e. the couple (group, element). * @param os The output stream to be written to. - * @param indent indent + * @param indent Indentation string to be prepended during printing */ void Dict::Print(std::ostream &os, std::string const & ) { diff --git a/src/gdcmDictEntry.cxx b/src/gdcmDictEntry.cxx index 186f2cb5..7c64268a 100644 --- a/src/gdcmDictEntry.cxx +++ b/src/gdcmDictEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictEntry.cxx,v $ Language: C++ - Date: $Date: 2005/01/17 17:27:03 $ - Version: $Revision: 1.42 $ + Date: $Date: 2005/01/23 10:12:33 $ + Version: $Revision: 1.43 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -52,6 +52,11 @@ DictEntry::DictEntry(uint16_t group, uint16_t elem, //----------------------------------------------------------------------------- // Print +/** + * \brief Prints an entry of the Dicom DictionaryEntry + * @param os ostream we want to print in + * @param indent Indentation string to be prepended during printing + */ void DictEntry::Print(std::ostream &os, std::string const & ) { std::string vr; diff --git a/src/gdcmDictSet.cxx b/src/gdcmDictSet.cxx index f4ae8c8c..c9cdfbcf 100644 --- a/src/gdcmDictSet.cxx +++ b/src/gdcmDictSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictSet.cxx,v $ Language: C++ - Date: $Date: 2005/01/18 14:28:32 $ - Version: $Revision: 1.55 $ + Date: $Date: 2005/01/23 10:12:33 $ + Version: $Revision: 1.56 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -65,7 +65,7 @@ DictSet::~DictSet() * \brief Print, in an informal fashion, the list of all the dictionaries * contained is this DictSet, along with their respective content. * @param os Output stream used for printing. - * @param indent indent + * @param indent Indentation string to be prepended during printing */ void DictSet::Print(std::ostream &os, std::string const & ) { diff --git a/src/gdcmDirList.h b/src/gdcmDirList.h index 7e79044b..6f1f234e 100644 --- a/src/gdcmDirList.h +++ b/src/gdcmDirList.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDirList.h,v $ Language: C++ - Date: $Date: 2005/01/14 22:20:11 $ - Version: $Revision: 1.18 $ + Date: $Date: 2005/01/23 10:12:33 $ + 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 @@ -28,17 +28,18 @@ namespace gdcm { +typedef std::vector DirListType; + //----------------------------------------------------------------------------- + +// NOTE: Due to a VC6 'feature' we can not export a std::list in a dll, +// so GDCM_EXPORT keyword was removed for this class only + /** * \ingroup DirList * \brief List containing the file Header s of all the gdcm readable files * found by exploring recursively a root directory. */ -// NOTE: Due to a VC6 'feature' we can not export a std::list in a dll, -// so GDCM_EXPORT keyword was removed for this class only - -typedef std::vector DirListType; - class GDCM_EXPORT DirList { public : diff --git a/src/gdcmDocEntry.cxx b/src/gdcmDocEntry.cxx index 3701d3a6..e82e2100 100644 --- a/src/gdcmDocEntry.cxx +++ b/src/gdcmDocEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.cxx,v $ Language: C++ - Date: $Date: 2005/01/19 15:58:00 $ - Version: $Revision: 1.44 $ + Date: $Date: 2005/01/23 10:12:33 $ + Version: $Revision: 1.45 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -116,7 +116,7 @@ void DocEntry::Print(std::ostream &os, std::string const & ) /** * \brief Writes the common part of any ValEntry, BinEntry, SeqEntry - * @param fp already open file pointer + * @param fp already open ofstream pointer * @param filetype type of the file to be written */ void DocEntry::WriteContent(std::ofstream *fp, FileType filetype) diff --git a/src/gdcmDocEntrySet.cxx b/src/gdcmDocEntrySet.cxx index 2ffa021a..141813d3 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/01/20 11:39:49 $ - Version: $Revision: 1.42 $ + Date: $Date: 2005/01/23 10:12:33 $ + Version: $Revision: 1.43 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -39,7 +39,7 @@ namespace gdcm * @param group group number of the underlying DictEntry * @param elem element number of the underlying DictEntry * @param vr VR (Value Representation) of the underlying DictEntry - * @param vm VM (Value Multiplicity) of the underlying DictEntry + * @param vm VM (Value Multiplicity) of the underlying DictEntry * @param name english name */ DictEntry* DocEntrySet::NewVirtualDictEntry( uint16_t group,uint16_t elem, @@ -125,7 +125,7 @@ SeqEntry* DocEntrySet::NewSeqEntry(uint16_t group,uint16_t elem) * exist)] for the presence of the DictEntry with given * group and element. The public dictionary has precedence on the * shadow one. - * @param group group number of the searched DictEntry + * @param group group number of the searched DictEntry * @param elem element number of the searched DictEntry * @return Corresponding DictEntry when it exists, NULL otherwise. */ @@ -149,7 +149,7 @@ DictEntry *DocEntrySet::GetDictEntry(uint16_t group,uint16_t elem) * \brief Searches both the public and the shadow dictionary (when they * exist) for the presence of the DictEntry with given * group and element, and create a new virtual DictEntry if necessary - * @param group group number of the searched DictEntry + * @param group group number of the searched DictEntry * @param elem element number of the searched DictEntry * @param vr Value Representation to use, if necessary * @return Corresponding DictEntry when it exists, NULL otherwise. @@ -185,10 +185,11 @@ DictEntry *DocEntrySet::GetDictEntry(uint16_t group, uint16_t elem, goodEntry = NewVirtualDictEntry(group, elem, goodVR); } } - return goodEntry; } + + //----------------------------------------------------------------------------- // Private diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index bb3d81df..8437264b 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2005/01/20 11:37:37 $ - Version: $Revision: 1.203 $ + Date: $Date: 2005/01/23 10:12:33 $ + Version: $Revision: 1.204 $ 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,7 @@ const unsigned int Document::MAX_SIZE_PRINT_ELEMENT_VALUE = 0x7fffffff; /** * \brief constructor - * @param filename file to be opened for parsing + * @param filename 'Document' (File or DicomDir) to be opened for parsing */ Document::Document( std::string const &filename ) : ElementSet(-1) { @@ -265,7 +265,8 @@ bool Document::IsReadable() return false; } - if( TagHT.empty() ) + //if( TagHT.empty() ) + if ( IsEmpty() ) { gdcmVerboseMacro( "No tag in internal hash table."); return false; @@ -324,6 +325,23 @@ bool Document::IsDicomV3() return GetDocEntry(0x0002, 0x0010) != NULL; } +/** + * \brief Predicate for Papyrus file + * Dedicated to whomsoever it may concern + * @return True when the file is a Papyrus file. + */ +bool Document::IsPapyrus() +{ + // check for Papyrus private Sequence + DocEntry *e = GetDocEntry(0x0041, 0x1050); + if ( !e ) + return false; + // check if it's actually a Sequence + if ( !dynamic_cast(e) ) + return false; + return true; +} + /** * \brief returns the File Type * (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown) @@ -663,39 +681,6 @@ bool Document::ReplaceIfExist(std::string const &value, //----------------------------------------------------------------------------- // Protected -/** - * \brief Checks if a given Dicom Element exists within the H table - * @param group Group number of the searched Dicom Element - * @param elem Element number of the searched Dicom Element - * @return true is found - */ -bool Document::CheckIfEntryExist(uint16_t group, uint16_t elem ) -{ - const std::string &key = DictEntry::TranslateToKey(group, elem ); - return TagHT.count(key) != 0; -} - - -/** - * \brief Searches within Header Entries (Dicom Elements) parsed with - * the public and private dictionaries - * for the element value representation of a given tag. - * @param group Group number of the searched tag. - * @param elem Element number of the searched tag. - * @return Corresponding element value representation when it exists, - * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. - */ -std::string Document::GetEntry(uint16_t group, uint16_t elem) -{ - TagKey key = DictEntry::TranslateToKey(group, elem); - if ( !TagHT.count(key)) - { - return GDCM_UNFOUND; - } - - return ((ValEntry *)TagHT.find(key)->second)->GetValue(); -} - /** * \brief Searches within Header Entries (Dicom Elements) parsed with * the public and private dictionaries @@ -2477,25 +2462,25 @@ DocEntry *Document::ReadNextDocEntry() return newEntry; } - +//GenerateFreeTagKeyInGroup? What was it designed for ?!? /** * \brief Generate a free TagKey i.e. a TagKey that is not present * in the TagHt dictionary. * @param group The generated tag must belong to this group. * @return The element of tag with given group which is fee. */ -uint32_t Document::GenerateFreeTagKeyInGroup(uint16_t group) -{ - for (uint32_t elem = 0; elem < UINT32_MAX; elem++) - { - TagKey key = DictEntry::TranslateToKey(group, elem); - if (TagHT.count(key) == 0) - { - return elem; - } - } - return UINT32_MAX; -} +//uint32_t Document::GenerateFreeTagKeyInGroup(uint16_t group) +//{ +// for (uint32_t elem = 0; elem < UINT32_MAX; elem++) +// { +// TagKey key = DictEntry::TranslateToKey(group, elem); +// if (TagHT.count(key) == 0) +// { +// return elem; +// } +// } +// return UINT32_MAX; +//} /** * \brief Assuming the internal file pointer \ref Document::Fp @@ -2749,7 +2734,7 @@ void Document::ComputeJPEGFragmentInfo() } } -/** +/* * \brief Walk recursively the given \ref DocEntrySet, and feed * the given hash table (\ref TagDocEntryHT) with all the * \ref DocEntry (Dicom entries) encountered. @@ -2810,7 +2795,7 @@ void Document::ComputeJPEGFragmentInfo() } }*/ -/** +/* * \brief Build a \ref TagDocEntryHT (i.e. a std::map<>) from the current * Document. * diff --git a/src/gdcmDocument.h b/src/gdcmDocument.h index 6ebc79c9..e8158246 100644 --- a/src/gdcmDocument.h +++ b/src/gdcmDocument.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.h,v $ Language: C++ - Date: $Date: 2005/01/21 11:40:55 $ - Version: $Revision: 1.96 $ + Date: $Date: 2005/01/23 10:12:33 $ + Version: $Revision: 1.97 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -48,8 +48,9 @@ public: FileType GetFileType(); std::string GetTransferSyntax(); - + /// returns RLEFramesInfo RLEFramesInfo *GetRLEInfo() { return RLEInfo; } + /// returns JPEGFragmentsInfo JPEGFragmentsInfo *GetJPEGInfo() { return JPEGInfo; } // Dictionaries @@ -99,22 +100,19 @@ public: virtual void *GetEntryBinArea(uint16_t group, uint16_t elem); - virtual std::string GetEntry (uint16_t group, uint16_t elem); virtual std::string GetEntryVR(uint16_t group, uint16_t elem); virtual int GetEntryLength(uint16_t group, uint16_t elem); ValEntry *ReplaceOrCreate(std::string const &value, uint16_t group, uint16_t elem, TagName const &vr = GDCM_UNKNOWN); - BinEntry *ReplaceOrCreate(uint8_t* binArea, int lgth, + BinEntry *ReplaceOrCreate(uint8_t *binArea, int lgth, uint16_t group, uint16_t elem, TagName const &vr = GDCM_UNKNOWN); SeqEntry *ReplaceOrCreate(uint16_t group, uint16_t elem); bool ReplaceIfExist(std::string const &value, uint16_t group, uint16_t elem ); - - bool CheckIfEntryExist(uint16_t group, uint16_t elem ); virtual void LoadEntryBinArea(uint16_t group, uint16_t elem); virtual void LoadEntryBinArea(BinEntry *entry); @@ -126,6 +124,7 @@ public: std::string GetTransferSyntaxName(); bool IsDicomV3(); + bool IsPapyrus(); protected: // Methods @@ -227,11 +226,11 @@ private: // DocEntry related utilities DocEntry *ReadNextDocEntry(); - uint32_t GenerateFreeTagKeyInGroup(uint16_t group); -/* void BuildFlatHashTableRecurse( TagDocEntryHT &builtHT, - DocEntrySet* set );*/ +// uint32_t GenerateFreeTagKeyInGroup(uint16_t group); +// void BuildFlatHashTableRecurse( TagDocEntryHT &builtHT, +// DocEntrySet *set ); - void HandleBrokenEndian(uint16_t &group, uint16_t &elem); + void HandleBrokenEndian (uint16_t &group, uint16_t &elem); void HandleOutOfGroup0002(uint16_t &group, uint16_t &elem); // Variables @@ -254,8 +253,9 @@ private: uint32_t MaxSizePrintEntry; private: - friend class FileHelper; + }; + } // end namespace gdcm //----------------------------------------------------------------------------- diff --git a/src/gdcmElementSet.cxx b/src/gdcmElementSet.cxx index cf778c42..317c108f 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/01/20 11:37:37 $ - Version: $Revision: 1.47 $ + Date: $Date: 2005/01/23 10:12:33 $ + 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 @@ -96,7 +96,6 @@ void ElementSet::WriteContent(std::ofstream *fp, FileType filetype) } } - /** * \brief retrieves a Dicom Element using (group, element) * @param group Group number of the searched Dicom Element @@ -189,6 +188,39 @@ SeqEntry *ElementSet::GetSeqEntry(uint16_t group, uint16_t elem) //----------------------------------------------------------------------------- // Protected +/** + * \brief Checks if a given Dicom Element exists within the H table + * @param group Group number of the searched Dicom Element + * @param elem Element number of the searched Dicom Element + * @return true is found + */ +bool ElementSet::CheckIfEntryExist(uint16_t group, uint16_t elem ) +{ + const std::string &key = DictEntry::TranslateToKey(group, elem ); + return TagHT.count(key) != 0; +} + +/** + * \brief Searches within Header Entries (Dicom Elements) parsed with + * the public and private dictionaries + * for the element value representation of a given tag. + * @param group Group number of the searched tag. + * @param elem Element number of the searched tag. + * @return Corresponding element value representation when it exists, + * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise. + */ +std::string ElementSet::GetEntry(uint16_t group, uint16_t elem) +{ + TagKey key = DictEntry::TranslateToKey(group, elem); + if ( !TagHT.count(key)) + { + return GDCM_UNFOUND; + } + + return ((ValEntry *)TagHT.find(key)->second)->GetValue(); +} + + //----------------------------------------------------------------------------- // Private @@ -276,5 +308,34 @@ DocEntry *ElementSet::GetNextEntry() return NULL; } + +/** + * \brief Get the larst entry while visiting the DocEntrySet + * \return The last DocEntry if found, otherwhise NULL + */ +DocEntry *ElementSet::GetLastEntry() +{ + ItTagHT = TagHT.end(); + if ( ItTagHT != TagHT.begin() ) + return ItTagHT->second; + return NULL; +} + +/** + * \brief Get the previous entry while visiting the Hash table (TagHT) + * \note : meaningfull only if GetFirstEntry already called + * \return The previous DocEntry if found, otherwhise NULL + */ +DocEntry *ElementSet::GetPreviousEntry() +{ + gdcmAssertMacro (ItTagHT != TagHT.begin()); + + --ItTagHT; + if (ItTagHT != TagHT.begin()) + return ItTagHT->second; + return NULL; +} + + //----------------------------------------------------------------------------- } // end namespace gdcm diff --git a/src/gdcmElementSet.h b/src/gdcmElementSet.h index 5622c19d..09499ad6 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/01/20 11:37:37 $ - Version: $Revision: 1.34 $ + Date: $Date: 2005/01/23 10:12:34 $ + Version: $Revision: 1.35 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -57,22 +57,27 @@ public: DocEntry *GetFirstEntry(); DocEntry *GetNextEntry(); + DocEntry *GetLastEntry(); + DocEntry *GetPreviousEntry(); DocEntry *GetDocEntry(uint16_t group, uint16_t elem); ValEntry *GetValEntry(uint16_t group, uint16_t elem); BinEntry *GetBinEntry(uint16_t group, uint16_t elem); SeqEntry *GetSeqEntry(uint16_t group, uint16_t elem); + bool IsEmpty() { return TagHT.empty(); }; + bool CheckIfEntryExist(uint16_t group, uint16_t elem); + std::string GetEntry(uint16_t group, uint16_t elem); + protected: - + private: // Variables /// Hash Table (map), to provide fast access TagDocEntryHT TagHT; /// Hash Table (map) iterator, used to visit the TagHT variable TagDocEntryHT::iterator ItTagHT; - - friend class Document; + friend class DicomDir; //For accessing private TagHT friend class DocEntryArchive; //For accessing private TagHT }; diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 4adfcd30..c3500c8b 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2005/01/21 12:37:15 $ - Version: $Revision: 1.196 $ + Date: $Date: 2005/01/23 10:12:34 $ + Version: $Revision: 1.197 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -45,7 +45,7 @@ File::File( std::string const &filename ): // is found by indirection through the "Image Location"). // Inside the group pointed by "Image Location" the searched element // is conventionally the element 0x0010 (when the norm is respected). - // When the "Image Location" is Missing we default to group 0x7fe0. + // When the "Image Location" is missing we default to group 0x7fe0. // Note: this IS the right place for the code // Image Location @@ -97,6 +97,8 @@ File::File( std::string const &filename ): GrPixel, NumPixel, PixelVR, "PXL", "Pixel Data"); + // friend class hunting : should we *create* a new entry, + // instead of modifying its DictEntry,in order not to use 'friend' ? entry->SetDictEntry( newEntry ); } } @@ -1283,6 +1285,7 @@ bool File::AnonymizeFile() /** * \brief gets the info from 0020,0037 : Image Orientation Patient + * (needed to organize DICOM files based on their x,y,z position) * @param iop adress of the (6)float aray to receive values * @return cosines of image orientation patient */ diff --git a/src/gdcmFile.h b/src/gdcmFile.h index 106ce066..d7d8a656 100644 --- a/src/gdcmFile.h +++ b/src/gdcmFile.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.h,v $ Language: C++ - Date: $Date: 2005/01/21 12:37:15 $ - Version: $Revision: 1.98 $ + Date: $Date: 2005/01/23 10:12:34 $ + Version: $Revision: 1.99 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -140,13 +140,16 @@ public: float GetYSpacing(); float GetZSpacing(); - // Useful for rescaling graylevel: + // For rescaling graylevel: float GetRescaleIntercept(); float GetRescaleSlope(); int GetNumberOfScalarComponents(); int GetNumberOfScalarComponentsRaw(); + // To organize DICOM files based on their x,y,z position + void GetImageOrientationPatient( float iop[6] ); + int GetImageNumber(); ModalityType GetModality(); @@ -172,12 +175,8 @@ protected: /// Replace patient's specific information by 'anonymous' bool AnonymizeFile(); - /// Helper function needed to organize DICOM files based on - /// their x,y,z position - void GetImageOrientationPatient( float iop[6] ); - private: - friend class SerieHeader; + }; } // end namespace gdcm diff --git a/src/gdcmFileHelper.cxx b/src/gdcmFileHelper.cxx index 43f6b89b..4c6595a3 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/01/21 11:40:55 $ - Version: $Revision: 1.2 $ + Date: $Date: 2005/01/23 10:12:34 $ + Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -901,7 +901,6 @@ ValEntry *FileHelper::CopyValEntry(uint16_t group,uint16_t elem) /** * \brief Modifies the value of a given Bin Entry (Dicom Element) * when it exists. Create it with the given value when unexistant. - * @param content (string) Value to be set * @param group Group number of the Entry * @param elem Element number of the Entry * \return pointer to the modified/created Bin Entry (NULL when creation diff --git a/src/gdcmFileHelper.h b/src/gdcmFileHelper.h index 13134d77..1906e485 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/01/21 11:40:55 $ - Version: $Revision: 1.3 $ + Date: $Date: 2005/01/23 10:12:34 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -98,7 +98,7 @@ public: uint8_t* GetLutRGBA(); // Write mode - void SetWriteModeToRaw() { SetWriteMode(WMODE_RAW); }; + void SetWriteModeToRaw() { SetWriteMode(WMODE_RAW); }; void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); }; void SetWriteMode(FileMode mode) { WriteMode = mode; }; FileMode GetWriteMode() { return WriteMode; }; @@ -139,7 +139,7 @@ private: /// gdcm::File to use to load the file File *FileInternal; - /// \brief Whether the underlying \ref Header was loaded by + /// \brief Whether the underlying \ref gdcm::File was loaded by /// the constructor or passed to the constructor. When false /// the destructor is in charge of deletion. bool SelfHeader; diff --git a/src/gdcmGlobal.cxx b/src/gdcmGlobal.cxx index a3a46599..5d8c4e71 100644 --- a/src/gdcmGlobal.cxx +++ b/src/gdcmGlobal.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmGlobal.cxx,v $ Language: C++ - Date: $Date: 2005/01/18 08:01:41 $ - Version: $Revision: 1.15 $ + Date: $Date: 2005/01/23 10:12:34 $ + 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 @@ -30,7 +30,7 @@ namespace gdcm // used to be in gdcmCommon.h but due to a 'bug' in gcc/MacOSX // you cannot have static initialization in a multithreaded environment // since there is a lazy construction everything got skrew up somehow -// Therefore the actual initiliazation is done in a cxx file (avoid +// Therefore the actual initialization is done in a cxx file (avoid // duplicated symbol), and an extern is used in gdcmCommon.h const std::string GDCM_UNKNOWN = "gdcm::Unknown"; const std::string GDCM_UNFOUND = "gdcm::Unfound"; diff --git a/src/gdcmJPEGFragmentsInfo.cxx b/src/gdcmJPEGFragmentsInfo.cxx index 3a666cb2..ddfaaabd 100644 --- a/src/gdcmJPEGFragmentsInfo.cxx +++ b/src/gdcmJPEGFragmentsInfo.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJPEGFragmentsInfo.cxx,v $ Language: C++ - Date: $Date: 2005/01/17 03:05:55 $ - Version: $Revision: 1.7 $ + Date: $Date: 2005/01/23 10:12:34 $ + 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 @@ -38,14 +38,15 @@ JPEGFragmentsInfo::~JPEGFragmentsInfo() /** * \brief Print self. - * @param indent Indentation string to be prepended during printing. * @param os Stream to print to. + * @param indent Indentation string to be prepended during printing. */ -void JPEGFragmentsInfo::Print( std::ostream &os, std::string const & indent ) +void JPEGFragmentsInfo::Print( std::ostream &os, std::string const &indent ) { + os << std::endl; os << indent << "----------------- JPEG fragments --------------------------------" - << std::endl; + << std::endl << std::endl; os << indent << "Total number of fragments : " << Fragments.size() << std::endl; @@ -57,12 +58,12 @@ void JPEGFragmentsInfo::Print( std::ostream &os, std::string const & indent ) os << indent << " fragment number :" << fragmentNumber++; (*it)->Print( os, indent + " "); - os << std::endl; } + os << std::endl; } /** - * \brief Calculate sum of all fragments lenght and return total + * \brief Calculate sum of all fragments length and return total * @return Total size of JPEG fragments length */ size_t JPEGFragmentsInfo::GetFragmentsLength() diff --git a/src/gdcmPixelReadConvert.cxx b/src/gdcmPixelReadConvert.cxx index 281eb696..f2bbb902 100644 --- a/src/gdcmPixelReadConvert.cxx +++ b/src/gdcmPixelReadConvert.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelReadConvert.cxx,v $ Language: C++ - Date: $Date: 2005/01/21 11:40:55 $ - Version: $Revision: 1.31 $ + Date: $Date: 2005/01/23 10:12:34 $ + Version: $Revision: 1.32 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -180,8 +180,8 @@ bool PixelReadConvert::DecompressRLE16BitsFromRLE8Bits( int NumberOfFrames ) /** * \brief Implementation of the RLE decoding algorithm for decompressing * a RLE fragment. [refer to PS 3.5-2003, section G.3.2 p 86] - * @param subRaw Sub region of \ref Raw where the de - * decoded fragment should be placed. + * @param subRaw Sub region of \ref Raw where the decoded fragment + * should be placed. * @param fragmentSize The length of the binary fragment as found on the disk. * @param RawSegmentSize The expected length of the fragment ONCE * Raw. @@ -351,7 +351,7 @@ void PixelReadConvert::ConvertSwapZone() } /** - * \brief Deal with endianity i.e. re-arange bytes inside the integer + * \brief Deal with endianness i.e. re-arange bytes inside the integer */ void PixelReadConvert::ConvertReorderEndianity() { @@ -562,7 +562,7 @@ bool PixelReadConvert::ConvertReArrangeBits() throw ( FormatError ) } /** - * \brief Convert (Y plane, cB plane, cR plane) to RGB pixels + * \brief Convert (cY plane, cB plane, cR plane) to RGB pixels * \warning Works on all the frames at a time */ void PixelReadConvert::ConvertYcBcRPlanesToRGBPixels() @@ -673,8 +673,8 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp ) else if ( IsRaw ) { // This problem can be found when some obvious informations are found - // after the field containing the image datas. In this case, these - // bad datas are added to the size of the image (in the PixelDataLength + // after the field containing the image data. In this case, these + // bad data are added to the size of the image (in the PixelDataLength // variable). But RawSize is the right size of the image ! if( PixelDataLength != RawSize) { @@ -841,7 +841,7 @@ void PixelReadConvert::GrabInformationsFromHeader( File *header ) BitsAllocated = 16; } - // Number of "Bits Stored" defaulted to number of "Bits Allocated" + // Number of "Bits Stored", defaulted to number of "Bits Allocated" // when absent from the header. BitsStored = header->GetBitsStored(); if ( BitsStored == 0 ) @@ -849,7 +849,7 @@ void PixelReadConvert::GrabInformationsFromHeader( File *header ) BitsStored = BitsAllocated; } - // High Bit Position + // High Bit Position, defaulted to "Bits Allocated" - 1 HighBitPosition = header->GetHighBitPosition(); if ( HighBitPosition == 0 ) { @@ -871,9 +871,13 @@ void PixelReadConvert::GrabInformationsFromHeader( File *header ) || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRLittleEndian || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRBigEndian || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::DeflatedExplicitVRLittleEndian; - IsJPEG2000 = Global::GetTS()->IsJPEG2000(ts); - IsJPEGLossless = Global::GetTS()->IsJPEGLossless(ts); - IsRLELossless = Global::GetTS()->IsRLELossless(ts); + + IsJPEG2000 = Global::GetTS()->IsJPEG2000(ts); + IsJPEGLS = Global::GetTS()->IsJPEGLS(ts); + IsJPEGLossy = Global::GetTS()->IsJPEGLossy(ts); + IsJPEGLossless = Global::GetTS()->IsJPEGLossless(ts); + IsRLELossless = Global::GetTS()->IsRLELossless(ts); + PixelOffset = header->GetPixelOffset(); PixelDataLength = header->GetPixelAreaLength(); RLEInfo = header->GetRLEInfo(); @@ -1137,7 +1141,7 @@ void PixelReadConvert::Print( std::ostream &os, std::string const & indent ) } } - if ( IsJPEG2000 || IsJPEGLossless ) + if ( IsJPEG2000 || IsJPEGLossless || IsJPEGLossy || IsJPEGLS ) { if ( JPEGInfo ) { diff --git a/src/gdcmPixelReadConvert.h b/src/gdcmPixelReadConvert.h index 8aceec49..a9839600 100644 --- a/src/gdcmPixelReadConvert.h +++ b/src/gdcmPixelReadConvert.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelReadConvert.h,v $ Language: C++ - Date: $Date: 2005/01/21 11:40:55 $ - Version: $Revision: 1.12 $ + Date: $Date: 2005/01/23 10:12:34 $ + 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 @@ -41,9 +41,9 @@ public: virtual ~PixelReadConvert(); //// Getter accessors: - uint8_t* GetRGB() { return RGB; } + uint8_t* GetRGB() { return RGB; } size_t GetRGBSize() { return RGBSize; } - uint8_t* GetRaw() { return Raw; } + uint8_t* GetRaw() { return Raw; } size_t GetRawSize() { return RawSize; } uint8_t* GetLutRGBA() { return LutRGBA; } @@ -118,7 +118,10 @@ private: bool IsRaw; bool IsJPEG2000; + bool IsJPEGLS; bool IsJPEGLossless; + bool IsJPEGLossy; + bool IsJPEG; bool IsRLELossless; RLEFramesInfo *RLEInfo; diff --git a/src/gdcmPixelWriteConvert.cxx b/src/gdcmPixelWriteConvert.cxx index 5f97e055..899f816f 100644 --- a/src/gdcmPixelWriteConvert.cxx +++ b/src/gdcmPixelWriteConvert.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelWriteConvert.cxx,v $ Language: C++ - Date: $Date: 2005/01/07 22:19:48 $ - Version: $Revision: 1.4 $ + Date: $Date: 2005/01/23 10:12:34 $ + Version: $Revision: 1.5 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -16,12 +16,6 @@ =========================================================================*/ -////////////////// TEMPORARY NOTE -// look for "fixMem" and convert that to a member of this class -// Removing the prefix fixMem and dealing with allocations should do the trick -// -// grep PixelWriteConvert everywhere and clean up ! - #include "gdcmDebug.h" #include "gdcmPixelWriteConvert.h" @@ -29,6 +23,8 @@ namespace gdcm { //----------------------------------------------------------------------------- // Constructor / Destructor + +/// \brief Construcror PixelWriteConvert::PixelWriteConvert() { ReadData = 0; @@ -38,24 +34,40 @@ PixelWriteConvert::PixelWriteConvert() UserDataSize = 0; } +/// \brief Destructor PixelWriteConvert::~PixelWriteConvert() { } //----------------------------------------------------------------------------- // Public + +/** + * \brief SetReadData + * @param data data + * @param size size + */ void PixelWriteConvert::SetReadData(uint8_t *data,size_t size) { ReadData = data; ReadDataSize = size; } +/** + * \brief SetUserData + * @param data data + * @param size size + */ void PixelWriteConvert::SetUserData(uint8_t *data,size_t size) { UserData = data; UserDataSize = size; } +/** + * \brief GetData + * @return data + */ uint8_t *PixelWriteConvert::GetData() { if(UserData) @@ -68,6 +80,10 @@ uint8_t *PixelWriteConvert::GetData() } } +/** + * \brief GetDataSize + * @return size + */ size_t PixelWriteConvert::GetDataSize() { if(UserData) diff --git a/src/gdcmSeqEntry.cxx b/src/gdcmSeqEntry.cxx index ec1a6d3d..d5683fdf 100644 --- a/src/gdcmSeqEntry.cxx +++ b/src/gdcmSeqEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSeqEntry.cxx,v $ Language: C++ - Date: $Date: 2005/01/20 11:26:18 $ - Version: $Revision: 1.48 $ + Date: $Date: 2005/01/23 10:12:34 $ + Version: $Revision: 1.49 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -50,7 +50,7 @@ SeqEntry::SeqEntry( DictEntry *e ) * \brief Constructor from a given SeqEntry * @param e Pointer to existing Doc entry * @param depth depth level of the current Seq entry - */ + */ SeqEntry::SeqEntry( DocEntry *e, int depth ) : DocEntry( e->GetDictEntry() ) { @@ -201,9 +201,10 @@ SQItem *SeqEntry::GetSQItem(int nb) return *cc; } } - return *(Items.end()); // Euhhhhh ?!? Is this the last one . FIXME + return *(Items.end()); } +/// \brief retuens the number of SQItems within the current Sequence unsigned int SeqEntry::GetNumberOfSQItems() { return Items.size(); diff --git a/src/gdcmTS.cxx b/src/gdcmTS.cxx index 392cc548..348f7e00 100644 --- a/src/gdcmTS.cxx +++ b/src/gdcmTS.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmTS.cxx,v $ Language: C++ - Date: $Date: 2005/01/18 08:01:42 $ - Version: $Revision: 1.37 $ + Date: $Date: 2005/01/23 10:12:34 $ + Version: $Revision: 1.38 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -59,6 +59,10 @@ static const char *SpecialStrings[] = { "1.2.840.10008.1.2.4.57", // JPEG Lossless, Hierarchical, First-Order Prediction (Process 14, [Selection Value 1]) "1.2.840.10008.1.2.4.70", + // JPEG-LS Lossless Image Compression + "1.2.840.10008.1.2.4.80", + // JPEG-LS Lossy (Near-Lossless) Image Compression + "1.2.840.10008.1.2.4.81", // JPEG 2000 Lossless "1.2.840.10008.1.2.4.90", // JPEG 2000 @@ -147,13 +151,24 @@ TSAtr const & TS::GetValue(TSKey const &key) } return it->second; } - +/** + * \brief Determines if the key passed corresponds to a 'Transfer Syntax' + * as defined in DICOM (and stored in gdcm::TS class) + * @return True when key is an actual 'Transfer Syntax'. False in all + * other cases. + */ bool TS::IsTransferSyntax(TSKey const &key) { TSHT::const_iterator it = TsMap.find(key); return it != TsMap.end(); } +/** + * \brief Determines if the Transfer Syntax was already encountered + * and if it corresponds to a Run Length Encoding Lossless one + * @return True when Run Length Encoding Lossless found. False in all + * other cases. + */ bool TS::IsRLELossless(TSKey const &key) { bool r = false; @@ -168,6 +183,12 @@ bool TS::IsRLELossless(TSKey const &key) return r; } +/** + * \brief Determines if the Transfer Syntax was already encountered + * and if it corresponds to a 'classical' JPEG Lossless one + * @return True when 'classical' Lossless found. False in all + * other cases. + */ bool TS::IsJPEGLossless(TSKey const &key) { bool r = false; @@ -184,6 +205,28 @@ bool TS::IsJPEGLossless(TSKey const &key) return r; } +/** + * \brief Determines if the Transfer Syntax was already encountered + * and if it corresponds to a 'classical' JPEG Lossy one + * @return True when 'classical' Lossy found. False in all + * other cases. + */ +bool TS::IsJPEGLossy(TSKey const &key) +{ + bool r = false; + // First check this is an actual transfer syntax + if( IsTransferSyntax(key) ) + { + if ( key == SpecialStrings[JPEGBaselineProcess1] + || key == SpecialStrings[JPEGExtendedProcess2_4] + || key == SpecialStrings[JPEGExtendedProcess3_5] + || key == SpecialStrings[JPEGSpectralSelectionProcess6_8] ) + { + r = true; + } + } + return r; +} /** * \brief Determines if the Transfer Syntax was already encountered * and if it corresponds to a JPEG2000 one @@ -206,8 +249,8 @@ bool TS::IsJPEG2000(TSKey const &key) } /** - * \brief Determines if the Transfer Syntax corresponds to any form - * of Jpeg encoded Pixel data. + * \brief Determines if the Transfer Syntax corresponds to + * 'classical' Jpeg Lossless or Jpeg lossy. * @return True when any form of JPEG found. False otherwise. */ bool TS::IsJPEG(TSKey const &key) @@ -216,12 +259,9 @@ bool TS::IsJPEG(TSKey const &key) // First check this is an actual transfer syntax if( IsTransferSyntax(key) ) { - if ( key == SpecialStrings[JPEGBaselineProcess1] - || key == SpecialStrings[JPEGExtendedProcess2_4] - || key == SpecialStrings[JPEGExtendedProcess3_5] - || key == SpecialStrings[JPEGSpectralSelectionProcess6_8] - || IsJPEGLossless( key ) - || IsJPEG2000( key ) ) + if ( IsJPEGLossy( key ) + || IsJPEGLossless( key ) + ) { r = true; } @@ -230,18 +270,18 @@ bool TS::IsJPEG(TSKey const &key) } /** - * \brief Determines if the Transfer Syntax corresponds to encapsulated - * of encoded Pixel Data (as opposed to native). - * @return True when encapsulated. False when native. + * \brief Determines if the Transfer Syntax corresponds to any form + * of Jpeg-LS encoded Pixel data. + * @return True when any form of JPEG-LS found. False otherwise. */ -bool TS::IsEncapsulate(TSKey const &key) +bool TS::IsJPEGLS(TSKey const &key) { bool r = false; // First check this is an actual transfer syntax if( IsTransferSyntax(key) ) { - if ( key == SpecialStrings[RLELossless] - || IsJPEG(key) ) + if ( key == SpecialStrings[JPEGLSLossless] + || key == SpecialStrings[JPEGLSNearLossless] ) { r = true; } diff --git a/src/gdcmTS.h b/src/gdcmTS.h index 4b6ddc50..6375a0a4 100644 --- a/src/gdcmTS.h +++ b/src/gdcmTS.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmTS.h,v $ Language: C++ - Date: $Date: 2005/01/11 16:44:43 $ - Version: $Revision: 1.17 $ + Date: $Date: 2005/01/23 10:12:34 $ + Version: $Revision: 1.18 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -54,7 +54,9 @@ enum SpecialType { JPEGFullProgressionProcess10_12, JPEGLosslessProcess14, JPEGLosslessProcess14_1, - JPEG2000Lossless, + JPEGLSLossless, + JPEGLSNearLossless, + JPEG2000Lossless, JPEG2000, RLELossless, UnknownTS @@ -71,9 +73,10 @@ public: bool IsTransferSyntax(TSKey const &key); bool IsRLELossless(TSKey const &key); bool IsJPEGLossless(TSKey const&key); + bool IsJPEGLossy(TSKey const&key); bool IsJPEG2000(TSKey const &key); bool IsJPEG(TSKey const &key); - bool IsEncapsulate(TSKey const &key); + bool IsJPEGLS(TSKey const &key); // This should be deprecated very soon SpecialType GetSpecialTransferSyntax(TSKey const &key); diff --git a/src/gdcmUtil.cxx b/src/gdcmUtil.cxx index 012e1b6c..14b4d52e 100644 --- a/src/gdcmUtil.cxx +++ b/src/gdcmUtil.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmUtil.cxx,v $ Language: C++ - Date: $Date: 2005/01/22 23:29:16 $ - Version: $Revision: 1.121 $ + Date: $Date: 2005/01/23 10:12:34 $ + Version: $Revision: 1.122 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -328,13 +328,13 @@ std::string Util::DicomString(const char *s, size_t l) /** * \brief Create a /DICOM/ string: - * It should a of even lenght (no odd length ever) + * It should a of even length (no odd length ever) * It can contain as many (if you are reading this from your * editor the following character is is backslash followed by zero * that needed to be escaped with an extra backslash for doxygen) \\0 * as you want. * This function is similar to DicomString(const char*), - * except it doesn't take a lenght. + * except it doesn't take a length. * It only pad with a null character if length is odd */ std::string Util::DicomString(const char *s) @@ -351,8 +351,8 @@ std::string Util::DicomString(const char *s) /** * \brief Safely compare two Dicom String: - * - Both string should be of even lenght - * - We allow padding of even lenght string by either a null + * - Both string should be of even length + * - We allow padding of even length string by either a null * character of a space */ bool Util::DicomStringEqual(const std::string &s1, const char *s2) diff --git a/src/gdcmValEntry.cxx b/src/gdcmValEntry.cxx index 22029469..2c589539 100644 --- a/src/gdcmValEntry.cxx +++ b/src/gdcmValEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmValEntry.cxx,v $ Language: C++ - Date: $Date: 2005/01/19 15:58:01 $ - Version: $Revision: 1.48 $ + Date: $Date: 2005/01/23 10:12:34 $ + Version: $Revision: 1.49 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -62,7 +62,9 @@ ValEntry::~ValEntry () //----------------------------------------------------------------------------- // Print /** - * \brief canonical Printer + * \brief Prints the 'std::string representable' value of ValEntry + * @param os ostream we want to print in + * @param indent Indentation string to be prepended during printing */ void ValEntry::Print(std::ostream &os, std::string const &) { @@ -173,6 +175,12 @@ void ValEntry::Print(std::ostream &os, std::string const &) //----------------------------------------------------------------------------- // Public + +/** + * \brief Sets the std::string representable' value of a ValEntry + * @param val value to set + */ + void ValEntry::SetValue(std::string const &val) { // Integers have a special treatement for their length: @@ -213,8 +221,10 @@ void ValEntry::SetValue(std::string const &val) SetLength(l); } -/* - * \brief canonical Writer +/** + * \brief Writes the std::string representable' value of a ValEntry + * @param fp already open ofstream pointer + * @param filetype type of the file to be written */ void ValEntry::WriteContent(std::ofstream *fp, FileType filetype) { @@ -227,7 +237,8 @@ void ValEntry::WriteContent(std::ofstream *fp, FileType filetype) const VRKey &vr = GetVR(); unsigned int lgr = GetLength(); - //std::cout<