<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        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;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
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]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=WordSection1>

<p class=MsoNormal>Based on <a
href="http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/Examples/VolumeRendering/Cxx/GPURenderDemo.cxx?root=VTK&amp;content-type=text/plain">http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/Examples/VolumeRendering/Cxx/GPURenderDemo.cxx?root=VTK&amp;content-type=text/plain</a>,
I&#8217;ve written a little app to display a volume constructed from a
directory of DICOM files of CT data.&nbsp; I&#8217;m having no problem
displaying individual image files, but when I try to see the volume, it&#8217;s
a different story.&nbsp; Here are what I believe are the germane C++ code fragments:<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>&#8230;<o:p></o:p></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>&nbsp; vtkDICOMImageReader *reader =
vtkDICOMImageReader::New();<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>&nbsp; reader-&gt;SetDirectoryName(&quot;C:\\Documents
and Settings\\Steve Chall\\My Documents\\IMRT\\CT&quot;);<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>&nbsp; reader-&gt;Update();<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>&nbsp; int dataScalarType =
reader-&gt;GetDataScalarType();<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>&nbsp;
reader-&gt;SetDataScalarTypeToUnsignedShort();<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>&nbsp; reader-&gt;GetOutput()-&gt;SetScalarTypeToUnsignedInt();<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>&#8230;&nbsp; <o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>&nbsp; vtkVolume *volume = vtkVolume::New();<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>&nbsp; vtkVolumeRayCastMapper *mapper =
vtkVolumeRayCastMapper::New();<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>&#8230;<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>&nbsp; renderer-&gt;AddVolume( volume );<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>&nbsp; renderer-&gt;ResetCamera();<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>&#8230;<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'>It builds and runs, but instead
of displaying the volume I get the following message: <o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>ERROR: In
..\..\VTK\VolumeRendering\vtkVolumeRayCastMapper.cxx, line 327<o:p></o:p></p>

<p class=MsoNormal>vtkVolumeRayCastMapper (01F111C8): Cannot volume render data
of type short, only unsigned char or unsigned short.<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I&#8217;d expect the call to <o:p></o:p></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>reader-&gt;SetDataScalarTypeToUnsignedShort();
<o:p></o:p></span></p>

<p class=MsoNormal>to do just that, and when I step through it in the debugger
it does indeed get called and does everything I&#8217;d expect except the reader&#8217;s
DataScalarType value never changes (down where the assignment should occur, in vtkImageReader2::SetDataScalarType(int
type)) from 4 (VTK_SHORT) to 5 (VTK_UNSIGNED_SHORT).&nbsp; <o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Finally, here&#8217;s the method comment for void
vtkImageReader2::SetDataScalarType(int type):<o:p></o:p></p>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:green'>// Set the data type of pixels in the
file.&nbsp; <o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:green'>// If you want the output scalar type to
have a different value, set it<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:green'>// after this method is called.<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New";color:green'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='text-autospace:none'>And that&#8217;s what I thought&nbsp;
<o:p></o:p></p>

<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>reader-&gt;GetOutput()-&gt;SetScalarTypeToUnsignedInt();<o:p></o:p></span></p>

<p class=MsoNormal style='text-autospace:none'>would do.&nbsp; But no, it&#8217;s
still VTK_SHORT.<o:p></o:p></p>

<p class=MsoNormal style='text-autospace:none'><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='text-autospace:none'>I&#8217;d appreciate any
suggestions y&#8217;all might have.&nbsp; I&#8217;m running VTK 5.4.2 with
Visual C++ 2008 in WinXP SP3. &nbsp;Thanks.<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal><span style='color:black'>-Steve Chall<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:black'>&nbsp;Senior Research Software
Developer<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:black'>&nbsp;Renaissance Computing
Institute (RENCI)<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:black'>&nbsp;Phone: 919-681-9639<o:p></o:p></span></p>

<p class=MsoNormal><span style='color:black'>&nbsp;Email: stevec@renci.org</span><o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>