[vtkusers] Map scalar data to color?
Mirelle Mellqvist
mirelle_mellqvist at hotmail.com
Mon Sep 6 05:35:51 EDT 2004
Hello!
I am a newbie at VTK. I have made a vtk file (see below) and I have created
a lookup table with some colors for every point. My problem is that I can't
see any of the colors. Do any of you have any suggestions what to do? I have
included my code below.
I have also tried to do this for every cell, but the biggest problem there
was that the first element had the right color but the rest of my 24
elements had the same colors as my last element. What caused that problem?
# vtk DataFile Version 4.2
Test data
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 36 float
0.0 -500.000 0.0
0.0 -400.000 0.0
0.0 -300.000 0.0
0.0 -200.000 0.0
0.0 -100.0 0.0
0.0 0.0 0.0
100.0 0.0 0.0
200.0 0.0 0.0
300.0 0.0 0.0
400.0 0.0 0.0
500.0 0.0 0.0
500.0 -100.0 0.0
500.0 -200.0 0.0
500.0 -300.0 0.0
500.0 -400.0 0.0
500.0 -500.0 0.0
400.0 -500.0 0.0
300.0 -500.0 0.0
200.0 -500.0 0.0
100.0 -500.0 0.0
400.0 -300.0 0.0
300.0 -300.0 0.0
200.0 -300.0 0.0
100.0 -300.0 0.0
100.0 -200.0 0.0
200.0 -200.0 0.0
100.0 -100.0 0.0
200.0 -100.0 0.0
300.0 -200.0 0.0
300.0 -100.0 0.0
400.0 -200.0 0.0
400.0 -100.0 0.0
100.0 -400.0 0.0
200.0 -400.0 0.0
300.0 -400.0 0.0
400.0 -400.0 0.0
CELLS 25 125
4 2 3 24 23
4 3 4 26 24
4 22 23 24 25
4 21 22 25 28
4 25 24 26 27
4 4 5 6 26
4 28 25 27 29
4 6 7 27 26
4 20 21 28 30
4 12 13 20 30
4 7 8 29 27
4 29 31 30 28
4 8 9 31 29
4 11 12 30 31
4 9 10 11 31
4 19 0 1 32
4 18 19 32 33
4 2 23 32 1
4 17 18 33 34
4 23 22 33 32
4 22 21 34 33
4 16 17 34 35
4 14 15 16 35
4 21 20 35 34
4 20 13 14 35
CELL_TYPES 25
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
POINT_DATA 36
SCALARS my_scalars float 1
LOOKUP_TABLE my_table
0.0
1.0
2.0
3.0
4.0
5.0
6.0
7.0
8.0
9.0
10.0
11.0
12.0
13.0
14.0
15.0
16.0
17.0
18.0
19.0
20.0
21.0
22.0
23.0
24.0
25.0
26.0
27.0
28.0
29.0
30.0
31.0
32.0
33.0
34.0
35.0
LOOKUP_TABLE my_table 36
1.0 0.0 0.0 1.0
1.0 0.0 0.0 1.0
0.0 1.0 0.0 1.0
0.0 0.0 1.0 1.0
0.0 0.0 0.7 1.0
0.0 0.7 0.0 1.0
0.7 0.0 0.0 1.0
0.0 0.5 0.0 1.0
0.0 0.0 0.5 1.0
0.5 0.0 0.0 1.0
0.5 0.5 0.5 1.0
0.0 0.8 0.8 1.0
0.0 0.0 0.0 1.0
0.7 0.7 0.0 1.0
0.9 0.9 0.9 1.0
0.6 0.2 0.2 1.0
0.8 0.3 0.1 1.0
0.0 0.4 0.4 1.0
0.4 0.0 0.0 1.0
0.0 0.6 0.9 1.0
0.2 0.4 0.6 1.0
0.1 0.0 0.5 0.0
0.3 0.5 0.0 0.5
0.3 0.4 0.4 0.7
0.0 1.0 0.0 1.0
0.6 0.2 0.2 1.0
0.8 0.3 0.1 1.0
0.0 0.4 0.4 1.0
0.4 0.0 0.0 1.0
0.0 0.6 0.9 1.0
0.2 0.4 0.6 1.0
0.1 0.0 0.5 0.0
0.3 0.5 0.0 0.5
0.3 0.4 0.4 0.7
0.0 1.0 0.0 1.0
1.0 0.0 0.5 1.0
#include "vtkUnstructuredGridReader.h"
#include "vtkUnstructuredGrid.h"
#include "vtkWarpVector.h"
#include "vtkConnectivityFilter.h"
#include "vtkDataSetMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkCamera.h"
#include "vtkGeometryFilter.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkObject.h"
#include "vtkPointDataToCellData.h"
#include "vtkRenderWindowInteractor.h"
int main(){
vtkUnstructuredGridReader *reader = vtkUnstructuredGridReader::New();
reader->SetFileName("filereader_20040906_v03.vtk");
//reader->SetVectorsName("vectors");
reader->SetScalarsName("my_scalars");
//reader->SetScalarsName("cell_scalars");
vtkPointData *pointData=vtkPointData::New();
vtkWarpVector *warp=vtkWarpVector::New();
warp->SetInput(reader->GetOutput());
vtkDataSetMapper *dataMapper=vtkDataSetMapper::New();
dataMapper->SetInput(warp->GetOutput());
vtkActor *actor=vtkActor::New();
actor->SetMapper(dataMapper);
vtkCamera *camera=vtkCamera::New();
camera->SetFocalPoint(0,0,0);
vtkRenderer *ren=vtkRenderer::New();
ren->AddActor(actor);
ren->SetBackground(1,1,1);
ren->SetActiveCamera(camera);
ren->ResetCamera();
vtkRenderWindow *renWin=vtkRenderWindow::New();
renWin->AddRenderer(ren);
renWin->SetSize(1000,1000);
vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
renWin->Render();
iren->Start();
reader->Delete();
dataMapper->Delete();
actor->Delete();
ren->Delete();
renWin->Delete();
system("PAUSE");
return 0;
}
Looking forward to hear from you!
Kind regards,
Mirelle
_________________________________________________________________
Hitta rätt på nätet med MSN Sök http://search.msn.se/
More information about the vtkusers
mailing list