GDCM_DEBUG, so you can turn verbosity ON/OFF for debug statement.
OPTION(BUILD_SHARED_LIBS "Build GDCM with shared libraries." ON)\r
SET(GDCM_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})\r
\r
+OPTION(GDCM_DEBUG "Turn verbosity of some statement ON." OFF)\r
\r
#-----------------------------------------------------------------------------\r
SET (EXECUTABLE_OUTPUT_PATH ${GDCM_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")\r
* Add a new test: ShowDicom, for now this is just the c++ version of
checkRead.sh, later it will be able to compare the image read against a
baseline.
+ * Replace the DEBUG on the stack with a global entry in cmake interface:
+ GDCM_DEBUG, so you can turn verbosity ON/OFF for debug statement.
2004-04-30 Mathieu Malaterre <Mathieu.Malaterre@creatis.insa-lyon.fr>
* Add an example subdir, with a real example on how to read + write a
#cmakedefine HAVE_NO_STDINT_H
-
+#cmakedefine GDCM_DEBUG
#ifndef GDCMDEBUG_H
#define GDCMDEBUG_H
-#define GDCM_DEBUG -1
-
/**
* \ingroup gdcmDebug
* \brief gdcmDebug is an object for debugging in program.
*/
class gdcmDebug {
public:
- gdcmDebug(int level = GDCM_DEBUG);
+ gdcmDebug(int level = -1);
void SetDebug (int level);
void Verbose(int, const char*, const char* ="");
// gdcmHeader.cxx
//-----------------------------------------------------------------------------
-#include <stdio.h>
-#include <cerrno>
-#include <cctype> // for isalpha
-#include <vector>
-
#include "gdcmHeader.h"
#include "gdcmGlobal.h"
#include "gdcmUtil.h"
#include "gdcmDebug.h"
#include "gdcmTS.h"
+#include <vector>
+
//-----------------------------------------------------------------------------
// Constructor / Destructor
/**
// This IS the right place for the code
- std::string ImageLocation = GetEntryByNumber(0x0028, 0x0200);
- if ( ImageLocation == GDCM_UNFOUND ) { // Image Location
- GrPixel = 0x7fe0; // default value
- } else {
- GrPixel = (guint16) atoi( ImageLocation.c_str() );
- }
- if (GrPixel == 0xe07f) // sometimes Image Location value doesn't follow
- GrPixel = 0x7fe0; // the supposed processor endianity.
- // see gdcmData/cr172241.dcm
- if (GrPixel != 0x7fe0)
- // This is a kludge for old dirty Philips imager.
- NumPixel = 0x1010;
- else
- NumPixel = 0x0010;
+ std::string ImageLocation = GetEntryByNumber(0x0028, 0x0200);
+ if ( ImageLocation == GDCM_UNFOUND ) { // Image Location
+ GrPixel = 0x7fe0; // default value
+ } else {
+ GrPixel = (guint16) atoi( ImageLocation.c_str() );
+ }
+ if (GrPixel == 0xe07f) // sometimes Image Location value doesn't follow
+ GrPixel = 0x7fe0; // the supposed processor endianity.
+ // see gdcmData/cr172241.dcm
+ if (GrPixel != 0x7fe0)
+ // This is a kludge for old dirty Philips imager.
+ NumPixel = 0x1010;
+ else
+ NumPixel = 0x0010;
- TagKey key = gdcmDictEntry::TranslateToKey(GrPixel, NumPixel);
- countGrPixel = GetEntry().count(key);
+ TagKey key = gdcmDictEntry::TranslateToKey(GrPixel, NumPixel);
+ countGrPixel = GetEntry().count(key);
- // we set the SQ Depth of each Header Entry
+ // we set the SQ Depth of each Header Entry
int top =-1;
int countSQ = 0;
std::ostringstream tab;
tab << " ";
- int DEBUG = 0; // Sorry; Dealing with e-film breaker images
- // will (certainly) cause a lot of troubles ...
- // I prefer keeping my 'trace' on .
+ // GDCM_DEBUG
+ // Sorry; Dealing with e-film breaker images
+ // will (certainly) cause a lot of troubles ...
+ // I prefer keeping my 'trace' on .
for (ListTag::iterator i = listEntries.begin();
- i != listEntries.end();
- ++i) {
- (*i)->SetSQDepthLevel(countSQ);
- if ( (*i)->GetVR() == "SQ" && (*i)->GetReadLength() != 0) { // SQ found
- countSQ++;
- top ++;
- if ( top >= 20) {
+ i != listEntries.end();
+ ++i) {
+ (*i)->SetSQDepthLevel(countSQ);
+ if ( (*i)->GetVR() == "SQ" && (*i)->GetReadLength() != 0) { // SQ found
+ countSQ++;
+ top ++;
+ if ( top >= 20) {
+#ifdef GDCM_DEBUG
std::cout << "Kaie ! Kaie! SQ Stack Overflow" << std::endl;
- return;
+#endif //GDCM_DEBUG
+ return;
}
- if (DEBUG) std::cout << "\n >>>>> empile niveau " << top
- << "; Lgr SeQ: " << (*i)->GetReadLength()
- << "\n" <<std::endl;
-
- pile[top].totalSQlength = (*i)->GetReadLength();
- pile[top].alreadyParsedlength = 0;
- currentParsedlength = 0;
-
- } else { // non SQ found
-
- if (countSQ != 0) { // we are 'inside a SeQuence'
- if ( (*i)->GetGroup()==0xfffe && (*i)->GetElement()==0xe0dd){
- // we just found 'end of SeQuence'
-
- if (DEBUG)
- std::cout << "fffe,e0dd : depile" << std::endl;
+#ifdef GDCM_DEBUG
+ std::cout << "\n >>>>> empile niveau " << top
+ << "; Lgr SeQ: " << (*i)->GetReadLength()
+ << "\n" <<std::endl;
+#endif //GDCM_DEBUG
+
+ pile[top].totalSQlength = (*i)->GetReadLength();
+ pile[top].alreadyParsedlength = 0;
+ currentParsedlength = 0;
+
+ } else { // non SQ found
+ if (countSQ != 0) { // we are 'inside a SeQuence'
+ if ( (*i)->GetGroup()==0xfffe && (*i)->GetElement()==0xe0dd) {
+ // we just found 'end of SeQuence'
+
+#ifdef GDCM_DEBUG
+ std::cout << "fffe,e0dd : depile" << std::endl;
+#endif //GDCM_DEBUG
+
currentParsedlength += 8; // gr:2 elem:2 vr:2 lgt:2
- countSQ --;
+ countSQ --;
top --;
pile[top].alreadyParsedlength += currentParsedlength;
} else {
- // we are on a 'standard' elem
- // or a Zero-length SeQuence
-
- totalElementlength = (*i)->GetFullLength();
- currentParsedlength += totalElementlength;
+ // we are on a 'standard' elem
+ // or a Zero-length SeQuence
+
+ totalElementlength = (*i)->GetFullLength();
+ currentParsedlength += totalElementlength;
pile[top].alreadyParsedlength += totalElementlength;
-
+
if (pile[top].totalSQlength == 0xffffffff) {
- if (DEBUG)
- std::cout << "totalSeQlength == 0xffffffff"
- << std::endl;
+#ifdef GDCM_DEBUG
+ std::cout << "totalSeQlength == 0xffffffff" << std::endl;
+#endif //GDCM_DEBUG
} else {
- if (DEBUG)
- std::cout << "alrdyPseLgt:"
- << pile[top].alreadyParsedlength << " totSeQlgt: "
- << pile[top].totalSQlength << " curPseLgt: "
- << currentParsedlength
- << std::endl;
+#ifdef GDCM_DEBUG
+ std::cout << "alrdyPseLgt:"
+ << pile[top].alreadyParsedlength << " totSeQlgt: "
+ << pile[top].totalSQlength << " curPseLgt: "
+ << currentParsedlength
+ << std::endl;
+#endif //GDCM_DEBUG
while (pile[top].alreadyParsedlength==pile[top].totalSQlength) {
-
- if (DEBUG)
- std::cout << " \n<<<<<< On depile niveau " << top
- << " \n" << std::endl;
- (*i)->SetSQDepthLevel(countSQ);
- currentParsedlength = pile[top].alreadyParsedlength;
- countSQ --;
- top --;
- if (top >=0) {
-
- pile[top].alreadyParsedlength += currentParsedlength +12;
- // 12 : length of 'SQ embedded' SQ element
- currentParsedlength += 8; // gr:2 elem:2 vr:2 lgt:2
-
- if (DEBUG)
- std::cout << pile[top].alreadyParsedlength << " "
- << pile[top].totalSQlength << " "
- << currentParsedlength
- << std::endl;
- }
- if (top == -1) {
- currentParsedlength = 0;
- break;
- }
+#ifdef GDCM_DEBUG
+ std::cout << " \n<<<<<< On depile niveau " << top
+ << " \n" << std::endl;
+#endif //GDCM_DEBUG
+ (*i)->SetSQDepthLevel(countSQ);
+ currentParsedlength = pile[top].alreadyParsedlength;
+ countSQ --;
+ top --;
+ if (top >=0) {
+ pile[top].alreadyParsedlength += currentParsedlength +12;
+ // 12 : length of 'SQ embedded' SQ element
+ currentParsedlength += 8; // gr:2 elem:2 vr:2 lgt:2
+
+#ifdef GDCM_DEBUG
+ std::cout << pile[top].alreadyParsedlength << " "
+ << pile[top].totalSQlength << " "
+ << currentParsedlength
+ << std::endl;
+#endif //GDCM_DEBUG
}
- }
- }
- } // end : 'inside a SeQuence'
- }
- if (DEBUG) {
- for (int k=0; k<(*i)->GetSQDepthLevel();k++) {
- std::cout << tab;
- }
- (*i)->SetPrintLevel(2);
- (*i)->Print();
- }
+ if (top == -1) {
+ currentParsedlength = 0;
+ break;
+ }
+ }
+ }
+ }
+ } // end : 'inside a SeQuence'
+ }
+#ifdef GDCM_DEBUG
+ for (int k=0; k<(*i)->GetSQDepthLevel();k++) {
+ std::cout << tab;
+ }
+ (*i)->SetPrintLevel(2);
+ (*i)->Print();
+#endif //GDCM_DEBUG
} // end for
}
if (PixelElement) {
return PixelElement->GetOffset();
} else {
-/* std::cout << "Big trouble : Pixel Element ("
+#ifdef GDCM_DEBUG
+ std::cout << "Big trouble : Pixel Element ("
<< std::hex << GrPixel<<","<< NumPixel<< ") NOT found"
- << std::endl; */
+ << std::endl;
+#endif //GDCM_DEBUG
return 0;
}
}
if (PixelElement) {
return PixelElement->GetLength();
} else {
-/* std::cout << "Big trouble : Pixel Element ("
+#ifdef GDCM_DEBUG
+ std::cout << "Big trouble : Pixel Element ("
<< std::hex << GrPixel<<","<< NumPixel<< ") NOT found"
<< std::endl;
-*/
+#endif //GDCM_DEBUG
return 0;
}
}
#define BITS_IN_JSAMPLE 8
-#define DEBUG 0
-
/*
DICOM provides a mechanism for supporting the use of JPEG Image Compression
through the Encapsulated Format (see PS 3.3 of the DICOM Standard).
int row_stride; /* physical row width in output buffer */
- if (DEBUG) printf("entree dans gdcmFile::gdcm_read_JPEG_file12, depuis gdcmJpeg\n");
+#ifdef GDCM_DEBUG
+ printf("entree dans gdcmFile::gdcm_read_JPEG_file12, depuis gdcmJpeg\n");
+#endif //GDCM_DEBUG
/* In this example we want to open the input file before doing anything else,
* so that the setjmp() error recovery below can assume the file is open.
*/
/* Step 1: allocate and initialize JPEG decompression object */
- if (DEBUG)printf("Entree Step 1\n");
+#ifdef GDCM_DEBUG
+ printf("Entree Step 1\n");
+#endif //GDCM_DEBUG
/* We set up the normal JPEG error routines, then override error_exit. */
jpeg_create_decompress(&cinfo);
/* Step 2: specify data source (eg, a file) */
- if (DEBUG) printf("Entree Step 2\n");
+#ifdef GDCM_DEBUG
+ printf("Entree Step 2\n");
+#endif //GDCM_DEBUG
jpeg_stdio_src(&cinfo, fp);
/* Step 3: read file parameters with jpeg_read_header() */
- if (DEBUG) printf("Entree Step 3\n");
+#ifdef GDCM_DEBUG
+ printf("Entree Step 3\n");
+#endif //GDCM_DEBUG
(void) jpeg_read_header(&cinfo, TRUE);
* See libjpeg.doc for more info.
*/
- if (DEBUG) {
+#ifdef GDCM_DEBUG
printf("--------------Header contents :----------------\n");
printf("image_width %d image_height %d\n",
cinfo.image_width , cinfo.image_height);
cinfo.output_components);
printf("nb of color components returned %d \n",
cinfo.data_precision);
- }
+#endif //GDCM_DEBUG
/*
*/
/* Step 4: set parameters for decompression */
- if (DEBUG) printf("Entree Step 4\n");
+#ifdef GDCM_DEBUG
+ printf("Entree Step 4\n");
+#endif //GDCM_DEBUG
/* In this example, we don't need to change any of the defaults set by
* jpeg_read_header(), so we do nothing here.
*/
/* Step 5: Start decompressor */
- if (DEBUG) printf("Entree Step 5\n");
+#ifdef GDCM_DEBUG
+ printf("Entree Step 5\n");
+#endif GDCM_DEBUG
(void) jpeg_start_decompress(&cinfo);
/* We can ignore the return value since suspension is not possible
/* JSAMPLEs per row in output buffer */
row_stride = cinfo.output_width * cinfo.output_components;
- if (DEBUG) printf ("cinfo.output_width %d cinfo.output_components %d row_stride %d\n",
+#ifdef GDCM_DEBUG
+ printf ("cinfo.output_width %d cinfo.output_components %d row_stride %d\n",
cinfo.output_width, cinfo.output_components,row_stride);
-
+#endif //GDCM_DEBUG
+
/* Make a one-row-high sample array that will go away when done with image */
buffer = (*cinfo.mem->alloc_sarray)
((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
/* Step 6: while (scan lines remain to be read) */
- if (DEBUG) printf("Entree Step 6\n");
-
+#ifdef GDCM_DEBUG
+ printf("Entree Step 6\n");
+#endif //GDCM_DEBUG
/* jpeg_read_scanlines(...); */
/* Here we use the library's state variable cinfo.output_scanline as the
* loop counter, so that we don't have to keep track ourselves.
*/
- if (DEBUG)
+#ifdef GDCM_DEBUG
printf ("cinfo.output_height %d cinfo.output_width %d\n",
cinfo.output_height,cinfo.output_width);
-
+#endif //GDCM_DEBUG
pimage=(char *)image_buffer;
while (cinfo.output_scanline < cinfo.output_height) {
}
/* Step 7: Finish decompression */
- if (DEBUG) printf("Entree Step 7\n");
+#ifdef GDCM_DEBUG
+ printf("Entree Step 7\n");
+#endif //GDCM_DEBUG
+
(void) jpeg_finish_decompress(&cinfo);
/* We can ignore the return value since suspension is not possible
/* Step 8: Release JPEG decompression object */
- if (DEBUG) printf("Entree Step 8\n");
+#ifdef GDCM_DEBUG
+ printf("Entree Step 8\n");
+#endif //GDCM_DEBUG
/* This is an important step since it will release a good deal of memory. */
#define BITS_IN_JSAMPLE 12
-#define DEBUG 0
-
// BITS_IN_JSAMPLE is a compile time defined options.
// We need both 8 an 12;
// To avoid renaming *all* the Jpeg functions,
// typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */
int row_stride; /* physical row width in output buffer */
-
- if (DEBUG) printf("entree dans gdcmFile::gdcm_read_JPEG_file12, depuis gdcmJpeg\n");
+#ifdef GDCM_DEBUG
+ printf("entree dans gdcmFile::gdcm_read_JPEG_file12, depuis gdcmJpeg\n");
+#endif //GDCM_DEBUG
/* In this example we want to open the input file before doing anything else,
* so that the setjmp() error recovery below can assume the file is open.
*/
/* Step 1: allocate and initialize JPEG decompression object */
- if (DEBUG)printf("Entree Step 1\n");
+#ifdef GDCM_DEBUG
+ printf("Entree Step 1\n");
+#endif //GDCM_DEBUG
/* We set up the normal JPEG error routines, then override error_exit. */
jpeg_create_decompress(&cinfo);
/* Step 2: specify data source (eg, a file) */
- if (DEBUG) printf("Entree Step 2\n");
+#ifdef GDCM_DEBUG
+ printf("Entree Step 2\n");
+#endif //GDCM_DEBUG
jpeg_stdio_src(&cinfo, fp);
/* Step 3: read file parameters with jpeg_read_header() */
- if (DEBUG) printf("Entree Step 3\n");
+#ifdef GDCM_DEBUG
+ printf("Entree Step 3\n");
+#endif //GDCM_DEBUG
(void) jpeg_read_header(&cinfo, TRUE);
/* We can ignore the return value from jpeg_read_header since
* See libjpeg.doc for more info.
*/
- if (DEBUG) {
+#ifdef GDCM_DEBUG
printf("--------------Header contents :----------------\n");
printf("image_width %d image_height %d\n",
cinfo.image_width , cinfo.image_height);
cinfo.output_components);
printf("nb of color components returned %d \n",
cinfo.data_precision);
- }
+#endif //GDCM_DEBUG
/*
*/
/* Step 4: set parameters for decompression */
- if (DEBUG) printf("Entree Step 4\n");
+#ifdef GDCM_DEBUG
+ printf("Entree Step 4\n");
+#endif //GDCM_DEBUG
/* In this example, we don't need to change any of the defaults set by
* jpeg_read_header(), so we do nothing here.
*/
/* Step 5: Start decompressor */
- if (DEBUG) printf("Entree Step 5\n");
+#ifdef GDCM_DEBUG
+ printf("Entree Step 5\n");
+#endif //GDCM_DEBUG
(void) jpeg_start_decompress(&cinfo);
/* We can ignore the return value since suspension is not possible
/* JSAMPLEs per row in output buffer */
row_stride = cinfo.output_width * cinfo.output_components;
- if (DEBUG)
+#ifdef GDCM_DEBUG
printf ("cinfo.output_width %d cinfo.output_components %d row_stride %d\n",
cinfo.output_width, cinfo.output_components,row_stride);
-
+#endif //GDCM_DEBUG
+
/* Make a one-row-high sample array that will go away when done with image */
buffer = (*cinfo.mem->alloc_sarray)
((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
/* Step 6: while (scan lines remain to be read) */
- if (DEBUG) printf("Entree Step 6\n");
+#ifdef GDCM_DEBUG
+ printf("Entree Step 6\n");
+#endif //GDCM_DEBUG
/* jpeg_read_scanlines(...); */
* loop counter, so that we don't have to keep track ourselves.
*/
- if (DEBUG) printf ("cinfo.output_height %d cinfo.output_width %d\n",
+#ifdef GDCM_DEBUG
+ printf ("cinfo.output_height %d cinfo.output_width %d\n",
cinfo.output_height,cinfo.output_width);
+#endif //GDCM_DEBUG
pimage=(char *)image_buffer;
}
/* Step 7: Finish decompression */
- if (DEBUG) printf("Entree Step 7\n");
+#ifdef GDCM_DEBUG
+ printf("Entree Step 7\n");
+#endif //GDCM_DEBUG
(void) jpeg_finish_decompress(&cinfo);
/* We can ignore the return value since suspension is not possible
* with the stdio data source.
*/
/* Step 8: Release JPEG decompression object */
- if (DEBUG) printf("Entree Step 8\n");
+#ifdef GDCM_DEBUG
+ printf("Entree Step 8\n");
+#endif //GDCM_DEBUG
/* This is an important step since it will release a good deal of memory. */
jpeg_destroy_decompress(&cinfo);