[vtkusers] A problem to get the specified scalar data array I want

Kenn Lin cqqlin at gmail.com
Tue Apr 24 02:07:35 EDT 2012


Hello World:

I got some problem when using 'SetInputArrayToProcess' to get the specified
data I want, here's the details:

I have an UnstructuredGrid data file(generated by opemfoam) in hand
containing several arrays of scalar(temperature, pressure etc.) data and
one array of vector(air current velocity) data of a room like this:

# vtk DataFile Version 2.0
outlet
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 116 float
......
CELLS 57 285
......
CELL_TYPES 57
......
CELL_DATA 57
FIELD attributes 6
patchID 1 57 float
......
p 1 57 float
......
nut 1 57 float
......
T 1 57 float
......
k 1 57 float
......
epsilon 1 57 float
......
U 3 57 float
......

POINT_DATA  116
FIELD attributes 5
p 1 116 float
......
nut 1 116 float
......
T 1 116 float
......
k 1 116 float
......
epsilon 1 116 float
......
U 3 116 float
......

Now I wish to visualize the array of "T"(Temperature) and "U"(Air current
volocity), and after some efforts I achieved to visualize the latter one,
which I thought may be the harder, by using a vtkGlyph3D and
vtkArrowSource. I used 'glyp.SetInputArrayToProcess(1,0,0,0,"U")' to
correctly specify the vector data array I want, it works.

However, when I switch to specify the scalar data "T" using
'mapper.SetInputArrayToProcess(0,0,0,0,"T")', the program dose not work,
seems to find no data to process in its pipeline.

Below is the pipeline part of my code that can work with "volicity"
visulization:

vtkUnstructuredGridReader reader = new vtkUnstructuredGridReader();
reader.setFileName(...);

vtkCutter sliceCutter = new vtkCutter();
vtkPlane slicePlane = new vtkPlane(); // slicePlane is controlled by a
vtkImplicitPlaneWidget
sliceCutter.SetCutFunction(slicePlane);
sliceCutter.SetInput(reader.GetOutput());

vtkArrowSource arrow= new vtkArrowSource();
// ... some configuration of the arrow ...

vtkGlyph3D glyp = new vtkGlyph3D();
glyp.SetSource(arrow.GetOutput());
glyp.SetInput(sliceCutter.GetOutput());
glyp.SetInputArrayToProcess(1,0,0,0,"U"); // vectors
glyp.SetScaleFactor(0.075);
glyp.SetScaleFactor(10);
glyp.SetColorModeToColorByVector();
glyp.SetScaleModeToScaleByVector();

sliceMapper = new vtkPolyDataMapper();
sliceMapper.SetInput(glyp.GetOutput());
....

The result is obvious:


Below is the code that can not work with "temperature" visulization:
(When it comes to scalar data "T", I removed the glyp3D, changed the
pipeline simply to this:)

vtkUnstructuredGridReader reader = new vtkUnstructuredGridReader();
reader.setFileName(...)
vtkCutter sliceCutter = new vtkCutter();
vtkPlane slicePlane = new vtkPlane();
sliceCutter.SetCutFunction(slicePlane);
sliceCutter.SetInput(reader.GetOutput());

sliceMapper = new vtkPolyDataMapper();
sliceMapper.SetInput(sliceCutter.GetOutput());

sliceMapper.SetInputArrayToProcess(0,0,0,0,"T"); // scalar
// Here I also tried
reader/sliceCutter.SetInputArrayToProcess(0,0,0,0,"T"), and even removed
this sentence, only to get the same result.

vtkActor sliceActor = new vtkActor();
sliceActor.SetMapper(sliceMapper);

The result is always a strange white plate:


Could anyone tell me what's wrong with my scalar visualization pipeline or
how to retrieve the specified scalar data I want?

I uploaded the code files and data file as attachments. Due to the real
temperature data file is really big, I replaced it with a smaller data file
with the same data structure whose scalar data array is named 'p'.

Really thanks very much for reading such a long question of mine :)

-- 
Sincerely,
Kenn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120424/d85052ca/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cavity_40.vtk
Type: application/octet-stream
Size: 48958 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120424/d85052ca/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PlaneCut09_openFoam_vector.java
Type: application/octet-stream
Size: 3137 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120424/d85052ca/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PlaneCut11_openFoam.java
Type: application/octet-stream
Size: 2418 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120424/d85052ca/attachment-0002.obj>


More information about the vtkusers mailing list