[vtkusers] (Scalar)Data on PolyData
Nils H. Busch
nilsb at cns.mpg.de
Mon Jul 15 14:08:48 EDT 2002
Hello,
I have some questions regarding displaying (field)data on vtkPolyData in
vtk4.0 and would appreciate it, if someone could clarify some issues
regarding that.
Let me first briefly state what I am doing (or try to do, I should say):
In my vtk pipeline, I am reading one dataset from file, extract an
isocontour (via vtkMarchingCubes) from it, read a second (scalar)
dataset ("dataArray)"from file and try to map that onto a vtkPolyData
instance generated from vtkMarchingCubes with a statement like the
following:
vtkPolyData *output;
vtkDataArray *dataArray;
...
dataArray->SetName("SurfaceData");
...
output->GetPointData()->AddArray(dataArray);
Then, I render the pipeline with vtk and also write the polydata to file
(in OpenInventor format) with a class I have written myself).
I found this to work only in a way, I find not altogether obvious. Both,
rendering with a vtkPolyDataMapper and exporting to OpenInventor showed
the scalar data mapped onto the polydata, only if I specify the second
scalar data as
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
mapper->SetScalarModeToUsePointFieldData();
mapper->ColorByArrayComponent("SurfaceData", 0);
Setting ScalarMode to use PointData or to Default did not work.
In my IO class, I use anagously something like:
vtkDataArray *scalars =
vtkAbstractMapper::GetScalars(pd,VTK_SCALAR_MODE_USE_POINT_FIELD_DATA,
0, 2, NULL, arrayComponent);
Why can't I specify the second dataset directly as point data (or how
would I have to do that correctly) ?
My second question concerns the 2 in the above statement.
If I add the surface data like above, the data array is added as the
third data array to my vtkPolyData instance. I am puzzled to why this is
so. Is this correct behaviour?
I really need to add the data array as the first data array in
vtkPolyData (below is a copy of the outcome of printing my vtkPolyData
instance to a stream to clarify what I mean).
BTW, what is supposed to be in the Scalars member ?
And the third question: what is the purpose of the Field Data member
(see below) and how can it be accessed?
I have tried to gather my code from various vtk examples and the vtk
sources, but I am not quite sure anymore what the correct and suggested
way of adding (scalar) data to poly data is for vtk4.0.
Thanks.
----------
ouput->PrintSelf(cout, 4); :
Debug: Off
Modified Time: 1660
Reference Count: 1
Registered Events: (none)
Source: 0x10031e90
Release Data: Off
Data Released: False
Global Release Data: Off
MaximumNumberOfPieces: -1
PipelineMTime: 270
UpdateTime: 1657
UpdateExtent: Not Initialized
Update Number Of Pieces: 1
Update Piece: 0
Update Ghost Level: 0
RequestExactExtent: Off
UpdateExtent: 0, 0, 0, 0, 0, 0
WholeExtent: 0, -1, 0, -1, 0, -1
Field Data:
Debug: Off
Modified Time: 258
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Locality: 0
NumberOfConsumers: 0
ExtentTranslator: (0x100320a0)
MaximumNumberOfPieces: -1
Number Of Points: 32608
Number Of Cells: 63897
Cell Data:
Debug: Off
Modified Time: 262
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Copy Flags: ( 1 1 1 1 1 )
Scalars: (none)
Vectors: (none)
Normals: (none)
TCoords: (none)
Tensors: (none)
Point Data:
Debug: Off
Modified Time: 1660
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 3
Array 0 name = NULL
Array 1 name = NULL
Array 2 name = SurfaceData
Number Of Components: 5
Number Of Tuples: 32608
Copy Flags: ( 1 1 1 1 1 )
Scalars:
Debug: Off
Modified Time: 294
Reference Count: 1
Registered Events: (none)
Name: (none)
Number Of Components: 1
Number Of Tuples: 32608
Size: 32608
MaxId: 32607
LookupTable: (none)
Array: 0x102e94a8
Vectors: (none)
Normals:
Debug: Off
Modified Time: 291
Reference Count: 1
Registered Events: (none)
Name: (none)
Number Of Components: 3
Number Of Tuples: 32608
Size: 97824
MaxId: 97823
LookupTable: (none)
Array: 0x10249490
TCoords: (none)
Tensors: (none)
Bounds:
Xmin,Xmax: (24.875, 80)
Ymin,Ymax: (31.9362, 174.25)
Zmin,Zmax: (3.07692, 35)
Compute Time: 1661
Release Data: Off
Number Of Points: 32608
Point Coordinates: 0x100327b8
Locator: 0x0
Number Of Vertices: 0
Number Of Lines: 0
Number Of Polygons: 63897
Number Of Triangle Strips: 0
Number Of Pieces: 1
Piece: 0
Ghost Level: 0
UpdateExtent: 0, 0, 0, 0, 0, 0
-----
--
Nils H. Busch
Max-Planck-Institute of Cognitive Neuroscience
phone: ++49 (341) 9940-035 fax: ++49 (341) 9940-204
e-mail: nilsb at cns.mpg.de
More information about the vtkusers
mailing list