- if ( (vr == "UL") || (vr == "US") || (vr == "SL") || (vr == "SS") )
- return true;
-
- return false;
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief Recover the offset (from the beginning of the file) of the pixels.
- */
-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
- // 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.
- guint16 grPixel;
- guint16 numPixel;
- std::string ImageLocation = GetPubElValByName("Image Location");
- if ( ImageLocation == GDCM_UNFOUND ) {
- grPixel = 0x7fe0;
- } else {
- grPixel = (guint16) atoi( ImageLocation.c_str() );
- }
- if (grPixel != 0x7fe0)
- // This is a kludge for old dirty Philips imager.
- numPixel = 0x1010;
- else
- numPixel = 0x0010;
-
- gdcmElValue* PixelElement = PubElValSet.GetElementByNumber(grPixel,
- numPixel);
- if (PixelElement)
- return PixelElement->GetOffset();
- else
- return 0;
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief Recover the pixel area length (in Bytes) .
- */
-size_t gdcmHeader::GetPixelAreaLength(void) {
- // If this file complies with the norm we should encounter the
- // "Image Location" tag (0x0028, 0x0200). This tag contains the
- // 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.
- guint16 grPixel;
- guint16 numPixel;
- std::string ImageLocation = GetPubElValByName("Image Location");
- if ( ImageLocation == GDCM_UNFOUND ) {
- grPixel = 0x7fe0;
- } else {
- grPixel = (guint16) atoi( ImageLocation.c_str() );
- }
- if (grPixel != 0x7fe0)
- // This is a kludge for old dirty Philips imager.
- numPixel = 0x1010;
- else
- numPixel = 0x0010;
-
- gdcmElValue* PixelElement = PubElValSet.GetElementByNumber(grPixel,
- numPixel);
- if (PixelElement)
- return PixelElement->GetLength();
- else
- return 0;
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief Searches both the public and the shadow dictionary (when they
- * exist) for the presence of the DictEntry with given
- * group and element. The public dictionary has precedence on the
- * shadow one.
- * @param group group of the searched DictEntry
- * @param element element of the searched DictEntry
- * @return Corresponding DictEntry when it exists, NULL otherwise.
- */
-gdcmDictEntry * gdcmHeader::GetDictEntryByNumber(guint16 group,
- guint16 element) {
- gdcmDictEntry * found = (gdcmDictEntry*)0;
- if (!RefPubDict && !RefShaDict) {
- dbg.Verbose(0, "gdcmHeader::GetDictEntry",
- "we SHOULD have a default dictionary");
- }
- if (RefPubDict) {
- found = RefPubDict->GetTagByNumber(group, element);
- if (found)
- return found;
- }
- if (RefShaDict) {
- found = RefShaDict->GetTagByNumber(group, element);
- if (found)
- return found;
- }
- return found;
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief Searches both the public and the shadow dictionary (when they
- * exist) for the presence of the DictEntry with given name.
- * The public dictionary has precedence on the shadow one.
- * @param Name name of the searched DictEntry
- * @return Corresponding DictEntry when it exists, NULL otherwise.
- */
-gdcmDictEntry * gdcmHeader::GetDictEntryByName(std::string Name) {
- gdcmDictEntry * found = (gdcmDictEntry*)0;
- if (!RefPubDict && !RefShaDict) {
- dbg.Verbose(0, "gdcmHeader::GetDictEntry",
- "we SHOULD have a default dictionary");
- }
- if (RefPubDict) {
- found = RefPubDict->GetTagByName(Name);
- if (found)
- return found;
- }
- if (RefShaDict) {
- found = RefShaDict->GetTagByName(Name);
- if (found)
- return found;
- }
- return found;
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief Searches within the public dictionary for element value of
- * a given tag.
- * @param group Group of the researched tag.
- * @param element Element of the researched tag.
- * @return Corresponding element value when it exists, and the string
- * GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string gdcmHeader::GetPubElValByNumber(guint16 group, guint16 element) {
- return PubElValSet.GetElValueByNumber(group, element);
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief Searches within the public dictionary for element value
- * representation of a given tag.
- *
- * Obtaining the VR (Value Representation) might be needed by caller
- * to convert the string typed content to caller's native type
- * (think of C++ vs Python). The VR is actually of a higher level
- * of semantics than just the native C++ type.
- * @param group Group of the researched tag.
- * @param element Element of the researched tag.
- * @return Corresponding element value representation when it exists,
- * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string gdcmHeader::GetPubElValRepByNumber(guint16 group, guint16 element) {
- gdcmElValue* elem = PubElValSet.GetElementByNumber(group, element);
- if ( !elem )
- return GDCM_UNFOUND;
- return elem->GetVR();
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief Searches within the public dictionary for element value of
- * a given tag.
- * @param TagName name of the searched element.
- * @return Corresponding element value when it exists, and the string
- * GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string gdcmHeader::GetPubElValByName(std::string TagName) {
- return PubElValSet.GetElValueByName(TagName);
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief Searches within the elements parsed with the public dictionary for
- * the element value representation of a given tag.
- *
- * Obtaining the VR (Value Representation) might be needed by caller
- * to convert the string typed content to caller's native type
- * (think of C++ vs Python). The VR is actually of a higher level
- * of semantics than just the native C++ type.
- * @param TagName name of the searched element.
- * @return Corresponding element value representation when it exists,
- * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string gdcmHeader::GetPubElValRepByName(std::string TagName) {
- gdcmElValue* elem = PubElValSet.GetElementByName(TagName);
- if ( !elem )
- return GDCM_UNFOUND;
- return elem->GetVR();
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief Searches within elements parsed with the SHADOW dictionary
- * for the element value of a given tag.
- * @param group Group of the searched tag.
- * @param element Element of the searched tag.
- * @return Corresponding element value representation when it exists,
- * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string gdcmHeader::GetShaElValByNumber(guint16 group, guint16 element) {
- return ShaElValSet.GetElValueByNumber(group, element);
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief Searches within the elements parsed with the SHADOW dictionary
- * for the element value representation of a given tag.
- *
- * Obtaining the VR (Value Representation) might be needed by caller
- * to convert the string typed content to caller's native type
- * (think of C++ vs Python). The VR is actually of a higher level
- * of semantics than just the native C++ type.
- * @param group Group of the searched tag.
- * @param element Element of the searched tag.
- * @return Corresponding element value representation when it exists,
- * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string gdcmHeader::GetShaElValRepByNumber(guint16 group, guint16 element) {
- gdcmElValue* elem = ShaElValSet.GetElementByNumber(group, element);
- if ( !elem )
- return GDCM_UNFOUND;
- return elem->GetVR();
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief Searches within the elements parsed with the shadow dictionary
- * for an element value of given tag.
- * @param TagName name of the searched element.
- * @return Corresponding element value when it exists, and the string
- * GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string gdcmHeader::GetShaElValByName(std::string TagName) {
- return ShaElValSet.GetElValueByName(TagName);
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief Searches within the elements parsed with the shadow dictionary for
- * the element value representation of a given tag.
- *
- * Obtaining the VR (Value Representation) might be needed by caller
- * to convert the string typed content to caller's native type
- * (think of C++ vs Python). The VR is actually of a higher level
- * of semantics than just the native C++ type.
- * @param TagName name of the searched element.
- * @return Corresponding element value representation when it exists,
- * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string gdcmHeader::GetShaElValRepByName(std::string TagName) {
- gdcmElValue* elem = ShaElValSet.GetElementByName(TagName);
- if ( !elem )
- return GDCM_UNFOUND;
- return elem->GetVR();
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief Searches within elements parsed with the public dictionary
- * and then within the elements parsed with the shadow dictionary
- * for the element value of a given tag.
- * @param group Group of the searched tag.
- * @param element Element of the searched tag.
- * @return Corresponding element value representation when it exists,
- * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string gdcmHeader::GetElValByNumber(guint16 group, guint16 element) {
- std::string pub = GetPubElValByNumber(group, element);
- if (pub.length())
- return pub;
- return GetShaElValByNumber(group, element);
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief Searches within elements parsed with the public dictionary
- * and then within the elements parsed with the shadow dictionary
- * for the element value representation of a given tag.
- *
- * Obtaining the VR (Value Representation) might be needed by caller
- * to convert the string typed content to caller's native type
- * (think of C++ vs Python). The VR is actually of a higher level
- * of semantics than just the native C++ type.
- * @param group Group of the searched tag.
- * @param element Element of the searched tag.
- * @return Corresponding element value representation when it exists,
- * and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.
- */
-std::string gdcmHeader::GetElValRepByNumber(guint16 group, guint16 element) {
- std::string pub = GetPubElValRepByNumber(group, element);
- if (pub.length())
- return pub;
- return GetShaElValRepByNumber(group, element);
-}