- return ( IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_55)
- || IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_57)
- || IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_70) );
-}
-
-/**
- * \brief Determines if the Transfer Syntax was already encountered
- * and if it corresponds to a JPEG2000 one
- * @return True when JPEG2000 (Lossly or LossLess) found. False in all
- * other cases.
- */
-bool gdcmDocument::IsJPEG2000()
-{
- return ( IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_90)
- || IsGivenTransferSyntax(UI1_2_840_10008_1_2_4_91) );
-}
-
-/**
- * \brief Determines if the Transfer Syntax corresponds to encapsulated
- * of encoded Pixel Data (as opposed to native).
- * @return True when encapsulated. False when native.
- */
-bool gdcmDocument::IsEncapsulateTransferSyntax()
-{
- return ( IsJPEGBaseLineProcess1TransferSyntax()
- || IsJPEGExtendedProcess2_4TransferSyntax()
- || IsJPEGExtendedProcess3_5TransferSyntax()
- || IsJPEGSpectralSelectionProcess6_8TransferSyntax()
- || IsRLELossLessTransferSyntax()
- || IsJPEGLossless()
- || IsJPEG2000() );
-}
-
-/**
- * \brief Predicate for dicom version 3 file.
- * @return True when the file is a dicom version 3.
- */
-bool gdcmDocument::IsDicomV3()
-{
- // Checking if Transfert Syntax exists is enough
- // Anyway, it's to late check if the 'Preamble' was found ...
- // And ... would it be a rich idea to check ?
- // (some 'no Preamble' DICOM images exist !)
- return GetDocEntryByNumber(0x0002, 0x0010) != NULL;
-}
-
-/**
- * \brief returns the File Type
- * (ACR, ACR_LIBIDO, ExplicitVR, ImplicitVR, Unknown)
- * @return the FileType code
- */
-FileType gdcmDocument::GetFileType()
-{
- return Filetype;
-}
-
-/**
- * \brief Tries to open the file \ref gdcmDocument::Filename and
- * checks the preamble when existing.
- * @return The FILE pointer on success.
- */
-FILE* gdcmDocument::OpenFile()
-{
- Fp = fopen(Filename.c_str(),"rb");
-
- if(!Fp)
- {
- dbg.Verbose( 0,
- "gdcmDocument::OpenFile cannot open file: ",
- Filename.c_str());
- return 0;
- }
-
- uint16_t zero;
- fread(&zero, (size_t)2, (size_t)1, Fp);
-
- //ACR -- or DICOM with no Preamble --
- if( zero == 0x0008 || zero == 0x0800 || zero == 0x0002 || zero == 0x0200 )
- {
- return Fp;
- }
-
- //DICOM
- fseek(Fp, 126L, SEEK_CUR);
- char dicm[4];
- fread(dicm, (size_t)4, (size_t)1, Fp);
- if( memcmp(dicm, "DICM", 4) == 0 )
- {
- return Fp;
- }
-
- fclose(Fp);
- dbg.Verbose( 0,
- "gdcmDocument::OpenFile not DICOM/ACR (missing preamble)",
- Filename.c_str());
-
- return 0;
-}
-
-/**
- * \brief closes the file
- * @return TRUE if the close was successfull
- */
-bool gdcmDocument::CloseFile()
-{
- int closed = fclose(Fp);
- Fp = 0;
-
- return closed;
-}
-
-/**
- * \brief Writes in a file all the Header Entries (Dicom Elements)
- * @param fp file pointer on an already open file
- * @param filetype Type of the File to be written
- * (ACR-NEMA, ExplicitVR, ImplicitVR)
- * \return Always true.
- */
-void gdcmDocument::Write(FILE* fp,FileType filetype)
-{
- /// \todo move the following lines (and a lot of others, to be written)
- /// to a future function CheckAndCorrectHeader
- /// (necessary if user wants to write a DICOM V3 file
- /// starting from an ACR-NEMA (V2) gdcmHeader
-
- if (filetype == gdcmImplicitVR)
- {
- std::string implicitVRTransfertSyntax = UI1_2_840_10008_1_2;
- ReplaceOrCreateByNumber(implicitVRTransfertSyntax,0x0002, 0x0010);
-
- /// \todo Refer to standards on page 21, chapter 6.2
- /// "Value representation": values with a VR of UI shall be
- /// padded with a single trailing null
- /// in the following case we have to padd manually with a 0
-
- SetEntryLengthByNumber(18, 0x0002, 0x0010);
- }
-
- if (filetype == gdcmExplicitVR)