<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
You can access the value as unsigned short and convert it to a
string:<br>
<br>
unsigned short SamplesPerPixel = *((unsigned short *)
p_Elem.GetByteValue()->GetPointer());<br>
std::stringstream s_SamplesPerPixel;<br>
s_SamplesPerPixel << SamplesPerPixel;<br>
p_Str = s_SamplesPerPixel.str();<br>
<br>
Christina<br>
<br>
Am 23.03.2012 09:14, schrieb Daanen:
<blockquote cite="mid:000e01cd08cc$fd1cdc10$f7569430$@koelis.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Texte de bulles Car";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.TextedebullesCar
        {mso-style-name:"Texte de bulles Car";
        mso-style-priority:99;
        mso-style-link:"Texte de bulles";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-US">I recently upgrade from
itk 3.16 to itk 4.1.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I thus have to update my
code source to use the new gdcm core (2.0.x)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Previously, I wrote a
method (for internal use) which returns the value of a given
Tag as string.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">This method now uses a
gdcm::DataElement as parameter.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">But I can’t get the
value of the DataElement as a string in all the case.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">My code is the following<o:p></o:p></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt;
font-family: "Courier New"; color: blue;"
lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt;
font-family: "Courier New"; color: blue;"
lang="EN-US">static</span><span style="font-size: 10pt;
font-family: "Courier New";" lang="EN-US"> <span
style="color: blue;">bool</span> GetValue(std::string
&p_Str, <span style="color: blue;">const</span>
gdcm::DataElement &p_Elem)<o:p></o:p></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt;
font-family: "Courier New";" lang="EN-US">{<o:p></o:p></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt;
font-family: "Courier New";" lang="EN-US">
p_Str.clear();<o:p></o:p></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt;
font-family: "Courier New"; color: green;"
lang="EN-US"> </span><span style="font-size: 10pt;
font-family: "Courier New";" lang="EN-US">if
(p_Elem.GetByteValue() == NULL) return false;<o:p></o:p></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt;
font-family: "Courier New";" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt;
font-family: "Courier New";" lang="EN-US">
p_Str =
std::string(p_Elem.GetByteValue()->GetBuffer(),p_Elem.GetByteValue()->GetLength());<o:p></o:p></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt;
font-family: "Courier New";" lang="EN-US"> <span
style="color: blue;">return</span> !p_Str.empty();<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New";" lang="EN-US">}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family:
"Courier New";" lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">But for a given tag
(SamplesPerPixel, which VR = US and Value is 1), p_Str is
not “1” but “ “. This seems to indicate that <o:p></o:p></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt;
font-family: "Courier New";" lang="EN-US">p_Str =
std::string(p_Elem.GetByteValue()->GetBuffer(),p_Elem.GetByteValue()->GetLength());<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">is not the correct way
to get the value of a US element in a string !<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Is there a way to do
want I want in a safe manner (not dependent to VR) ?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks for help<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Vincent<o:p></o:p></span></p>
</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_____________________________________
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>
Visit other Kitware open-source projects at
<a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>
Kitware offers ITK Training Courses, for more information visit:
<a class="moz-txt-link-freetext" href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a>
Please keep messages on-topic and check the ITK FAQ at:
<a class="moz-txt-link-freetext" href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a>
</pre>
</blockquote>
<br>
</body>
</html>