+ * \brief Performs the Loading Job (internal use only)
+ * @return false if file cannot be open or no swap info was found,
+ * or no tag was found.
+ */
+bool Document::DoTheLoadingDocumentJob( )
+{
+ if ( ! IsDocumentModified ) // Nothing to do !
+ return true;
+
+ // if ( Filename == fileName )
+ // {
+ // gdcmWarningMacro( "The file was already parsed inside this "
+ // << "gdcm::Document (its name is: "
+ // << Filename.c_str() );
+ // return true;
+ // }
+
+ //gdcmWarningMacro( "A file was already parsed inside this "
+ // << "gdcm::Document (previous name was: "
+ // << Filename.c_str() << ". New name is :"
+ // << fileName );
+ // clean out the Entries, if already parsed
+ // (probabely a mistake from the user)
+
+ ClearEntry();
+
+ Fp = 0;
+ if ( !OpenFile() )
+ {
+ // warning already performed in OpenFile()
+ //gdcmWarningMacro( "Unable to open as an ACR/DICOM file: "
+ // << Filename.c_str() );
+ Filetype = Unknown;
+ return false;
+ }
+
+ Group0002Parsed = false;
+
+ gdcmWarningMacro( "Starting parsing of file: " << Filename.c_str());
+
+ Fp->seekg(0, std::ios::end);
+ long lgt = Fp->tellg(); // total length of the file
+
+ Fp->seekg(0, std::ios::beg);
+
+ // CheckSwap returns a boolean
+ // (false if no swap info of any kind was found)
+ if (! CheckSwap() )
+ {
+ gdcmWarningMacro( "Neither a DICOM V3 nor an ACR-NEMA file: "
+ << Filename.c_str());
+ CloseFile();
+ return false;
+ }
+
+ long beg = Fp->tellg(); // just after DICOM preamble (if any)
+
+ lgt -= beg; // remaining length to parse
+
+ // Recursive call.
+ // Loading is done during parsing
+ ParseDES( this, beg, lgt, false); // delim_mode is first defaulted to false
+
+ if ( IsEmpty() )
+ {
+ gdcmWarningMacro( "No tag in internal hash table for: "
+ << Filename.c_str());
+ CloseFile();
+ return false;
+ }
+ IsDocumentAlreadyLoaded = true;
+
+ Fp->seekg( 0, std::ios::beg);
+
+ // Load 'non string' values
+
+ std::string PhotometricInterpretation = GetEntryValue(0x0028,0x0004);
+ if ( PhotometricInterpretation == "PALETTE COLOR " )
+ {
+ // FIXME
+ // Probabely this line should be outside the 'if'
+ // Try to find an image sample holding a 'gray LUT'
+ LoadEntryBinArea(0x0028,0x1200); // gray LUT
+
+ /// FIXME
+ /// The tags refered by the three following lines used to be CORRECTLY
+ /// defined as having an US Value Representation in the public
+ /// dictionary. BUT the semantics implied by the three following
+ /// lines state that the corresponding tag contents are in fact
+ /// the ones of a BinEntry.
+ /// In order to fix things "Quick and Dirty" the dictionary was
+ /// altered on PURPOSE but now contains a WRONG value.
+ /// In order to fix things and restore the dictionary to its
+ /// correct value, one needs to decided of the semantics by deciding
+ /// whether the following tags are either :
+ /// - multivaluated US, and hence loaded as ValEntry, but afterwards
+ /// also used as BinEntry, which requires the proper conversion,
+ /// - OW, and hence loaded as BinEntry, but afterwards also used
+ /// as ValEntry, which requires the proper conversion.
+ LoadEntryBinArea(0x0028,0x1201); // R LUT
+ LoadEntryBinArea(0x0028,0x1202); // G LUT
+ LoadEntryBinArea(0x0028,0x1203); // B LUT
+
+ // Segmented Red Palette Color LUT Data
+ LoadEntryBinArea(0x0028,0x1221);
+ // Segmented Green Palette Color LUT Data
+ LoadEntryBinArea(0x0028,0x1222);
+ // Segmented Blue Palette Color LUT Data
+ LoadEntryBinArea(0x0028,0x1223);
+ }
+
+ //FIXME later : how to use it?
+ SeqEntry *modLutSeq = GetSeqEntry(0x0028,0x3000);
+ if ( modLutSeq !=0 )
+ {
+ SQItem *sqi= modLutSeq->GetFirstSQItem();
+ if ( sqi != 0 )
+ {
+ BinEntry *b = sqi->GetBinEntry(0x0028,0x3006);
+ if ( b != 0 )
+ {
+ if ( b->GetLength() != 0 )
+ {
+ LoadEntryBinArea(b); //LUT Data (CTX dependent)
+ }
+ }
+ }
+ }
+
+ CloseFile();
+
+ // ----------------------------
+ // Specific code to allow gdcm to read ACR-LibIDO formated images
+ // Note: ACR-LibIDO is an extension of the ACR standard that was
+ // used at CREATIS. For the time being (say a couple of years)
+ // we keep this kludge to allow CREATIS users
+ // reading their old images.
+ //
+ // if recognition code tells us we deal with a LibIDO image
+ // we switch lineNumber and columnNumber
+ //
+ std::string RecCode;
+ RecCode = GetEntryValue(0x0008, 0x0010); // recognition code (RET)
+ if (RecCode == "ACRNEMA_LIBIDO_1.1" ||
+ RecCode == "CANRME_AILIBOD1_1." ) // for brain-damaged softwares
+ // with "little-endian strings"
+ {
+ Filetype = ACR_LIBIDO;
+ std::string rows = GetEntryValue(0x0028, 0x0010);
+ std::string columns = GetEntryValue(0x0028, 0x0011);
+ SetValEntry(columns, 0x0028, 0x0010);
+ SetValEntry(rows , 0x0028, 0x0011);
+ }
+ // --- End of ACR-LibIDO kludge ---
+
+ return true;