X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmFile.cxx;h=c7b50b50f9298dd0cb933cb7b32c7e08b7b96302;hb=029ba8b100584e6ee9d963589e3a1d36205f25c4;hp=2c6928956289de5d23e0a8efa80a097382e54734;hpb=6b4aa7387613d98b62ee41d18aba2dbe0306b4ba;p=gdcm.git diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 2c692895..c7b50b50 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/11/25 13:56:31 $ - Version: $Revision: 1.309 $ + Date: $Date: 2006/02/07 12:37:19 $ + Version: $Revision: 1.314 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -768,17 +768,19 @@ float File::GetZOrigin() /** * \brief gets the info from 0020,0037 : Image Orientation Patient * or from 0020 0035 : Image Orientation (RET) + * * (needed to organize DICOM files based on their x,y,z position) - * @param iop adress of the (6)float array to receive values - * @return true when one of the tag is found - * false when nothing is found + * + * @param iop adress of the (6)float array to receive values. + * (defaulted as 1.,0.,0.,0.,1.,0. if nothing -or inconsistent stuff- + * is found. + * @return true when one of the tag -with consistent values- is found + * false when nothing or inconsistent stuff - is found */ -bool File::GetImageOrientationPatient( double iop[6] ) +bool File::GetImageOrientationPatient( float iop[6] ) { std::string strImOriPat; - //iop is supposed to be double[6] - iop[0] = iop[4] = 1.; - iop[1] = iop[2] = iop[3] = iop[5] = 0.; + //iop is supposed to be float[6] // 0020 0037 DS REL Image Orientation (Patient) if ( (strImOriPat = GetEntryString(0x0020,0x0037)) != GDCM_UNFOUND ) @@ -786,10 +788,14 @@ bool File::GetImageOrientationPatient( double iop[6] ) if ( sscanf( strImOriPat.c_str(), "%f \\ %f \\%f \\%f \\%f \\%f ", &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 ) { + iop[0] = iop[4] = 1.; + iop[1] = iop[2] = iop[3] = iop[5] = 0.; gdcmWarningMacro( "Wrong Image Orientation Patient (0020,0037)." << " Less than 6 values were found." ); return false; } + else + return true; } //For ACR-NEMA // 0020 0035 DS REL Image Orientation (RET) @@ -798,12 +804,16 @@ bool File::GetImageOrientationPatient( double iop[6] ) if ( sscanf( strImOriPat.c_str(), "%f \\ %f \\%f \\%f \\%f \\%f ", &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 ) { + iop[0] = iop[4] = 1.; + iop[1] = iop[2] = iop[3] = iop[5] = 0.; gdcmWarningMacro( "wrong Image Orientation Patient (0020,0035). " << "Less than 6 values were found." ); return false; } + else + return true; } - return true; + return false; } /** @@ -1153,7 +1163,7 @@ int File::GetLUTNbits() /** *\brief gets the info from 0028,1052 : Rescale Intercept - * @return Rescale Intercept + * @return Rescale Intercept. defaulted to 0.0 is not found or empty */ float File::GetRescaleIntercept() { @@ -1170,7 +1180,7 @@ float File::GetRescaleIntercept() /** *\brief gets the info from 0028,1053 : Rescale Slope - * @return Rescale Slope + * @return Rescale Slope. defaulted to 0.0 is not found or empty */ float File::GetRescaleSlope() { @@ -1496,7 +1506,7 @@ bool File::Write(std::string fileName, FileType writetype) e0000->SetString(sLen.str()); } - // FIXME : Derma?.dcm does not have it...let's remove it ?!? JPRx + /// \todo FIXME : Derma?.dcm does not have it...let's remove it ?!? JPRx if( writetype != JPEG ) { int i_lgPix = GetEntryLength(GrPixel, NumPixel); @@ -1516,6 +1526,7 @@ bool File::Write(std::string fileName, FileType writetype) return true; } + //----------------------------------------------------------------------------- // Protected @@ -1580,7 +1591,7 @@ void File::ComputeRLEInfo() // Offset Table information on fragments of this current Frame. // Note that the fragment pixels themselves are not loaded // (but just skipped). - long frameOffset = Fp->tellg(); + long frameOffset = Fp->tellg(); // once per fragment uint32_t nbRleSegments = ReadInt32(); if ( nbRleSegments > 16 ) @@ -1627,7 +1638,7 @@ void File::ComputeRLEInfo() // Make sure that we encounter a 'Sequence Delimiter Item' // at the end of the item : - if ( !ReadTag(0xfffe, 0xe0dd) ) + if ( !ReadTag(0xfffe, 0xe0dd) ) // once per RLE File { gdcmWarningMacro( "No sequence delimiter item at end of RLE item sequence"); } @@ -1655,7 +1666,7 @@ void File::ComputeJPEGFragmentInfo() long fragmentLength; int i=0; uint32_t sum = 0; - while ( (fragmentLength = ReadTagLength(0xfffe, 0xe000)) != 0 ) + while ( (fragmentLength = ReadTagLength(0xfffe, 0xe000)) != 0 ) { // Since we have read the basic offset table, let's check the value were correct // or else produce a warning: @@ -1680,7 +1691,7 @@ void File::ComputeJPEGFragmentInfo() i++; } - long fragmentOffset = Fp->tellg(); + long fragmentOffset = Fp->tellg(); // Once per fragment // Store the collected info JPEGFragment *newFragment = new JPEGFragment; newFragment->SetOffset(fragmentOffset); @@ -1713,8 +1724,8 @@ void File::ComputeJPEGFragmentInfo() */ bool File::ReadTag(uint16_t testGroup, uint16_t testElem) { - long positionOnEntry = Fp->tellg(); - long currentPosition = Fp->tellg(); // On debugging purposes + long positionOnEntry = Fp->tellg(); // Only when reading fragments + //long currentPosition = positionOnEntry; // On debugging purposes // Read the Item Tag group and element, and make // sure they are what we expected: @@ -1744,7 +1755,7 @@ bool File::ReadTag(uint16_t testGroup, uint16_t testElem) << " but instead we encountered tag (" << DictEntry::TranslateToKey(itemTagGroup,itemTagElem) << ")" << " at address: " << " 0x(" << std::hex - << (unsigned int)currentPosition << std::dec << ")" + << (unsigned int)positionOnEntry << std::dec << ")" ) ; Fp->seekg(positionOnEntry, std::ios::beg); @@ -1781,10 +1792,12 @@ uint32_t File::ReadTagLength(uint16_t testGroup, uint16_t testElem) } //// Then read the associated Item Length - long currentPosition = Fp->tellg(); + + // long currentPosition = Fp->tellg(); // save time // JPRx uint32_t itemLength = ReadInt32(); gdcmDebugMacro( "Basic Item Length is: " << itemLength - << " at address: " << std::hex << (unsigned int)currentPosition); +// << " at address: " << std::hex << (unsigned int)currentPosition + ); return itemLength; }