[vtkusers] Problem to visualize a scalar
c fd
labcfd at yahoo.fr
Mon May 9 10:05:18 EDT 2005
Hello,
I'm a begginner in vtk!
I try to read a vtk file wich contains a structured grid and some data for each cell (I define it as a scalar). I try to read everything with vtkDataSetReader but only the grid appears in blue...???...
I would like to see the surface of each cell with a different color according to the value of the scalar...
I'll copy my code and an extract of the vtk file...If someone can help me, I'll appreciate...I'm blocked on this problem...Any help or suggestion is welcome!
Thank you!
Code:
//read the .vtk file
vtkDataSetReader *reader = vtkDataSetReader::New();
reader->SetFileName("vtkdatas.vtk");
reader->Update();
// Set up a lookup table for coloring
vtkLookupTable *lut = vtkLookupTable::New();
lut->SetNumberOfColors(256);
lut->SetHueRange(0.67,0.0);
lut->Build();
//convert data set from reader into graphics primitives
vtkDataSetMapper *Mapper = vtkDataSetMapper::New();
Mapper->SetInput( (vtkDataSet *) reader->GetOutput());
//actor
vtkActor *Actor = vtkActor::New();
Actor->SetMapper(Mapper);
Actor->GetProperty()->SetRepresentationToWireframe();
//convert data set from reader into graphics primitives
vtkDataSetMapper *Mapper2 = vtkDataSetMapper::New();
Mapper2->SetInput( (vtkDataSet *) reader->GetOutput());
Mapper2->ScalarVisibilityOn();
//actor
vtkActor *Actor2 = vtkActor::New();
Actor2->SetMapper(Mapper2);
Actor2->GetProperty()->SetRepresentationToWireframe();
//renderer and render window
vtkRenderer *ren = vtkRenderer::New();
ren -> SetBackground(1, 1, 1);
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin -> SetSize( 400, 400 );
renWin->AddRenderer( ren );
ren->AddActor(Actor);
vtkRenderer *ren2 = vtkRenderer::New();
ren2 -> SetBackground(0, 0, 0);
vtkRenderWindow *renWin2 = vtkRenderWindow::New();
renWin2 -> SetSize( 400, 400 );
renWin2->AddRenderer( ren2 );
ren2->AddActor(Actor2);
VTK file:
# vtk DataFile Version 1.0
Grid datas
ASCII
DATASET STRUCTURED_GRID
DIMENSIONS 101 101 2
POINTS 20402 float
0.0000000E+00 0.0000000E+00 0.0000000E+00
7.5757573E-04 0.0000000E+00 0.0000000E+00
1.5151515E-03 0.0000000E+00 0.0000000E+00
......
POINT_DATA 20402
SCALARS pressure float
LOOKUP_TABLE default
101325.2
101325.2
101325.0
---------------------------------
Découvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage pour vos mails !
Créez votre Yahoo! Mail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050509/7f510e78/attachment.htm>
More information about the vtkusers
mailing list