[prev in list] [next in list] [prev in thread] [next in thread] 

List:       paraview
Subject:    [Paraview] How to add scalar data in a custom reader?
From:       shenyanwen <shenyanwen () gmail ! com>
Date:       2009-03-26 14:27:55
Message-ID: 245222690903260727h716111b7x27be82c027f048e2 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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!






-- 
shenyanwen@gmail.com
Mobile Phone:13476177952
Tel: 027-87558144

[Attachment #5 (text/html)]

<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&#39;s wrong with my code!<br> 1. \
set the extent using WHOLE_EXTENT in RequestInformation() like below:<div><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><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>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"><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>



_______________________________________________
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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic