[Insight-users] [GDCM] Can't read easily value of a DataElement

Daanen daanen at koelis.com
Fri Mar 23 04:14:37 EDT 2012


Hi,

 

I recently upgrade from itk 3.16 to itk 4.1.

I thus have to update my code source to use the new gdcm core (2.0.x)

 

Previously, I wrote a method (for internal use) which returns the value of a
given Tag as string.

This method now uses a gdcm::DataElement as parameter.

 

But I can't get the value of the DataElement as a string in all the case.

My code is the following

 

static bool GetValue(std::string &p_Str, const gdcm::DataElement &p_Elem)

{

      p_Str.clear();

      if (p_Elem.GetByteValue() == NULL) return false;

 

      p_Str =
std::string(p_Elem.GetByteValue()->GetBuffer(),p_Elem.GetByteValue()->GetLen
gth());

      return !p_Str.empty();

}

 

But for a given tag (SamplesPerPixel, which VR = US and Value is 1), p_Str
is not "1" but " ". This seems to indicate that 

p_Str =
std::string(p_Elem.GetByteValue()->GetBuffer(),p_Elem.GetByteValue()->GetLen
gth());

is not the correct way to get the value of a US element in a string !

 

Is there a way to do want I want in a safe manner (not dependent to VR) ?

 

Thanks for help

 

Vincent

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120323/4b285470/attachment.htm>


More information about the Insight-users mailing list