[Paraview] CSV Data using extra fields.

Andrew Maclean andrew.amaclean at gmail.com
Fri Jul 30 18:34:17 EDT 2010


Thankyou, works a treat! Now I know what I was doing wrong.

Regards
   Andrew


On Sat, Jul 31, 2010 at 12:15 AM, Andy Bauer <andy.bauer at kitware.com> wrote:

> Something like the code below should work for the programmable filter.
> Note that this assumes the input and output are polydata.
>
>   pdi = self.GetPolyDataInput()
>
> pdo = self.GetPolyDataOutput()
>
> pdo.SetPoints(pdi.GetPoints())
>
> np = pdo.GetNumberOfPoints()
>
> a = vtk.vtkUnsignedCharArray()
>
> a.SetNumberOfComponents(3)
>
> a.SetNumberOfTuples(np)
>
> a.SetName("color")
>
> r = pdi.GetPointData().GetArray("r")
>
> g = pdi.GetPointData().GetArray("g")
>
> b = pdi.GetPointData().GetArray("b")
>
> for i in range(np):
>
> a.SetValue(i*3, r.GetValue(i))
>
> a.SetValue(i*3+1, g.GetValue(i))
>
> a.SetValue(i*3+2, b.GetValue(i))
>
>
> pdo.GetPointData().AddArray(a)
>
>
>
> On Fri, Jul 30, 2010 at 2:13 AM, Andrew Maclean <andrew.amaclean at gmail.com
> > wrote:
>
>> I have a file that looks like this:
>> x y z r g b px py
>>
>> -2.064749 -1.623789 5.264024 254 254 254 5.000000 7.000000
>>
>> -2.267242 -1.790226 5.803583 254 254 254 5.000000 8.000000
>>
>> -2.251401 -1.784915 5.786366 254 254 254 5.000000 9.000000
>>
>> -1.401535 -1.134097 3.676532 201 201 201 5.000000 14.000000
>>
>> -1.420374 -1.154109 3.741410 179 179 179 5.000000 15.000000
>>
>> ...
>>
>> In ParaVew, I use the inbuilt CSV reader and get a table of labelled
>> columns.
>> In order tot get the points, I use a TableToPoints filter.
>> The output of this filter is a table consisting of r,g,b, px, py,
>> points, point ID.
>> This plots OK in 3D.
>>
>> How can I transform the r, g, b arrays into a vtkUnsignedCharArray in
>> order to add colour information to the points?
>> I have been trying to use a programmable filter but don't seem to be
>> able to access the r, g, b components.
>> Also will the other components of the array be passed through, namely
>> (points, and px, py)? Ultimately I want to create a 2d image of the
>> px, py and colours.
>>
>>
>>
>> Any help appreciated.
>>
>> Thanks
>>   Andrew
>>
>> --
>> ___________________________________________
>> Andrew J. P. Maclean
>> Centre for Autonomous Systems
>> The Rose Street Building J04
>> The University of Sydney  2006  NSW
>> AUSTRALIA
>> Ph: +61 2 9351 3283
>> Fax: +61 2 9351 7474
>> URL: http://www.acfr.usyd.edu.au/
>> ___________________________________________
>> _______________________________________________
>> 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
>>
>
>


-- 
___________________________________________
Andrew J. P. Maclean
Centre for Autonomous Systems
The Rose Street Building J04
The University of Sydney  2006  NSW
AUSTRALIA
Ph: +61 2 9351 3283
Fax: +61 2 9351 7474
URL: http://www.acfr.usyd.edu.au/
___________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20100731/a7dc4d33/attachment.htm>


More information about the ParaView mailing list