[vtkusers] FieldData to PointData

Philipp.Batchelor philipp.batchelor at kcl.ac.uk
Wed Jul 3 11:34:44 EDT 2002


Brad, Berk,

thanks for the answers. Yes, sorry, 
for 1.
the do2ds was there because
I took the vtk tcl example 'FinancialField.tcl', modified it, and
I was going back and forth to locate the difference. 

2.The 'Update's were there for the same reason, I started without,
and added one after the other to see if it was the problem.

About 3., you are spot on what I didn't understand. I misinterpreted
the fact that vtkScalars etc...had disappeared into believing that
the SetScalars method had disappeared, which is  not the case. So now I modified
the C++ filter to create directly the Scalars as you suggest. This was silly of me,
because I had had a look at the link you gave, but somehow missed the relevant line.

As to why the script didn't work for me, (also with vtkPolyDataReader),
I'll try again with vtk 4.1.

Ph



Berk Geveci wrote:
> 
> A few comments:
> 
> 1. I ran the script you included (I had to replace the input
> of vtkRearrangeField with the output of the reader since there
> is no do2ds). The output contains a scalars field which has
> values of 0.328119. I can then read the file and color the
> polygons it with these scalars.
> 
> 2. The updates are not necessary. You can replace the last
> update (write) with Write
> 
> 3. I don't understand why you are putting the array(s) in
> the "general" field data. That is for data which is not normally
> associated with geometry. You can instead add the array(s)
> to the point data (or cell data). For example:
> 
> # vtk DataFile Version 3.0
> vtk output
> ASCII
> DATASET POLYDATA
> 
> POINTS 12 float
> -0.552786 -1.7013 -0.894427 -1.44721 -1.05146 0.894427 -1.78885 0
> -0.894427
> 0.552786 -1.7013 0.894427 1.78885 0 0.894427 1.44721 -1.05146 -0.894427
> 0 0 -2 -0.552786 1.7013 -0.894427 1.44721 1.05146 -0.894427
> 0.552786 1.7013 0.894427 0 0 2 -1.44721 1.05146 0.894427
> 
> POLYGONS 20 80
> 3 0 1 2
> 3 3 1 0
> 3 5 3 0
> 3 8 4 5
> 3 4 3 5
> 3 8 6 7
> 3 7 6 2
> 3 2 6 0
> 3 0 6 5
> 3 5 6 8
> 3 9 10 4
> 3 11 10 9
> 3 1 10 11
> 3 3 10 1
> 3 4 10 3
> 3 9 4 8
> 3 7 9 8
> 3 11 9 7
> 3 2 11 7
> 3 1 11 2
> 
> CELL_DATA 20
> 
> POINT_DATA 12
> FIELD Arrays 1
> GaussCurvature 1 12 float
> 0.328119 0.328119 0.328119 0.328119 0.328119 0.328119 0.328119 0.328119
> 0.328119
> 0.328119 0.328119 0.328119
> 
> You can get rid of the vtkRearrangeFields if you do it this way. Of
> course, you can always do this:
> 
> # vtk DataFile Version 3.0
> vtk output
> ASCII
> DATASET POLYDATA
> 
> POINTS 12 float
> -0.552786 -1.7013 -0.894427 -1.44721 -1.05146 0.894427 -1.78885 0
> -0.894427
> 0.552786 -1.7013 0.894427 1.78885 0 0.894427 1.44721 -1.05146 -0.894427
> 0 0 -2 -0.552786 1.7013 -0.894427 1.44721 1.05146 -0.894427
> 0.552786 1.7013 0.894427 0 0 2 -1.44721 1.05146 0.894427
> 
> POLYGONS 20 80
> 3 0 1 2
> 3 3 1 0
> 3 5 3 0
> 3 8 4 5
> 3 4 3 5
> 3 8 6 7
> 3 7 6 2
> 3 2 6 0
> 3 0 6 5
> 3 5 6 8
> 3 9 10 4
> 3 11 10 9
> 3 1 10 11
> 3 3 10 1
> 3 4 10 3
> 3 9 4 8
> 3 7 9 8
> 3 11 9 7
> 3 2 11 7
> 3 1 11 2
> 
> CELL_DATA 20
> 
> POINT_DATA 12
> SCALARS GaussCurvature float
> LOOKUP_TABLE default
> 0.328119 0.328119 0.328119 0.328119 0.328119 0.328119 0.328119 0.328119
> 0.328119 0.328119 0.328119 0.328119
> 
> and get rid of vtkAssignAttribute as well. vtkAssignAttribute is most
> commonly used when you have multiple arrays and you want to change which
> one is currently marked as an attribute (scalars, vectors etc.)
> You can also find some information on
> http://public.kitware.com/cgi-bin/vtkfaq?req=show&file=faq06.009.htp
> 
> -Berk
> 
> On Tue, 2002-07-02 at 14:02, Philipp.Batchelor wrote:
> > Hello,
> >
> > maybe somebody can enlighten me, I don't seem to understand
> > how to the  FieldData is converted to PointData under vtk4.0.
> >
> > I just want to render the field, here curvature. I used to store
> > it as a 'vtkScalars', and that was it, but now, as I have to use
> > FieldData->DataArray, I can't manage to get a PointData that can
> > be rendered, or as in the code below, written to a file. The output
> > file contains only the geometry.
> >
> > Ph.
> >
> > ----------------------------------------------------
> > set scalar "GaussCurvature"
> >
> > vtkDataSetReader reader
> > reader SetFileName "icosaK.vtk"
> > reader SetFieldDataName "Curvatures"
> > #necessary?
> > reader Update
> >
> > vtkRearrangeFields rf
> > rf SetInput [do2ds GetOutput]
> > rf AddOperation COPY $scalar DATA_OBJECT POINT_DATA
> > rf Update
> >
> > vtkAssignAttribute aa
> > aa SetInput [rf GetOutput]
> > aa Assign $scalar SCALARS POINT_DATA
> > aa Update
> >
> > vtkPolyDataWriter wr
> > wr SetInput [aa GetOutput]
> > wr SetFileName "tmp.pd.vtk"
> > wr Update
> > ----------------------------------------------------
> >
> > My example input data file is:
> >
> > ----------------------------------------------------
> > # vtk DataFile Version 3.0
> > vtk output
> > ASCII
> > DATASET POLYDATA
> > FIELD Curvatures 1
> > GaussCurvature 1 12 float
> > 0.328119 0.328119 0.328119 0.328119 0.328119 0.328119 0.328119 0.328119 0.328119
> >
> > 0.328119 0.328119 0.328119
> > POINTS 12 float
> > -0.552786 -1.7013 -0.894427 -1.44721 -1.05146 0.894427 -1.78885 0 -0.894427
> > 0.552786 -1.7013 0.894427 1.78885 0 0.894427 1.44721 -1.05146 -0.894427
> > 0 0 -2 -0.552786 1.7013 -0.894427 1.44721 1.05146 -0.894427
> > 0.552786 1.7013 0.894427 0 0 2 -1.44721 1.05146 0.894427
> >
> > POLYGONS 20 80
> > 3 0 1 2
> > 3 3 1 0
> > 3 5 3 0
> > 3 8 4 5
> > 3 4 3 5
> > 3 8 6 7
> > 3 7 6 2
> > 3 2 6 0
> > 3 0 6 5
> > 3 5 6 8
> > 3 9 10 4
> > 3 11 10 9
> > 3 1 10 11
> > 3 3 10 1
> > 3 4 10 3
> > 3 9 4 8
> > 3 7 9 8
> > 3 11 9 7
> > 3 2 11 7
> > 3 1 11 2
> >
> > CELL_DATA 20
> > POINT_DATA 12
> > _______________________________________________
> > This is the private VTK discussion list.
> > Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> > Follow this link to subscribe/unsubscribe:
> > http://public.kitware.com/mailman/listinfo/vtkusers

-- 
----------------------------------
Dr Philippe Batchelor
King's College London  	
London	SE1 9RT

phone: 	+44 207 955 4223
fax:	+44 207 955 4532
------------------------------------------------------



More information about the vtkusers mailing list