[vtkusers] Blanking, GetScalars AND vtk4.0
Stephane Lemaire
stephanelemairefr at yahoo.fr
Tue May 14 05:09:32 EDT 2002
Hello Everyone,
I try to get cells blanking using scalar values but I
get an error message I don't understand. Here is the
source code :
#include "vtkRenderer.h"
#include "vtkQuartzRenderWindow.h"
#include "vtkQuartzRenderWindowInteractor.h"
#include "vtkDataSetMapper.h"
#include "vtkActor.h"
#include "vtkStructuredGridReader.h"
#include "vtkStructuredGrid.h"
#include "vtkFloatArray.h"
#include "vtkLookupTable.h"
int main( int argc, char *argv[] )
{
int npoints;
float valuerange[2];
float rho_i;
vtkRenderer *ren1 = vtkRenderer::New();
vtkQuartzRenderWindow *renWin =
vtkQuartzRenderWindow::New();
renWin->AddRenderer(ren1);
vtkQuartzRenderWindowInteractor *iren =
vtkQuartzRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
vtkStructuredGridReader *reader =
vtkStructuredGridReader::New();
reader->SetFileName("data.vtk");
reader->SetScalarsName("pressure");
reader->Update();
reader->GetOutput()->GetScalarRange(valuerange);
npoints=(reader->GetOutput())->GetNumberOfPoints();
reader->SetScalarsName("rho");
vtkFloatArray *rho = vtkFloatArray::New();
(reader->GetOutput())->GetPointData()->SetActiveScalars("rho");
rho=reader->GetOutput()->GetPointData()->GetScalars();
for (int i=0; i < npoints; i++)
{rho_i=rho->GetComponent(i,0);
if (rho_i < 0.04)
{reader->GetOutput()->BlankingOn();
reader->GetOutput()->BlankPoint(i);}
}
vtkLookupTable *lut = vtkLookupTable::New();
lut->SetNumberOfColors(30);
lut->SetHueRange(0.6667,0.);
lut->Build();
vtkDataSetMapper *dataMapper =
vtkDataSetMapper::New();
reader->SetScalarsName("pressure");
dataMapper->SetInput(reader->GetOutput());
dataMapper->SetScalarRange(valuerange[0],valuerange[1]);
dataMapper->SetLookupTable(lut);
dataMapper->Update();
printf("%.4f\n",valuerange[0]);
printf("%.4f\n",valuerange[1]);
printf("%.5i\n",npoints);
vtkActor *dataActor = vtkActor::New();
dataActor->SetMapper(dataMapper);
ren1->AddActor(dataActor);
ren1->SetBackground(0.1,0.2,0.4);
renWin->Render();
iren->Start();
return 0;
}
and here is the error message :
type `vtkFloatArray' is not a base type for type
`vtkDataArray'
The problem seems to be linked with the command
vtkFloatArray *rho=vtkFloatArray::New() because if I
replace it with vtkDataArray
rho=reader->GetOutput()->GetPointData()->GetScalars()it
works !! So I guess I can't directly create rho with
the former command (why ?).
The second issue is with Blanking command, I verified
that the points I wanted to be blanked were blanked
effectively (with IsPointVisible method) but I don't
see any difference on screen so should I use an
additional filter ?
Any help will be really appreciated !
Stephane.
___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com
More information about the vtkusers
mailing list