newbie ?: How do I store & read scalar value in a vtk formatfile ?

Paul Hsieh pahsieh at usgs.gov
Fri Aug 27 10:46:46 EDT 1999


Chris:

You need to include a lookup table with the scalar data.
You can include a default lookup table by:

SCALARS my_scalars_name float
LOOKUP_TABLE default
<Your scalar data>

You can put this inside your polydata file, and the whole
thing will be read by vtkPolyDataReader. There is no
need to create a separate data file. However, note that the
number of scalars must be the same as the number of points
i.e., one scalar per point (assuming you are using point
attributes).

An example would be:

# vtk DataFile Version 2.0
example polydata for a square
ASCII
DATASET POLYDATA
POINTS 4 float
1 0 0
1 1 0
1 1 1 
1 0 1
POLYGONS 1 5
4 0 1 2 3 
POINT_DATA 4
SCALARS scalars float
LOOKUP_TABLE default
0 0.3 0.5 0.2


"Pieper, Chris" wrote:
> 
> I have a vtk format file containing PolyData (points & lines) which is
> working fine.  I'd like to add a single scalar attribute.  My guess at the
> format to use is;
> 
> SCALARS my_scalars_name float
> 2.1e-2
> 
> This may or may not be correct (1st question)...
> 
> The 2nd question is how do I read it? I read the PolyData using
> PolyDataReader, but how can I get the scalar value?
> 
> I've tried;
> 
> vtkScalars *scalars = vtkScalars::New();
> 
> vtkDataReader *datareader = vtkDataReader::New();
>         datareader->SetFileName("my_vtk_file");
>         datareader->SetScalersName("my_scalars_name");
>         datareader->Read(scalars);
> 
> obviously, this is wrong...


-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list