X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmFileHelper.cxx;h=a1cfd210b9f1a45ec058f9f9efce5cb1fd65acd7;hb=dfd2b1cd2925e77ef9466cfb2fc71706c84a418c;hp=43f6b89be5063d15293831715ba23f98d0256b1e;hpb=c094e185dd6404df031524ccae8e1b51e3b84871;p=gdcm.git diff --git a/src/gdcmFileHelper.cxx b/src/gdcmFileHelper.cxx index 43f6b89b..a1cfd210 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/26 16:28:58 $ + 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 @@ -23,6 +23,8 @@ #include "gdcmDebug.h" #include "gdcmUtil.h" #include "gdcmBinEntry.h" +#include "gdcmValEntry.h" +#include "gdcmContentEntry.h" #include "gdcmFile.h" #include "gdcmPixelReadConvert.h" #include "gdcmPixelWriteConvert.h" @@ -282,7 +284,7 @@ size_t FileHelper::GetImageDataIntoVector (void *destination, size_t maxSize) * 'image' Pixels are presented as C-like 2D arrays : line per line. * '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 it's data before gdcm uses them (e.g. with + * 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 @@ -295,8 +297,8 @@ void FileHelper::SetImageData(uint8_t *inData, size_t expectedSize) } /** - * \brief Set the image datas defined by the user - * \warning When writting the file, this datas are get as default datas to write + * \brief Set the image data defined by the user + * \warning When writting the file, this data are get as default data to write */ void FileHelper::SetUserData(uint8_t *data, size_t expectedSize) { @@ -304,8 +306,8 @@ void FileHelper::SetUserData(uint8_t *data, size_t expectedSize) } /** - * \brief Get the image datas defined by the user - * \warning When writting the file, this datas are get as default data to write + * \brief Get the image data defined by the user + * \warning When writting the file, this data are get as default data to write */ uint8_t *FileHelper::GetUserData() { @@ -314,7 +316,7 @@ uint8_t *FileHelper::GetUserData() /** * \brief Get the image data size defined by the user - * \warning When writting the file, this datas are get as default data to write + * \warning When writting the file, this data are get as default data to write */ size_t FileHelper::GetUserDataSize() { @@ -322,7 +324,7 @@ size_t FileHelper::GetUserDataSize() } /** - * \brief Get the image datas from the file. + * \brief Get the image data from the file. * If a LUT is found, the data are expanded to be RGB */ uint8_t *FileHelper::GetRGBData() @@ -340,8 +342,8 @@ size_t FileHelper::GetRGBDataSize() } /** - * \brief Get the image datas from the file. - * If a LUT is found, the datas are not expanded ! + * \brief Get the image data from the file. + * If a LUT is found, the data are not expanded ! */ uint8_t *FileHelper::GetRawData() { @@ -527,13 +529,13 @@ bool FileHelper::Write(std::string const &fileName) * through it's (group, element) and modifies it's content with * the given value. * @param content new value (string) to substitute with - * @param group group number of the Dicom Element to modify + * @param group group number of the Dicom Element to modify * @param elem element number of the Dicom Element to modify */ -bool FileHelper::SetEntry(std::string const &content, +bool FileHelper::SetValEntry(std::string const &content, uint16_t group, uint16_t elem) { - return FileInternal->SetEntry(content,group,elem); + return FileInternal->SetValEntry(content,group,elem); } @@ -543,13 +545,13 @@ bool FileHelper::SetEntry(std::string const &content, * the given value. * @param content new value (void* -> uint8_t*) to substitute with * @param lgth new value length - * @param group group number of the Dicom Element to modify + * @param group group number of the Dicom Element to modify * @param elem element number of the Dicom Element to modify */ -bool FileHelper::SetEntry(uint8_t *content, int lgth, - uint16_t group, uint16_t elem) +bool FileHelper::SetBinEntry(uint8_t *content, int lgth, + uint16_t group, uint16_t elem) { - return FileInternal->SetEntry(content,lgth,group,elem); + return FileInternal->SetBinEntry(content,lgth,group,elem); } /** @@ -561,10 +563,10 @@ bool FileHelper::SetEntry(uint8_t *content, int lgth, * \return pointer to the modified/created Dicom entry (NULL when creation * failed). */ -bool FileHelper::ReplaceOrCreate(std::string const &content, - uint16_t group, uint16_t elem) +ValEntry *FileHelper::InsertValEntry(std::string const &content, + uint16_t group, uint16_t elem) { - return FileInternal->ReplaceOrCreate(content,group,elem) != NULL; + return FileInternal->InsertValEntry(content,group,elem); } /* @@ -577,10 +579,24 @@ bool FileHelper::ReplaceOrCreate(std::string const &content, * \return pointer to the modified/created Dicom entry (NULL when creation * failed). */ -bool FileHelper::ReplaceOrCreate(uint8_t *binArea, int lgth, - uint16_t group, uint16_t elem) +BinEntry *FileHelper::InsertBinEntry(uint8_t *binArea, int lgth, + uint16_t group, uint16_t elem) { - return FileInternal->ReplaceOrCreate(binArea,lgth,group,elem) != NULL; + 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. + * @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). + */ +SeqEntry *FileHelper::InsertSeqEntry(uint16_t group, uint16_t elem) +{ + return FileInternal->InsertSeqEntry(group,elem); } /** @@ -600,7 +616,7 @@ uint8_t* FileHelper::GetLutRGBA() * The tests made are : * - verify the size of the image to write with the possible write * when the user set an image data - * @return true if the check successfulls + * @return true if check is successfull */ bool FileHelper::CheckWriteIntegrity() { @@ -626,16 +642,18 @@ bool FileHelper::CheckWriteIntegrity() case WMODE_RAW : if( decSize!=PixelWriteConverter->GetUserDataSize() ) { - gdcmVerboseMacro( "Data size is incorrect (Raw)" << decSize - << " / " << PixelWriteConverter->GetUserDataSize() ); + gdcmVerboseMacro( "Data size (Raw) is incorrect. Should be " + << decSize << " / Found :" + << PixelWriteConverter->GetUserDataSize() ); return false; } break; case WMODE_RGB : if( rgbSize!=PixelWriteConverter->GetUserDataSize() ) { - gdcmVerboseMacro( "Data size is incorrect (RGB)" << decSize - << " / " << PixelWriteConverter->GetUserDataSize() ); + gdcmVerboseMacro( "Data size (RGB) is incorrect. Should be " + << decSize << " / Found " + << PixelWriteConverter->GetUserDataSize() ); return false; } break; @@ -901,7 +919,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 @@ -941,7 +958,7 @@ void FileHelper::Initialize() if ( FileInternal->IsReadable() ) { - PixelReadConverter->GrabInformationsFromHeader( FileInternal ); + PixelReadConverter->GrabInformationsFromFile( FileInternal ); } }