//-----------------------------------------------------------------------------
// Constructor / Destructor
+
+/*
+ * \ingroup gdcmDicomDir
+ * \brief
+ * @param Filename
+ * @param exception_on_error
+ */
gdcmDicomDir::gdcmDicomDir(std::string & FileName,
bool exception_on_error):
gdcmParser(FileName.c_str(),exception_on_error, true )
}
+/*
+ * \ingroup gdcmDicomDir
+ * \brief
+ * @param exception_on_error
+ */
+gdcmDicomDir::gdcmDicomDir(bool exception_on_error):
+ gdcmParser(exception_on_error )
+{
+
+}
+
+
+
gdcmDicomDir::~gdcmDicomDir()
{
for(ListPatient::iterator cc = patients.begin();cc!=patients.end();++cc)
class GDCM_EXPORT gdcmDicomDir: public gdcmParser
{
public:
+ gdcmDicomDir(bool exception_on_error = false);
gdcmDicomDir(std::string &FileName,bool exception_on_error = false );
+
~gdcmDicomDir(void);
void SetPrintLevel(int level) { printLevel = level; };
std::string res = GetEntryByNumber(0x0028, 0x0005);
if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 )
return false; // Image Dimensions
-
if ( !GetHeaderEntryByNumber(0x0028, 0x0100) )
return false; // "Bits Allocated"
if ( !GetHeaderEntryByNumber(0x0028, 0x0101) )
if ( !Element )
return false;
LoadHeaderEntrySafe(Element);
-
- std::string Transfer = Element->GetValue();
- if ( Transfer == "1.2.840.10008.1.2.4.51" )
- return true;
- return false;
+ return ( Element->GetValue() == "1.2.840.10008.1.2.4.51" );
}
/**
/**
* \ingroup gdcmHeader
* \brief Recover the offset (from the beginning of the file)
- * \ of *image* pixels (not *icone* pixels, if any !)
+ * \ of *image* pixels (not *icone image* pixels, if any !)
*/
size_t gdcmHeader::GetPixelOffset(void) {
- // If this file complies with the norm we should encounter the
- // "Image Location" tag (0x0028, 0x0200). This tag contains the
+ // We may encounter the 'RETired' (0x0028, 0x0200) tag
+ // (Image Location") . This Element contains the number of
// the group that contains the pixel data (hence the "Pixel Data"
// is found by indirection through the "Image Location").
// Inside the group pointed by "Image Location" the searched element
// is conventionally the element 0x0010 (when the norm is respected).
// When the "Image Location" is absent we default to group 0x7fe0.
+ //
// If the element (0x0088,0x0200) 'icone image sequence' is found
// (grPixel,numPixel) is stored twice : the first one for the icon
// the second one for the image ...
if ( !GetHeaderEntryByNumber(0x0028,0x1103) )
return false;
- // It is not enough
+ // It is not enough :
// we check also
// Red Palette Color Lookup Table Data
// if it works, we shall have to check the 3 Palettes
// to see which byte is ==0 (first one, or second one)
// and fix the code
- // We give up the checking to avoid some overhead
+ // We give up the checking to avoid some (useless ?)overhead
+ // (optimistic asumption)
unsigned char *a;
int i;
}
//How to free the now useless LUTs?
-
//free(LutR); free(LutB); free(LutG); // Seg Fault when used
return(LUTRGBA);
}
void gdcmHeader::SetImageDataSize(size_t ImageDataSize) {
std::string content1;
char car[20];
- // Assumes HeaderEntry (0x7fe0, 0x0010) exists ...
+ // Assumes HeaderEntry (0x7fe0, 0x0010) exists ...
+ // TODO define private members PixelGroupNumber, PicxelElementNumber
+ // update them, use them (only necessary for ACR-NEMA, not DICOM)
sprintf(car,"%d",ImageDataSize);
gdcmHeaderEntry *a = GetHeaderEntryByNumber(0x7fe0, 0x0010);
// Some heuristic based accessors, end user intended
// (to be move to gdcmHeaderHelper?)
- int GetXSize(void);
+ int GetXSize(void);
int GetYSize(void);
int GetZSize(void);
int GetBitsStored(void);
// TODO Swig int SetPubDict(std::string filename);
// Entry
- inline virtual std::string GetEntryByName (std::string tagName)
- { return(gdcmParser::GetEntryByName(tagName)); }
- inline virtual std::string GetEntryVRByName (std::string tagName)
- { return(gdcmParser::GetEntryVRByName(tagName)); }
+
inline virtual std::string GetEntryByNumber (guint16 group, guint16 element)
{ return(gdcmParser::GetEntryByNumber(group,element)); }
inline virtual std::string GetEntryVRByNumber(guint16 group, guint16 element)
{ return(gdcmParser::GetEntryVRByNumber(group,element)); }
-
- inline virtual bool SetEntryByName(std::string content,std::string tagName)
- { return(gdcmParser::SetEntryByName(content,tagName)); }
+
+ inline virtual std::string GetEntryByName (std::string tagName)
+ { return(gdcmParser::GetEntryByName(tagName)); }
+ inline virtual std::string GetEntryVRByName (std::string tagName)
+ { return(gdcmParser::GetEntryVRByName(tagName)); }
+
inline virtual bool SetEntryByNumber(std::string content,guint16 group, guint16 element)
{ return(gdcmParser::SetEntryByNumber(content,group,element)); }
+ inline virtual bool SetEntryByName(std::string content,std::string tagName)
+ { return(gdcmParser::SetEntryByName(content,tagName)); }
+
inline virtual void UpdateShaEntries(void)
{ gdcmParser::UpdateShaEntries(); }
if (g == 0x0008) {
if ( (e == 0x0016) || (e == 0x1150) )
s << " ==>\t[" << ts->GetValue(v) << "]";
+ } else {
+ if (g == 0x0004) {
+ if ( (e == 0x1510) || (e == 0x1512) )
+ s << " ==>\t[" << ts->GetValue(v) << "]";
+ }
}
}
//if (e == 0x0000) { // elem 0x0000 --> group length
//-----------------------------------------------------------------------------
/*
- * \defgroup gdcmHeader
- * \brief
+ * \defgroup gdcmParser
+ * \brief used by both gdcmHeader and gdcmDicomDir
*/
class GDCM_EXPORT gdcmParser
{
IterHT GetHeaderEntrySameNumber(guint16 group, guint16 element);
// IterHT GetHeaderEntrySameName (std::string Name);
-
void LoadHeaderEntrySafe(gdcmHeaderEntry *);
void UpdateGroupLength(bool SkipSequence = false, FileType type = ImplicitVR);
void SwitchSwapToBigEndian(void);
void SetMaxSizeLoadEntry(long);
- // Dict
+ // DictEntry related utilities
gdcmDictEntry *GetDictEntryByName (std::string Name);
gdcmDictEntry *GetDictEntryByNumber(guint16, guint16);
-
- // HeaderEntry related utilities
- gdcmHeaderEntry *ReadNextHeaderEntry (void);
- gdcmHeaderEntry *NewHeaderEntryByNumber(guint16 group,
- guint16 element);
- gdcmHeaderEntry *NewHeaderEntryByName (std::string Name);
gdcmDictEntry *NewVirtualDictEntry(guint16 group,
guint16 element,
std::string vr = "Unknown",
std::string fourth = "Unknown",
std::string name = "Unknown");
gdcmDictEntry *NewVirtualDictEntry(gdcmHeaderEntry *);
+
+ // HeaderEntry related utilities
+ gdcmHeaderEntry *ReadNextHeaderEntry (void);
+ gdcmHeaderEntry *NewHeaderEntryByNumber(guint16 group,
+ guint16 element);
+ gdcmHeaderEntry *NewHeaderEntryByName (std::string Name);
+
// Deprecated (Not used)
gdcmHeaderEntry *NewManualHeaderEntryToPubDict(std::string NewTagName,