<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&content-type=text/plain">http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/Examples/VolumeRendering/Cxx/GPURenderDemo.cxx?root=VTK&content-type=text/plain</a>,
I’ve written a little app to display a volume constructed from a
directory of DICOM files of CT data. I’m having no problem
displaying individual image files, but when I try to see the volume, it’s
a different story. Here are what I believe are the germane C++ code fragments:<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>…<o:p></o:p></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'> 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"'> reader->SetDirectoryName("C:\\Documents
and Settings\\Steve Chall\\My Documents\\IMRT\\CT");<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'> reader->Update();<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'> int dataScalarType =
reader->GetDataScalarType();<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>
reader->SetDataScalarTypeToUnsignedShort();<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'> reader->GetOutput()->SetScalarTypeToUnsignedInt();<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></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'> 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"'> 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"'>…<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'> renderer->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"'> renderer->ResetCamera();<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></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'><o:p> </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> </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> </o:p></p>
<p class=MsoNormal>I’d expect the call to <o:p></o:p></p>
<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>reader->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’d expect except the reader’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). <o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Finally, here’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> </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. <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> </o:p></span></p>
<p class=MsoNormal style='text-autospace:none'>And that’s what I thought
<o:p></o:p></p>
<p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;
font-family:"Courier New"'>reader->GetOutput()->SetScalarTypeToUnsignedInt();<o:p></o:p></span></p>
<p class=MsoNormal style='text-autospace:none'>would do. But no, it’s
still VTK_SHORT.<o:p></o:p></p>
<p class=MsoNormal style='text-autospace:none'><o:p> </o:p></p>
<p class=MsoNormal style='text-autospace:none'>I’d appreciate any
suggestions y’all might have. I’m running VTK 5.4.2 with
Visual C++ 2008 in WinXP SP3. Thanks.<o:p></o:p></p>
<p class=MsoNormal><o:p> </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'> Senior Research Software
Developer<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:black'> Renaissance Computing
Institute (RENCI)<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:black'> Phone: 919-681-9639<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:black'> Email: stevec@renci.org</span><o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</body>
</html>