#include <gdcmFileHelper.h>
Inheritance diagram for gdcm::FileHelper:
Public Types | |
enum | FileMode { WMODE_RAW, WMODE_RGB } |
Public Member Functions | |
FileHelper () | |
Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3 file (gdcm::File only deals with the ... header) Opens (in read only and when possible) an existing file and checks for DICOM compliance. Returns NULL on failure. It will be up to the user to load the pixels into memory. | |
FileHelper (File *header) | |
Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3 file (File only deals with the ... header) Opens (in read only and when possible) an existing file and checks for DICOM compliance. Returns NULL on failure. It will be up to the user to load the pixels into memory. | |
FileHelper (std::string const &filename) | |
Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3 file (gdcm::File only deals with the ... header) Opens (in read only and when possible) an existing file and checks for DICOM compliance. Returns NULL on failure. It will be up to the user to load the pixels into memory. | |
virtual | ~FileHelper () |
canonical destructor | |
void | Print (std::ostream &os=std::cout, std::string const &indent="") |
Print all the object. | |
File * | GetFile () |
Accessor to File. | |
bool | SetValEntry (std::string const &content, uint16_t group, uint16_t elem) |
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value. | |
bool | SetBinEntry (uint8_t *content, int lgth, uint16_t group, uint16_t elem) |
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value. | |
ValEntry * | InsertValEntry (std::string const &content, uint16_t group, uint16_t elem) |
Modifies the value of a given DocEntry (Dicom entry) when it exists. Create it with the given value when unexistant. | |
BinEntry * | InsertBinEntry (uint8_t *binArea, int lgth, uint16_t group, uint16_t elem) |
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. | |
SeqEntry * | InsertSeqEntry (uint16_t group, uint16_t elem) |
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. | |
size_t | GetImageDataSize () |
Get the size of the image data If the image can be RGB (with a lut or by default), the size corresponds to the RGB image (use GetImageDataRawSize if you want to be sure to get *only* the size of the pixels). | |
size_t | GetImageDataRawSize () |
Get the size of the image data If the image could be converted to RGB using a LUT, this transformation is not taken into account by GetImageDataRawSize (use GetImageDataSize if you wish). | |
uint8_t * | GetImageData () |
| |
uint8_t * | GetImageDataRaw () |
Allocates necessary memory, Transforms YBR pixels (if any) into RGB pixels Transforms 3 planes R, G, B (if any) into a single RGB Plane Copies the pixel data (image[s]/volume[s]) to newly allocated zone. DOES NOT transform Grey plane + 3 Palettes into a RGB Plane. | |
size_t | GetImageDataIntoVector (void *destination, size_t maxSize) |
Read the pixels from disk (uncompress if necessary), 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 at most MaxSize bytes of pixel data to caller allocated memory space. | |
void | SetImageData (uint8_t *data, size_t expectedSize) |
Points the internal pointer to the callers inData image representation, BUT WITHOUT COPYING THE DATA. 'image' Pixels are presented as C-like 2D arrays : line per line. 'volume'Pixels are presented as C-like 3D arrays : plane per plane. | |
void | SetUserData (uint8_t *data, size_t expectedSize) |
Set the image data defined by the user. | |
uint8_t * | GetUserData () |
Get the image data defined by the user. | |
size_t | GetUserDataSize () |
Get the image data size defined by the user. | |
uint8_t * | GetRGBData () |
Get the image data from the file. If a LUT is found, the data are expanded to be RGB. | |
size_t | GetRGBDataSize () |
Get the image data size from the file. If a LUT is found, the data are expanded to be RGB. | |
uint8_t * | GetRawData () |
Get the image data from the file. If a LUT is found, the data are not expanded ! | |
size_t | GetRawDataSize () |
Get the image data size from the file. If a LUT is found, the data are not expanded ! | |
uint8_t * | GetLutRGBA () |
Access to the underlying PixelReadConverter RGBA LUT. | |
void | SetWriteModeToRaw () |
Tells the writer we want to write a Raw File (no header). | |
void | SetWriteModeToRGB () |
Tells the writer we want to write RGB image when possible (as opposite to 'Grey pixels + Palettes color'). | |
void | SetWriteMode (FileMode mode) |
Sets the Write Mode ( ). | |
FileMode | GetWriteMode () |
Gets the Write Mode ( ). | |
void | SetWriteTypeToDcmImplVR () |
Tells the writer we want to write as Implicit VR. | |
void | SetWriteTypeToDcmExplVR () |
Tells the writer we want to write as Explicit VR. | |
void | SetWriteTypeToAcr () |
Tells the writer we want to write as ACR-NEMA. | |
void | SetWriteTypeToAcrLibido () |
Tells the writer we want to write as LibIDO. | |
void | SetWriteType (FileType format) |
Tells the writer which format want to write (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO). | |
FileType | GetWriteType () |
Gets the format we want to write (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO). | |
bool | WriteRawData (std::string const &fileName) |
Writes on disk A SINGLE Dicom file NO test is performed on processor "Endiannity". It's up to the user to call his Reader properly. | |
bool | WriteDcmImplVR (std::string const &fileName) |
Writes on disk A SINGLE Dicom file, using the Implicit Value Representation convention NO test is performed on processor "Endiannity". | |
bool | WriteDcmExplVR (std::string const &fileName) |
Writes on disk A SINGLE Dicom file, using the Explicit Value Representation convention NO test is performed on processor "Endiannity". | |
bool | WriteAcr (std::string const &fileName) |
Writes on disk A SINGLE Dicom file, using the ACR-NEMA convention NO test is performed on processor "Endiannity". (a l'attention des logiciels cliniques qui ne prennent en entrée QUE des images ACR ... | |
bool | Write (std::string const &fileName) |
Writes on disk A SINGLE Dicom file,. | |
void | SetPrintLevel (int level) |
Sets the print level for the Dicom Header Elements. | |
int | GetPrintLevel () |
Gets the print level for the Dicom Entries. | |
Protected Member Functions | |
bool | CheckWriteIntegrity () |
Check the write integrity. | |
void | SetWriteToRaw () |
Update the File to write RAW datas. | |
void | SetWriteToRGB () |
Update the File to write RGB datas. | |
void | RestoreWrite () |
Restore the File write mode. | |
void | SetWriteFileTypeToACR () |
Set in the File the write type to ACR. | |
void | SetWriteFileTypeToExplicitVR () |
Set in the File the write type to Explicit VR. | |
void | SetWriteFileTypeToImplicitVR () |
Set in the File the write type to Implicit VR. | |
void | RestoreWriteFileType () |
Restore in the File the write type. | |
void | SetWriteToLibido () |
Set the Write not to Libido format. | |
void | SetWriteToNoLibido () |
Set the Write not to No Libido format. | |
void | RestoreWriteOfLibido () |
Restore the Write format. | |
ValEntry * | CopyValEntry (uint16_t group, uint16_t elem) |
Copy a ValEntry content. | |
BinEntry * | CopyBinEntry (uint16_t group, uint16_t elem, const std::string &vr) |
Modifies the value of a given Bin Entry (Dicom Element) when it exists. Create it with the given value when unexistant. | |
Protected Attributes | |
int | PrintLevel |
Amount of printed details for each Dicom Entries : 0 : stands for the least detail level. | |
Private Member Functions | |
void | Initialize () |
Factorization for various forms of constructors. | |
uint8_t * | GetRaw () |
Private Attributes | |
File * | FileInternal |
gdcm::File to use to load the file | |
bool | SelfHeader |
Whether the underlying gdcm::File was loaded by the constructor or passed to the constructor. When false the destructor is in charge of deletion. | |
bool | Parsed |
Wether already parsed or not. | |
PixelReadConvert * | PixelReadConverter |
Pointer to the PixelReadConverter. | |
PixelWriteConvert * | PixelWriteConverter |
Pointer to the PixelWriteConverter. | |
DocEntryArchive * | Archive |
Pointer to the DocEntryArchive (used while writting process). | |
FileMode | WriteMode |
(WMODE_RAW, WMODE_RGB) | |
FileType | WriteType |
(ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO) |
Definition at line 40 of file gdcmFileHelper.h.
|
Definition at line 43 of file gdcmFileHelper.h.
|
|
Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3 file (gdcm::File only deals with the ... header) Opens (in read only and when possible) an existing file and checks for DICOM compliance. Returns NULL on failure. It will be up to the user to load the pixels into memory.
Definition at line 51 of file gdcmFileHelper.cxx. References FileInternal, Initialize(), and SelfHeader.
00052 { 00053 FileInternal = new File( ); 00054 SelfHeader = true; 00055 Initialize(); 00056 } |
|
Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3 file (File only deals with the ... header) Opens (in read only and when possible) an existing file and checks for DICOM compliance. Returns NULL on failure. It will be up to the user to load the pixels into memory.
Definition at line 71 of file gdcmFileHelper.cxx. References FileInternal, Initialize(), and SelfHeader.
00072 { 00073 FileInternal = header; 00074 SelfHeader = false; 00075 Initialize(); 00076 } |
|
Constructor dedicated to deal with the *pixels* area of a ACR/DICOMV3 file (gdcm::File only deals with the ... header) Opens (in read only and when possible) an existing file and checks for DICOM compliance. Returns NULL on failure. It will be up to the user to load the pixels into memory.
Definition at line 91 of file gdcmFileHelper.cxx. References FileInternal, Initialize(), and SelfHeader.
00092 { 00093 FileInternal = new File( filename ); 00094 SelfHeader = true; 00095 Initialize(); 00096 } |
|
canonical destructor
Definition at line 103 of file gdcmFileHelper.cxx. References FileInternal, PixelReadConverter, PixelWriteConverter, and SelfHeader.
00104 { 00105 if( PixelReadConverter ) 00106 { 00107 delete PixelReadConverter; 00108 } 00109 if( PixelWriteConverter ) 00110 { 00111 delete PixelWriteConverter; 00112 } 00113 if( Archive ) 00114 { 00115 delete Archive; 00116 } 00117 00118 if( SelfHeader ) 00119 { 00120 delete FileInternal; 00121 } 00122 FileInternal = 0; 00123 } |
|
Check the write integrity. The tests made are :
Definition at line 614 of file gdcmFileHelper.cxx. References FileInternal, gdcmWarningMacro, gdcm::File::GetBitsAllocated(), gdcm::File::GetSamplesPerPixel(), gdcm::PixelWriteConvert::GetUserData(), gdcm::PixelWriteConvert::GetUserDataSize(), gdcm::File::GetXSize(), gdcm::File::GetYSize(), gdcm::File::GetZSize(), gdcm::File::HasLUT(), PixelWriteConverter, WMODE_RAW, WMODE_RGB, and WriteMode. Referenced by Write().
00615 { 00616 if(PixelWriteConverter->GetUserData()) 00617 { 00618 int numberBitsAllocated = FileInternal->GetBitsAllocated(); 00619 if ( numberBitsAllocated == 0 || numberBitsAllocated == 12 ) 00620 { 00621 numberBitsAllocated = 16; 00622 } 00623 00624 size_t decSize = FileInternal->GetXSize() 00625 * FileInternal->GetYSize() 00626 * FileInternal->GetZSize() 00627 * ( numberBitsAllocated / 8 ) 00628 * FileInternal->GetSamplesPerPixel(); 00629 size_t rgbSize = decSize; 00630 if( FileInternal->HasLUT() ) 00631 rgbSize = decSize * 3; 00632 00633 switch(WriteMode) 00634 { 00635 case WMODE_RAW : 00636 if( decSize!=PixelWriteConverter->GetUserDataSize() ) 00637 { 00638 gdcmWarningMacro( "Data size (Raw) is incorrect. Should be " 00639 << decSize << " / Found :" 00640 << PixelWriteConverter->GetUserDataSize() ); 00641 return false; 00642 } 00643 break; 00644 case WMODE_RGB : 00645 if( rgbSize!=PixelWriteConverter->GetUserDataSize() ) 00646 { 00647 gdcmWarningMacro( "Data size (RGB) is incorrect. Should be " 00648 << decSize << " / Found " 00649 << PixelWriteConverter->GetUserDataSize() ); 00650 return false; 00651 } 00652 break; 00653 } 00654 } 00655 00656 return true; 00657 } |
|
Modifies the value of a given Bin Entry (Dicom Element) when it exists. Create it with the given value when unexistant.
Definition at line 941 of file gdcmFileHelper.cxx. References gdcm::ContentEntry::Copy(), FileInternal, gdcm::DocEntry::GetDictEntry(), gdcm::ElementSet::GetDocEntry(), GetFile(), gdcm::DocEntry::GetVR(), and gdcm::DocEntrySet::NewBinEntry(). Referenced by SetWriteToRaw(), and SetWriteToRGB().
00943 { 00944 DocEntry *oldE = FileInternal->GetDocEntry(group, elem); 00945 BinEntry *newE; 00946 00947 if( oldE ) 00948 if( oldE->GetVR()!=vr ) 00949 oldE = NULL; 00950 00951 if( oldE ) 00952 { 00953 newE = new BinEntry(oldE->GetDictEntry()); 00954 newE->Copy(oldE); 00955 } 00956 else 00957 { 00958 newE = GetFile()->NewBinEntry(group,elem,vr); 00959 } 00960 00961 return newE; 00962 } |
|
Copy a ValEntry content.
Definition at line 914 of file gdcmFileHelper.cxx. References gdcm::ContentEntry::Copy(), FileInternal, gdcm::DocEntry::GetDictEntry(), gdcm::ElementSet::GetDocEntry(), GetFile(), and gdcm::DocEntrySet::NewValEntry(). Referenced by SetWriteFileTypeToExplicitVR(), SetWriteFileTypeToImplicitVR(), SetWriteToLibido(), SetWriteToNoLibido(), SetWriteToRaw(), and SetWriteToRGB().
00915 { 00916 DocEntry *oldE = FileInternal->GetDocEntry(group, elem); 00917 ValEntry *newE; 00918 00919 if( oldE ) 00920 { 00921 newE = new ValEntry(oldE->GetDictEntry()); 00922 newE->Copy(oldE); 00923 } 00924 else 00925 { 00926 newE = GetFile()->NewValEntry(group,elem); 00927 } 00928 00929 return newE; 00930 } |
|
Accessor to File.
Definition at line 59 of file gdcmFileHelper.h. Referenced by CopyBinEntry(), CopyValEntry(), vtkGdcmReader::LoadImageInMemory(), RestoreWrite(), SetWriteToRaw(), and SetWriteToRGB().
00059 { return FileInternal; } |
|
Definition at line 248 of file gdcmFileHelper.cxx. References gdcm::PixelReadConvert::BuildRGBImage(), FileInternal, gdcm::PixelReadConvert::GetRaw(), GetRaw(), gdcm::PixelReadConvert::GetRGB(), gdcm::PixelWriteConvert::GetUserData(), gdcm::File::HasLUT(), PixelReadConverter, and PixelWriteConverter. Referenced by vtkGdcmReader::LoadImageInMemory().
00249 { 00250 if ( PixelWriteConverter->GetUserData() ) 00251 { 00252 return PixelWriteConverter->GetUserData(); 00253 } 00254 00255 if ( ! GetRaw() ) 00256 { 00257 // If the decompression failed nothing can be done. 00258 return 0; 00259 } 00260 00261 if ( FileInternal->HasLUT() && PixelReadConverter->BuildRGBImage() ) 00262 { 00263 return PixelReadConverter->GetRGB(); 00264 } 00265 else 00266 { 00267 // When no LUT or LUT conversion fails, return the Raw 00268 return PixelReadConverter->GetRaw(); 00269 } 00270 } |
|
Read the pixels from disk (uncompress if necessary), 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 at most MaxSize bytes of pixel data to caller allocated memory space.
Definition at line 311 of file gdcmFileHelper.cxx. References gdcm::PixelReadConvert::BuildRGBImage(), FileInternal, gdcmWarningMacro, gdcm::PixelReadConvert::GetRaw(), GetRaw(), gdcm::PixelReadConvert::GetRawSize(), gdcm::PixelReadConvert::GetRGB(), gdcm::PixelReadConvert::GetRGBSize(), gdcm::File::HasLUT(), and PixelReadConverter.
00312 { 00313 if ( ! GetRaw() ) 00314 { 00315 // If the decompression failed nothing can be done. 00316 return 0; 00317 } 00318 00319 if ( FileInternal->HasLUT() && PixelReadConverter->BuildRGBImage() ) 00320 { 00321 if ( PixelReadConverter->GetRGBSize() > maxSize ) 00322 { 00323 gdcmWarningMacro( "Pixel data bigger than caller's expected MaxSize"); 00324 return 0; 00325 } 00326 memcpy( destination, 00327 (void*)PixelReadConverter->GetRGB(), 00328 PixelReadConverter->GetRGBSize() ); 00329 return PixelReadConverter->GetRGBSize(); 00330 } 00331 00332 // Either no LUT conversion necessary or LUT conversion failed 00333 if ( PixelReadConverter->GetRawSize() > maxSize ) 00334 { 00335 gdcmWarningMacro( "Pixel data bigger than caller's expected MaxSize"); 00336 return 0; 00337 } 00338 memcpy( destination, 00339 (void*)PixelReadConverter->GetRaw(), 00340 PixelReadConverter->GetRawSize() ); 00341 return PixelReadConverter->GetRawSize(); 00342 } |
|
Allocates necessary memory, Transforms YBR pixels (if any) into RGB pixels Transforms 3 planes R, G, B (if any) into a single RGB Plane Copies the pixel data (image[s]/volume[s]) to newly allocated zone. DOES NOT transform Grey plane + 3 Palettes into a RGB Plane.
Definition at line 281 of file gdcmFileHelper.cxx. References GetRaw(). Referenced by vtkGdcmReader::LoadImageInMemory().
00282 { 00283 return GetRaw(); 00284 } |
|
Get the size of the image data If the image could be converted to RGB using a LUT, this transformation is not taken into account by GetImageDataRawSize (use GetImageDataSize if you wish).
Definition at line 228 of file gdcmFileHelper.cxx. References gdcm::PixelReadConvert::GetRawSize(), gdcm::PixelWriteConvert::GetUserData(), gdcm::PixelWriteConvert::GetUserDataSize(), PixelReadConverter, and PixelWriteConverter.
00229 { 00230 if ( PixelWriteConverter->GetUserData() ) 00231 { 00232 return PixelWriteConverter->GetUserDataSize(); 00233 } 00234 00235 return PixelReadConverter->GetRawSize(); 00236 } |
|
Get the size of the image data If the image can be RGB (with a lut or by default), the size corresponds to the RGB image (use GetImageDataRawSize if you want to be sure to get *only* the size of the pixels).
Definition at line 211 of file gdcmFileHelper.cxx. References gdcm::PixelReadConvert::GetRGBSize(), gdcm::PixelWriteConvert::GetUserData(), gdcm::PixelWriteConvert::GetUserDataSize(), PixelReadConverter, and PixelWriteConverter. Referenced by vtkGdcmReader::LoadImageInMemory().
00212 { 00213 if ( PixelWriteConverter->GetUserData() ) 00214 { 00215 return PixelWriteConverter->GetUserDataSize(); 00216 } 00217 00218 return PixelReadConverter->GetRGBSize(); 00219 } |
|
Access to the underlying PixelReadConverter RGBA LUT.
Definition at line 435 of file gdcmFileHelper.cxx. References gdcm::PixelReadConvert::GetLutRGBA(), and PixelReadConverter. Referenced by vtkGdcmReader::LoadImageInMemory().
00436 { 00437 return PixelReadConverter->GetLutRGBA(); 00438 } |
|
Gets the print level for the Dicom Entries.
Definition at line 48 of file gdcmBase.h.
00048 { return PrintLevel; }; |
|
Definition at line 987 of file gdcmFileHelper.cxx. References gdcm::Document::CloseFile(), FileInternal, gdcmWarningMacro, gdcm::PixelReadConvert::GetRaw(), gdcm::Document::OpenFile(), PixelReadConverter, and gdcm::PixelReadConvert::ReadAndDecompressPixelData(). Referenced by GetImageData(), GetImageDataIntoVector(), and GetImageDataRaw().
00988 { 00989 uint8_t *raw = PixelReadConverter->GetRaw(); 00990 if ( ! raw ) 00991 { 00992 // The Raw image migth not be loaded yet: 00993 std::ifstream *fp = FileInternal->OpenFile(); 00994 PixelReadConverter->ReadAndDecompressPixelData( fp ); 00995 if(fp) 00996 FileInternal->CloseFile(); 00997 00998 raw = PixelReadConverter->GetRaw(); 00999 if ( ! raw ) 01000 { 01001 gdcmWarningMacro( "Read/decompress of pixel data apparently went wrong."); 01002 return 0; 01003 } 01004 } 01005 01006 return raw; 01007 } |
|
Get the image data from the file. If a LUT is found, the data are not expanded !
Definition at line 418 of file gdcmFileHelper.cxx. References gdcm::PixelReadConvert::GetRaw(), and PixelReadConverter.
00419 { 00420 return PixelReadConverter->GetRaw(); 00421 } |
|
Get the image data size from the file. If a LUT is found, the data are not expanded !
Definition at line 427 of file gdcmFileHelper.cxx. References gdcm::PixelReadConvert::GetRawSize(), and PixelReadConverter.
00428 { 00429 return PixelReadConverter->GetRawSize(); 00430 } |
|
Get the image data from the file. If a LUT is found, the data are expanded to be RGB.
Definition at line 400 of file gdcmFileHelper.cxx. References gdcm::PixelReadConvert::GetRGB(), and PixelReadConverter.
00401 { 00402 return PixelReadConverter->GetRGB(); 00403 } |
|
Get the image data size from the file. If a LUT is found, the data are expanded to be RGB.
Definition at line 409 of file gdcmFileHelper.cxx. References gdcm::PixelReadConvert::GetRGBSize(), and PixelReadConverter.
00410 { 00411 return PixelReadConverter->GetRGBSize(); 00412 } |
|
Get the image data defined by the user.
Definition at line 382 of file gdcmFileHelper.cxx. References gdcm::PixelWriteConvert::GetUserData(), and PixelWriteConverter. Referenced by vtkGdcmWriter::WriteDcmFile().
00383 { 00384 return PixelWriteConverter->GetUserData(); 00385 } |
|
Get the image data size defined by the user.
Definition at line 391 of file gdcmFileHelper.cxx. References gdcm::PixelWriteConvert::GetUserDataSize(), and PixelWriteConverter. Referenced by vtkGdcmWriter::WriteDcmFile().
00392 { 00393 return PixelWriteConverter->GetUserDataSize(); 00394 } |
|
Gets the Write Mode ( ).
Definition at line 107 of file gdcmFileHelper.h.
00107 { return WriteMode; }; |
|
Gets the format we want to write (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO).
Definition at line 124 of file gdcmFileHelper.h. References gdcm::FileType.
00124 { return WriteType; }; |
|
Factorization for various forms of constructors.
Definition at line 969 of file gdcmFileHelper.cxx. References gdcm::ExplicitVR, FileInternal, gdcm::PixelReadConvert::GrabInformationsFromFile(), gdcm::File::IsReadable(), PixelReadConverter, PixelWriteConverter, WMODE_RAW, WriteMode, and WriteType. Referenced by FileHelper().
00970 { 00971 WriteMode = WMODE_RAW; 00972 WriteType = ExplicitVR; 00973 00974 PixelReadConverter = new PixelReadConvert; 00975 PixelWriteConverter = new PixelWriteConvert; 00976 Archive = new DocEntryArchive( FileInternal ); 00977 00978 if ( FileInternal->IsReadable() ) 00979 { 00980 PixelReadConverter->GrabInformationsFromFile( FileInternal ); 00981 } 00982 } |
|
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.
Definition at line 183 of file gdcmFileHelper.cxx. References FileInternal, and gdcm::DocEntrySet::InsertBinEntry().
00185 { 00186 return FileInternal->InsertBinEntry(binArea,lgth,group,elem); 00187 } |
|
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.
Definition at line 198 of file gdcmFileHelper.cxx. References FileInternal, and gdcm::DocEntrySet::InsertSeqEntry().
00199 { 00200 return FileInternal->InsertSeqEntry(group,elem); 00201 } |
|
Modifies the value of a given DocEntry (Dicom entry) when it exists. Create it with the given value when unexistant.
Definition at line 166 of file gdcmFileHelper.cxx. References FileInternal, and gdcm::DocEntrySet::InsertValEntry(). Referenced by SetImageInformation(), and vtkGdcmWriter::WriteDcmFile().
00168 { 00169 return FileInternal->InsertValEntry(content,group,elem); 00170 } |
|
Print all the object.
Reimplemented from gdcm::Base. Definition at line 1011 of file gdcmFileHelper.cxx. References FileInternal, PixelReadConverter, gdcm::PixelReadConvert::Print(), gdcm::ElementSet::Print(), and gdcm::Base::SetPrintLevel().
01012 { 01013 FileInternal->SetPrintLevel(PrintLevel); 01014 FileInternal->Print(os); 01015 01016 PixelReadConverter->SetPrintLevel(PrintLevel); 01017 PixelReadConverter->Print(os); 01018 } |
|
Restore the File write mode.
Definition at line 781 of file gdcmFileHelper.cxx. References GetFile(), and gdcm::DocEntryArchive::Restore(). Referenced by Write().
00782 { 00783 Archive->Restore(0x0028,0x0002); 00784 Archive->Restore(0x0028,0x0004); 00785 Archive->Restore(0x0028,0x0006); 00786 Archive->Restore(GetFile()->GetGrPixel(),GetFile()->GetNumPixel()); 00787 00788 // For old ACR-NEMA (24 bits problem) 00789 Archive->Restore(0x0028,0x0100); 00790 Archive->Restore(0x0028,0x0101); 00791 Archive->Restore(0x0028,0x0102); 00792 00793 // For the LUT 00794 Archive->Restore(0x0028,0x1101); 00795 Archive->Restore(0x0028,0x1102); 00796 Archive->Restore(0x0028,0x1103); 00797 Archive->Restore(0x0028,0x1201); 00798 Archive->Restore(0x0028,0x1202); 00799 Archive->Restore(0x0028,0x1203); 00800 } |
|
Restore in the File the write type.
Definition at line 842 of file gdcmFileHelper.cxx. References gdcm::DocEntryArchive::Restore(). Referenced by Write().
00843 { 00844 Archive->Restore(0x0002,0x0010); 00845 } |
|
Restore the Write format.
Definition at line 900 of file gdcmFileHelper.cxx. References gdcm::DocEntryArchive::Restore(). Referenced by Write().
|
|
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.
Definition at line 151 of file gdcmFileHelper.cxx. References FileInternal, and gdcm::DocEntrySet::SetBinEntry().
00153 { 00154 return FileInternal->SetBinEntry(content,lgth,group,elem); 00155 } |
|
Points the internal pointer to the callers inData image representation, BUT WITHOUT COPYING THE DATA. 'image' Pixels are presented as C-like 2D arrays : line per line. 'volume'Pixels are presented as C-like 3D arrays : plane per plane.
Definition at line 359 of file gdcmFileHelper.cxx. References SetUserData().
00360 { 00361 SetUserData(inData,expectedSize); 00362 } |
|
Sets the print level for the Dicom Header Elements.
Definition at line 45 of file gdcmBase.h. Referenced by gdcm::SQItem::Print(), gdcm::SeqEntry::Print(), Print(), gdcm::ElementSet::Print(), and gdcm::DicomDir::Print().
00045 { PrintLevel = level; }; |
|
Set the image data defined by the user.
Definition at line 373 of file gdcmFileHelper.cxx. References PixelWriteConverter, and gdcm::PixelWriteConvert::SetUserData(). Referenced by SetImageData(), and SetImageInformation().
00374 { 00375 PixelWriteConverter->SetUserData(inData,expectedSize); 00376 } |
|
Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.
Definition at line 135 of file gdcmFileHelper.cxx. References FileInternal, and gdcm::DocEntrySet::SetValEntry().
00137 { 00138 return FileInternal->SetValEntry(content,group,elem); 00139 } |
|
Set in the File the write type to ACR.
Definition at line 805 of file gdcmFileHelper.cxx. References gdcm::DocEntryArchive::Push(). Referenced by Write().
00806 { 00807 Archive->Push(0x0002,0x0010); 00808 } |
|
Set in the File the write type to Explicit VR.
Definition at line 813 of file gdcmFileHelper.cxx. References CopyValEntry(), gdcm::DocEntryArchive::Push(), and gdcm::ValEntry::SetValue(). Referenced by Write().
00814 { 00815 std::string ts = Util::DicomString( 00816 Global::GetTS()->GetSpecialTransferSyntax(TS::ExplicitVRLittleEndian) ); 00817 00818 ValEntry *tss = CopyValEntry(0x0002,0x0010); 00819 tss->SetValue(ts); 00820 00821 Archive->Push(tss); 00822 } |
|
Set in the File the write type to Implicit VR.
Definition at line 827 of file gdcmFileHelper.cxx. References CopyValEntry(), gdcm::DocEntryArchive::Push(), and gdcm::ValEntry::SetValue(). Referenced by Write().
00828 { 00829 std::string ts = Util::DicomString( 00830 Global::GetTS()->GetSpecialTransferSyntax(TS::ImplicitVRLittleEndian) ); 00831 00832 ValEntry *tss = CopyValEntry(0x0002,0x0010); 00833 tss->SetValue(ts); 00834 00835 Archive->Push(tss); 00836 } |
|
Sets the Write Mode ( ).
Definition at line 105 of file gdcmFileHelper.h.
00105 { WriteMode = mode; }; |
|
Tells the writer we want to write a Raw File (no header).
Definition at line 100 of file gdcmFileHelper.h.
00100 { SetWriteMode(WMODE_RAW); }; |
|
Tells the writer we want to write RGB image when possible (as opposite to 'Grey pixels + Palettes color').
Definition at line 103 of file gdcmFileHelper.h.
00103 { SetWriteMode(WMODE_RGB); }; |
|
Set the Write not to Libido format.
Definition at line 850 of file gdcmFileHelper.cxx. References gdcm::ContentEntry::Copy(), CopyValEntry(), FileInternal, gdcm::DocEntry::GetDictEntry(), gdcm::ElementSet::GetDocEntry(), gdcm::ContentEntry::GetValue(), gdcm::DocEntryArchive::Push(), and gdcm::ValEntry::SetValue(). Referenced by Write().
00851 { 00852 ValEntry *oldRow = dynamic_cast<ValEntry *> 00853 (FileInternal->GetDocEntry(0x0028, 0x0010)); 00854 ValEntry *oldCol = dynamic_cast<ValEntry *> 00855 (FileInternal->GetDocEntry(0x0028, 0x0011)); 00856 00857 if( oldRow && oldCol ) 00858 { 00859 std::string rows, columns; 00860 00861 ValEntry *newRow=new ValEntry(oldRow->GetDictEntry()); 00862 ValEntry *newCol=new ValEntry(oldCol->GetDictEntry()); 00863 00864 newRow->Copy(oldCol); 00865 newCol->Copy(oldRow); 00866 00867 newRow->SetValue(oldCol->GetValue()); 00868 newCol->SetValue(oldRow->GetValue()); 00869 00870 Archive->Push(newRow); 00871 Archive->Push(newCol); 00872 } 00873 00874 ValEntry *libidoCode = CopyValEntry(0x0008,0x0010); 00875 libidoCode->SetValue("ACRNEMA_LIBIDO_1.1"); 00876 Archive->Push(libidoCode); 00877 } |
|
Set the Write not to No Libido format.
Definition at line 882 of file gdcmFileHelper.cxx. References CopyValEntry(), FileInternal, gdcm::ElementSet::GetDocEntry(), gdcm::ContentEntry::GetValue(), gdcm::DocEntryArchive::Push(), and gdcm::ValEntry::SetValue(). Referenced by Write().
00883 { 00884 ValEntry *recCode = dynamic_cast<ValEntry *> 00885 (FileInternal->GetDocEntry(0x0008,0x0010)); 00886 if( recCode ) 00887 { 00888 if( recCode->GetValue() == "ACRNEMA_LIBIDO_1.1" ) 00889 { 00890 ValEntry *libidoCode = CopyValEntry(0x0008,0x0010); 00891 libidoCode->SetValue(""); 00892 Archive->Push(libidoCode); 00893 } 00894 } 00895 } |
|
Update the File to write RAW datas.
Definition at line 662 of file gdcmFileHelper.cxx. References CopyBinEntry(), CopyValEntry(), FileInternal, gdcm::GDCM_BINLOADED, gdcm::File::GetBitsAllocated(), gdcm::PixelWriteConvert::GetData(), gdcm::PixelWriteConvert::GetDataSize(), GetFile(), gdcm::File::GetNumberOfScalarComponents(), gdcm::PixelReadConvert::GetRaw(), gdcm::PixelReadConvert::GetRawSize(), gdcm::File::HasLUT(), PixelReadConverter, PixelWriteConverter, gdcm::DocEntryArchive::Push(), gdcm::BinEntry::SetBinArea(), gdcm::DocEntry::SetLength(), gdcm::PixelWriteConvert::SetReadData(), gdcm::ContentEntry::SetValue(), gdcm::ValEntry::SetValue(), and SetWriteToRGB(). Referenced by SetWriteToRGB(), and Write().
00663 { 00664 if( FileInternal->GetNumberOfScalarComponents() == 3 00665 && !FileInternal->HasLUT()) 00666 { 00667 SetWriteToRGB(); 00668 } 00669 else 00670 { 00671 ValEntry *photInt = CopyValEntry(0x0028,0x0004); 00672 if(FileInternal->HasLUT()) 00673 { 00674 photInt->SetValue("PALETTE COLOR "); 00675 } 00676 else 00677 { 00678 photInt->SetValue("MONOCHROME1 "); 00679 } 00680 00681 PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(), 00682 PixelReadConverter->GetRawSize()); 00683 00684 std::string vr = "OB"; 00685 if( FileInternal->GetBitsAllocated()>8 ) 00686 vr = "OW"; 00687 if( FileInternal->GetBitsAllocated()==24 ) // For RGB ACR files 00688 vr = "OB"; 00689 BinEntry *pixel = 00690 CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr); 00691 pixel->SetValue(GDCM_BINLOADED); 00692 pixel->SetBinArea(PixelWriteConverter->GetData(),false); 00693 pixel->SetLength(PixelWriteConverter->GetDataSize()); 00694 00695 Archive->Push(photInt); 00696 Archive->Push(pixel); 00697 } 00698 } |
|
Update the File to write RGB datas.
Definition at line 703 of file gdcmFileHelper.cxx. References gdcm::PixelReadConvert::BuildRGBImage(), CopyBinEntry(), CopyValEntry(), FileInternal, gdcm::GDCM_BINLOADED, gdcm::File::GetBitsAllocated(), gdcm::PixelWriteConvert::GetData(), gdcm::PixelWriteConvert::GetDataSize(), GetFile(), gdcm::File::GetNumberOfScalarComponents(), gdcm::PixelReadConvert::GetRaw(), gdcm::PixelReadConvert::GetRawSize(), gdcm::PixelReadConvert::GetRGB(), gdcm::PixelReadConvert::GetRGBSize(), PixelReadConverter, PixelWriteConverter, gdcm::DocEntryArchive::Push(), gdcm::BinEntry::SetBinArea(), gdcm::DocEntry::SetLength(), gdcm::PixelWriteConvert::SetReadData(), gdcm::ContentEntry::SetValue(), gdcm::ValEntry::SetValue(), and SetWriteToRaw(). Referenced by SetWriteToRaw(), and Write().
00704 { 00705 if(FileInternal->GetNumberOfScalarComponents()==3) 00706 { 00707 PixelReadConverter->BuildRGBImage(); 00708 00709 ValEntry *spp = CopyValEntry(0x0028,0x0002); 00710 spp->SetValue("3 "); 00711 00712 ValEntry *planConfig = CopyValEntry(0x0028,0x0006); 00713 planConfig->SetValue("0 "); 00714 00715 ValEntry *photInt = CopyValEntry(0x0028,0x0004); 00716 photInt->SetValue("RGB "); 00717 00718 if(PixelReadConverter->GetRGB()) 00719 { 00720 PixelWriteConverter->SetReadData(PixelReadConverter->GetRGB(), 00721 PixelReadConverter->GetRGBSize()); 00722 } 00723 else // Raw data 00724 { 00725 PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(), 00726 PixelReadConverter->GetRawSize()); 00727 } 00728 00729 std::string vr = "OB"; 00730 if( FileInternal->GetBitsAllocated()>8 ) 00731 vr = "OW"; 00732 if( FileInternal->GetBitsAllocated()==24 ) // For RGB ACR files 00733 vr = "OB"; 00734 BinEntry *pixel = 00735 CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr); 00736 pixel->SetValue(GDCM_BINLOADED); 00737 pixel->SetBinArea(PixelWriteConverter->GetData(),false); 00738 pixel->SetLength(PixelWriteConverter->GetDataSize()); 00739 00740 Archive->Push(spp); 00741 Archive->Push(planConfig); 00742 Archive->Push(photInt); 00743 Archive->Push(pixel); 00744 00745 // Remove any LUT 00746 Archive->Push(0x0028,0x1101); 00747 Archive->Push(0x0028,0x1102); 00748 Archive->Push(0x0028,0x1103); 00749 Archive->Push(0x0028,0x1201); 00750 Archive->Push(0x0028,0x1202); 00751 Archive->Push(0x0028,0x1203); 00752 00753 // For old ACR-NEMA 00754 // Thus, we have a RGB image and the bits allocated = 24 and 00755 // samples per pixels = 1 (in the read file) 00756 if(FileInternal->GetBitsAllocated()==24) 00757 { 00758 ValEntry *bitsAlloc = CopyValEntry(0x0028,0x0100); 00759 bitsAlloc->SetValue("8 "); 00760 00761 ValEntry *bitsStored = CopyValEntry(0x0028,0x0101); 00762 bitsStored->SetValue("8 "); 00763 00764 ValEntry *highBit = CopyValEntry(0x0028,0x0102); 00765 highBit->SetValue("7 "); 00766 00767 Archive->Push(bitsAlloc); 00768 Archive->Push(bitsStored); 00769 Archive->Push(highBit); 00770 } 00771 } 00772 else 00773 { 00774 SetWriteToRaw(); 00775 } 00776 } |
|
Tells the writer which format want to write (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO).
Definition at line 121 of file gdcmFileHelper.h.
00121 { WriteType = format; }; |
|
Tells the writer we want to write as ACR-NEMA.
Definition at line 116 of file gdcmFileHelper.h. References gdcm::ACR. Referenced by WriteAcr(), and vtkGdcmWriter::WriteDcmFile().
00116 { SetWriteType(ACR); }; |
|
Tells the writer we want to write as LibIDO.
Definition at line 118 of file gdcmFileHelper.h. References gdcm::ACR_LIBIDO. Referenced by vtkGdcmWriter::WriteDcmFile().
00118 { SetWriteType(ACR_LIBIDO); }; |
|
Tells the writer we want to write as Explicit VR.
Definition at line 114 of file gdcmFileHelper.h. References gdcm::ExplicitVR. Referenced by WriteDcmExplVR(), and vtkGdcmWriter::WriteDcmFile().
00114 { SetWriteType(ExplicitVR); }; |
|
Tells the writer we want to write as Implicit VR.
Definition at line 112 of file gdcmFileHelper.h. References gdcm::ImplicitVR. Referenced by vtkGdcmWriter::WriteDcmFile(), and WriteDcmImplVR().
00112 { SetWriteType(ImplicitVR); }; |
|
Writes on disk A SINGLE Dicom file,.
Definition at line 538 of file gdcmFileHelper.cxx. References gdcm::ACR, gdcm::ACR_LIBIDO, CheckWriteIntegrity(), gdcm::ExplicitVR, FileInternal, gdcm::ImplicitVR, RestoreWrite(), RestoreWriteFileType(), RestoreWriteOfLibido(), SetWriteFileTypeToACR(), SetWriteFileTypeToExplicitVR(), SetWriteFileTypeToImplicitVR(), SetWriteToLibido(), SetWriteToNoLibido(), SetWriteToRaw(), SetWriteToRGB(), WMODE_RAW, WMODE_RGB, gdcm::File::Write(), WriteMode, and WriteType. Referenced by WriteAcr(), WriteDcmExplVR(), vtkGdcmWriter::WriteDcmFile(), and WriteDcmImplVR().
00539 { 00540 switch(WriteType) 00541 { 00542 case ImplicitVR: 00543 SetWriteFileTypeToImplicitVR(); 00544 break; 00545 case ExplicitVR: 00546 SetWriteFileTypeToExplicitVR(); 00547 break; 00548 case ACR: 00549 case ACR_LIBIDO: 00550 SetWriteFileTypeToACR(); 00551 break; 00552 default: 00553 SetWriteFileTypeToExplicitVR(); 00554 } 00555 00556 // -------------------------------------------------------------- 00557 // Special Patch to allow gdcm to re-write ACR-LibIDO formated images 00558 // 00559 // if recognition code tells us we dealt with a LibIDO image 00560 // we reproduce on disk the switch between lineNumber and columnNumber 00561 // just before writting ... 00564 if( WriteType == ACR_LIBIDO ) 00565 { 00566 SetWriteToLibido(); 00567 } 00568 else 00569 { 00570 SetWriteToNoLibido(); 00571 } 00572 // ----------------- End of Special Patch ---------------- 00573 00574 switch(WriteMode) 00575 { 00576 case WMODE_RAW : 00577 SetWriteToRaw(); 00578 break; 00579 case WMODE_RGB : 00580 SetWriteToRGB(); 00581 break; 00582 } 00583 00584 bool check = CheckWriteIntegrity(); 00585 if(check) 00586 { 00587 check = FileInternal->Write(fileName,WriteType); 00588 } 00589 00590 RestoreWrite(); 00591 RestoreWriteFileType(); 00592 00593 // -------------------------------------------------------------- 00594 // Special Patch to allow gdcm to re-write ACR-LibIDO formated images 00595 // 00596 // ...and we restore the header to be Dicom Compliant again 00597 // just after writting 00598 RestoreWriteOfLibido(); 00599 // ----------------- End of Special Patch ---------------- 00600 00601 return check; 00602 } |
|
Writes on disk A SINGLE Dicom file, using the ACR-NEMA convention NO test is performed on processor "Endiannity". (a l'attention des logiciels cliniques qui ne prennent en entrée QUE des images ACR ...
Definition at line 526 of file gdcmFileHelper.cxx. References SetWriteTypeToAcr(), and Write().
00527 { 00528 SetWriteTypeToAcr(); 00529 return Write(fileName); 00530 } |
|
Writes on disk A SINGLE Dicom file, using the Explicit Value Representation convention NO test is performed on processor "Endiannity".
Definition at line 506 of file gdcmFileHelper.cxx. References SetWriteTypeToDcmExplVR(), and Write().
00507 { 00508 SetWriteTypeToDcmExplVR(); 00509 return Write(fileName); 00510 } |
|
Writes on disk A SINGLE Dicom file, using the Implicit Value Representation convention NO test is performed on processor "Endiannity".
Definition at line 491 of file gdcmFileHelper.cxx. References SetWriteTypeToDcmImplVR(), and Write().
00492 { 00493 SetWriteTypeToDcmImplVR(); 00494 return Write(fileName); 00495 } |
|
Writes on disk A SINGLE Dicom file NO test is performed on processor "Endiannity". It's up to the user to call his Reader properly.
Definition at line 448 of file gdcmFileHelper.cxx. References gdcmErrorMacro, gdcmWarningMacro, gdcm::PixelReadConvert::GetRaw(), gdcm::PixelReadConvert::GetRawSize(), gdcm::PixelReadConvert::GetRGB(), gdcm::PixelReadConvert::GetRGBSize(), gdcm::PixelWriteConvert::GetUserData(), gdcm::PixelWriteConvert::GetUserDataSize(), PixelReadConverter, and PixelWriteConverter.
00449 { 00450 std::ofstream fp1(fileName.c_str(), std::ios::out | std::ios::binary ); 00451 if (!fp1) 00452 { 00453 gdcmWarningMacro( "Fail to open (write) file:" << fileName.c_str()); 00454 return false; 00455 } 00456 00457 if( PixelWriteConverter->GetUserData() ) 00458 { 00459 fp1.write( (char*)PixelWriteConverter->GetUserData(), 00460 PixelWriteConverter->GetUserDataSize() ); 00461 } 00462 else if ( PixelReadConverter->GetRGB() ) 00463 { 00464 fp1.write( (char*)PixelReadConverter->GetRGB(), 00465 PixelReadConverter->GetRGBSize()); 00466 } 00467 else if ( PixelReadConverter->GetRaw() ) 00468 { 00469 fp1.write( (char*)PixelReadConverter->GetRaw(), 00470 PixelReadConverter->GetRawSize()); 00471 } 00472 else 00473 { 00474 gdcmErrorMacro( "Nothing written." ); 00475 } 00476 00477 fp1.close(); 00478 00479 return true; 00480 } |
|
Pointer to the DocEntryArchive (used while writting process).
Definition at line 180 of file gdcmFileHelper.h. |
|
gdcm::File to use to load the file
Definition at line 162 of file gdcmFileHelper.h. Referenced by CheckWriteIntegrity(), CopyBinEntry(), CopyValEntry(), FileHelper(), GetImageData(), GetImageDataIntoVector(), GetRaw(), Initialize(), InsertBinEntry(), InsertSeqEntry(), InsertValEntry(), Print(), SetBinEntry(), SetValEntry(), SetWriteToLibido(), SetWriteToNoLibido(), SetWriteToRaw(), SetWriteToRGB(), Write(), and ~FileHelper(). |
|
Wether already parsed or not.
Definition at line 170 of file gdcmFileHelper.h. |
|
Pointer to the PixelReadConverter.
Definition at line 174 of file gdcmFileHelper.h. Referenced by GetImageData(), GetImageDataIntoVector(), GetImageDataRawSize(), GetImageDataSize(), GetLutRGBA(), GetRaw(), GetRawData(), GetRawDataSize(), GetRGBData(), GetRGBDataSize(), Initialize(), Print(), SetWriteToRaw(), SetWriteToRGB(), WriteRawData(), and ~FileHelper(). |
|
Pointer to the PixelWriteConverter.
Definition at line 176 of file gdcmFileHelper.h. Referenced by CheckWriteIntegrity(), GetImageData(), GetImageDataRawSize(), GetImageDataSize(), GetUserData(), GetUserDataSize(), Initialize(), SetUserData(), SetWriteToRaw(), SetWriteToRGB(), WriteRawData(), and ~FileHelper(). |
|
Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.
Definition at line 53 of file gdcmBase.h. Referenced by gdcm::Base::Base(). |
|
Whether the underlying gdcm::File was loaded by the constructor or passed to the constructor. When false the destructor is in charge of deletion.
Definition at line 167 of file gdcmFileHelper.h. Referenced by FileHelper(), and ~FileHelper(). |
|
(WMODE_RAW, WMODE_RGB)
Definition at line 184 of file gdcmFileHelper.h. Referenced by CheckWriteIntegrity(), Initialize(), and Write(). |
|
(ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)
Definition at line 186 of file gdcmFileHelper.h. Referenced by Initialize(), and Write(). |