Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2004/07/30 16:09:27 $
- Version: $Revision: 1.60 $
+ Date: $Date: 2004/07/31 23:30:04 $
+ Version: $Revision: 1.61 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
long beg = ftell(Fp);
lgt -= beg;
- SQDepthLevel=0;
+ SQDepthLevel = 0;
long l = ParseDES( this, beg, lgt, false); // le Load sera fait a la volee
(void)l; //is l used anywhere ?
bool gdcmDocument::CloseFile()
{
int closed = fclose(Fp);
- Fp = (FILE *)0;
+ Fp = 0;
return closed;
}
*/
gdcmValEntry * gdcmDocument::ReplaceOrCreateByNumber(
- std::string value,
+ std::string const & value,
uint16_t group,
uint16_t elem )
{
* @param Elem element number of the Entry
* \return boolean
*/
-bool gdcmDocument::ReplaceIfExistByNumber(const char* value, uint16_t group,
- uint16_t elem )
+bool gdcmDocument::ReplaceIfExistByNumber(std::string const & value,
+ uint16_t group, uint16_t elem )
{
- const std::string v = value;
- SetEntryByNumber(v, group, elem);
+ SetEntryByNumber(value, group, elem);
return true;
}
*/
int gdcmDocument::CheckIfEntryExistByNumber(uint16_t group, uint16_t element )
{
- std::string key = gdcmDictEntry::TranslateToKey(group, element );
+ const std::string &key = gdcmDictEntry::TranslateToKey(group, element );
return TagHT.count(key);
}
* @return Corresponding element value when it exists,
* and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
*/
-std::string gdcmDocument::GetEntryByName(TagName tagName)
+std::string gdcmDocument::GetEntryByName(TagName const & tagName)
{
gdcmDictEntry *dictEntry = RefPubDict->GetDictEntryByName(tagName);
if( !dictEntry )
* @return Corresponding element value representation when it exists,
* and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
*/
-std::string gdcmDocument::GetEntryVRByName(TagName tagName)
+std::string gdcmDocument::GetEntryVRByName(TagName const & tagName)
{
gdcmDictEntry *dictEntry = RefPubDict->GetDictEntryByName(tagName);
if( dictEntry == NULL)
return GDCM_UNFOUND;
}
- gdcmDocEntry* elem = GetDocEntryByNumber(dictEntry->GetGroup(),
- dictEntry->GetElement());
+ gdcmDocEntry* elem = GetDocEntryByNumber(dictEntry->GetGroup(),
+ dictEntry->GetElement());
return elem->GetVR();
}
default :
std::cout << "swapCode= " << SwapCode << std::endl;
dbg.Error(" gdcmDocument::SwapLong : unset swap code");
- a=0;
+ a = 0;
}
return a;
}
Program: gdcm
Module: $RCSfile: gdcmDocument.h,v $
Language: C++
- Date: $Date: 2004/07/31 18:43:43 $
- Version: $Revision: 1.26 $
+ Date: $Date: 2004/07/31 23:30:04 $
+ Version: $Revision: 1.27 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
void Write(FILE* fp, FileType type);
- gdcmValEntry* ReplaceOrCreateByNumber(std::string value,
+ gdcmValEntry* ReplaceOrCreateByNumber(std::string const & value,
uint16_t group, uint16_t elem);
gdcmBinEntry* ReplaceOrCreateByNumber(void *voidArea, int lgth,
uint16_t group, uint16_t elem);
- bool ReplaceIfExistByNumber (const char* value, uint16_t group, uint16_t elem);
+ bool ReplaceIfExistByNumber (std::string const & value, uint16_t group, uint16_t elem);
virtual void* LoadEntryVoidArea(uint16_t group, uint16_t elem);
virtual void* LoadEntryVoidArea(gdcmBinEntry* entry);
// Entry
int CheckIfEntryExistByNumber(uint16_t group, uint16_t elem ); // int !
public:
- virtual std::string GetEntryByName (TagName tagName);
- virtual std::string GetEntryVRByName (TagName tagName);
+ virtual std::string GetEntryByName (TagName const & tagName);
+ virtual std::string GetEntryVRByName (TagName const & tagName);
virtual std::string GetEntryByNumber (uint16_t group, uint16_t elem);
virtual std::string GetEntryVRByNumber(uint16_t group, uint16_t elem);
virtual int GetEntryLengthByNumber(uint16_t group, uint16_t elem);
Program: gdcm
Module: $RCSfile: gdcmFile.cxx,v $
Language: C++
- Date: $Date: 2004/07/30 16:09:27 $
- Version: $Revision: 1.118 $
+ Date: $Date: 2004/07/31 23:30:04 $
+ Version: $Revision: 1.119 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
std::string str_PhotometricInterpretation =
Header->GetEntryByNumber(0x0028,0x0004);
- /*if ( str_PhotometricInterpretation == "PALETTE COLOR " )*/
+ // if ( str_PhotometricInterpretation == "PALETTE COLOR " )
// pb when undealt Segmented Palette Color
if ( Header->HasLUT() )
case 4321:
for(i=0; i < lgr/2; i++)
{
- im16[i]= (im16[i] >> 8) | (im16[i] << 8 );
+ im16[i]= (im16[i] >> 8) | (im16[i] << 8 );
}
break;
default:
if ( jpg2000 )
{
// JPEG 2000 : call to ???
- res = (bool)gdcm_read_JPEG2000_file (fp,destination); // Not Yet written
+ res = gdcm_read_JPEG2000_file (fp,destination); // Not Yet written
// ------------------------------------- endif (JPEG2000)
}
else if (jpgLossless)
if ( Header->GetBitsStored() == 8)
{
// Reading Fragment pixels
- res = (bool)gdcm_read_JPEG_file (fp,destination);
+ res = gdcm_read_JPEG_file (fp,destination);
}
else
{
// Reading Fragment pixels
- res = (bool)gdcm_read_JPEG_file12 (fp,destination);
+ res = gdcm_read_JPEG_file12 (fp,destination);
}
// ------------------------------------- endif (JPEGLossy)
}
Program: gdcm
Module: $RCSfile: gdcmFile.h,v $
Language: C++
- Date: $Date: 2004/07/30 16:09:27 $
- Version: $Revision: 1.40 $
+ Date: $Date: 2004/07/31 23:30:04 $
+ Version: $Revision: 1.41 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
public:
gdcmFile(gdcmHeader *header);
gdcmFile(std::string const & filename,
- bool exception_on_error = false);
+ bool exception_on_error = false);
virtual ~gdcmFile();
void * GetImageDataRaw();
size_t GetImageDataIntoVectorRaw(void* destination, size_t maxSize);
- // Allocates ExpectedSize bytes of memory at this->Data and copies the
- // pointed data to it. Copying the image might look useless but
- // the caller might destroy it's image (without knowing it: think
- // of a complicated interface where display is done with a library
- // e.g. VTK) before calling the Write
+ // Allocates ExpectedSize bytes of memory at this->Data and copies the
+ // pointed data to it. Copying the image might look useless but
+ // the caller might destroy it's image (without knowing it: think
+ // of a complicated interface where display is done with a library
+ // e.g. VTK) before calling the Write
- // voir gdcmHeader::SetImageDataSize ?!?
+ // see also gdcmHeader::SetImageDataSize ?!?
bool SetImageData (void * data, size_t expectedSize);
/// \todo When the caller is aware we simply point to the data:
bool gdcm_read_JPEG_file (FILE *fp, void * image_buffer);
static int gdcm_read_RLE_fragment(char **areaToRead, long lengthToDecode,
long uncompressedSegmentSize, FILE *fp);
+
// For JPEG 12 Bits, body in file gdcmJpeg12.cxx
bool gdcm_read_JPEG_file12 (FILE *fp, void* image_buffer);
+
// For JPEG 2000, body in file gdcmJpeg2000.cxx
bool gdcm_read_JPEG2000_file (FILE *fp, void* image_buffer);
// For Run Length Encoding (TOCHECK)
bool gdcm_read_RLE_file (FILE *fp, void* image_buffer);
-// Variables
+// members variables:
/// \brief Header to use to load the file
gdcmHeader *Header;
Program: gdcm
Module: $RCSfile: gdcmHeader.cxx,v $
Language: C++
- Date: $Date: 2004/07/30 16:09:27 $
- Version: $Revision: 1.180 $
+ Date: $Date: 2004/07/31 23:30:04 $
+ Version: $Revision: 1.181 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* @param filetype Type of the File to be written
* (ACR-NEMA, ExplicitVR, ImplicitVR)
*/
-void gdcmHeader::Write(FILE* fp,FileType filetype) {
-
+void gdcmHeader::Write(FILE* fp,FileType filetype)
+{
// Bits Allocated
- if ( GetEntryByNumber(0x0028,0x0100) == "12") {
+ if ( GetEntryByNumber(0x0028,0x0100) == "12")
+ {
SetEntryByNumber("16", 0x0028,0x0100);
}
// (only gdcmHeader knows GrPixel, NumPixel)
int i_lgPix = GetEntryLengthByNumber(GrPixel, NumPixel);
- if (i_lgPix != -2) { // no (GrPixel, NumPixel) element
- char * dumm = new char[20];
+ if (i_lgPix != -2)
+ {
+ // no (GrPixel, NumPixel) element
+ char* dumm = new char[20];
sprintf(dumm ,"%d", i_lgPix+12);
std::string s_lgPix = dumm;
- delete dumm;
+ delete[] dumm;
ReplaceOrCreateByNumber(s_lgPix,GrPixel, 0x0000);
}
// Drop Palette Color, if necessary
- if ( GetEntryByNumber(0x0028,0x0002).c_str()[0] == '3' ) {
- // if SamplesPerPixel = 3, sure we don't need any LUT !
- // Drop 0028|1101, 0028|1102, 0028|1103
- // Drop 0028|1201, 0028|1202, 0028|1203
-
- gdcmDocEntry *e;
- e=GetDocEntryByNumber(0x0028,0x01101);
- if (e)
- RemoveEntry(e);
- e=GetDocEntryByNumber(0x0028,0x1102);
- if (e)
- RemoveEntry(e);
- e=GetDocEntryByNumber(0x0028,0x1103);
-
- if (e)
- RemoveEntry(e);
- e=GetDocEntryByNumber(0x0028,0x01201);
- if (e)
- RemoveEntry(e);
- e=GetDocEntryByNumber(0x0028,0x1202);
- if (e)
- RemoveEntry(e);
- e=GetDocEntryByNumber(0x0028,0x1203);
- if (e)
- RemoveEntry(e);
- }
+ if ( GetEntryByNumber(0x0028,0x0002).c_str()[0] == '3' )
+ {
+ // if SamplesPerPixel = 3, sure we don't need any LUT !
+ // Drop 0028|1101, 0028|1102, 0028|1103
+ // Drop 0028|1201, 0028|1202, 0028|1203
+ gdcmDocEntry* e = GetDocEntryByNumber(0x0028,0x01101);
+ if (e)
+ {
+ RemoveEntry(e);
+ }
+ e = GetDocEntryByNumber(0x0028,0x1102);
+ if (e)
+ {
+ RemoveEntry(e);
+ }
+ e = GetDocEntryByNumber(0x0028,0x1103);
+ if (e)
+ {
+ RemoveEntry(e);
+ }
+ e = GetDocEntryByNumber(0x0028,0x01201);
+ if (e)
+ {
+ RemoveEntry(e);
+ }
+ e = GetDocEntryByNumber(0x0028,0x1202);
+ if (e)
+ {
+ RemoveEntry(e);
+ }
+ e = GetDocEntryByNumber(0x0028,0x1203);
+ if (e)
+ {
+ RemoveEntry(e);
+ }
+ }
gdcmDocument::Write(fp,filetype);
}
}
}
- return resInter;
+ return resInter;
}
/**
if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos) != 3 )
{
- return 0.;
+ return 0.;
}
return xImPos;
*/
void gdcmHeader::SetImageDataSize(size_t ImageDataSize)
{
- std::string content1;
char car[20];
-
sprintf(car,"%d",ImageDataSize);
gdcmDocEntry *a = GetDocEntryByNumber(GrPixel, NumPixel);
a->SetLength(ImageDataSize);
- ImageDataSize+=8;
+ ImageDataSize += 8;
sprintf(car,"%d",ImageDataSize);
- content1=car;
+
+ const std::string content1 = car;
SetEntryByNumber(content1, GrPixel, NumPixel);
}
* @param iop adress of the (6)float aray to receive values
* @return cosines of image orientation patient
*/
-void gdcmHeader::GetImageOrientationPatient( float* iop )
+void gdcmHeader::GetImageOrientationPatient( float iop[6] )
{
+ std::string strImOriPat;
//iop is supposed to be float[6]
- iop[0] = iop[1] = iop[2] = iop[3] = iop[4] = iop[5] = 0;
+ iop[0] = iop[1] = iop[2] = iop[3] = iop[4] = iop[5] = 0.;
// 0020 0037 DS REL Image Orientation (Patient)
- std::string strImOriPat = GetEntryByNumber(0x0020,0x0037);
- if ( strImOriPat != GDCM_UNFOUND )
+ if ( (strImOriPat = GetEntryByNumber(0x0020,0x0037)) != GDCM_UNFOUND )
{
if( sscanf( strImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f",
&iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 )
{
dbg.Verbose(0, "gdcmHeader::GetImageOrientationPatient: wrong Image Orientation Patient (0020,0037)");
- return ; // bug in the element 0x0020,0x0037
- }
- else
- {
- return ;
+ // bug in the element 0x0020,0x0037
}
}
-
//For ACR-NEMA
// 0020 0035 DS REL Image Orientation (RET)
- strImOriPat = GetEntryByNumber(0x0020,0x0035);
- if ( strImOriPat != GDCM_UNFOUND )
+ else if ( (strImOriPat = GetEntryByNumber(0x0020,0x0035)) != GDCM_UNFOUND )
{
if( sscanf( strImOriPat.c_str(), "%f\\%f\\%f\\%f\\%f\\%f",
&iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 )
{
dbg.Verbose(0, "gdcmHeader::GetImageOrientationPatient: wrong Image Orientation Patient (0020,0035)");
- return ; // bug in the element 0x0020,0x0035
+ // bug in the element 0x0020,0x0035
}
}
- else
- {
- return;
- }
}
//-----------------------------------------------------------------------------
Program: gdcm
Module: $RCSfile: gdcmHeader.h,v $
Language: C++
- Date: $Date: 2004/07/31 18:43:43 $
- Version: $Revision: 1.84 $
+ Date: $Date: 2004/07/31 23:30:04 $
+ Version: $Revision: 1.85 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/// Read (used in gdcmFile)
void SetImageDataSize(size_t expectedSize);
- void Write(FILE* fp,FileType filetype);
+ void Write(FILE* fp, FileType filetype);
protected:
bool AnonymizeHeader();
- void GetImageOrientationPatient( float* iop );
+ void GetImageOrientationPatient( float iop[6] );
private:
friend class gdcmSerieHeader;