<br><br><div class="gmail_quote"><br><br><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's wrong with my code!<br>
1. set the extent using WHOLE_EXTENT in RequestInformation() like below:<div><br> <br> outInfo->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->GetInformationObject(0);<br> vtkImageData *output = vtkImageData::GetDateFormat(outInfo);<br>
int *extent = output->GetUpdateExtent();<div><br> output->SetExtent(extent);<br> output->SetOrigin(origin);<br> output->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->SetName("casting_<div>type");<br> for (int i=0; i<dim[0]; i++)<br> {<br> for (int j=0;j<dim[1]; j++)<br>
{<br>
for (int k=0; k<dim[2]; k++)<br> {<br> int idx = i*dim[2]*dim[1]+j*dim[2]+k;<br> castkey->InsertNextValue(sgnfile.GetData()[idx]);<br> }<br> }<br>
}<br><br> output->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"><font color="#888888"><br><br></font></div><br><br clear="all"><br>-- <br><a href="mailto:shenyanwen@gmail.com">shenyanwen@gmail.com</a><br>Mobile Phone:13476177952<br>Tel: 027-87558144<br>