Hi, everyone!
I am writing a custom reader to read my own file which VTK does not support!
The output type of my file is vtkImageData, and each point has 3~5 type of
scalar. Now I have written
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!
1. set the extent using WHOLE_EXTENT in RequestInformation() like below:

       outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),
                 0,dim[0]-1,0,dim[1]-1,0,dim[2]-1);

2.set the origin and the extent and spacing in RequestData() like below:

   vtkInformation *outInfo = outputVector->GetInformationObject(0);
    vtkImageData *output = vtkImageData::GetDateFormat(outInfo);
    int *extent = output->GetUpdateExtent();
     output->SetExtent(extent);
     output->SetOrigin(origin);
      output->SetSpacing(ar);

And now, I want to add some scalar data to the output object.

I wrote my code like this:
vtkIntArray *castkey = vtkIntArray::New();
    castkey->SetName("casting_type");
    for (int i=0; i<dim[0]; i++)
    {
        for (int j=0;j<dim[1]; j++)
        {
            for (int k=0; k<dim[2]; k++)
            {
                int idx = i*dim[2]*dim[1]+j*dim[2]+k;
                castkey->InsertNextValue(sgnfile.GetData()[idx]);
            }
        }
    }

    output->AddArray(castkey);

note:GetData() returns the scalar value of the point idx.
So I was wonder what I did is right or wrong !
Please give me some suggestion!
Thank you so much!






-- 
[email protected]
Mobile Phone:13476177952
Tel: 027-87558144
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to