<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:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 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;}
/* 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:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1694064225;
        mso-list-type:hybrid;
        mso-list-template-ids:-1890309748 -800441342 68354051 68354053 68354049 68354051 68354053 68354049 68354051 68354053;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:-;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-font-family:Calibri;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></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=NL link=blue vlink=purple><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-GB>I’ve recently started a little project to create an image reader for a specific type of medical image data (Philips PAR/REC).<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>Hopefully I can do this neatly in VTK style, but I’m not pleased with the approach I’ve taken so far. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>I’d appreciate your take on this! Here’s my idea so far.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>vtkPARRECParser: to read the data properties. No troubles here<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>vtkPARRECReader: derives from vtkImageReader2<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>By default vtkImageReader is build to return a single slice or volume through the GetOutput function.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>My data also deals with time series. The vtkDICOMReader deals with series of slices, by stacking them into a volume.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>However, I’ll have to deal with series of volumes.  So I thought: do not depair – there is the vtkTemporalDataSet.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>In the reader I have<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>ExecuteInformation – parses the parameters<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>ExecuteData (vtkDataObject* out) – get the info from the rec file.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>Ah, so ‘out’ is a generic container. So I can cast types:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-family:"Courier New"'>if(singleTime)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-family:"Courier New"'>{<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>  vtkImageData *data = <span style='color:blue'>this</span>->AllocateOutputData(out);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>  // go get the data<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>}</span><span lang=EN-GB style='font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-family:"Courier New"'>else<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-family:"Courier New"'>{<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>  vtkTemporalDataSet *data = vtkTemporalDataSet::New();<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>  // go get the data<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>  out->DeepCopy(data);    <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>}</span><span lang=EN-GB style='font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>Seems plausible, although the deepcopy is surely not preferable. The main issue I have with this<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>is the way the data set is returned to the application. GetOutput returns a vtkImageData, this being<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>a child of the vtkImageReader. My initial thought was to return as a vtkObject:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>vtkDataObject * GetOutput()<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>{<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New"'>  <span style='color:blue'>return</span> <span style='color:blue'>this</span>->GetOutputDataObject(0);<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>}<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>However, this leaves it up to the application to decide to which type it should downcast.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>This approach doesn’t ‘feel right’. What would you suggest to do to keep it in line with the VTK philisophy?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>Thanks!</span><span lang=EN-GB><o:p></o:p></span></p></div></body></html>