<font size="2">Hi, everyone!<br>I am writing a custom reader to read my own file which VTK does not support!<br>The output type of my file is vtkImageData, and each point has 3~5 type of scalar. Now I have written <br>the reader like below, I just do not know how to add the scalar value to the output object! Please check my code and point what&#39;s wrong with my code!<br>
1. set the extent using WHOLE_EXTENT in RequestInformation() like below:<div class="im"><br>   <br>       outInfo-&gt;Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),<br></div>
                 0,dim[0]-1,0,dim[1]-1,0,dim[2]-1);<br><br>2.set the origin and the extent and spacing in RequestData() like below:<br><br>   vtkInformation *outInfo = outputVector-&gt;GetInformationObject(0);<br>    vtkImageData *output = vtkImageData::GetDateFormat(outInfo);<br>

    int *extent = output-&gt;GetUpdateExtent();<div class="im"><br>     output-&gt;SetExtent(extent);<br>     output-&gt;SetOrigin(origin);<br>      output-&gt;SetSpacing(ar);<br><br></div>And now, I want to add some scalar data to the output object.<br>

</font><br>
I wrote my code like this:<br>vtkIntArray *castkey = vtkIntArray::New();<br>    castkey-&gt;SetName(&quot;casting_<div id=":17w" class="ii gt">type&quot;);<br>    for (int i=0; i&lt;dim[0]; i++)<br>    {<br>        for (int j=0;j&lt;dim[1]; j++)<br>
        {<br>
            for (int k=0; k&lt;dim[2]; k++)<br>            {<br>                int idx = i*dim[2]*dim[1]+j*dim[2]+k;<br>                castkey-&gt;InsertNextValue(sgnfile.GetData()[idx]);<br>            }<br>        }<br>

    }<br><br>    output-&gt;AddArray(castkey);<br><br>note:GetData() returns the scalar value of the point idx.<br>So I was wonder what I did is right or wrong !<br>Please give me some suggestion! <br>Thank you so much!</div>
<br clear="all"><br>-- <br><a href="mailto:shenyanwen@gmail.com">shenyanwen@gmail.com</a><br>Mobile Phone:13476177952<br>Tel: 027-87558144<br>